|
| 1 | +import { Follow, type FollowProps } from "../dist/Follow"; |
| 2 | +import { sectionName } from "./sectionName"; |
| 3 | +import { getStoryFactory } from "./getStory"; |
| 4 | +import { action } from "@storybook/addon-actions"; |
| 5 | +import React from "react"; |
| 6 | + |
| 7 | +const { meta, getStory } = getStoryFactory<FollowProps>({ |
| 8 | + sectionName, |
| 9 | + wrappedComponent: { Follow }, |
| 10 | + description: ` |
| 11 | +- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/elements-d-interface/lettre-d-information-et-reseaux-sociaux) |
| 12 | +- [See DSFR demos](https://main--ds-gouv.netlify.app/example/component/follow/) |
| 13 | +- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Follow.tsx)`, |
| 14 | + argTypes: { |
| 15 | + classes: { |
| 16 | + control: { type: null }, |
| 17 | + description: |
| 18 | + 'Add custom classes for various inner elements. Possible keys are "root", "container", "row", "newsletter-col", "newsletter", "newsletter-title", "newsletter-desc", "newsletter-form-wrapper", "newsletter-form-hint", "social-col", "social", "social-title", "social-buttons", "social-buttons-each"' |
| 19 | + } |
| 20 | + }, |
| 21 | + disabledProps: ["lang"] |
| 22 | +}); |
| 23 | + |
| 24 | +export default meta; |
| 25 | + |
| 26 | +const defaultSocialButtons: [FollowProps.SocialButton, ...FollowProps.SocialButton[]] = [ |
| 27 | + { |
| 28 | + type: "facebook", |
| 29 | + linkProps: { |
| 30 | + href: "#facebook" |
| 31 | + } |
| 32 | + }, |
| 33 | + { |
| 34 | + type: "twitter-x", |
| 35 | + linkProps: { |
| 36 | + href: "#twitter" |
| 37 | + } |
| 38 | + }, |
| 39 | + { |
| 40 | + type: "linkedin", |
| 41 | + linkProps: { |
| 42 | + href: "#linkedin" |
| 43 | + } |
| 44 | + }, |
| 45 | + { |
| 46 | + type: "instagram", |
| 47 | + linkProps: { |
| 48 | + href: "#instagram" |
| 49 | + } |
| 50 | + }, |
| 51 | + { |
| 52 | + type: "youtube", |
| 53 | + linkProps: { |
| 54 | + href: "#youtube" |
| 55 | + } |
| 56 | + } |
| 57 | +]; |
| 58 | + |
| 59 | +export const Default = getStory({ |
| 60 | + newsletter: { |
| 61 | + buttonProps: { |
| 62 | + onClick: action("Default onClick") |
| 63 | + }, |
| 64 | + form: { |
| 65 | + formComponent: ({ children }) => <form action="#">{children}</form>, |
| 66 | + inputProps: { |
| 67 | + label: undefined |
| 68 | + }, |
| 69 | + success: false |
| 70 | + } |
| 71 | + }, |
| 72 | + social: { |
| 73 | + buttons: defaultSocialButtons |
| 74 | + } |
| 75 | +}); |
| 76 | + |
| 77 | +export const SocialOnly = getStory({ |
| 78 | + social: { |
| 79 | + buttons: defaultSocialButtons |
| 80 | + } |
| 81 | +}); |
| 82 | + |
| 83 | +export const NewsletterOnly = getStory({ |
| 84 | + newsletter: { |
| 85 | + buttonProps: { |
| 86 | + onClick: action("NewsletterOnly onClick") |
| 87 | + } |
| 88 | + } |
| 89 | +}); |
| 90 | + |
| 91 | +export const NewsletterOnlyButtonAsLink = getStory({ |
| 92 | + newsletter: { |
| 93 | + buttonProps: { |
| 94 | + linkProps: { |
| 95 | + href: "#" |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | +}); |
| 100 | + |
| 101 | +export const NewsletterOnlyWithDescription = getStory({ |
| 102 | + newsletter: { |
| 103 | + buttonProps: { |
| 104 | + onClick: action("NewsletterOnlyWithDescription onClick") |
| 105 | + }, |
| 106 | + desc: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et." |
| 107 | + } |
| 108 | +}); |
| 109 | + |
| 110 | +export const NewsletterOnlyWithForm = getStory({ |
| 111 | + newsletter: { |
| 112 | + buttonProps: { |
| 113 | + onClick: action("NewsletterOnlyWithForm onClick") |
| 114 | + }, |
| 115 | + desc: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et.", |
| 116 | + form: { |
| 117 | + formComponent: ({ children }) => <form action="#">{children}</form>, |
| 118 | + success: false |
| 119 | + } |
| 120 | + } |
| 121 | +}); |
| 122 | + |
| 123 | +export const SocialAndNewsletter = getStory({ |
| 124 | + newsletter: { |
| 125 | + buttonProps: { |
| 126 | + onClick: action("SocialAndNewsletter onClick") |
| 127 | + }, |
| 128 | + desc: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et." |
| 129 | + }, |
| 130 | + social: { |
| 131 | + buttons: defaultSocialButtons |
| 132 | + } |
| 133 | +}); |
| 134 | + |
| 135 | +export const SocialAndNewsletterWithForm = getStory({ |
| 136 | + newsletter: { |
| 137 | + buttonProps: { |
| 138 | + onClick: action("SocialAndNewsletterWithForm onClick") |
| 139 | + }, |
| 140 | + desc: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et.", |
| 141 | + form: { |
| 142 | + formComponent: ({ children }) => <form action="#">{children}</form>, |
| 143 | + success: false |
| 144 | + } |
| 145 | + }, |
| 146 | + social: { |
| 147 | + buttons: defaultSocialButtons |
| 148 | + } |
| 149 | +}); |
| 150 | + |
| 151 | +export const SocialAndNewsletterWithFormSuccess = getStory({ |
| 152 | + newsletter: { |
| 153 | + buttonProps: { |
| 154 | + onClick: action("SocialAndNewsletterWithFormSuccess onClick") |
| 155 | + }, |
| 156 | + desc: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et.", |
| 157 | + form: { |
| 158 | + formComponent: ({ children }) => <form action="#">{children}</form>, |
| 159 | + success: true |
| 160 | + } |
| 161 | + }, |
| 162 | + social: { |
| 163 | + buttons: defaultSocialButtons |
| 164 | + } |
| 165 | +}); |
| 166 | + |
| 167 | +export const SocialAndNewsletterWithFormError = getStory({ |
| 168 | + newsletter: { |
| 169 | + buttonProps: { |
| 170 | + onClick: action("SocialAndNewsletterWithFormError onClick") |
| 171 | + }, |
| 172 | + desc: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et.", |
| 173 | + form: { |
| 174 | + formComponent: ({ children }) => <form action="#">{children}</form>, |
| 175 | + success: false, |
| 176 | + inputProps: { |
| 177 | + state: "error", |
| 178 | + stateRelatedMessage: |
| 179 | + "Le format de l’adresse electronique saisie n’est pas valide. Le format attendu est : nom@exemple.org" |
| 180 | + } |
| 181 | + } |
| 182 | + }, |
| 183 | + social: { |
| 184 | + buttons: defaultSocialButtons |
| 185 | + } |
| 186 | +}); |
0 commit comments