Skip to content

Commit f1eaba3

Browse files
committed
Update AnchorNav playground story
Adds controls for actions, removes controls from default story.
1 parent 3a8b899 commit f1eaba3

File tree

1 file changed

+85
-61
lines changed

1 file changed

+85
-61
lines changed

packages/react/src/AnchorNav/AnchorNav.stories.tsx

+85-61
Original file line numberDiff line numberDiff line change
@@ -14,66 +14,20 @@ export default {
1414
parameters: {
1515
layout: 'fullscreen',
1616
},
17-
args: {
18-
enableDefaultBgColor: true,
19-
data: {
20-
['GitHub vs Jenkins']: 'githubvsjenkins',
21-
['GitHub vs GitLab']: 'githubvsgitlab',
22-
['GitHub vs CircleCI']: 'githubvscircleci',
23-
['GitHub vs BitBucket']: 'githubvsvsbitbucket',
24-
['GitHub vs TravisCI']: 'githubvsvstravis',
25-
},
26-
sectionHeight: 1000,
27-
offset: 100,
28-
},
29-
argTypes: {
30-
data: {
31-
name: 'Data',
32-
description: 'Test data',
33-
control: {
34-
type: 'object',
35-
},
36-
table: {
37-
category: 'Story customization',
38-
},
39-
},
40-
sectionHeight: {
41-
name: 'Section height',
42-
description: 'Section height',
43-
control: {
44-
type: 'number',
45-
},
46-
table: {
47-
category: 'Story customization',
48-
},
49-
},
50-
offset: {
51-
name: 'Offset',
52-
description: 'Offset from the top of the page',
53-
control: {
54-
type: 'number',
55-
},
56-
table: {
57-
category: 'Story customization',
58-
},
59-
},
60-
},
6117
} as Meta<typeof AnchorNav>
6218

63-
export const Default = ({data, ...args}: {data: MockData}) => {
64-
return (
65-
<AnchorNav {...args}>
66-
<AnchorNav.Link href="#section">Section one</AnchorNav.Link>
67-
<AnchorNav.Link href="#section">Section two</AnchorNav.Link>
68-
<AnchorNav.Link href="#section">Section three</AnchorNav.Link>
69-
<AnchorNav.Link href="#section">Section four</AnchorNav.Link>
70-
<AnchorNav.Link href="#section">Section five</AnchorNav.Link>
71-
<AnchorNav.Action href="#">Sign up</AnchorNav.Action>
72-
</AnchorNav>
73-
)
74-
}
19+
export const Default = () => (
20+
<AnchorNav>
21+
<AnchorNav.Link href="#section">Section one</AnchorNav.Link>
22+
<AnchorNav.Link href="#section">Section two</AnchorNav.Link>
23+
<AnchorNav.Link href="#section">Section three</AnchorNav.Link>
24+
<AnchorNav.Link href="#section">Section four</AnchorNav.Link>
25+
<AnchorNav.Link href="#section">Section five</AnchorNav.Link>
26+
<AnchorNav.Action href="#">Sign up</AnchorNav.Action>
27+
</AnchorNav>
28+
)
7529

76-
export const Playground = ({data, ...args}: {data: MockData; offset: number; sectionHeight: number}) => {
30+
export const Playground = ({data, sectionHeight, actionText, secondaryAction, secondaryActionText, ...args}) => {
7731
return (
7832
<div style={{backgroundColor: 'var(--base-color-scale-red-0)'}}>
7933
<RedlineBackground height={args.offset}>
@@ -87,12 +41,13 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
8741
</Stack>
8842
</RedlineBackground>
8943
<AnchorNav {...args}>
90-
{Object.entries(data).map(([key, value]) => (
44+
{Object.entries(data as MockData).map(([key, value]) => (
9145
<AnchorNav.Link href={value} key={value}>
9246
{key}
9347
</AnchorNav.Link>
9448
))}
95-
<AnchorNav.Action href="#">Sign up</AnchorNav.Action>
49+
<AnchorNav.Action href="#">{actionText}</AnchorNav.Action>
50+
{secondaryAction && <AnchorNav.SecondaryAction href="#">{secondaryActionText}</AnchorNav.SecondaryAction>}
9651
</AnchorNav>
9752
{/**
9853
* The following markup is provided for demonstration purposes only.
@@ -105,15 +60,15 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
10560
style={{marginBottom: '100px'}}
10661
padding="none"
10762
>
108-
{Object.entries(data).map(([key, value]) => (
63+
{Object.entries(data as MockData).map(([key, value]) => (
10964
<RedlineBackground key={value}>
11065
<Stack
11166
key={value}
11267
id={value}
11368
direction="vertical"
11469
alignItems="flex-start"
11570
style={{
116-
padding: `${args.sectionHeight / 2}px var(--base-size-24)`,
71+
padding: `${sectionHeight / 2}px var(--base-size-24)`,
11772
}}
11873
>
11974
<Heading>{key}</Heading>
@@ -128,3 +83,72 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
12883
</div>
12984
)
13085
}
86+
Playground.argTypes = {
87+
actionText: {
88+
name: 'text',
89+
control: {type: 'text'},
90+
table: {
91+
category: 'AnchorNav.Action',
92+
},
93+
},
94+
secondaryAction: {
95+
name: 'visible',
96+
control: {type: 'boolean'},
97+
table: {
98+
category: 'AnchorNav.SecondaryAction',
99+
},
100+
},
101+
secondaryActionText: {
102+
name: 'text',
103+
control: {type: 'text'},
104+
table: {
105+
category: 'AnchorNav.SecondaryAction',
106+
},
107+
},
108+
data: {
109+
name: 'Data',
110+
description: 'Test data',
111+
control: {
112+
type: 'object',
113+
},
114+
table: {
115+
category: 'Story customization',
116+
},
117+
},
118+
sectionHeight: {
119+
name: 'Section height',
120+
description: 'Section height',
121+
control: {
122+
type: 'number',
123+
},
124+
table: {
125+
category: 'Story customization',
126+
},
127+
},
128+
offset: {
129+
name: 'Offset',
130+
description: 'Offset from the top of the page',
131+
control: {
132+
type: 'number',
133+
},
134+
table: {
135+
category: 'Story customization',
136+
},
137+
},
138+
}
139+
Playground.args = {
140+
hideUntilSticky: false,
141+
enableDefaultBgColor: false,
142+
actionText: 'Sign up',
143+
secondaryAction: false,
144+
secondaryActionText: 'Learn more',
145+
data: {
146+
['GitHub vs Jenkins']: 'githubvsjenkins',
147+
['GitHub vs GitLab']: 'githubvsgitlab',
148+
['GitHub vs CircleCI']: 'githubvscircleci',
149+
['GitHub vs BitBucket']: 'githubvsvsbitbucket',
150+
['GitHub vs TravisCI']: 'githubvsvstravis',
151+
},
152+
sectionHeight: 1000,
153+
offset: 100,
154+
}

0 commit comments

Comments
 (0)