You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_Note:_ In your story, be sure to include the `if:false` override otherwise the control will only show up if you have a `setName` arg and it is equal to `workflow`.
122
122
123
-
Want to load UI icons instead? Use the following variable import instead:
123
+
Want to load UI icons instead? Use the following variable import instead of the above:
124
124
125
125
```js
126
126
argTypes: {
@@ -205,6 +205,75 @@ label: {
205
205
},
206
206
```
207
207
208
+
### args
209
+
210
+
In a story, the args object contains all the default values for the component. These values will be used to render the component in the storybook preview. The values can be overridden by the user via the controls or by setting a custom args object in a specific story.
211
+
212
+
The default story should _almost_ always have any empty args object because it is, by nature, using all the default settings.
213
+
214
+
```js
215
+
exportconstDefault=Template.bind({});
216
+
Default.args= {};
217
+
```
218
+
219
+
Subsequent stories can override the default args object by setting a new value for the desired property. i.e.,
220
+
221
+
```js
222
+
exportconstExpress=Template.bind({});
223
+
Express.args= {
224
+
express:true
225
+
};
226
+
```
227
+
228
+
Try to focus stories on a single property or set of properties. This will make it easier for users to find the story they are looking for and will help in debugging issues.
229
+
230
+
#### customStorybookStyles
231
+
232
+
All stories are wrapped in a custom decorator that applies a few standard display properties to the preview. If you need to override these styles, you can do so by adding a `customStorybookStyles` property to your args object. This should be a string of CSS rules. i.e.,
233
+
234
+
```js
235
+
args: {
236
+
customStorybookStyles: {
237
+
flexDirection:"column",
238
+
alignItems:"flex-start",
239
+
},
240
+
},
241
+
```
242
+
243
+
The following properties are set on `#root-inner` by default:
244
+
245
+
```css
246
+
display: flex;
247
+
gap:10px;
248
+
```
249
+
250
+
If the display property is updated to something other than `*flex` or `*grid`, the gap property will be removed (`*flex` can equal `flex` or `inline-flex`). As long as the display property is not `contents`, the gap value will be assigned to `padding` instead.
251
+
252
+
For example, if the display value is set to `block`, the following styles will be applied:
253
+
254
+
```css
255
+
display: block;
256
+
padding:10px;
257
+
```
258
+
259
+
Leveraging an argType in your component that matches `staticColor` with allowed values of `white` or `black` will automatically set the background color of the preview to an appropriate value (white will use `rgb(15, 121, 125)`; black will use `rgb(181, 209, 211)`). If you need to override this value, you can do so by setting the `customStorybookStyles` property to an object with a `backgroundColor` property. i.e.,
260
+
261
+
```js
262
+
args: {
263
+
customStorybookStyles: {
264
+
backgroundColor:"rgb(238, 14, 189)",
265
+
},
266
+
},
267
+
```
268
+
269
+
Any settings added by the story will override these values. You can unset a value completely using undefined, i.e.:
270
+
271
+
```js
272
+
customStorybookStyles: {
273
+
display:undefined,
274
+
},
275
+
```
276
+
208
277
## Templates
209
278
210
279
The goal of the template files is to create a definition for this component to enforce and demonstrate the allowed semantics and required classNames and settings to achieve the desired output (based on the user's selected controls).
@@ -240,14 +309,14 @@ All return values for Template functions should be outputting TemplateResults. S
@@ -339,142 +401,5 @@ Runs will generate a JUnit XML file with build results (`chromatic-build-{buildN
339
401
340
402
Running without publishing to Chromatic? Add the `--dry-run` flag. Need more information to debug a run? Try the `--diagnostics` flag (writes process context information to `chromatic-diagnostics.json`).
341
403
342
-
# Migration to Storybook 7.0(Draft)
343
-
344
-
## Updates
345
-
346
-
---
347
-
`*` Added support for handler actions with ```withActions``` on each stories which have action handlers.
348
-
349
-
Example:
350
-
351
-
```js
352
-
import globalThis from 'global';
353
-
+ import { withActions } from '@storybook/addon-actions/decorator';
0 commit comments