Skip to content

Commit aca0b2a

Browse files
committed
Add share functionality to BuildRecap component; implement copyShareMessage method for sharing build details via clipboard; enhance localization files with share messages and notifications in English, French, and 'laranguiva' for improved user experience.
1 parent d0618b1 commit aca0b2a

4 files changed

Lines changed: 139 additions & 3 deletions

File tree

frontend/src/components/composants/BuildRecap.vue

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { useRoute, useRouter } from 'vue-router'
33
import { ref, computed } from 'vue'
4+
import { useI18n } from 'vue-i18n'
45
import SheetBuild from '@/components/composants/SheetBuild.vue'
56
import type { BuildData } from '@/types/build'
67
import { useBuildStore } from '@/stores/buildStore'
@@ -14,6 +15,7 @@ import { useItemStore } from '@/stores/itemStore'
1415
import { useRoleStore } from '@/stores/roleStore'
1516
import StatistiquesBuild from '@/components/composants/StatistiquesBuild.vue'
1617
18+
const { t } = useI18n()
1719
const connexionStore = useConnexionStore()
1820
const route = useRoute()
1921
const router = useRouter()
@@ -29,6 +31,9 @@ const isAdmin = computed(
2931
() => connexionStore.userName === import.meta.env.VITE_NAME,
3032
)
3133
34+
const showNotification = ref(false)
35+
const notificationMessage = ref('')
36+
3237
const championStore = useChampionStore()
3338
const runeStore = useRuneStore()
3439
const summonerStore = useSummonerStore()
@@ -161,12 +166,64 @@ const editBuild = () => {
161166
162167
router.push('/build')
163168
}
169+
170+
async function copyShareMessage() {
171+
try {
172+
if (!buildData.value) return
173+
174+
const currentUrl = window.location.href
175+
const championName = buildData.value.sheet.champion.name
176+
const description = buildData.value.description || ''
177+
const version = buildData.value.version || t('build-recap.no-version')
178+
const certified = buildData.value.certified || false
179+
const author = buildData.value.author || t('build-recap.no-author')
180+
const roles = buildData.value.roles.join(', ') || t('build-recap.all-roles')
181+
182+
let messageTemplate = ''
183+
184+
if (type === 'lelariva') {
185+
messageTemplate = t('build-recap.share-message-lelariva')
186+
} else if (certified) {
187+
messageTemplate = t('build-recap.share-message-user-certified')
188+
} else {
189+
messageTemplate = t('build-recap.share-message-user')
190+
}
191+
192+
const message = messageTemplate
193+
.replace('{champion}', championName)
194+
.replace('{author}', author)
195+
.replace('{description}', description)
196+
.replace('{version}', version)
197+
.replace('{url}', currentUrl)
198+
.replace('{roles}', roles)
199+
200+
await navigator.clipboard.writeText(message)
201+
notificationMessage.value = t('build-recap.share-copied')
202+
203+
showNotification.value = true
204+
205+
setTimeout(() => {
206+
showNotification.value = false
207+
}, 3000)
208+
} catch (error) {
209+
console.error('Erreur lors de la copie du message:', error)
210+
notificationMessage.value = 'Erreur lors de la copie'
211+
showNotification.value = true
212+
setTimeout(() => {
213+
showNotification.value = false
214+
}, 3000)
215+
}
216+
}
164217
</script>
165218

166219
<template>
167220
<main class="build-recap" role="main">
168221
<h1 class="page-title">Build</h1>
169222

