@sproutsocial/racine 9.1.0-beta-pr-1290.0 → 9.1.1-theme-extension.1

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 (73) hide show
  1. package/CHANGELOG.md +0 -28
  2. package/__flow__/Breadcrumb/styles.js +5 -0
  3. package/__flow__/Button/styles.js +1 -1
  4. package/__flow__/Card/index.stories.js +1 -0
  5. package/__flow__/Card/styles.js +1 -1
  6. package/__flow__/CustomThemeProvider/index.js +17 -0
  7. package/__flow__/Drawer/index.stories.js +3 -3
  8. package/__flow__/Drawer/styles.js +1 -1
  9. package/__flow__/KeyboardKey/styles.js +1 -1
  10. package/__flow__/Listbox/__snapshots__/index.test.js.snap +34 -40
  11. package/__flow__/Menu/__snapshots__/index.test.js.snap +12 -15
  12. package/__flow__/Menu/index.js +7 -3
  13. package/__flow__/Menu/index.stories.js +1 -1
  14. package/__flow__/Menu/styles.js +18 -1
  15. package/__flow__/Modal/__snapshots__/index.test.js.snap +80 -0
  16. package/__flow__/Modal/index.test.js +16 -0
  17. package/__flow__/Modal/styles.js +1 -1
  18. package/__flow__/Popout/index.js +1 -1
  19. package/__flow__/ThemeProvider/index.js +2 -2
  20. package/__flow__/Token/index.js +1 -4
  21. package/__flow__/Token/index.stories.js +0 -11
  22. package/__flow__/Token/styles.js +33 -43
  23. package/__flow__/Tooltip/index.js +1 -1
  24. package/__flow__/index.js +1 -0
  25. package/__flow__/themes/dark/theme.js +156 -180
  26. package/__flow__/themes/default/theme.js +8 -19
  27. package/__flow__/themes/sprout/theme.js +22 -0
  28. package/__flow__/types/system-props.flow.js +2 -1
  29. package/__flow__/utils/extendTheme.js +17 -0
  30. package/commonjs/Breadcrumb/styles.js +1 -1
  31. package/commonjs/Button/styles.js +1 -1
  32. package/commonjs/Card/styles.js +1 -1
  33. package/commonjs/CustomThemeProvider/index.js +23 -0
  34. package/commonjs/Drawer/styles.js +1 -1
  35. package/commonjs/KeyboardKey/styles.js +1 -1
  36. package/commonjs/Menu/index.js +1 -3
  37. package/commonjs/Menu/styles.js +16 -3
  38. package/commonjs/Modal/styles.js +1 -1
  39. package/commonjs/Popout/index.js +1 -1
  40. package/commonjs/Token/index.js +2 -5
  41. package/commonjs/Token/styles.js +50 -19
  42. package/commonjs/Tooltip/index.js +1 -1
  43. package/commonjs/index.js +5 -1
  44. package/commonjs/themes/dark/theme.js +154 -179
  45. package/commonjs/themes/default/theme.js +8 -19
  46. package/commonjs/themes/sprout/theme.js +29 -0
  47. package/commonjs/utils/extendTheme.js +22 -0
  48. package/lib/Breadcrumb/styles.js +1 -1
  49. package/lib/Button/styles.js +1 -1
  50. package/lib/Card/styles.js +1 -1
  51. package/lib/CustomThemeProvider/index.js +12 -0
  52. package/lib/Drawer/styles.js +1 -1
  53. package/lib/KeyboardKey/styles.js +1 -1
  54. package/lib/Menu/index.js +2 -4
  55. package/lib/Menu/styles.js +13 -2
  56. package/lib/Modal/styles.js +1 -1
  57. package/lib/Popout/index.js +1 -1
  58. package/lib/Token/index.js +2 -5
  59. package/lib/Token/styles.js +50 -19
  60. package/lib/Tooltip/index.js +1 -1
  61. package/lib/index.js +1 -0
  62. package/lib/themes/dark/theme.js +153 -174
  63. package/lib/themes/default/theme.js +8 -18
  64. package/lib/themes/sprout/theme.js +19 -0
  65. package/lib/utils/extendTheme.js +12 -0
  66. package/package.json +3 -3
  67. package/__flow__/themes/_themes.scss +0 -138
  68. package/__flow__/themes/utils/interact.js +0 -12
  69. package/commonjs/themes/utils/interact.js +0 -19
  70. package/dist/themes/_themes.scss +0 -138
  71. package/dist/themes/dark.scss +0 -601
  72. package/dist/themes/default.scss +0 -692
  73. package/lib/themes/utils/interact.js +0 -13
