Skip to content

Commit 5c5a33c

Browse files
committed
[Refactor #209] Global controls now present in the top toolbar in storybook. Decorators might need further work to make it simple and unified
1 parent 73c4d70 commit 5c5a33c

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

.storybook/preview.js

+38-19
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ export const globalTypes = {
2323
name: "Icon behavior",
2424
description: "Set the behavior for the icons",
2525
defaultValue: Constants.ICON_BEHAVIOR.ON_HOVER,
26-
options: [
27-
Constants.ICON_BEHAVIOR.ON_HOVER,
28-
Constants.ICON_BEHAVIOR.ENABLE,
29-
Constants.ICON_BEHAVIOR.DISABLE,
30-
],
31-
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+
},
3235
},
33-
locale2: {
36+
locale: {
3437
description: "Internationalization locale",
3538
defaultValue: "en",
3639
toolbar: {
@@ -42,30 +45,47 @@ export const globalTypes = {
4245
dynamicTitle: true,
4346
},
4447
},
45-
locale: {
46-
name: "Locale",
47-
description: "Internationalization locale",
48-
defaultValue: "en",
49-
options: ["en", "cs"],
50-
control: { type: "radio" },
51-
},
5248
debugMode: {
5349
name: "Debug Mode",
5450
description: "Show irrelevant questions",
5551
defaultValue: false,
56-
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+
},
5760
},
5861
horizontalNavBar: {
5962
name: "Toggle Horizontal Navigation Bar",
6063
description: "Set the navigation bar to horizontal",
6164
defaultValue: false,
62-
control: { type: "boolean" },
65+
toolbar: {
66+
icon: "expandalt",
67+
items: [
68+
{ value: true, title: "On" },
69+
{ value: false, title: "Off" },
70+
],
71+
},
6372
},
6473
timeOut: {
6574
name: "Time Out (ms)",
6675
description: "Set time-out for possible values (in ms)",
6776
defaultValue: 1500,
68-
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+
},
6989
},
7090
};
7191

@@ -120,13 +140,12 @@ const preview = {
120140
(Story, context) => (
121141
<ConfigurationContextProvider options={options}>
122142
<FormGenContextProvider fetchTypeAheadValues={fetchTypeAheadValues}>
123-
<IntlContextProvider locale={context.globals.locale2}>
143+
<IntlContextProvider locale={context.globals.locale}>
124144
<Story />
125145
</IntlContextProvider>
126146
</FormGenContextProvider>
127147
</ConfigurationContextProvider>
128148
),
129149
],
130150
};
131-
132151
export default preview;

src/stories/SForms.stories.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,11 @@ const Template: ComponentStory<typeof SForms> = (
9191
};
9292

9393
return (
94-
<IntlContextProvider locale={locale}>
95-
<SForms
96-
{...args}
97-
options={options}
98-
fetchTypeAheadValues={fetchTypeAheadValues}
99-
/>
100-
</IntlContextProvider>
94+
<SForms
95+
{...args}
96+
options={options}
97+
fetchTypeAheadValues={fetchTypeAheadValues}
98+
/>
10199
);
102100
};
103101

0 commit comments

Comments
 (0)