diff --git a/lib/components/index.ts b/lib/components/index.ts index 66d8140..84899fa 100644 --- a/lib/components/index.ts +++ b/lib/components/index.ts @@ -47,3 +47,6 @@ export * from '@lib/components/ms-progress-bar'; // ** ms-textarea ** // export * from '@lib/components/ms-textarea'; + +// ** ms-card ** // +export * from '@lib/components/ms-card'; diff --git a/lib/components/ms-card/MsSummaryCard.vue b/lib/components/ms-card/MsSummaryCard.vue new file mode 100644 index 0000000..cd5f888 --- /dev/null +++ b/lib/components/ms-card/MsSummaryCard.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/lib/components/ms-card/MsSummaryCardItem.vue b/lib/components/ms-card/MsSummaryCardItem.vue new file mode 100644 index 0000000..79eac46 --- /dev/null +++ b/lib/components/ms-card/MsSummaryCardItem.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/lib/components/ms-card/index.ts b/lib/components/ms-card/index.ts new file mode 100644 index 0000000..95d3096 --- /dev/null +++ b/lib/components/ms-card/index.ts @@ -0,0 +1,7 @@ +import MsSummaryCard from '@lib/components/ms-card/MsSummaryCard.vue'; +import MsSummaryCardItem from '@lib/components/ms-card/MsSummaryCardItem.vue'; + +export * from '@lib/components/ms-card/types'; +export * from '@lib/components/ms-card/utils'; + +export { MsSummaryCard, MsSummaryCardItem }; diff --git a/lib/components/ms-card/types.ts b/lib/components/ms-card/types.ts new file mode 100644 index 0000000..091abe0 --- /dev/null +++ b/lib/components/ms-card/types.ts @@ -0,0 +1,18 @@ +import { Translatable } from '@lib/services'; + +interface MsSummaryCardItemData { + label: Translatable; + text: Translatable; + error?: Translatable; + secondLine?: { + text: Translatable; + error?: Translatable; + }; +} + +interface MsSummaryCardRowData { + item: MsSummaryCardItemData; + secondItem?: MsSummaryCardItemData; +} + +export type { MsSummaryCardItemData, MsSummaryCardRowData }; diff --git a/lib/components/ms-card/utils.ts b/lib/components/ms-card/utils.ts new file mode 100644 index 0000000..3473af2 --- /dev/null +++ b/lib/components/ms-card/utils.ts @@ -0,0 +1,27 @@ +import { MsSummaryCardItemData } from '@lib/components/ms-card/types'; +import { Translatable } from '@lib/services'; + +function createSummaryCardItem( + label: Translatable, + text: Translatable, + error?: Translatable, + secondLineText?: Translatable, + secondLineError?: Translatable, +): MsSummaryCardItemData | undefined { + if (!text) return; + const item: MsSummaryCardItemData = { + label, + text, + error, + }; + + if (secondLineText) { + item.secondLine = { + text: secondLineText, + error: secondLineError, + }; + } + return item; +} + +export { createSummaryCardItem }; diff --git a/lib/locales/en-US.json b/lib/locales/en-US.json index 8dd1478..659adbc 100644 --- a/lib/locales/en-US.json +++ b/lib/locales/en-US.json @@ -49,6 +49,9 @@ "msBooleanToogle": { "yes": "Yes", "no": "No" + }, + "msSummaryCard": { + "updateButtonLabel": "Update" } }, "common": { @@ -76,6 +79,7 @@ "confirmButtonLabel": "Close" }, "translation": { + "asIs": "{value}", "date": { "asIs": "{date}" }, diff --git a/lib/locales/fr-FR.json b/lib/locales/fr-FR.json index bc880cb..0b9cbb7 100644 --- a/lib/locales/fr-FR.json +++ b/lib/locales/fr-FR.json @@ -49,6 +49,9 @@ "msBooleanToogle": { "yes": "Oui", "no": "Non" + }, + "msSummaryCard": { + "updateButtonLabel": "Modifier" } }, "common": { @@ -76,6 +79,7 @@ "confirmButtonLabel": "Fermer" }, "translation": { + "asIs": "{value}", "date": { "asIs": "{date}" }, diff --git a/lib/services/translation.ts b/lib/services/translation.ts index 2d0ffd5..bf391ce 100644 --- a/lib/services/translation.ts +++ b/lib/services/translation.ts @@ -162,6 +162,10 @@ function getLocale(): any { return i18n.global.locale.value; } +function valueAsTranslatable(value: any): Translatable { + return { key: 'lib.services.translation.asIs', data: { value } }; +} + export const I18n = { translate, formatDate, @@ -169,4 +173,5 @@ export const I18n = { getLocale, init, getPreferredLocale, + valueAsTranslatable, }; diff --git a/src/locales/en-US.json b/src/locales/en-US.json index faf3d8c..863c6a3 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -190,6 +190,24 @@ }, "codeValidation": { "title": "Code validation" + }, + "summaryCard": { + "title": "Summary card", + "example": { + "title": "Your profile", + "firstName": { + "label": "First name", + "value": "Jon" + }, + "lastName": { + "label": "Last name", + "value": "Snow" + }, + "job": { + "label": "Job", + "value": "Night's Watch Lord Commander" + } + } } } } diff --git a/src/locales/fr-FR.json b/src/locales/fr-FR.json index 73eb84c..643b1cd 100644 --- a/src/locales/fr-FR.json +++ b/src/locales/fr-FR.json @@ -190,6 +190,24 @@ }, "codeValidation": { "title": "Validation de code" + }, + "summaryCard": { + "title": "Summary card", + "example": { + "title": "Vos informations", + "firstName": { + "label": "Prénom", + "value": "Jean" + }, + "lastName": { + "label": "Nom", + "value": "Neige" + }, + "job": { + "label": "Emploi", + "value": "Lord Commandant de la Garde de Nuit" + } + } } } } diff --git a/src/views/HomePage.vue b/src/views/HomePage.vue index 3038a0f..1960c2c 100644 --- a/src/views/HomePage.vue +++ b/src/views/HomePage.vue @@ -362,6 +362,35 @@ + + {{ $msTranslate('usage.components.summaryCard.title') }} +
+
+ +
+
+
@@ -423,6 +452,9 @@ import { MsStripeCardDetails, MsDropdownChangeEvent, MsProgressBar, + MsSummaryCard, + createSummaryCardItem, + MsSummaryCardItemData, } from '@lib/components'; import { DateTime } from 'luxon'; import { inject, ref, Ref, onMounted } from 'vue';