|
7 | 7 | "// import { StoryTemplateName } from './OtherStoryFile.stories' // import stories for component compositions", |
8 | 8 | "", |
9 | 9 | "export default {", |
10 | | - " title: 'Components/ComponentName',", |
11 | | - " excludeStories: ['ComponentTemplateName'],", |
12 | | - " argTypes: {", |
13 | | - " booleanExample: {", |
14 | | - " control: { type: 'boolean' },", |
15 | | - " description: 'true/false toggle to controls',", |
16 | | - " table: {", |
17 | | - " category: 'Pick one: CSS, HTML, Interactive'", |
18 | | - " }", |
19 | | - " },", |
20 | | - " selectExample: {", |
21 | | - " options: [0, 1, 2, 3], // iterator", |
22 | | - " mapping: ['string1', 'string2', 'string3', 'string4'], // values", |
23 | | - " control: {", |
24 | | - " type: 'select',", |
25 | | - " labels: ['string1-label', 'string2-label', 'string3-label', 'string4-label'] // public labels", |
26 | | - " },", |
27 | | - " description: 'select menu mapping to strings (example: use for variant class names)',", |
28 | | - " table: {", |
29 | | - " category: 'Pick one: CSS, HTML, Interactive'", |
30 | | - " }", |
31 | | - " },", |
32 | | - " stringExample: {", |
33 | | - " name: 'stringExample',", |
34 | | - " type: 'string',", |
35 | | - " description: 'text box control',", |
36 | | - " table: {", |
37 | | - " category: 'Pick one: CSS, HTML, Interactive'", |
38 | | - " }", |
39 | | - " },", |
40 | | - " children: {", |
41 | | - " description: 'creates a slot for children',", |
42 | | - " table: {", |
43 | | - " category: 'HTML'", |
44 | | - " }", |
45 | | - " },", |
| 10 | + " title: 'Components/ComponentName',", |
| 11 | + " excludeStories: ['ComponentTemplateName'],", |
| 12 | + " layout: 'padded',", |
| 13 | + " argTypes: {", |
| 14 | + " booleanExample: {", |
| 15 | + " control: {type: 'boolean'},", |
| 16 | + " description: 'true/false toggle to controls',", |
| 17 | + " table: {", |
| 18 | + " category: 'Pick one: CSS, HTML, Interactive'", |
| 19 | + " }", |
| 20 | + " },", |
| 21 | + " radioExample: {", |
| 22 | + " options: ['string1', 'string2', 'string3', 'string4'],", |
| 23 | + " control: {", |
| 24 | + " type: 'inline-radio',", |
| 25 | + " },", |
| 26 | + " description: 'radio buttons mapping to strings (example: use for variant class names)',", |
| 27 | + " table: {", |
| 28 | + " category: 'Pick one: CSS, HTML, Interactive'", |
| 29 | + " }", |
| 30 | + " },", |
| 31 | + " stringExample: {", |
| 32 | + " name: 'stringExample',", |
| 33 | + " type: 'string',", |
| 34 | + " description: 'text box control',", |
| 35 | + " table: {", |
| 36 | + " category: 'Pick one: CSS, HTML, Interactive'", |
| 37 | + " }", |
| 38 | + " },", |
| 39 | + " children: {", |
| 40 | + " description: 'creates a slot for children',", |
| 41 | + " table: {", |
| 42 | + " category: 'HTML'", |
| 43 | + " }", |
46 | 44 | " }", |
| 45 | + " }", |
47 | 46 | "}", |
48 | 47 | "", |
49 | 48 | "// build every component case here in the template (private api)", |
50 | | - "export const ComponentTemplateName = ({ booleanExample, selectExample, stringExample, children }) => (", |
51 | | - " <div", |
52 | | - " // use clsx for multiple classnames", |
53 | | - " className={clsx('defaultClass', selectExample && `${selectExample}`, booleanExample && 'defaultClass--modifier')}", |
54 | | - " // use undefined for values that shouldn't be set if false", |
55 | | - " aria-hidden={booleanExample ? 'true' : undefined}", |
56 | | - " >", |
57 | | - " {/* use {children} for wrapper component templates */}", |
58 | | - " <>", |
59 | | - " {stringExample}", |
60 | | - " {children}", |
61 | | - " </>", |
62 | | - " </div>", |
| 49 | + "export const ComponentTemplateName = ({booleanExample, radioExample, stringExample, children}) => (", |
| 50 | + " <div", |
| 51 | + " // use clsx for multiple classnames", |
| 52 | + " className={clsx('defaultClass', radioExample && `radioExample`, booleanExample && 'defaultClass--modifier')}", |
| 53 | + " // use undefined for values that shouldn't be set if false", |
| 54 | + " // aria-hidden={booleanExample ? 'true' : undefined}", |
| 55 | + " >", |
| 56 | + " {/* use {children} for wrapper component templates */}", |
| 57 | + " <>", |
| 58 | + " {stringExample}", |
| 59 | + " {children}", |
| 60 | + " </>", |
| 61 | + " </div>", |
63 | 62 | ")", |
64 | 63 | "", |
65 | 64 | "// create a \"playground\" demo page that may set some defaults and allow story to access component controls", |
66 | 65 | "export const Playground = ComponentTemplateName.bind({})", |
67 | 66 | "Playground.args = {", |
68 | | - " stringExample: 'Default text',", |
69 | | - " booleanExample: false,", |
70 | | - " children: (", |
71 | | - " <>", |
72 | | - " <StoryTemplateName someProp=\"Use props from other stories\" />", |
73 | | - " </>", |
74 | | - " )", |
| 67 | + " stringExample: 'Default text',", |
| 68 | + " booleanExample: false", |
| 69 | + " // children: (", |
| 70 | + " // <>", |
| 71 | + " // <StoryTemplateName {...StoryTemplateName.args} />", |
| 72 | + " // </>", |
| 73 | + " // )", |
75 | 74 | "}", |
76 | 75 | "" |
77 | 76 | ], |
|
0 commit comments