Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DsfrModal): ✨ changer la taille de la modale #641

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/components/DsfrModal/DsfrModal.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default {
control: 'text',
description: 'Icone à afficher au début du titre de la modale',
},
size: {
control: 'radio',
options: ['sm', 'md', 'lg', 'xl'],
description: 'Taille de la modale : `SM` (Small), `MD` (Medium), `LG` (Large), `XL`(Extra large). Attention la taille `XL` ne fait pas partie du Design System de l’État',
},
close: {
description: 'Événement déclenché à la fermeture de la modale',
},
Expand All @@ -65,10 +70,13 @@ export const Modal = (args) => ({
},

data () {
return {
...args,
actions: args.actions.map(action => ({ ...action, onClick: () => { args.onClick(); this.onClose() } })),
}
return args
},

computed: {
modifiedActions () {
return this.actions.map(action => ({ ...action, onClick: () => { action.onClick(); this.onClose() } }))
},
},

template: `
Expand All @@ -80,11 +88,12 @@ export const Modal = (args) => ({
<DsfrModal
ref="modal"
:opened="opened"
:actions="actions"
:actions="modifyActions"
:is-alert="isAlert"
:icon="icon"
:title="title"
:origin="$refs.modalOrigin"
:size="size"
@close="onClose()"
>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et. Aenean eu enim justo. Vestibulum aliquam hendrerit molestie. Mauris malesuada nisi sit amet augue accumsan tincidunt. Maecenas tincidunt, velit ac porttitor pulvinar, tortor eros facilisis libero, vitae commodo nunc quam et ligula. Ut nec ipsum sapien. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer id nisi nec nulla luctus lacinia non eu turpis. Etiam in ex imperdiet justo tincidunt egestas. Ut porttitor urna ac augue cursus tincidunt sit amet sed orci.</p>
Expand All @@ -105,6 +114,7 @@ Modal.args = {
title: 'Titre de la modale',
isAlert: false,
icon: 'ri-checkbox-circle-line',
size: 'md',
actions: [
{
label: 'Valider',
Expand Down
11 changes: 10 additions & 1 deletion src/components/DsfrModal/DsfrModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ const props = withDefaults(defineProps<{
origin?: {focus:() => void}
title: string
icon?: string
size?: 'sm' | 'md' | 'lg' | 'xl'
}>(), {
modalId: () => getRandomId('modal', 'dialog'),
actions: () => [],
origin: () => ({ focus () {} }), // eslint-disable-line @typescript-eslint/no-empty-function
icon: undefined,
size: 'md',
})

const emit = defineEmits<{(e: 'close'): void}>()
Expand Down Expand Up @@ -88,7 +90,14 @@ async function close () {
>
<div class="fr-container fr-container--fluid fr-container-md">
<div class="fr-grid-row fr-grid-row--center">
<div class="fr-col-12 fr-col-md-8 fr-col-lg-6">
<div
class="fr-col-12"
:class="{
'fr-col-md-8': size === 'lg',
'fr-col-md-6': size === 'md',
'fr-col-md-4': size === 'sm',
}"
Comment on lines +94 to +99
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi fr-col-12 serait toujours présent ?
Pourquoi pas ceci :

<div
            :class="{
              'fr-col-md-12': size === 'xl',
              'fr-col-md-8': size === 'lg',
              'fr-col-md-6': size === 'md',
              'fr-col-md-4': size === 'sm',
            }"
            ```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jusqu'à présent je crois que c'était pour le mode mobile pour que la modale ne soit pas trop petite et prenne tout l'écran dans ce cas là

Copy link
Collaborator

@cailliaud cailliaud Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'après le dsfr: modal simple fr-col-12 fr-col-md-8 fr-col-lg-6
Modal SM fr-col-12 fr-col-md-4
Modal LG fr-col-12 fr-col-md-8

https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/modale

>
<div class="fr-modal__body">
<div class="fr-modal__header">
<button
Expand Down
Loading