1
1
import Constants from "../src/constants/Constants" ;
2
- import { addDecorator } from "@storybook/react" ;
3
2
import IntlContextProvider from "../src/contexts/IntlContextProvider" ;
4
3
import { FormGenContextProvider } from "../src/contexts/FormGenContext" ;
5
4
import { ConfigurationContextProvider } from "../src/contexts/ConfigurationContext" ;
@@ -24,37 +23,69 @@ export const globalTypes = {
24
23
name : "Icon behavior" ,
25
24
description : "Set the behavior for the icons" ,
26
25
defaultValue : Constants . ICON_BEHAVIOR . ON_HOVER ,
27
- options : [
28
- Constants . ICON_BEHAVIOR . ON_HOVER ,
29
- Constants . ICON_BEHAVIOR . ENABLE ,
30
- Constants . ICON_BEHAVIOR . DISABLE ,
31
- ] ,
32
- control : { type : "radio" } ,
26
+ toolbar : {
27
+ icon : "photo" ,
28
+ items : [
29
+ { value : Constants . ICON_BEHAVIOR . ON_HOVER , title : "onHover" } ,
30
+ { value : Constants . ICON_BEHAVIOR . ENABLE , title : "Enabled" } ,
31
+ { value : Constants . ICON_BEHAVIOR . DISABLE , title : "Disabled" } ,
32
+ ] ,
33
+ dynamicTitle : true ,
34
+ } ,
33
35
} ,
34
36
locale : {
35
- name : "Locale" ,
36
37
description : "Internationalization locale" ,
37
38
defaultValue : "en" ,
38
- options : [ "en" , "cs" ] ,
39
- control : { type : "radio" } ,
39
+ toolbar : {
40
+ icon : "globe" ,
41
+ items : [
42
+ { value : "en" , right : "🇺🇸" , title : "English" } ,
43
+ { value : "cs" , right : "🇨🇿" , title : "Česky" } ,
44
+ ] ,
45
+ dynamicTitle : true ,
46
+ } ,
40
47
} ,
41
48
debugMode : {
42
49
name : "Debug Mode" ,
43
50
description : "Show irrelevant questions" ,
44
51
defaultValue : false ,
45
- control : { type : "boolean" } ,
52
+ toolbar : {
53
+ title : "Debug mode" ,
54
+ icon : "beaker" ,
55
+ items : [
56
+ { value : true , title : "On" } ,
57
+ { value : false , title : "Off" } ,
58
+ ] ,
59
+ } ,
46
60
} ,
47
61
horizontalNavBar : {
48
62
name : "Toggle Horizontal Navigation Bar" ,
49
63
description : "Set the navigation bar to horizontal" ,
50
64
defaultValue : false ,
51
- control : { type : "boolean" } ,
65
+ toolbar : {
66
+ icon : "expandalt" ,
67
+ items : [
68
+ { value : true , title : "On" } ,
69
+ { value : false , title : "Off" } ,
70
+ ] ,
71
+ } ,
52
72
} ,
53
73
timeOut : {
54
74
name : "Time Out (ms)" ,
55
75
description : "Set time-out for possible values (in ms)" ,
56
76
defaultValue : 1500 ,
57
- control : { type : "number" , min : 0 , max : 10000 , step : 500 } ,
77
+ toolbar : {
78
+ title : "Time Out (ms)" ,
79
+ icon : "timer" ,
80
+ items : [
81
+ { value : 200 , title : "200 ms" } ,
82
+ { value : 500 , title : "500 ms" } ,
83
+ { value : 1000 , title : "1000 ms" } ,
84
+ { value : 1500 , title : "1500 ms" } ,
85
+ { value : 2000 , title : "2000 ms" } ,
86
+ { value : 2500 , title : "2500 ms" } ,
87
+ ] ,
88
+ } ,
58
89
} ,
59
90
} ;
60
91
@@ -104,12 +135,17 @@ const fetchTypeAheadValues = () => {
104
135
) ;
105
136
} ;
106
137
107
- addDecorator ( ( story ) => (
108
- < ConfigurationContextProvider options = { options } >
109
- < FormGenContextProvider fetchTypeAheadValues = { fetchTypeAheadValues } >
110
- < IntlContextProvider locale = { globalTypes . locale . defaultValue } >
111
- { story ( ) }
112
- </ IntlContextProvider >
113
- </ FormGenContextProvider >
114
- </ ConfigurationContextProvider >
115
- ) ) ;
138
+ const preview = {
139
+ decorators : [
140
+ ( Story , context ) => (
141
+ < ConfigurationContextProvider options = { options } >
142
+ < FormGenContextProvider fetchTypeAheadValues = { fetchTypeAheadValues } >
143
+ < IntlContextProvider locale = { context . globals . locale } >
144
+ < Story />
145
+ </ IntlContextProvider >
146
+ </ FormGenContextProvider >
147
+ </ ConfigurationContextProvider >
148
+ ) ,
149
+ ] ,
150
+ } ;
151
+ export default preview ;
0 commit comments