223+
<div v-if="showNotification" class="notification-toast">
224+
{{ notificationMessage }}
225+
</div>
226+
170227
<div class="build-content">
171228
<div class="left-column">
172229
<div class="actions-panel">
@@ -235,6 +292,23 @@ const editBuild = () => {
235292
</svg>
236293
<span>{{ $t('build-recap.image') }}</span>
237294
</button>
295+
<button class="btn" @click="copyShareMessage">
296+
<svg
297+
width="24"
298+
height="24"
299+
viewBox="0 0 24 24"
300+
stroke-width="2"
301+
stroke="currentColor"
302+
fill="none"
303+
>
304+
<path d="M6 12m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"></path>
305+
<path d="M18 6m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"></path>
306+
<path d="M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"></path>
307+
<path d="M8.7 10.7l6.6 -3.4"></path>
308+
<path d="M8.7 13.3l6.6 3.4"></path>
309+
</svg>
310+
<span>{{ $t('build-recap.share') }}</span>
311+
</button>
238312
</div>
239313

240314
<div
@@ -518,6 +592,13 @@ main[role='main'] {
518592
justify-content: center;
519593
margin-top: 1rem;
520594
}
595+
596+
.notification-toast {
597+
top: 10px;
598+
right: 10px;
599+
left: 10px;
600+
text-align: center;
601+
}
521602
}
522603
523604
@media (min-width: 1024px) {
@@ -602,4 +683,29 @@ main[role='main'] {
602683
max-width: 800px;
603684
margin: 0 auto;
604685
}
686+
687+
.notification-toast {
688+
position: fixed;
689+
top: 20px;
690+
right: 20px;
691+
background-color: var(--color-gold-300);
692+
color: var(--color-grey-800);
693+
padding: 1rem 1.5rem;
694+
border-radius: 8px;
695+
font-weight: bold;
696+
z-index: 1000;
697+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
698+
animation: slideInFromRight 0.3s ease-out;
699+
}
700+
701+
@keyframes slideInFromRight {
702+
from {
703+
transform: translateX(100%);
704+
opacity: 0;
705+
}
706+
to {
707+
transform: translateX(0);
708+
opacity: 1;
709+
}
710+
}
605711
</style>

frontend/src/i18n/locales/en.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
"gold": "Gold"
6060
},
6161
"build-recap": {
62+
"no-version": "Unknown version",
63+
"no-author": "Anonymous",
64+
"all-roles": "All roles",
6265
"json": "JSON",
6366
"image": "Image",
6467
"delete": "Delete",
@@ -69,7 +72,14 @@
6972
"total": "Total",
7073
"certify": "Certify",
7174
"uncertify": "Uncertify",
72-
"statistic": "Statistic"
75+
"statistic": "Statistic",
76+
"share": "Share",
77+
"share-message-user": "✨ Check out {author}'s build for {champion} {roles}\n\n🎯 {description}\n\n📱 Version {version}\n\n🔗 {url}",
78+
"share-message-user-certified": "✨ Check out {author}'s build recognized by Lelariva for {champion} {roles}\n\n🎯 {description}\n\n📱 Version {version}\n\n🔗 {url}",
79+
"share-message-lelariva": "✨ Check out this {champion} build by Lelariva for {champion} {roles}\n\n🎯 {description}\n\n📱 Version {version}\n\n🔗 {url}",
80+
"share-copied": "Link copied to clipboard!",
81+
"share-text": "Copy text",
82+
"share-image": "Copy image"
7383
},
7484
"contact": {
7585
"title": "Contact",

frontend/src/i18n/locales/fr.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
"gold": "Or"
6060
},
6161
"build-recap": {
62+
"no-version": "Inconnue",
63+
"no-author": "Anonyme",
64+
"all-roles": "tous les rôles",
6265
"json": "JSON",
6366
"image": "Image",
6467
"delete": "Supprimer",
@@ -69,7 +72,14 @@
6972
"total": "Total",
7073
"certify": "Certifier",
7174
"uncertify": "Décertifier",
72-
"statistic": "Statistique"
75+
"statistic": "Statistique",
76+
"share": "Partager",
77+
"share-message-user": "✨ Découvrez le build de {author} pour {champion} {roles}\n\n🎯 {description}\n\n📱 Version {version}\n\n🔗 {url}",
78+
"share-message-user-certified": "✨ Découvrez le build de {author} reconnu par Lelariva pour {champion} {roles}\n\n🎯 {description}\n\n📱 Version {version}\n\n🔗 {url}",
79+
"share-message-lelariva": "✨ Découvrez le build de {champion} proposé par Lelariva pour {champion} {roles}\n\n🎯 {description}\n\n📱 Version {version}\n\n🔗 {url}",
80+
"share-copied": "Lien copié dans le presse-papier !",
81+
"share-text": "Copier le texte",
82+
"share-image": "Copier l'image"
7383
},
7484
"contact": {
7585
"title": "Contact",

frontend/src/i18n/locales/laranguiva.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
"gold": "Or"
6060
},
6161
"build-recap": {
62+
"no-version": "Inconnue",
63+
"no-author": "Anonyme",
64+
"all-roles": "tous les rôles",
6265
"json": "JSON",
6366
"image": "Image",
6467
"delete": "Supprimer",
@@ -68,7 +71,14 @@
6871
"total": "Total",
6972
"certify": "Certifiva",
7073
"uncertify": "Décertifiva",
71-
"statistic": "Statistique"
74+
"statistic": "Statistique",
75+
"share": "Partagiva",
76+
"share-message-user": "✨ Découvrez le buildriva de {author} pour {champion} {roles}\n\n🎯 {description}\n\n📱 Versionriva {version}\n\n🔗 {url}",
77+
"share-message-user-certified": "✨ Découvrez le buildriva de {author} reconnu par Lelariva pour {champion} {roles}\n\n🎯 {description}\n\n📱 Versionriva {version}\n\n🔗 {url}",
78+
"share-message-lelariva": "✨ Découvrez le buildriva de {champion} proposé par Lelariva pour {champion} {roles}\n\n🎯 {description}\n\n📱 Versionriva {version}\n\n🔗 {url}",
79+
"share-copied": "Lienriva copié dans le presse-papieriva !",
80+
"share-text": "Copier le texteriva",
81+
"share-image": "Copier l'imageriva"
7282
},
7383
"contact": {
7484
"title": "Contact",

0 commit comments

Comments
 (0)