@automattic/vip-design-system 0.28.1 → 0.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.storybook/decorators/withColorMode.jsx +15 -2
  2. package/README.md +3 -3
  3. package/build/system/Accordion/Accordion.js +21 -30
  4. package/build/system/Badge/Badge.stories.js +1 -1
  5. package/build/system/Dropdown/Dropdown.stories.js +9 -5
  6. package/build/system/Form/Radio.stories.js +1 -1
  7. package/build/system/NewForm/FormAutocomplete.js +12 -2
  8. package/build/system/NewForm/FormAutocomplete.stories.js +14 -2
  9. package/build/system/NewForm/FormSelect.stories.js +3 -1
  10. package/build/system/Notice/Notice.stories.js +13 -23
  11. package/build/system/Table/Table.stories.js +0 -3
  12. package/build/system/Tabs/Tabs.stories.js +3 -3
  13. package/build/system/Wizard/WizardStep.js +5 -3
  14. package/build/system/theme/colors.js +7 -170
  15. package/build/system/theme/generated/valet-theme-dark.json +2924 -0
  16. package/{src/system/theme/generated/valet-theme.json → build/system/theme/generated/valet-theme-light.json} +47 -8
  17. package/build/system/theme/getColor.js +53 -50
  18. package/build/system/theme/index.js +114 -147
  19. package/build/system/theme/textStyles.js +51 -0
  20. package/package.json +7 -3
  21. package/src/system/Accordion/Accordion.js +8 -6
  22. package/src/system/Badge/Badge.stories.jsx +2 -2
  23. package/src/system/Dropdown/Dropdown.stories.jsx +12 -10
  24. package/src/system/Form/Radio.stories.jsx +3 -3
  25. package/src/system/NewForm/FormAutocomplete.js +11 -0
  26. package/src/system/NewForm/FormAutocomplete.stories.jsx +13 -0
  27. package/src/system/NewForm/FormSelect.stories.jsx +3 -2
  28. package/src/system/Notice/Notice.stories.jsx +8 -12
  29. package/src/system/Table/Table.stories.jsx +1 -1
  30. package/src/system/Tabs/Tabs.stories.jsx +3 -3
  31. package/src/system/Wizard/WizardStep.js +9 -3
  32. package/src/system/theme/colors.js +5 -171
  33. package/src/system/theme/generated/valet-theme-dark.json +2924 -0
  34. package/src/system/theme/generated/valet-theme-light.json +2918 -0
  35. package/src/system/theme/getColor.js +46 -40
  36. package/src/system/theme/index.js +150 -170
  37. package/src/system/theme/textStyles.js +46 -0
  38. package/tokens/valet-core/$metadata.json +1 -0
  39. package/tokens/valet-core/$themes.json +0 -2
  40. package/tokens/valet-core/wpvip-productive-color-dark.json +946 -0
  41. package/tokens/valet-core/wpvip-productive-color.json +47 -8
@@ -2,46 +2,52 @@
2
2
  * Internal dependencies
3
3
  */
4
4
 
5
- import Valet from './generated/valet-theme.json';
6
-
7
- export const getColor = ( color, variant = 'default' ) => {
8
- if ( ! Valet[ color ] ) {
9
- return '#000000';
10
- }
11
-
12
- return Valet[ color ][ variant ].value;
13
- };
14
-
15
- const resolvePath = ( object, path, defaultValue ) => {
16
- return path.split( '.' ).reduce( ( acc, property ) => {
17
- return acc ? acc[ property ] : defaultValue;
18
- }, object );
19
- };
20
-
21
- export const getVariants = color => {
22
- const property = resolvePath( Valet, color, {} );
23
-
24
- return Object.keys( property ).reduce(
25
- ( variants, variant ) => ( { ...variants, [ variant ]: property[ variant ].value } ),
26
- {}
27
- );
28
- };
29
-
30
- const traverse = root => {
31
- if ( root.hasOwnProperty( 'value' ) && root.hasOwnProperty( 'type' ) ) {
32
- return root.value;
33
- }
34
-
35
- return Object.entries( root ).reduce(
36
- ( acc, [ key, value ] ) => ( {
37
- ...acc,
38
- [ key ]: traverse( value ),
39
- } ),
40
- {}
41
- );
42
- };
43
-
44
5
  // Valet Theme Productive Theme
