1
1
import React from 'react' ;
2
- import styled from 'styled-components' ;
2
+ import { themes } from '@storybook/theming' ;
3
+
4
+ import { classnames } from '../src/js/components/utils/classnames' ;
5
+ import { GlobalStyles } from '../src/js/components/utils/style/style' ;
6
+ import { badges , Storybook } from '../src/js/components/utils/storybook' ;
3
7
4
8
export const parameters = {
5
9
actions : { argTypesRegex : "^on[A-Z].*" } ,
10
+ layout : 'fullscreen' ,
6
11
controls : {
7
12
matchers : {
8
13
color : / ( b a c k g r o u n d | c o l o r ) $ / i,
9
14
date : / D a t e $ / ,
10
15
} ,
11
16
} ,
17
+ badgesConfig : {
18
+ ...badges
19
+ } ,
20
+ darkMode : {
21
+ // Override the default dark theme
22
+ dark : {
23
+ ...themes . dark ,
24
+ appBg : '#151515' ,
25
+ appContentBg : '#1A1A1A' ,
26
+ } ,
27
+ // Override the default light theme
28
+ light : {
29
+ ...themes . normal ,
30
+ appBg : '#EFEDEB' ,
31
+ appContentBg : "#F6F6F6"
32
+ }
33
+ }
12
34
}
13
35
14
- const cssVars = `
15
- :root {
16
- --background-color---opacity-high: hsla(0, 0%, 10.196078431372548%, 0.75);
17
- --background-color---opacity-higher: hsla(0, 0%, 10.196078431372548%, 0.85);
18
- --background-color---opacity-low: hsla(0, 0%, 10.196078431372548%, 0.25);
19
- --background-color---opacity-lower: hsla(0, 0%, 10.196078431372548%, 0.1);
20
- --background-color---opacity-med: hsla(0, 0%, 10.196078431372548%, 0.5);
21
- --background-color: #1A1A1A;
22
- --background-minus-1---opacity-high: hsla(0, 0%, 8.235294117647058%, 0.75);
23
- --background-minus-1---opacity-higher: hsla(0, 0%, 8.235294117647058%, 0.85);
24
- --background-minus-1---opacity-low: hsla(0, 0%, 8.235294117647058%, 0.25);
25
- --background-minus-1---opacity-lower: hsla(0, 0%, 8.235294117647058%, 0.1);
26
- --background-minus-1---opacity-med: hsla(0, 0%, 8.235294117647058%, 0.5);
27
- --background-minus-1: #151515;
28
- --background-minus-2---opacity-high: hsla(0, 0%, 6.6667%, 0.75);
29
- --background-minus-2---opacity-higher: hsla(0, 0%, 6.6667%, 0.85);
30
- --background-minus-2---opacity-low: hsla(0, 0%, 6.6667%, 0.25);
31
- --background-minus-2---opacity-lower: hsla(0, 0%, 6.6667%, 0.1);
32
- --background-minus-2---opacity-med: hsla(0, 0%, 6.6667%, 0.5);
33
- --background-minus-2: #111;
34
- --background-plus-1---opacity-high: hsla(0, 0%, 13.333%, 0.75);
35
- --background-plus-1---opacity-higher: hsla(0, 0%, 13.333%, 0.85);
36
- --background-plus-1---opacity-low: hsla(0, 0%, 13.333%, 0.25);
37
- --background-plus-1---opacity-lower: hsla(0, 0%, 13.333%, 0.1);
38
- --background-plus-1---opacity-med: hsla(0, 0%, 13.333%, 0.5);
39
- --background-plus-1: #222;
40
- --background-plus-2---opacity-high: hsla(0, 0%, 20%, 0.75);
41
- --background-plus-2---opacity-higher: hsla(0, 0%, 20%, 0.85);
42
- --background-plus-2---opacity-low: hsla(0, 0%, 20%, 0.25);
43
- --background-plus-2---opacity-lower: hsla(0, 0%, 20%, 0.1);
44
- --background-plus-2---opacity-med: hsla(0, 0%, 20%, 0.5);
45
- --background-plus-2: #333;
46
- --body-text-color---opacity-high: hsla(0, 0%, 66.666%, 0.75);
47
- --body-text-color---opacity-higher: hsla(0, 0%, 66.666%, 0.85);
48
- --body-text-color---opacity-low: hsla(0, 0%, 66.666%, 0.25);
49
- --body-text-color---opacity-lower: hsla(0, 0%, 66.666%, 0.1);
50
- --body-text-color---opacity-med: hsla(0, 0%, 66.666%, 0.5);
51
- --body-text-color: #AAA;
52
- --border-color---opacity-high: hsla(0, 0%, 0%, 0.75);
53
- --border-color---opacity-higher: hsla(0, 0%, 0%, 0.85);
54
- --border-color---opacity-low: hsla(0, 0%, 0%, 0.25);
55
- --border-color---opacity-lower: hsla(0, 0%, 0%, 0.1);
56
- --border-color---opacity-med: hsla(0, 0%, 0%, 0.5);
57
- --border-color: hsla(32, 81%, 90%, 0.08);
58
- --confirmation-color---opacity-high: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.75);
59
- --confirmation-color---opacity-higher: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.85);
60
- --confirmation-color---opacity-low: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.25);
61
- --confirmation-color---opacity-lower: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.1);
62
- --confirmation-color---opacity-med: hsla(133.43283582089555, 73.62637362637363%, 35.68627450980392%, 0.5);
63
- --confirmation-color: #189E36;
64
- --error-color---opacity-high: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.75);
65
- --error-color---opacity-higher: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.85);
66
- --error-color---opacity-low: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.25);
67
- --error-color---opacity-lower: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.1);
68
- --error-color---opacity-med: hsla(4.838709677419331, 97.89473684210527%, 62.745098039215684%, 0.5);
69
- --error-color: #fd5243;
70
- --graph-control-bg---opacity-high: hsla(0, 0%, 15.294117647058824%, 0.75);
71
- --graph-control-bg---opacity-higher: hsla(0, 0%, 15.294117647058824%, 0.85);
72
- --graph-control-bg---opacity-low: hsla(0, 0%, 15.294117647058824%, 0.25);
73
- --graph-control-bg---opacity-lower: hsla(0, 0%, 15.294117647058824%, 0.1);
74
- --graph-control-bg---opacity-med: hsla(0, 0%, 15.294117647058824%, 0.5);
75
- --graph-control-bg: #272727;
76
- --graph-control-color---opacity-high: hsla(0, 0%, 0%, 0.75);
77
- --graph-control-color---opacity-higher: hsla(0, 0%, 0%, 0.85);
78
- --graph-control-color---opacity-low: hsla(0, 0%, 0%, 0.25);
79
- --graph-control-color---opacity-lower: hsla(0, 0%, 0%, 0.1);
80
- --graph-control-color---opacity-med: hsla(0, 0%, 0%, 0.5);
81
- --graph-control-color: white;
82
- --graph-link-normal---opacity-high: hsla(0, 0%, 19.607843137254903%, 0.75);
83
- --graph-link-normal---opacity-higher: hsla(0, 0%, 19.607843137254903%, 0.85);
84
- --graph-link-normal---opacity-low: hsla(0, 0%, 19.607843137254903%, 0.25);
85
- --graph-link-normal---opacity-lower: hsla(0, 0%, 19.607843137254903%, 0.1);
86
- --graph-link-normal---opacity-med: hsla(0, 0%, 19.607843137254903%, 0.5);
87
- --graph-link-normal: #323232;
88
- --graph-node-hlt---opacity-high: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.75);
89
- --graph-node-hlt---opacity-higher: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.85);
90
- --graph-node-hlt---opacity-low: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.25);
91
- --graph-node-hlt---opacity-lower: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.1);
92
- --graph-node-hlt---opacity-med: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.5);
93
- --graph-node-hlt: #FBBE63;
94
- --graph-node-normal---opacity-high: hsla(0, 0%, 56.470588235294116%, 0.75);
95
- --graph-node-normal---opacity-higher: hsla(0, 0%, 56.470588235294116%, 0.85);
96
- --graph-node-normal---opacity-low: hsla(0, 0%, 56.470588235294116%, 0.25);
97
- --graph-node-normal---opacity-lower: hsla(0, 0%, 56.470588235294116%, 0.1);
98
- --graph-node-normal---opacity-med: hsla(0, 0%, 56.470588235294116%, 0.5);
99
- --graph-node-normal: #909090;
100
- --header-text-color---opacity-high: hsla(0, 0%, 72.94117647058823%, 0.75);
101
- --header-text-color---opacity-higher: hsla(0, 0%, 72.94117647058823%, 0.85);
102
- --header-text-color---opacity-low: hsla(0, 0%, 72.94117647058823%, 0.25);
103
- --header-text-color---opacity-lower: hsla(0, 0%, 72.94117647058823%, 0.1);
104
- --header-text-color---opacity-med: hsla(0, 0%, 72.94117647058823%, 0.5);
105
- --header-text-color: #BABABA;
106
- --highlight-color---opacity-high: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.75);
107
- --highlight-color---opacity-higher: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.85);
108
- --highlight-color---opacity-low: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.25);
109
- --highlight-color---opacity-lower: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.1);
110
- --highlight-color---opacity-med: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.5);
111
- --highlight-color: #FBBE63;
112
- --link-color---opacity-high: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.75);
113
- --link-color---opacity-higher: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.85);
114
- --link-color---opacity-low: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.25);
115
- --link-color---opacity-lower: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.1);
116
- --link-color---opacity-med: hsla(203.8775510204082, 80.32786885245902%, 52.156862745098046%, 0.5);
117
- --link-color: #2399E7;
118
- --text-highlight-color---opacity-high: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.75);
119
- --text-highlight-color---opacity-higher: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.85);
120
- --text-highlight-color---opacity-low: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.25);
121
- --text-highlight-color---opacity-lower: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.1);
122
- --text-highlight-color---opacity-med: hsla(35.92105263157896, 94.99999999999999%, 68.62745098039215%, 0.5);
123
- --text-highlight-color: #FBBE63;
124
- --warning-color---opacity-high: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.75);
125
- --warning-color---opacity-higher: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.85);
126
- --warning-color---opacity-low: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.25);
127
- --warning-color---opacity-lower: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.1);
128
- --warning-color---opacity-med: hsla(8.571428571428555, 74.11764705882354%, 50%, 0.5);
129
- --warning-color: #DE3C21;
130
- }
131
-
132
- .docs-story {
133
- background: var(--background-color);
134
- }`
36
+ export const globalTypes = {
37
+ theme : {
38
+ name : 'Story Theme' ,
39
+ description : 'Global theme for components' ,
40
+ defaultValue : 'light' ,
41
+ toolbar : {
42
+ // Array of plain string values or MenuItem shape (see below)
43
+ items : [ 'light' , 'dark' ] ,
44
+ // Property that specifies if the name of the item will be displayed
45
+ showName : true ,
46
+ } ,
47
+ } ,
48
+ } ;
135
49
136
- const StoryWrapper = styled . div `
137
- ` ;
138
50
139
51
export const decorators = [
140
- ( Story ) => (
141
- < StoryWrapper >
142
- < style > { cssVars } </ style >
143
- < Story />
144
- </ StoryWrapper >
145
- ) ,
52
+ ( Story , context ) => {
53
+
54
+ React . useEffect ( ( ) => {
55
+ const theme = context . globals . theme === 'dark' ? 'is-theme-dark' : 'is-theme-light' ;
56
+ document . body . classList . add ( theme ) ;
57
+ return ( ) => document . body . classList . remove ( theme ) ;
58
+ } , [ context ] )
59
+
60
+ console . log ( context ) ;
61
+ return (
62
+ < >
63
+ < GlobalStyles />
64
+ < Storybook . App
65
+ id = "app"
66
+ className = { classnames (
67
+ context . globals . hostType === 'electron' ? 'is-electron' : 'is-browser' ,
68
+ context . viewMode === 'docs' ? 'is-storybook-docs' : 'is-storybook-canvas'
69
+ ) } >
70
+ < Story />
71
+ </ Storybook . App >
72
+ </ >
73
+ )
74
+ } ,
146
75
] ;
0 commit comments