@@ -1,207 +1,186 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import COLORS from "@sproutsocial/seeds-color";
4
- import DEPTH from "@sproutsocial/seeds-depth";
5
4
  import defaultTheme from "../default/theme";
6
5
  import { datavizPalette } from "./dataviz-palette";
7
6
  import { green, blue, purple, yellow, orange, red, neutral } from "./decorative-palettes";
8
- import interact from "../utils/interact";
9
- var MODE = "default-dark";
10
- export var shadows = {
11
- low: DEPTH.ELEVATION_LEVEL_100 + " " + COLORS.COLOR_NEUTRAL_1100 + "FF",
12
- medium: DEPTH.ELEVATION_LEVEL_300 + " " + COLORS.COLOR_NEUTRAL_1100 + "FF",
13
- high: DEPTH.ELEVATION_LEVEL_400 + " " + COLORS.COLOR_NEUTRAL_1100 + "FF"
14
- };
15
7
 
16
- var colors = _extends({}, defaultTheme.colors, {
17
- utils: {
18
- interact: interact(MODE)
19
- },
20
- app: {
21
- background: {
22
- base: COLORS.COLOR_NEUTRAL_1000
23
- }
24
- },
25
- container: {
26
- background: {
27
- base: COLORS.COLOR_NEUTRAL_900,
28
- success: green.background,
29
- warning: yellow.background,
30
- error: red.background,
31
- info: blue.background,
32
- opportunity: purple.background,
33
- danger: red.background,
34
- decorative: {
35
- green: green.background,
36
- blue: blue.background,
37
- purple: purple.background,
38
- yellow: yellow.background,
39
- orange: orange.background,
40
- red: red.background,
41
- neutral: neutral.background
42
- },
43
- selected: COLORS.COLOR_NEUTRAL_0
44
- },
45
- border: {
46
- base: COLORS.COLOR_NEUTRAL_1100,
47
- success: green.highlight,
48
- warning: yellow.highlight,
49
- error: red.highlight,
50
- danger: red.highlight,
51
- info: blue.highlight,
52
- opportunity: purple.highlight,
53
- decorative: {
54
- green: green.highlight,
55
- blue: blue.highlight,
56
- purple: purple.highlight,
57
- yellow: yellow.highlight,
58
- orange: orange.highlight,
59
- red: red.highlight,
60
- neutral: neutral.highlight
61
- },
62
- selected: COLORS.COLOR_NEUTRAL_0
63
- }
64
- },
65
- button: {
66
- primary: {
8
+ var darkTheme = _extends({}, defaultTheme, {
9
+ colors: _extends({}, defaultTheme.colors, {
10
+ app: {
67
11
  background: {
68
- base: COLORS.COLOR_BLUE_400,
69
- hover: COLORS.COLOR_BLUE_300,
70
- active: COLORS.COLOR_BLUE_200
71
- },
72
- border: {
73
- base: "transparent"
74
- },
75
- text: {
76
- base: COLORS.COLOR_NEUTRAL_900,
77
- hover: COLORS.COLOR_NEUTRAL_1000
12
+ base: COLORS.COLOR_NEUTRAL_1000
78
13
  }
79
14
  },
80
- secondary: {
15
+ container: {
81
16
  background: {
82
- base: "transparent",
83
- hover: COLORS.COLOR_NEUTRAL_100,
84
- active: COLORS.COLOR_NEUTRAL_0
17
+ base: COLORS.COLOR_NEUTRAL_900,
18
+ success: green.background,
19
+ warning: yellow.background,
20
+ error: red.background,
21
+ info: blue.background,
22
+ opportunity: purple.background,
23
+ danger: red.background,
24
+ decorative: {
25
+ green: green.background,
26
+ blue: blue.background,
27
+ purple: purple.background,
28
+ yellow: yellow.background,
29
+ orange: orange.background,
30
+ red: red.background,
31
+ neutral: neutral.background
32
+ },
33
+ selected: COLORS.COLOR_NEUTRAL_0
85
34
  },
86
35
  border: {
87
- base: COLORS.COLOR_NEUTRAL_0
88
- },
89
- text: {
90
- base: COLORS.COLOR_NEUTRAL_0,
91
- hover: COLORS.COLOR_NEUTRAL_800
36
+ base: COLORS.COLOR_NEUTRAL_1100,
37
+ success: green.highlight,
38
+ warning: yellow.highlight,
39
+ error: red.highlight,
40
+ danger: red.highlight,
41
+ info: blue.highlight,
42
+ opportunity: purple.highlight,
43
+ decorative: {
44
+ green: green.highlight,
45
+ blue: blue.highlight,
46
+ purple: purple.highlight,
47
+ yellow: yellow.highlight,
48
+ orange: orange.highlight,
49
+ red: red.highlight,
50
+ neutral: neutral.highlight
51
+ },
52
+ selected: COLORS.COLOR_NEUTRAL_0
92
53
  }
93
54
  },
94
- pill: {
95
- background: {
96
- base: "transparent",
97
- hover: COLORS.COLOR_NEUTRAL_1000,
98
- active: COLORS.COLOR_NEUTRAL_900
55
+ button: {
56
+ primary: {
57
+ background: {
58
+ base: COLORS.COLOR_BLUE_400,
59
+ hover: COLORS.COLOR_BLUE_300,
60
+ active: COLORS.COLOR_BLUE_200
61
+ },
62
+ border: {
63
+ base: "transparent"
64
+ },
65
+ text: {
66
+ base: COLORS.COLOR_NEUTRAL_900,
67
+ hover: COLORS.COLOR_NEUTRAL_1000
68
+ }
99
69
  },
100
- border: {
101
- base: "transparent"
70
+ secondary: {
71
+ background: {
72
+ base: "transparent",
73
+ hover: COLORS.COLOR_NEUTRAL_100,
74
+ active: COLORS.COLOR_NEUTRAL_0
75
+ },
76
+ border: {
77
+ base: COLORS.COLOR_NEUTRAL_0
78
+ },
79
+ text: {
80
+ base: COLORS.COLOR_NEUTRAL_0,
81
+ hover: COLORS.COLOR_NEUTRAL_800
82
+ }
102
83
  },
103
- text: {
104
- base: COLORS.COLOR_NEUTRAL_100,
105
- hover: COLORS.COLOR_NEUTRAL_0
106
- }
107
- },
108
- destructive: {
109
- background: {
110
- base: COLORS.COLOR_RED_400,
111
- hover: COLORS.COLOR_RED_300,
112
- active: COLORS.COLOR_RED_200
84
+ pill: {
85
+ background: {
86
+ base: "transparent",
87
+ hover: COLORS.COLOR_NEUTRAL_1000,
88
+ active: COLORS.COLOR_NEUTRAL_900
89
+ },
90
+ border: {
91
+ base: "transparent"
92
+ },
93
+ text: {
94
+ base: COLORS.COLOR_NEUTRAL_100,
95
+ hover: COLORS.COLOR_NEUTRAL_0
96
+ }
113
97
  },
114
- border: {
115
- base: "transparent"
98
+ destructive: {
99
+ background: {
100
+ base: COLORS.COLOR_RED_400,
101
+ hover: COLORS.COLOR_RED_300,
102
+ active: COLORS.COLOR_RED_200
103
+ },
104
+ border: {
105
+ base: "transparent"
106
+ },
107
+ text: {
108
+ base: COLORS.COLOR_NEUTRAL_900,
109
+ hover: COLORS.COLOR_NEUTRAL_1000
110
+ }
116
111
  },
117
- text: {
118
- base: COLORS.COLOR_NEUTRAL_900,
119
- hover: COLORS.COLOR_NEUTRAL_1000
112
+ placeholder: {
113
+ background: {
114
+ base: "transparent",
115
+ hover: COLORS.COLOR_NEUTRAL_1100,
116
+ active: COLORS.COLOR_NEUTRAL_1100
117
+ },
118
+ border: {
119
+ base: COLORS.COLOR_NEUTRAL_500
120
+ },
121
+ text: {
122
+ base: COLORS.COLOR_BLUE_400,
123
+ hover: COLORS.COLOR_BLUE_300
124
+ }
125
+ },
126
+ unstyled: {
127
+ background: {
128
+ base: "transparent"
129
+ },
130
+ border: {
131
+ base: "transparent"
132
+ },
133
+ text: {
134
+ base: COLORS.COLOR_NEUTRAL_300,
135
+ hover: COLORS.COLOR_NEUTRAL_200
136
+ }
120
137
  }
121
138
  },
122
- placeholder: {
139
+ link: {
140
+ base: COLORS.COLOR_BLUE_400,
141
+ hover: COLORS.COLOR_BLUE_300
142
+ },
143
+ text: {
144
+ headline: COLORS.COLOR_NEUTRAL_0,
145
+ subtext: COLORS.COLOR_NEUTRAL_300,
146
+ body: COLORS.COLOR_NEUTRAL_100,
147
+ inverse: COLORS.COLOR_NEUTRAL_900,
148
+ error: COLORS.COLOR_RED_400
149
+ },
150
+ icon: {
151
+ base: COLORS.COLOR_NEUTRAL_100,
152
+ inverse: COLORS.COLOR_NEUTRAL_900,
153
+ success: green.foreground,
154
+ warning: yellow.foreground,
155
+ error: red.foreground,
156
+ danger: red.foreground,
157
+ info: blue.foreground,
158
+ opportunity: purple.foreground
159
+ },
160
+ form: {
123
161
  background: {
124
- base: "transparent",
125
- hover: COLORS.COLOR_NEUTRAL_1100,
126
- active: COLORS.COLOR_NEUTRAL_1100
162
+ base: COLORS.COLOR_NEUTRAL_900,
163
+ selected: COLORS.COLOR_NEUTRAL_0
127
164
  },
128
165
  border: {
129
- base: COLORS.COLOR_NEUTRAL_500
166
+ base: COLORS.COLOR_NEUTRAL_500,
167
+ error: red.highlight,
168
+ warning: yellow.highlight,
169
+ selected: COLORS.COLOR_NEUTRAL_0
130
170
  },
131
- text: {
132
- base: COLORS.COLOR_BLUE_400,
133
- hover: COLORS.COLOR_BLUE_300
171
+ placeholder: {
172
+ base: COLORS.COLOR_NEUTRAL_500
134
173
  }
135
174
  },
136
- unstyled: {
175
+ listItem: {
137
176
  background: {
138
- base: "transparent"
139
- },
140
- border: {
141
- base: "transparent"
142
- },
143
- text: {
144
- base: COLORS.COLOR_NEUTRAL_300,
145
- hover: COLORS.COLOR_NEUTRAL_200
177
+ base: "transparent",
178
+ hover: COLORS.COLOR_NEUTRAL_800,
179
+ selected: COLORS.COLOR_NEUTRAL_0
146
180
  }
147
181
  }
148
- },
149
- link: {
150
- base: COLORS.COLOR_BLUE_400,
151
- hover: COLORS.COLOR_BLUE_300
152
- },
153
- text: {
154
- headline: COLORS.COLOR_NEUTRAL_0,
155
- subtext: COLORS.COLOR_NEUTRAL_300,
156
- body: COLORS.COLOR_NEUTRAL_100,
157
- inverse: COLORS.COLOR_NEUTRAL_900,
158
- error: COLORS.COLOR_RED_400
159
- },
160
- icon: {
161
- base: COLORS.COLOR_NEUTRAL_100,
162
- inverse: COLORS.COLOR_NEUTRAL_900,
163
- success: green.foreground,
164
- warning: yellow.foreground,
165
- error: red.foreground,
166
- danger: red.foreground,
167
- info: blue.foreground,
168
- opportunity: purple.foreground
169
- },
170
- form: {
171
- background: {
172
- base: COLORS.COLOR_NEUTRAL_900,
173
- selected: COLORS.COLOR_NEUTRAL_0
174
- },
175
- border: {
176
- base: COLORS.COLOR_NEUTRAL_500,
177
- error: red.highlight,
178
- warning: yellow.highlight,
179
- selected: COLORS.COLOR_NEUTRAL_0
180
- },
181
- placeholder: {
182
- base: COLORS.COLOR_NEUTRAL_500
183
- }
184
- },
185
- listItem: {
186
- background: {
187
- base: "transparent",
188
- hover: COLORS.COLOR_NEUTRAL_800,
189
- selected: COLORS.COLOR_NEUTRAL_0
190
- }
191
- },
192
- elevation: {
193
- base: COLORS.COLOR_NEUTRAL_1100
194
- },
195
- dataviz: {
196
- map: datavizPalette.DATAVIZ_COLORS_MAP,
197
- list: datavizPalette.DATAVIZ_COLORS_LIST
198
- }
199
- }, datavizPalette);
200
-
201
- var darkTheme = _extends({}, defaultTheme, {
202
- colors: colors,
203
- shadows: shadows,
204
- mode: MODE
182
+ }, datavizPalette),
183
+ mode: "dark"
205
184
  });
206
185
 
207
186
  export default darkTheme;
@@ -10,9 +10,7 @@ import SPACE from "@sproutsocial/seeds-space";
10
10
  import DEPTH from "@sproutsocial/seeds-depth";
11
11
  import MOTION from "@sproutsocial/seeds-motion";
12
12
  import BORDER from "@sproutsocial/seeds-border";
13
- import interact from "../utils/interact";
14
13
  export var breakpoints = ["900px", "1200px", "1500px", "1800px"];
15
- var MODE = "default-light";
16
14
 
17
15
  var colors = _extends({
18
16
  app: {
@@ -187,9 +185,6 @@ var colors = _extends({
187
185
  selected: COLORS.COLOR_NEUTRAL_800
188
186
  }
189
187
  },
190
- elevation: {
191
- base: COLORS.COLOR_NEUTRAL_900 + "3D"
192
- },
193
188
  network: {
194
189
  twitter: NETWORKCOLORS.NETWORK_COLOR_TWITTER,
195
190
  twitter_like: NETWORKCOLORS.NETWORK_COLOR_TWITTER_LIKE,
@@ -216,10 +211,6 @@ var colors = _extends({
216
211
  yelp: NETWORKCOLORS.NETWORK_COLOR_YELP,
217
212
  whatsapp: NETWORKCOLORS.NETWORK_COLOR_WHATSAPP,
218
213
  tiktok: NETWORKCOLORS.NETWORK_COLOR_TIKTOK
219
- },
220
- dataviz: {
221
- map: datavizPalette.DATAVIZ_COLORS_MAP,
222
- list: datavizPalette.DATAVIZ_COLORS_LIST
223
214
  }
224
215
  }, literalColors, datavizPalette);
225
216
 
@@ -271,9 +262,10 @@ export var borderWidths = {
271
262
  "500": BORDER.BORDER_WIDTH_500
272
263
  };
273
264
  export var shadows = {
274
- low: DEPTH.ELEVATION_LEVEL_100 + " " + COLORS.COLOR_NEUTRAL_900 + "3D",
275
- medium: DEPTH.ELEVATION_LEVEL_300 + " " + COLORS.COLOR_NEUTRAL_900 + "3D",
276
- high: DEPTH.ELEVATION_LEVEL_400 + " " + COLORS.COLOR_NEUTRAL_900 + "3D"
265
+ "100": DEPTH.ELEVATION_LEVEL_100,
266
+ "200": DEPTH.ELEVATION_LEVEL_200,
267
+ "300": DEPTH.ELEVATION_LEVEL_300,
268
+ "400": DEPTH.ELEVATION_LEVEL_400
277
269
  };
278
270
  export var easing = {
279
271
  ease_in: MOTION.MOTION_EASE_IN,
@@ -286,9 +278,6 @@ export var duration = {
286
278
  slow: MOTION.MOTION_DURATION_SLOW
287
279
  };
288
280
  var theme = {
289
- utils: {
290
- interact: interact(MODE)
291
- },
292
281
  breakpoints: breakpoints,
293
282
  colors: colors,
294
283
  typography: _extends({}, typography, {
@@ -309,9 +298,10 @@ var theme = {
309
298
  }),
310
299
  borders: borders,
311
300
  borderWidths: borderWidths,
312
- shadows: shadows,
301
+ shadows: _extends({}, shadows, {
302
+ shadows: shadows
303
+ }),
313
304
  easing: easing,
314
- duration: duration,
315
- mode: MODE
305
+ duration: duration
316
306
  };
317
307
  export default theme;
@@ -0,0 +1,19 @@
1
+ import theme from "../default/theme";
2
+ import { COLOR_RED_800 } from "@sproutsocial/seeds-color";
3
+ var sproutTheme = {
4
+ container: {
5
+ background: {
6
+ error: {
7
+ hover: COLOR_RED_800
8
+ }
9
+ }
10
+ },
11
+ button: {
12
+ primary: {
13
+ background: {
14
+ base: "purple"
15
+ }
16
+ }
17
+ }
18
+ };
19
+ export default sproutTheme;
@@ -0,0 +1,12 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import * as merge from "deepmerge";
4
+ export function extendColorTheme(baseTheme, extension) {
5
+ var newColorTheme = merge(baseTheme.colors, extension);
6
+
7
+ var newTheme = _extends({}, baseTheme, {
8
+ colors: _extends({}, newColorTheme)
9
+ });
10
+
11
+ return newTheme;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/racine",
3
- "version": "9.1.0-beta-pr-1290.0",
3
+ "version": "9.1.1-theme-extension.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "__flow__",
@@ -64,6 +64,7 @@
64
64
  "dependencies": {
65
65
  "@styled-system/theme-get": "^5.1.2",
66
66
  "classnames": "^2.2.6",
67
+ "deepmerge": "^4.2.2",
67
68
  "lodash.curry": "^4.1.1",
68
69
  "lodash.uniqueid": "^4.0.1",
69
70
  "lru-memoize": "^1.1.0",
@@ -92,7 +93,7 @@
92
93
  "@reach/component-component": "^0.1.3",
93
94
  "@sproutsocial/seeds-border": "^1.1.0",
94
95
  "@sproutsocial/seeds-color": "^1.5.3",
95
- "@sproutsocial/seeds-depth": "^3.0.0",
96
+ "@sproutsocial/seeds-depth": "^1.1.1",
96
97
  "@sproutsocial/seeds-motion": "^1.2.0",
97
98
  "@sproutsocial/seeds-networkcolor": "^2.9.0",
98
99
  "@sproutsocial/seeds-space": "^0.4.7",
@@ -140,7 +141,6 @@
140
141
  "jest-dom": "^3.5.0",
141
142
  "jest-styled-components": "7.0.0-beta.1",
142
143
  "jscodeshift": "^0.6.4",
143
- "json-to-scss": "^1.6.2",
144
144
  "lint-staged": "^10.2.11",
145
145
  "moment": "^2.29.1",
146
146
  "npm-run-all": "^4.1.2",
@@ -1,138 +0,0 @@
1
- // Inspired by https://medium.com/@katiemctigue/how-to-create-a-dark-mode-in-sass-609f131a3995
2
- // This file is excluded from stylelint, because stylelint is only set up to lint styled-components at the moment.
3
-
4
- // SET-UP
5
- // These files are auto-generated based on JS theme files, ensuring our SCSS theme variables stay in sync.
6
- @import "../../dist/themes/default.scss";
7
- @import "../../dist/themes/dark.scss";
8
-
9
- // In the JS theme files, the theme object is exported as "default" (i.e., using "export default"),
10
- // so we need to map-get "default" to access it.
11
- $themes: (
12
- light: map-get($default, "default"),
13
- dark: map-get($dark, "default")
14
- );
15
-
16
- // MIXIN
17
- // CSS properties that are theme-dependent must be wrapped in this mixin
18
- @mixin themed() {
19
- @each $theme, $map in $themes {
20
- .theme--#{$theme} & {
21
- $theme-map: () !global;
22
- @each $key, $submap in $map {
23
- $value: map-get(map-get($themes, $theme), "#{$key}");
24
- $theme-map: map-merge($theme-map, ($key: $value)) !global;
25
- }
26
- @content;
27
- $theme-map: null !global;
28
- }
29
- }
30
- }
31
-
32
- // FUNCTIONS
33
- // This function will allow you to get any value from the theme.
34
- // @param {string} $key - the period-separated path to the value in the theme object. e.g., "colors.text.body"
35
- @function t($key) {
36
- $keys: _str-split($key, ".");
37
- @return _map-deep-get($theme-map, $keys);
38
- }
39
-
40
- // The rest of the functions are convenience methods to get theme values for subsets of the theme.
41
- // @param {string} $key - the period-separated path to the value in the theme object, with "colors." omitted. e.g., "text.body"
42
- @function colors($key) {
43
- $keys: _str-split($key, ".");
44
- @return _map-deep-get($theme-map, join("colors", $keys));
45
- }
46
-
47
- // @param {string} $key - the period-separated path to the value in the theme object, with "typography." omitted. e.g., "100.fontSize"
48
- @function typography($key) {
49
- $keys: _str-split($key, ".");
50
- @return _map-deep-get($theme-map, join("typography", $keys));
51
- }
52
-
53
- // @param {string} $key - the period-separated path to the value in the theme object, with "fontWeights." omitted. e.g., "normal"
54
- @function fontWeights($key) {
55
- $keys: _str-split($key, ".");
56
- @return _map-deep-get($theme-map, join("fontWeights", $keys));
57
- }
58
-
59
- // @param {string} $key - the period-separated path to the value in the theme object, with "space." omitted. e.g., "100"
60
- @function space($key) {
61
- $keys: _str-split($key, ".");
62
- @return _map-deep-get($theme-map, join("space", $keys));
63
- }
64
-
65
- // @param {string} $key - the period-separated path to the value in the theme object, with "radii." omitted. e.g., "inner"
66
- @function radii($key) {
67
- $keys: _str-split($key, ".");
68
- @return _map-deep-get($theme-map, join("radii", $keys));
69
- }
70
-
71
- // @param {string} $key - the period-separated path to the value in the theme object, with "borders." omitted. e.g., "500"
72
- @function borders($key) {
73
- $keys: _str-split($key, ".");
74
- @return _map-deep-get($theme-map, join("borders", $keys));
75
- }
76
-
77
- // @param {string} $key - the period-separated path to the value in the theme object, with "borderWidths." omitted. e.g., "500"
78
- @function borderWidths($key) {
79
- $keys: _str-split($key, ".");
80
- @return _map-deep-get($theme-map, join("borderWidths", $keys));
81
- }
82
-
83
- // @param {string} $key - the period-separated path to the value in the theme object, with "shadows." omitted. e.g., "low"
84
- @function shadows($key) {
85
- $keys: _str-split($key, ".");
86
- @return _map-deep-get($theme-map, join("shadows", $keys));
87
- }
88
-
89
- // @param {string} $key - the period-separated path to the value in the theme object, with "easing." omitted. e.g., "ease_in"
90
- @function easing($key) {
91
- $keys: _str-split($key, ".");
92
- @return _map-deep-get($theme-map, join("easing", $keys));
93
- }
94
-
95
- // @param {string} $key - the period-separated path to the value in the theme object, with "duration." omitted. e.g., "fast"
96
- @function duration($key) {
97
- $keys: _str-split($key, ".");
98
- @return _map-deep-get($theme-map, join("duration", $keys));
99
- }
100
-
101
- // UTILITIES
102
- // Helper functions that power the functions above. Not relevant to the theme.
103
- // If you import this file with @use, these functions will be excluded because they are private.
104
-
105
- // Via https://stackoverflow.com/a/42295154
106
- // Used to split period-separated object keys, e.g. "colors.text.body" => ["colors", "text", "body"]
107
- // Only works with a single-character separator.
108
- @function _str-split($string, $separator) {
109
- // empty array/list
110
- $split-arr: ();
111
- // first index of separator in string
112
- $index : str-index($string, $separator);
113
- // loop through string
114
- @while $index != null {
115
- // get the substring from the first character to the separator
116
- $item: str-slice($string, 1, $index - 1);
117
- // push item to array
118
- $split-arr: append($split-arr, $item);
119
- // remove item and separator from string
120
- $string: str-slice($string, $index + 1);
121
- // find new index of separator
122
- $index : str-index($string, $separator);
123
- }
124
- // add the remaining string to list (the last item)
125
- $split-arr: append($split-arr, $string);
126
-
127
- @return $split-arr;
128
- }
129
-
130
- // Adapted from https://css-tricks.com/snippets/sass/deep-getset-maps/
131
- // Iterates over a list of keys to read multi-level maps.
132
- // e.g., _map-deep-get((colors: (text: (body: "#364141"))), ["colors", "text", "body"]) => "#364141"
133
- @function _map-deep-get($map, $keys) {
134
- @each $key in $keys {
135
- $map: map-get($map, $key);
136
- }
137
- @return $map;
138
- }
@@ -1,12 +0,0 @@
1
- //@flow strict-local
2
- import { darken, lighten } from "polished";
3
-
4
- const interact = (mode: string) => (themeValue: string) => {
5
- if (mode === "default-dark") {
6
- return lighten(0.2, themeValue);
7
- } else {
8
- return darken(0.2, themeValue);
9
- }
10
- };
11
-
12
- export default interact;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
-
6
- var _polished = require("polished");
7
-
8
- var interact = function interact(mode) {
9
- return function (themeValue) {
10
- if (mode === "default-dark") {
11
- return (0, _polished.lighten)(0.2, themeValue);
12
- } else {
13
- return (0, _polished.darken)(0.2, themeValue);
14
- }
15
- };
16
- };
17
-
18
- var _default = interact;
19
- exports.default = _default;