-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design-system:newsletter_form): add base component
- Loading branch information
1 parent
8b2ef42
commit e76eae3
Showing
9 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions
54
packages/design-system/src/organisms/newsletter_form/newsletter_confirmation_dialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script lang="ts" setup> | ||
import { computed, ref, unref } from 'vue'; | ||
import Button from '../../atoms/button/button.vue'; | ||
import Dialog from '../../molecules/dialog/dialog.vue'; | ||
import Checkbox from '../../atoms/checkbox/checkbox.vue'; | ||
import Field from '../../molecules/field/field.vue'; | ||
const emit = defineEmits<{ | ||
accepted: []; | ||
}>(); | ||
const email = defineModel<string>({ required: true }); | ||
const open = ref(false); | ||
const acceptTerms = ref(false); | ||
const isFormValid = computed(() => { | ||
return acceptTerms.value && unref(email).length > 1; | ||
}); | ||
function handleSubmit() { | ||
emit('accepted'); | ||
open.value = false; | ||
} | ||
</script> | ||
|
||
<template> | ||
<Dialog title="Confirmez votre inscription" v-model="open"> | ||
<template #trigger> | ||
<Button size="extraSmall">S'abonner</Button> | ||
</template> | ||
|
||
<template #content> | ||
<form class="flex flex-col gap-4" @submit.prevent="handleSubmit"> | ||
<Field v-model="email" label="Adresse email" type="email" /> | ||
|
||
<Checkbox v-model="acceptTerms" label="J'accepte de recevoir la newsletter de RomainLanz" /> | ||
|
||
<p class="text-sm text-gray-700"> | ||
Nous utilisons Brevo en tant que plateforme marketing. En soumettant ce formulaire, vous acceptez que les | ||
données personnelles que vous avez fournies soient transférées à Brevo pour être traitées conformément à la | ||
<a class="underline" href="https://www.brevo.com/fr/legal/privacypolicy" target="_blank" rel="nofollow"> | ||
politique de confidentialité | ||
</a> | ||
de Brevo. | ||
</p> | ||
|
||
<div class="flex justify-end"> | ||
<Button color="violet" size="small" type="submit" :disabled="!isFormValid">S'abonner</Button> | ||
</div> | ||
</form> | ||
</template> | ||
</Dialog> | ||
</template> |
13 changes: 13 additions & 0 deletions
13
packages/design-system/src/organisms/newsletter_form/newsletter_form.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import NewsletterForm from './newsletter_form.vue'; | ||
import type { Meta, StoryObj } from '@storybook/vue3'; | ||
|
||
const meta = { | ||
component: NewsletterForm, | ||
title: 'Organisms/NewsletterForm', | ||
} satisfies Meta<typeof NewsletterForm>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Base: Story = {}; |
27 changes: 27 additions & 0 deletions
27
packages/design-system/src/organisms/newsletter_form/newsletter_form.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts" setup> | ||
import { ref, unref } from 'vue'; | ||
import NewsletterConfirmationDialog from './newsletter_confirmation_dialog.vue'; | ||
import Field from '../../molecules/field/field.vue'; | ||
const emit = defineEmits<{ | ||
register: [email: string]; | ||
}>(); | ||
const email = ref(''); | ||
function onAccept() { | ||
emit('register', unref(email)); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-10 w-min"> | ||
<p>Abonne-toi pour recevoir les dernières tendances et ressources pour ta veille technique.</p> | ||
|
||
<div class="flex gap-4"> | ||
<Field class="h-full" v-model="email" placeholder="[email protected]" type="email" /> | ||
|
||
<NewsletterConfirmationDialog v-model="email" @accepted="onAccept" /> | ||
</div> | ||
</div> | ||
</template> |