1
1
import type { Meta , StoryFn } from '@storybook/react' ;
2
2
3
- import { Label } from '../../Label' ;
4
- import { Select } from './' ;
3
+ import { Field , Label , Select , ValidationMessage } from '../../' ;
5
4
6
5
export default {
7
6
title : 'Komponenter/Select' ,
8
7
component : Select ,
9
8
parameters : {
10
9
layout : 'padded' ,
11
10
} ,
12
- decorators : [
13
- ( Story ) => (
14
- < div
15
- style = { {
16
- display : 'flex' ,
17
- gap : 'var(--ds-spacing-2)' ,
18
- flexDirection : 'column' ,
19
- } }
20
- >
21
- < Story />
22
- </ div >
23
- ) ,
24
- ] ,
25
11
} as Meta ;
26
12
27
13
export const Preview : StoryFn < typeof Select > = ( args ) => (
28
- < >
29
- < Label htmlFor = { args . id } > Velg et fjell</ Label >
14
+ < Field >
15
+ < Label > Velg et fjell</ Label >
30
16
< Select { ...args } >
31
17
< Select . Option value = 'blank' > Velg …</ Select . Option >
32
18
< Select . Option value = 'everest' > Mount Everest</ Select . Option >
@@ -38,20 +24,19 @@ export const Preview: StoryFn<typeof Select> = (args) => (
38
24
< Select . Option value = 'puncakjaya' > Puncak Jaya</ Select . Option >
39
25
< Select . Option value = 'kosciuszko' > Mount Kosciuszko</ Select . Option >
40
26
</ Select >
41
- </ >
27
+ </ Field >
42
28
) ;
43
29
44
30
Preview . args = {
45
31
'aria-invalid' : false ,
46
32
'data-size' : 'md' ,
47
33
disabled : false ,
48
34
readOnly : false ,
49
- id : 'my-select' ,
50
35
} ;
51
36
52
37
export const Disabled : StoryFn < typeof Select > = ( args ) => (
53
- < >
54
- < Label htmlFor = { args . id } > Velg et fjell</ Label >
38
+ < Field >
39
+ < Label > Velg et fjell</ Label >
55
40
< Select { ...args } >
56
41
< Select . Option value = 'blank' > Velg …</ Select . Option >
57
42
< Select . Option value = 'everest' > Mount Everest</ Select . Option >
@@ -63,17 +48,16 @@ export const Disabled: StoryFn<typeof Select> = (args) => (
63
48
< Select . Option value = 'puncakjaya' > Puncak Jaya</ Select . Option >
64
49
< Select . Option value = 'kosciuszko' > Mount Kosciuszko</ Select . Option >
65
50
</ Select >
66
- </ >
51
+ </ Field >
67
52
) ;
68
53
69
54
Disabled . args = {
70
55
disabled : true ,
71
- id : 'my-select' ,
72
56
} ;
73
57
74
58
export const WithError : StoryFn < typeof Select > = ( args ) => (
75
- < >
76
- < Label htmlFor = { args . id } > Velg et fjell</ Label >
59
+ < Field >
60
+ < Label > Velg et fjell</ Label >
77
61
< Select { ...args } >
78
62
< Select . Option value = 'blank' > Velg …</ Select . Option >
79
63
< Select . Option value = 'everest' > Mount Everest</ Select . Option >
@@ -85,17 +69,17 @@ export const WithError: StoryFn<typeof Select> = (args) => (
85
69
< Select . Option value = 'puncakjaya' > Puncak Jaya</ Select . Option >
86
70
< Select . Option value = 'kosciuszko' > Mount Kosciuszko</ Select . Option >
87
71
</ Select >
88
- </ >
72
+ < ValidationMessage > Velg et fjell</ ValidationMessage >
73
+ </ Field >
89
74
) ;
90
75
91
76
WithError . args = {
92
77
'aria-invalid' : true ,
93
- id : 'my-select' ,
94
78
} ;
95
79
96
80
export const WithOptgroup : StoryFn < typeof Select > = ( args ) => (
97
- < >
98
- < Label htmlFor = { args . id } > Velg et fjell</ Label >
81
+ < Field >
82
+ < Label > Velg et fjell</ Label >
99
83
< Select { ...args } >
100
84
< Select . Optgroup label = 'Gruppe 1' >
101
85
< Select . Option value = 'everest' > Mount Everest</ Select . Option >
@@ -110,9 +94,5 @@ export const WithOptgroup: StoryFn<typeof Select> = (args) => (
110
94
< Select . Option value = 'kosciuszko' > Mount Kosciuszko</ Select . Option >
111
95
</ Select . Optgroup >
112
96
</ Select >
113
- </ >
97
+ </ Field >
114
98
) ;
115
-
116
- WithOptgroup . args = {
117
- id : 'my-select' ,
118
- } ;
0 commit comments