@@ -14,66 +14,20 @@ export default {
14
14
parameters : {
15
15
layout : 'fullscreen' ,
16
16
} ,
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
- } ,
61
17
} as Meta < typeof AnchorNav >
62
18
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
+ )
75
29
76
- export const Playground = ( { data, ... args } : { data : MockData ; offset : number ; sectionHeight : number } ) => {
30
+ export const Playground = ( { data, sectionHeight , actionText , secondaryAction , secondaryActionText , ... args } ) => {
77
31
return (
78
32
< div style = { { backgroundColor : 'var(--base-color-scale-red-0)' } } >
79
33
< RedlineBackground height = { args . offset } >
@@ -87,12 +41,13 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
87
41
</ Stack >
88
42
</ RedlineBackground >
89
43
< AnchorNav { ...args } >
90
- { Object . entries ( data ) . map ( ( [ key , value ] ) => (
44
+ { Object . entries ( data as MockData ) . map ( ( [ key , value ] ) => (
91
45
< AnchorNav . Link href = { value } key = { value } >
92
46
{ key }
93
47
</ AnchorNav . Link >
94
48
) ) }
95
- < AnchorNav . Action href = "#" > Sign up</ AnchorNav . Action >
49
+ < AnchorNav . Action href = "#" > { actionText } </ AnchorNav . Action >
50
+ { secondaryAction && < AnchorNav . SecondaryAction href = "#" > { secondaryActionText } </ AnchorNav . SecondaryAction > }
96
51
</ AnchorNav >
97
52
{ /**
98
53
* The following markup is provided for demonstration purposes only.
@@ -105,15 +60,15 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
105
60
style = { { marginBottom : '100px' } }
106
61
padding = "none"
107
62
>
108
- { Object . entries ( data ) . map ( ( [ key , value ] ) => (
63
+ { Object . entries ( data as MockData ) . map ( ( [ key , value ] ) => (
109
64
< RedlineBackground key = { value } >
110
65
< Stack
111
66
key = { value }
112
67
id = { value }
113
68
direction = "vertical"
114
69
alignItems = "flex-start"
115
70
style = { {
116
- padding : `${ args . sectionHeight / 2 } px var(--base-size-24)` ,
71
+ padding : `${ sectionHeight / 2 } px var(--base-size-24)` ,
117
72
} }
118
73
>
119
74
< Heading > { key } </ Heading >
@@ -128,3 +83,72 @@ export const Playground = ({data, ...args}: {data: MockData; offset: number; sec
128
83
</ div >
129
84
)
130
85
}
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