45
6
  // https://www.figma.com/file/sILtW5Cs2tAnPWrSOEVyER/Productive-Color?node-id=1%3A17&t=4kHdpoprxntk5Ilw-0
46
7
 
47
- export const ValetTheme = traverse( Valet );
8
+ export default theme => {
9
+ const getColor = ( color, variant = 'default' ) => {
10
+ if ( ! theme[ color ] ) {
11
+ return '#000000';
12
+ }
13
+
14
+ return theme[ color ][ variant ].value;
15
+ };
16
+
17
+ const resolvePath = ( object, path, defaultValue ) => {
18
+ return path.split( '.' ).reduce( ( acc, property ) => {
19
+ return acc ? acc[ property ] : defaultValue;
20
+ }, object );
21
+ };
22
+
23
+ const getVariants = color => {
24
+ const property = resolvePath( theme, color, {} );
25
+
26
+ return Object.keys( property ).reduce(
27
+ ( variants, variant ) => ( { ...variants, [ variant ]: property[ variant ].value } ),
28
+ {}
29
+ );
30
+ };
31
+
32
+ const traverse = root => {
33
+ if ( root.hasOwnProperty( 'value' ) && root.hasOwnProperty( 'type' ) ) {
34
+ return root.value;
35
+ }
36
+
37
+ return Object.entries( root ).reduce(
38
+ ( acc, [ key, value ] ) => ( {
39
+ ...acc,
40
+ [ key ]: traverse( value ),
41
+ } ),
42
+ {}
43
+ );
44
+ };
45
+
46
+ return {
47
+ ValetTheme: traverse( theme ),
48
+ getColor,
49
+ getVariants,
50
+ traverse,
51
+ resolvePath,
52
+ };
53
+ };
@@ -1,55 +1,25 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { getColor, getVariants, ValetTheme } from './getColor';
5
- import { light, dark } from './colors';
6
-
7
- const textStyles = {
8
- h1: {
9
- fontSize: 5,
10
- marginBottom: 3,
11
- letterSpacing: '-.02em',
12
- fontWeight: 'body',
13
- fontFamily: 'serif',
14
- color: 'heading',
15
- },
16
- h2: {
17
- fontSize: 4,
18
- marginBottom: 2,
19
- letterSpacing: '-.005em',
20
- fontWeight: 400,
21
- color: 'heading',
22
- },
23
- h3: {
24
- fontSize: 3,
25
- marginBottom: 3,
26
- letterSpacing: '-.005em',
27
- lineHeight: 1.4,
28
- fontWeight: 'heading',
29
- color: 'heading',
30
- },
31
- h4: {
32
- fontSize: 2,
33
- marginBottom: 1,
34
- lineHeight: 1.5,
35
- fontWeight: 'heading',
36
- color: 'heading',
37
- },
38
- h5: {
39
- fontSize: 1,
40
- marginBottom: 1,
41
- lineHeight: 1.5,
42
- fontWeight: 'heading',
43
- color: 'heading',
44
- },
45
- caps: {
46
- fontSize: 1,
47
- marginBottom: 2,
48
- color: 'muted',
49
- fontWeight: 'bold',
50
- letterSpacing: '.05em',
51
- },
52
- };
4
+ import ThemeBuilder from './getColor';
5
+
6
+ import Valet from './generated/valet-theme-light.json';
7
+ import ValetDark from './generated/valet-theme-dark.json';
8
+ import ColorBuilder from './colors';
9
+ import { textStyles } from './textStyles';
10
+
11
+ // Light
12
+ const { getColor, getVariants, ValetTheme } = ThemeBuilder( Valet );
13
+ const light = ColorBuilder( ValetTheme );
14
+
15
+ // Dark
16
+ const {
17
+ getColor: getColorDark,
18
+ getVariants: getVariantsDark,
19
+ ValetTheme: ValetThemeDark,
20
+ } = ThemeBuilder( ValetDark );
21
+
22
+ const dark = ColorBuilder( ValetThemeDark );
53
23
 
