Skip to content

Commit 8fd33c9

Browse files
authored
Fix Modal.stories.tsx code documentation (#97)
* Fix `Modal.stories.tsx` code documentation Signed-off-by: Nicolas KOKLA <1872767+nkokla@users.noreply.github.com> * Update `Modal.stories.tsx` code documentation --------- Signed-off-by: Nicolas KOKLA <1872767+nkokla@users.noreply.github.com>
1 parent 56dc123 commit 8fd33c9

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

stories/Modal.stories.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ const { meta, getStory } = getStoryFactory({
1717
This is a uncontrolled implementation of the modal, compatible with Server Components.
1818
An controlled variant is coming soon.
1919
20+
## The 'createModal' function
21+
22+
The \`createModal(options)\` function take an \`options\` object as parameter.
23+
24+
**Options Params keys:**
25+
- \`name\` (*STRING - Required*): Prefix of the \`Modal\` component name and \`ModalButtonProps\` object name.
26+
- \`isOpenedByDefault\` (*BOOLEAN - Required*): Set the opening state of the Modal after it mount.
27+
28+
**Return:**
29+
An object with two keys. The name of these keys are computed from the value
30+
of \`name\` key of the \`options\` param object :
31+
- \`\${PascalCasePrefix}Modal\`: The Modal component
32+
- \`\${camelCasePrefix}ModalButtonProps\`: The props object for \`Button\` DSFR component
33+
34+
**Eg.:**
35+
\`\`\`
36+
const { MyComponentModal, myComponentButtonProps } = createModal({
37+
name: "myComponent", // The name of Modal component and modalButtonProps is compute from this string
38+
isOpenedByDefault: false
39+
});
40+
\`\`\`
41+
42+
## The Modal component
43+
2044
`,
2145
"argTypes": {
2246
"title": {
@@ -115,10 +139,10 @@ Default.parameters = {
115139
import { createModal } from "@codegouvfr/react-dsfr/Modal";
116140
import { Button } from "@codegouvfr/react-dsfr/Button";
117141
118-
const { AcceptTermsModal, acceptTermsModalButtonProps } = createModal(
119-
name: "simple",
142+
const { AcceptTermsModal, acceptTermsModalButtonProps } = createModal({
143+
name: "acceptTerms",
120144
isOpenedByDefault: false
121-
);
145+
});
122146
123147
function MyComponent(){
124148

0 commit comments

Comments
 (0)