|
| 1 | +import type { Meta, StoryObj } from '@storybook/react-vite'; |
| 2 | +import '../../components-css/button-css/src/button.scss'; |
| 3 | +import packageJSON from '../../components-react/button-react/package.json'; |
| 4 | +import { Button } from '../../components-react/button-react/src/button'; |
| 5 | + |
| 6 | +const meta = { |
| 7 | + args: { label: 'Klik mij!' }, |
| 8 | + parameters: { |
| 9 | + externalLinks: [ |
| 10 | + { |
| 11 | + name: 'Open op NL Design System', |
| 12 | + url: 'https://nldesignsystem.nl/button', |
| 13 | + }, |
| 14 | + { |
| 15 | + name: 'Open op GitHub', |
| 16 | + url: packageJSON.homepage, |
| 17 | + }, |
| 18 | + ], |
| 19 | + }, |
| 20 | + component: Button, |
| 21 | + title: 'Componenten/Button/attributen', |
| 22 | +} satisfies Meta<typeof Button>; |
| 23 | + |
| 24 | +export default meta; |
| 25 | + |
| 26 | +type Story = StoryObj<typeof meta>; |
| 27 | + |
| 28 | +export const AriaLabel: Story = { |
| 29 | + args: { |
| 30 | + 'aria-label': 'Klik mij via aria-label', |
| 31 | + }, |
| 32 | + parameters: { |
| 33 | + docs: { |
| 34 | + description: { |
| 35 | + story: 'De toegankelijke naam van de button is `Klik mij via aria-label` inplaats van `Klik mij!`', |
| 36 | + }, |
| 37 | + }, |
| 38 | + }, |
| 39 | +}; |
| 40 | + |
| 41 | +export const AriaLabelledBy: Story = { |
| 42 | + render: (props) => ( |
| 43 | + <> |
| 44 | + <p id="label">button label</p> |
| 45 | + <Button {...props} aria-labelledby="label" /> |
| 46 | + </> |
| 47 | + ), |
| 48 | + parameters: { |
| 49 | + docs: { |
| 50 | + description: { |
| 51 | + story: 'De toegankelijke naam van de button is `button label` inplaats van `Klik mij!`', |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | +}; |
| 56 | + |
| 57 | +export const AriaDisabled: Story = { |
| 58 | + args: { |
| 59 | + disabled: true, |
| 60 | + }, |
| 61 | + parameters: { |
| 62 | + docs: { |
| 63 | + description: { |
| 64 | + story: 'De button is disabled via `aria-disabled`', |
| 65 | + }, |
| 66 | + }, |
| 67 | + }, |
| 68 | +}; |
| 69 | + |
| 70 | +export const HtmlDisabled: Story = { |
| 71 | + args: { |
| 72 | + htmlDisabled: true, |
| 73 | + }, |
| 74 | + parameters: { |
| 75 | + docs: { |
| 76 | + description: { |
| 77 | + story: 'De button is disabled via `disabled`', |
| 78 | + }, |
| 79 | + }, |
| 80 | + }, |
| 81 | +}; |
| 82 | + |
| 83 | +export const Name: Story = { |
| 84 | + args: { |
| 85 | + name: 'button name', |
| 86 | + // eslint-disable-next-line |
| 87 | + onClick: (event) => alert('Name: ' + event.target.name), |
| 88 | + }, |
| 89 | + parameters: { |
| 90 | + docs: { |
| 91 | + description: { |
| 92 | + story: 'Als er op de button geklikt wordt toont er een popup die de `name` weergeeft (`button name`)', |
| 93 | + }, |
| 94 | + }, |
| 95 | + }, |
| 96 | +}; |
| 97 | + |
| 98 | +export const Value: Story = { |
| 99 | + args: { |
| 100 | + value: 'button value', |
| 101 | + // eslint-disable-next-line |
| 102 | + onClick: (event) => alert('Name: ' + event.target.value), |
| 103 | + }, |
| 104 | + parameters: { |
| 105 | + docs: { |
| 106 | + description: { |
| 107 | + story: 'Als er op de button geklikt wordt toont er een popup die de `value` weergeeft (`button value`)', |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | +}; |
| 112 | + |
| 113 | +export const Autofocus: Story = { |
| 114 | + args: { |
| 115 | + autoFocus: true, |
| 116 | + }, |
| 117 | + parameters: { |
| 118 | + docs: { |
| 119 | + description: { |
| 120 | + story: 'Deze button krijgt automatisch focus, best te zien in de story pagina', |
| 121 | + }, |
| 122 | + }, |
| 123 | + }, |
| 124 | +}; |
| 125 | + |
| 126 | +export const CommandFor: Story = { |
| 127 | + render: () => ( |
| 128 | + <> |
| 129 | + <dialog id="dialog"> |
| 130 | + Sluit mij <Button label="Sluiten" command="close" commandfor="dialog" /> |
| 131 | + </dialog> |
| 132 | + <Button label="Open dialog" command="show-modal" commandfor="dialog" /> |
| 133 | + </> |
| 134 | + ), |
| 135 | + parameters: { |
| 136 | + docs: { |
| 137 | + description: { |
| 138 | + story: 'Deze button opent een modal via de `command` en `commandfor` attributes', |
| 139 | + }, |
| 140 | + }, |
| 141 | + }, |
| 142 | +}; |
| 143 | + |
| 144 | +export const Dir: Story = { |
| 145 | + args: { |
| 146 | + dir: 'rtl', |
| 147 | + }, |
| 148 | + parameters: { |
| 149 | + docs: { |
| 150 | + description: { |
| 151 | + story: 'Deze heeft een `dir="rtl"` attribute. Het uitroepteken staat daardoor voor de tekst', |
| 152 | + }, |
| 153 | + }, |
| 154 | + }, |
| 155 | +}; |
| 156 | + |
| 157 | +export const Form: Story = { |
| 158 | + args: { |
| 159 | + type: 'submit', |
| 160 | + form: 'theform', |
| 161 | + formAction: 'http://localhost:3000', |
| 162 | + formEncType: 'text/plain', |
| 163 | + formNoValidate: true, |
| 164 | + }, |
| 165 | + render: (props) => ( |
| 166 | + <> |
| 167 | + <form id="theform"> |
| 168 | + <input name="with-value" value="the value #" required /> |
| 169 | + <input name="without-value" required /> |
| 170 | + </form> |
| 171 | + <Button {...props} /> |
| 172 | + </> |
| 173 | + ), |
| 174 | + parameters: { |
| 175 | + docs: { |
| 176 | + description: { |
| 177 | + story: 'De form word gesubmit door de button, zonder validatie. Als action wordt localhost:3000 geopend.', |
| 178 | + }, |
| 179 | + }, |
| 180 | + }, |
| 181 | +}; |
| 182 | + |
| 183 | +export const Lang: Story = { |
| 184 | + args: { |
| 185 | + lang: 'fr', |
| 186 | + label: 'Cliquez ici', |
| 187 | + }, |
| 188 | + parameters: { |
| 189 | + docs: { |
| 190 | + description: { |
| 191 | + story: 'De `lang="fr"` attribute zorgt voor een franse uitspraak in een screenreader', |
| 192 | + }, |
| 193 | + }, |
| 194 | + }, |
| 195 | +}; |
| 196 | + |
| 197 | +export const Tabindex: Story = { |
| 198 | + args: { |
| 199 | + tabIndex: -1, |
| 200 | + }, |
| 201 | + parameters: { |
| 202 | + docs: { |
| 203 | + description: { |
| 204 | + story: 'Deze button is niet focusbaar omdat er een `tabindex="-1"` gebruikt is', |
| 205 | + }, |
| 206 | + }, |
| 207 | + }, |
| 208 | +}; |
0 commit comments