54
24
  const outline = {
55
25
  outlineStyle: 'solid',
@@ -65,6 +35,117 @@ const fonts = {
65
35
  serif: 'recoletaregular, Georgia, serif',
66
36
  };
67
37
 
38
+ const getComponentColors = ( theme, gColor, gVariants ) => ( {
39
+ // Valet Theme Colors
40
+
41
+ // This has to be in the plural because we already have a flag: text
42
+ texts: {
43
+ ...theme.text,
44
+ disabled: '#716e6e',
45
+ },
46
+
47
+ button: {
48
+ ...theme.button,
49
+ },
50
+
51
+ tag: {
52
+ ...theme.tag,
53
+ },
54
+
55
+ // Notice
56
+ notice: {
57
+ ...theme.support,
58
+ },
59
+
60
+ // layer
61
+ layer: {
62
+ ...theme.layer,
63
+ },
64
+
65
+ // icon
66
+ icon: {
67
+ ...theme.icon,
68
+ },
69
+
70
+ // Form Controls
71
+ input: {
72
+ ...theme.input,
73
+ },
74
+
75
+ // Accordion
76
+ accordion: {
77
+ content: {
78
+ background: gColor( 'layer', '2' ),
79
+ text: gColor( 'text', 'secondary' ),
80
+ },
81
+ trigger: {
82
+ text: gColor( 'text', 'primary' ),
83
+ },
84
+ background: {
85
+ open: gColor( 'layer', '3' ),
86
+ closed: 'transparent',
87
+ hover: gColor( 'layer', '3' ),
88
+ },
89
+ },
90
+
91
+ optionRow: {
92
+ hover: 'rgba(0,0,0,.02)',
93
+ border: gColor( 'border', '1' ),
94
+ text: gColor( 'text', 'secondary' ),
95
+ textAccent: gColor( 'link', 'default' ),
96
+ icon: gColor( 'icon', 'primary' ),
97
+ iconBackground: gColor( 'layer', 'accent' ),
98
+ },
99
+
100
+ table: {
101
+ border: gColor( 'border', '2' ),
102
+ heading: gColor( 'text', 'primary' ),
103
+ text: gColor( 'text', 'secondary' ),
104
+ },
105
+
106
+ // Common Tokens
107
+ text: gColor( 'text', 'secondary' ),
108
+ heading: gColor( 'text', 'primary' ),
109
+ background: gColor( 'layer', '2' ),
110
+ backgroundSecondary: gColor( 'layer', '1' ),
111
+ primary: gColor( 'link', 'default' ),
112
+ secondary: light.gray[ '70' ],
113
+ muted: gColor( 'text', 'helper' ),
114
+ border: gColor( 'border', '1' ),
115
+ borders: {
116
+ 1: gColor( 'border', '1' ),
117
+ 2: gColor( 'border', '2' ),
118
+ 3: gColor( 'border', '3' ),
119
+ 4: gColor( 'border', '4' ),
120
+ inverse: gColor( 'border', 'inverse' ),
121
+ accent: gColor( 'border', 'accent' ),
122
+ },
123
+ hover: 'rgba(0,0,0,.02)',
124
+ darken: 'rgba(0,0,0,.05)',
125
+ placeholder: gVariants( 'input.text' ).placeholder,
126
+ midnight: '#13191E',
127
+ dialog: light.gray[ '0' ],
128
+ backgroundMuted: gColor( 'layer', '1' ),
129
+
130
+ // Variant colors
131
+ success: theme.support.link.success.default,
132
+ error: theme.support.link.error.default,
133
+ warning: theme.support.link.warning.default,
134
+ info: theme.support.link.info.default,
135
+
136
+ // Card
137
+ card: '#fff',
138
+
139
+ // Link
140
+ link: gColor( 'link', 'default' ),
141
+ links: {
142
+ default: gColor( 'link', 'default' ),
143
+ hover: gColor( 'link', 'hover' ),
144
+ active: gColor( 'link', 'active' ),
145
+ visited: gColor( 'link', 'visited' ),
146
+ },
147
+ } );
148
+
68
149
  export default {
69
150
  outline,
70
151
  space: [ 0, 4, 8, 16, 32, 64, 128, 256, 512 ],
@@ -88,122 +169,29 @@ export default {
88
169
  },
89
170
  initialColorModeName: 'light',
90
171
  colors: {
91
- // Valet Theme Colors
92
-
93
- // This has to be in the plural because we already have a flag: text
94
- texts: {
95
- ...ValetTheme.text,
96
- disabled: '#716e6e',
97
- },
98
-
99
- button: {
100
- ...ValetTheme.button,
101
- },
102
-
103
- tag: {
104
- ...ValetTheme.tag,
105
- },
106
-
107
- // Notice
108
- notice: {
109
- ...ValetTheme.support,
110
- },
111
-
112
- // layer
113
- layer: {
114
- ...ValetTheme.layer,
115
- },
116
-
117
- // icon
118
- icon: {
119
- ...ValetTheme.icon,
120
- },
121
-
122
- // Form Controls
123
- input: {
124
- ...ValetTheme.input,
125
- },
126
-
127
- optionRow: {
128
- hover: 'rgba(0,0,0,.02)',
129
- border: getColor( 'border', '2' ),
130
- text: getColor( 'text', 'secondary' ),
131
- textAccent: getColor( 'link', 'default' ),
132
- icon: getColor( 'icon', 'primary' ),
133
- iconBackground: getColor( 'layer', 'accent' ),
134
- },
135
-
136
- table: {
137
- border: getColor( 'border', '2' ),
138
- heading: getColor( 'text', 'primary' ),
139
- text: getColor( 'text', 'secondary' ),
140
- },
141
-
142
- // Common Tokens
143
- text: getColor( 'text', 'secondary' ),
144
- heading: getColor( 'text', 'primary' ),
145
- background: getColor( 'layer', '2' ),
146
- backgroundSecondary: getColor( 'layer', '1' ),
147
- primary: getColor( 'link', 'default' ),
148
- secondary: light.gray[ '70' ],
149
- muted: getColor( 'text', 'helper' ),
150
- border: getColor( 'border', '1' ),
151
- borders: {
152
- 1: getColor( 'border', '1' ),
153
- 2: getColor( 'border', '2' ),
154
- 3: getColor( 'border', '3' ),
155
- 4: getColor( 'border', '4' ),
156
- inverse: getColor( 'border', 'inverse' ),
157
- accent: getColor( 'border', 'accent' ),
158
- },
159
- hover: 'rgba(0,0,0,.02)',
160
- darken: 'rgba(0,0,0,.05)',
161
- placeholder: getVariants( 'input.text' ).placeholder,
162
- midnight: '#13191E',
163
- dialog: light.gray[ '0' ],
164
- backgroundMuted: getColor( 'layer', '1' ),
165
-
166
- // Variant colors
167
- success: ValetTheme.support.link.success.default,
168
- error: ValetTheme.support.link.error.default,
169
- warning: ValetTheme.support.link.warning.default,
170
- info: ValetTheme.support.link.info.default,
171
-
172
- // Card
173
- card: '#fff',
174
-
175
- // Link
176
- link: getColor( 'link', 'default' ),
177
- links: {
178
- default: getColor( 'link', 'default' ),
179
- hover: getColor( 'link', 'hover' ),
180
- active: getColor( 'link', 'active' ),
181
- visited: getColor( 'link', 'visited' ),
182
- },
183
-
172
+ ...getComponentColors( ValetTheme, getColor, getVariants ),
184
173
  ...light,
185
-
186
174
  modes: {
187
- // Dark Mode not fully supported yet
188
175
  dark: {
189
- text: dark.grey[ '90' ],
190
- heading: dark.grey[ '100' ],
191
- background: dark.grey[ '5' ],
192
- backgroundSecondary: dark.grey[ '10' ],
193
- primary: light.brand[ '70' ],
194
- secondary: '#30c',
195
- muted: dark.grey[ '90' ],
196
- link: dark.brand[ '90' ],
197
- card: dark.grey[ '20' ],
198
- placeholder: dark.grey[ '70' ],
199
- border: dark.grey[ '30' ],
200
- hover: 'rgba(255,255,255,.02)',
201
- midnight: dark.grey[ '90' ],
202
- success: dark.green[ '90' ],
203
- error: dark.red[ '90' ],
204
- warning: dark.yellow[ '90' ],
205
- dialog: dark.grey[ '40' ],
206
- backgroundMuted: dark.grey[ '10' ],
176
+ ...getComponentColors( ValetThemeDark, getColorDark, getVariantsDark ),
177
+ // text: dark.grey[ '90' ],
178
+ // heading: dark.grey[ '100' ],
179
+ // background: dark.grey[ '5' ],
180
+ // backgroundSecondary: dark.grey[ '10' ],
181
+ // primary: light.brand[ '70' ],
182
+ // secondary: '#30c',
183
+ // muted: dark.grey[ '90' ],
184
+ // link: dark.brand[ '90' ],
185
+ // card: dark.grey[ '20' ],
186
+ // placeholder: dark.grey[ '70' ],
187
+ // border: dark.grey[ '30' ],
188
+ // hover: 'rgba(255,255,255,.02)',
189
+ // midnight: dark.grey[ '90' ],
190
+ // success: dark.green[ '90' ],
191
+ // error: dark.red[ '90' ],
192
+ // warning: dark.yellow[ '90' ],
193
+ // dialog: dark.grey[ '40' ],
194
+ // backgroundMuted: dark.grey[ '10' ],
207
195
  ...dark,
208
196
  },
209
197
  },
@@ -219,14 +207,6 @@ export default {
219
207
  '0px 2.76726px 2.21381px rgba(0, 0, 0, 0.0196802), 0px 6.6501px 5.32008px rgba(0, 0, 0, 0.0282725), 0px 12.5216px 10.0172px rgba(0, 0, 0, 0.035), 0px 22.3363px 17.869px rgba(0, 0, 0, 0.0417275), 0px 41.7776px 33.4221px rgba(0, 0, 0, 0.0503198), 0px 100px 80px rgba(0, 0, 0, 0.07)',
220
208
  },
221
209
 
222
- accordion: {
223
- background: {
224
- open: getVariants( 'color.gold' )[ '7' ],
225
- closed: 'transparent',
226
- hover: getVariants( 'color.gold' )[ '7' ],
227
- },
228
- },
229
-
230
210
  tag: {
231
211
  gold: getVariants( 'tag.gold' ),
232
212
  },
@@ -0,0 +1,46 @@
1
+ export const textStyles = {
2
+ h1: {
3
+ fontSize: 5,
4
+ marginBottom: 3,
5
+ letterSpacing: '-.02em',
6
+ fontWeight: 'body',
7
+ fontFamily: 'serif',
8
+ color: 'heading',
9
+ },
10
+ h2: {
11
+ fontSize: 4,
12
+ marginBottom: 2,
13
+ letterSpacing: '-.005em',
14
+ fontWeight: 400,
15
+ color: 'heading',
16
+ },
17
+ h3: {
18
+ fontSize: 3,
19
+ marginBottom: 3,
20
+ letterSpacing: '-.005em',
21
+ lineHeight: 1.4,
22
+ fontWeight: 'heading',
23
+ color: 'heading',
24
+ },
25
+ h4: {
26
+ fontSize: 2,
27
+ marginBottom: 1,
28
+ lineHeight: 1.5,
29
+ fontWeight: 'heading',
30
+ color: 'heading',
31
+ },
32
+ h5: {
33
+ fontSize: 1,
34
+ marginBottom: 1,
35
+ lineHeight: 1.5,
36
+ fontWeight: 'heading',
37
+ color: 'heading',
38
+ },
39
+ caps: {
40
+ fontSize: 1,
41
+ marginBottom: 2,
42
+ color: 'muted',
43
+ fontWeight: 'bold',
44
+ letterSpacing: '.05em',
45
+ },
46
+ };
@@ -8,6 +8,7 @@
8
8
  "wpvip-expressive-color",
9
9
  "wpvip-expressive-type",
10
10
  "wpvip-productive-color",
11
+ "wpvip-productive-color-dark",
11
12
  "parsely-expressive-core",
12
13
  "parsely-expressive-color",
13
14
  "parsely-expressive-type",
@@ -928,8 +928,6 @@
928
928
  "support.link.success.visited": "S:fe87fcbe28eb16c19e23181f7d4bb2555bd4cd90,",
929
929
  "focus.default": "S:695b977c23ba1e9b94f379e817160e3061cc5c86,",
930
930
  "focus.inset": "S:eef682a70d4f5f05ebeca563cf599499c7adcc49,",
931
- "overlay": "S:194e19160810c9bd0a2f486adfb3cac054703149,",
932
- "interactive": "S:961c614ec6f50d6bee6e938eba9f7de62bcc0aa9,",
933
931
  "tag.gray.background": "S:b05e9218d3ffbf23e4a307c0a05ab0584f081b72,",
934
932
  "tag.gray.text": "S:fa3f30d92699bf366603f5230583f8d6c48298a6,",
935
933
  "tag.gray.icon": "S:f8d1a16f90a5a07e545338c6ad3b6738c6e47f3a,",