@@ -25,46 +25,28 @@ const stack = (Story: PartialStoryFn<ReactRenderer>) => (
25
25
26
26
const icon = < akselIcons . FloppydiskIcon /> ;
27
27
28
- type AkselIcon = ( typeof akselIcons ) [ 'AirplaneFillIcon' ] ;
29
- type AkselIcons = Record < string , AkselIcon > ;
30
-
31
28
export const Preview : Story = {
32
- render : ( { icon = '' , ...args } ) => {
33
- // Hack to get dynamic preview of Aksel icons in Storybook
34
- const Icon : AkselIcon | undefined = ( akselIcons as AkselIcons ) [
35
- icon as string
36
- ] ;
37
-
38
- return (
39
- < Button
40
- { ...args }
41
- icon = { Icon ? < Icon /> : undefined }
42
- > </ Button >
43
- ) ;
29
+ render : ( { ...args } ) => {
30
+ return < Button { ...args } /> ;
44
31
} ,
45
32
args : {
46
33
children : 'Knapp' ,
47
34
disabled : false ,
48
35
variant : 'primary' ,
49
36
color : 'first' ,
50
37
size : 'medium' ,
51
- } ,
52
- argTypes : {
53
- icon : {
54
- control : 'select' ,
55
- options : Object . keys ( akselIcons ) ,
56
- } ,
38
+ icon : false ,
39
+ fullWidth : false ,
57
40
} ,
58
41
} ;
59
42
60
43
export const UsedAsLink : StoryFn < typeof Button > = ( ) => (
61
44
< Button
62
45
as = 'a'
63
- icon = { < akselIcons . PersonChatIcon /> }
64
- iconPlacement = 'right'
65
46
target = '_blank'
66
47
href = 'https://www.designsystemet.no'
67
48
>
49
+ < akselIcons . PersonChatIcon />
68
50
Gå til Designsystemet
69
51
</ Button >
70
52
) ;
@@ -137,74 +119,96 @@ Variants.decorators = [
137
119
export const WithIcon : StoryFn < typeof Button > = ( ) => (
138
120
< >
139
121
< Button
140
- icon = { icon }
122
+ icon = { true }
141
123
variant = 'primary'
142
124
aria-label = 'Primary med ikon'
143
- > </ Button >
125
+ >
126
+ { icon }
127
+ </ Button >
144
128
< Button
145
- icon = { icon }
129
+ icon = { true }
146
130
variant = 'secondary'
147
131
aria-label = ' Secondary med ikon'
148
- > </ Button >
132
+ >
133
+ { icon }
134
+ </ Button >
149
135
< Button
150
- icon = { icon }
136
+ icon = { true }
151
137
variant = 'tertiary'
152
138
aria-label = 'Tertiary med ikon'
153
- > </ Button >
139
+ >
140
+ { icon }
141
+ </ Button >
154
142
< Button
155
- icon = { icon }
143
+ icon = { true }
156
144
color = 'second'
157
145
variant = 'primary'
158
146
aria-label = 'Primary med ikon'
159
- > </ Button >
147
+ >
148
+ { icon }
149
+ </ Button >
160
150
< Button
161
- icon = { icon }
151
+ icon = { true }
162
152
color = 'second'
163
153
variant = 'secondary'
164
154
aria-label = ' Secondary med ikon'
165
- > </ Button >
155
+ >
156
+ { icon }
157
+ </ Button >
166
158
< Button
167
- icon = { icon }
159
+ icon = { true }
168
160
color = 'second'
169
161
variant = 'tertiary'
170
162
aria-label = 'Tertiary med ikon'
171
163
> </ Button >
172
164
< Button
173
- icon = { < akselIcons . CheckmarkIcon /> }
165
+ icon = { true }
174
166
color = 'success'
175
167
variant = 'primary'
176
168
aria-label = 'Primary med ikon'
177
- > </ Button >
169
+ >
170
+ < akselIcons . CheckmarkIcon />
171
+ </ Button >
178
172
< Button
179
- icon = { < akselIcons . CheckmarkIcon /> }
173
+ icon = { true }
180
174
color = 'success'
181
175
variant = 'secondary'
182
176
aria-label = ' Secondary med ikon'
183
- > </ Button >
177
+ >
178
+ < akselIcons . CheckmarkIcon />
179
+ </ Button >
184
180
< Button
185
- icon = { < akselIcons . CheckmarkIcon /> }
181
+ icon = { true }
186
182
color = 'success'
187
183
variant = 'tertiary'
188
184
aria-label = 'Tertiary med ikon'
189
- > </ Button >
185
+ >
186
+ < akselIcons . CheckmarkIcon />
187
+ </ Button >
190
188
< Button
191
- icon = { < akselIcons . TrashIcon /> }
189
+ icon = { true }
192
190
color = 'danger'
193
191
variant = 'primary'
194
192
aria-label = 'Primary med ikon'
195
- > </ Button >
193
+ >
194
+ < akselIcons . TrashIcon />
195
+ </ Button >
196
196
< Button
197
- icon = { < akselIcons . TrashIcon /> }
197
+ icon = { true }
198
198
color = 'danger'
199
199
variant = 'secondary'
200
200
aria-label = ' Secondary med ikon'
201
- > </ Button >
201
+ >
202
+ < akselIcons . TrashIcon />
203
+ </ Button >
202
204
< Button
203
- icon = { < akselIcons . TrashIcon /> }
205
+ icon = { true }
204
206
color = 'danger'
205
207
variant = 'tertiary'
206
208
aria-label = 'Tertiary med ikon'
207
- > </ Button >
209
+ >
210
+ < akselIcons . TrashIcon />
211
+ </ Button >
208
212
</ >
209
213
) ;
210
214
@@ -223,22 +227,16 @@ WithIcon.decorators = [
223
227
224
228
export const WithIconAndText : StoryFn < typeof Button > = ( ) => (
225
229
< >
226
- < Button
227
- icon = { icon }
228
- variant = 'primary'
229
- >
230
+ < Button variant = 'primary' >
231
+ { icon }
230
232
Primary
231
233
</ Button >
232
- < Button
233
- icon = { icon }
234
- variant = 'secondary'
235
- >
234
+ < Button variant = 'secondary' >
235
+ { icon }
236
236
Secondary
237
237
</ Button >
238
- < Button
239
- icon = { icon }
240
- variant = 'tertiary'
241
- >
238
+ < Button variant = 'tertiary' >
239
+ { icon }
242
240
Tertiary
243
241
</ Button >
244
242
</ >
@@ -249,10 +247,10 @@ WithIconAndText.decorators = [stack];
249
247
export const WithSpinner : StoryFn < typeof Button > = ( ) => (
250
248
< >
251
249
< Button
252
- icon = { icon }
253
250
variant = 'primary'
254
251
aria-disabled
255
252
>
253
+ { icon }
256
254
< Spinner
257
255
variant = 'interaction'
258
256
title = 'loading'
@@ -261,10 +259,10 @@ export const WithSpinner: StoryFn<typeof Button> = () => (
261
259
Laster...
262
260
</ Button >
263
261
< Button
264
- icon = { icon }
265
262
variant = 'secondary'
266
263
aria-disabled
267
264
>
265
+ { icon }
268
266
< Spinner
269
267
variant = 'interaction'
270
268
title = 'loading'
@@ -273,10 +271,10 @@ export const WithSpinner: StoryFn<typeof Button> = () => (
273
271
Laster...
274
272
</ Button >
275
273
< Button
276
- icon = { icon }
277
274
variant = 'tertiary'
278
275
aria-disabled
279
276
>
277
+ { icon }
280
278
< Spinner
281
279
variant = 'interaction'
282
280
title = 'loading'
0 commit comments