From 0365a6a2838ebe5f80fbb3ab97f39bb8f72d85a0 Mon Sep 17 00:00:00 2001 From: Matthias Goudjil Date: Fri, 21 Jun 2024 17:24:10 +0200 Subject: [PATCH] docs: [Storybook][PuikConfigProvider] - fix #350 - create doc + update fr translations --- .../src/config-provider-props.ts | 9 +- .../stories/config-provider.stories.ts | 86 +++++++++++++++++++ packages/locale/lang/fr.ts | 32 ++++++- 3 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 packages/components/config-provider/stories/config-provider.stories.ts diff --git a/packages/components/config-provider/src/config-provider-props.ts b/packages/components/config-provider/src/config-provider-props.ts index 3ba942ef..e1d08483 100644 --- a/packages/components/config-provider/src/config-provider-props.ts +++ b/packages/components/config-provider/src/config-provider-props.ts @@ -1,10 +1,15 @@ import type { ExtractPropTypes } from 'vue'; +export enum PuikConfigProviderLocale { + En = 'en', + Fr = 'fr', +} + export const configProviderProps = { locale: { - type: String, + type: String as () => PuikConfigProviderLocale, required: false, - default: 'en' + default: PuikConfigProviderLocale.En } }; diff --git a/packages/components/config-provider/stories/config-provider.stories.ts b/packages/components/config-provider/stories/config-provider.stories.ts new file mode 100644 index 00000000..973393a5 --- /dev/null +++ b/packages/components/config-provider/stories/config-provider.stories.ts @@ -0,0 +1,86 @@ +import { PuikConfigProvider, PuikPagination, PuikLabel, PuikConfigProviderLocale } from '@prestashopcorp/puik-components'; +import type { Meta, StoryFn, Args } from '@storybook/vue3'; +import { ref } from 'vue'; + +const configProviderLocales = Object.values(PuikConfigProviderLocale); +const configProviderLocalesSummary = configProviderLocales.join('|'); + +export default { + title: 'Components/ConfigProvider', + component: PuikConfigProvider, + argTypes: { + locale: { + description: + 'defines language', + control: 'select', + options: configProviderLocales, + table: { + type: { + summary: configProviderLocalesSummary + }, + defaultValue: { + summary: PuikConfigProviderLocale.En + } + } + } + }, + args: {} +} as Meta; + +const DefaultTemplate: StoryFn = (args: Args) => ({ + components: { + PuikConfigProvider, + PuikPagination, + PuikLabel + }, + setup() { + const page = ref(1); + const itemsPerPage = ref(5); + return { args, page, itemsPerPage }; + }, + template: ` + +
+

Translation feature: examples with PuikLabel and PuikPagination

+ + Label + + +
+
+ ` +}); + +export const Default = { + render: DefaultTemplate, + args: {}, + parameters: { + docs: { + source: { + code: ` + + + + + + + + Label + + + +`, + language: 'html' + } + } + } +}; diff --git a/packages/locale/lang/fr.ts b/packages/locale/lang/fr.ts index 2f0e5307..a9fe4839 100644 --- a/packages/locale/lang/fr.ts +++ b/packages/locale/lang/fr.ts @@ -1,6 +1,22 @@ export default { name: 'fr', puik: { + input: { + increase: 'Augmenter', + decrease: 'diminuer' + }, + switch: { + enable: 'Activer', + disable: 'Désactiver' + }, + label: { + optional: 'Optionnel', + readonly: 'Lecture uniquement' + }, + select: { + searchPlaceholder: 'Chercher', + noResults: 'Aucun résultat' + }, table: { selectLabel: 'Cocher', unselectLabel: 'Décocher', @@ -11,6 +27,9 @@ export default { reset: 'Réinitialiser', search: 'Rechercher' }, + skeletonLoaderGroup: { + label: 'Chargement' + }, pagination: { ariaLabel: 'Pagination', goTo: 'Aller à la page {page}', @@ -28,13 +47,22 @@ export default { jumperDescription: 'Sur {maxPage} pages' }, loader: { - label: - 'Vous visualisez {itemCount} produits sur un total de {totalItem}.', + label: 'Vous visualisez {itemCount} produits sur un total de {totalItem}.', button: 'Charger plus' }, mobile: { label: 'Page {page} à {maxPage}' } + }, + sidebar: { + expandButtonLabel: { + expanded: 'Étendre le menu', + collapsed: 'Reduire le menu', + close: 'Fermer le menu' + } + }, + snackbar: { + closeBtnLabel: 'Fermer' } } };