@sproutsocial/racine 11.6.1 → 11.6.2-themed-beta.0

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 (27) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/__flow__/Checkbox/styles.js +75 -75
  3. package/__flow__/Collapsible/index.js +3 -2
  4. package/__flow__/Image/index.js +10 -2
  5. package/__flow__/SegmentedControl/index.js +3 -2
  6. package/__flow__/TableCell/index.js +9 -2
  7. package/__flow__/ToggleHint/index.js +9 -2
  8. package/__flow__/systemProps/color.js +1 -2
  9. package/__flow__/themes/extendedThemes/sproutTheme/dark/theme.js +12 -0
  10. package/__flow__/themes/extendedThemes/sproutTheme/light/theme.js +12 -0
  11. package/__flow__/themes/utils/_themed.scss +119 -0
  12. package/__flow__/types/theme.flow.js +5 -1
  13. package/__flow__/utils/responsiveProps/index.test.js +10 -2
  14. package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +14 -2
  15. package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +14 -2
  16. package/dist/themes/dark/_themed.scss +4 -3
  17. package/dist/themes/dark/{dark.scss → theme.scss} +1 -1
  18. package/dist/themes/extendedThemes/sproutTheme/dark/_themed.scss +119 -0
  19. package/dist/themes/extendedThemes/sproutTheme/dark/theme.scss +692 -0
  20. package/dist/themes/extendedThemes/sproutTheme/light/_themed.scss +119 -0
  21. package/dist/themes/extendedThemes/sproutTheme/light/theme.scss +692 -0
  22. package/dist/themes/light/_themed.scss +4 -3
  23. package/dist/themes/light/{light.scss → theme.scss} +1 -1
  24. package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +12 -1
  25. package/lib/themes/extendedThemes/sproutTheme/light/theme.js +12 -1
  26. package/lib/types/theme.flow.js +1 -1
  27. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 560c463: Added a new extended theme for the compare to period for the date picker.
8
+
3
9
  ## 11.6.1
4
10
 
5
11
  ### Patch Changes
@@ -182,90 +182,90 @@ const getIcon = (type, color) => {
182
182
 
183
183
  // eslint-disable-next-line prettier/prettier
184
184
  export const CheckboxContainer: StyledComponent<any, TypeTheme, *> = styled.span(
185
- (props) => css`
186
- display: inline-flex;
187
- align-items: center;
188
- box-sizing: border-box;
189
- position: relative;
190
- transition: all ${props.theme.duration.fast} ${props.theme.easing.ease_in};
191
-
192
- @supports (-webkit-appearance: none) {
193
- &:before {
194
- /* stylelint-disable */
195
- content: url("data:image/svg+xml;utf8,${getIcon(
196
- props.indeterminate ? "indeterminate" : "check",
197
-
198
- props.checked
199
- ? props.theme.colors.form.background.base
200
- : props.theme.colors.form.border.base
201
- )}");
202
- opacity: ${props.checked ? 1 : 0};
203
- position: absolute;
204
- width: ${props.theme.space[400]};
205
- height: ${props.theme.space[400]};
206
- text-align: center;
207
- transform: translateY(1px);
208
- line-height: 1;
209
- margin: auto;
210
- pointer-events: none;
211
- transition: ${props.theme.duration.fast}
212
- ${props.theme.easing.ease_inout};
185
+ (props) => css`
186
+ display: inline-flex;
187
+ align-items: center;
188
+ box-sizing: border-box;
189
+ position: relative;
190
+ transition: all ${props.theme.duration.fast} ${props.theme.easing.ease_in};
191
+
192
+ @supports (-webkit-appearance: none) {
193
+ &:before {
194
+ /* stylelint-disable */
195
+ content: url("data:image/svg+xml;utf8,${getIcon(
196
+ props.indeterminate ? "indeterminate" : "check",
197
+
198
+ props.checked
199
+ ? props.theme.colors.form.background.base
200
+ : props.theme.colors.form.border.base
201
+ )}");
202
+ opacity: ${props.checked ? 1 : 0};
203
+ position: absolute;
204
+ width: ${props.theme.space[400]};
205
+ height: ${props.theme.space[400]};
206
+ text-align: center;
207
+ transform: translateY(1px);
208
+ line-height: 1;
209
+ margin: auto;
210
+ pointer-events: none;
211
+ transition: ${props.theme.duration.fast}
212
+ ${props.theme.easing.ease_inout};
213
+ }
214
+
215
+ &:hover:before {
216
+ opacity: ${props.disabled && !props.checked ? 0 : 1};
217
+ }
218
+
219
+ ${props.disabled &&
220
+ css`
221
+ opacity: 0.4;
222
+ `}
223
+
224
+ input[type='checkbox'] {
225
+ box-sizing: border-box;
226
+ appearance: none;
227
+ margin: 0;
228
+ padding: 0;
229
+ width: ${props.theme.space[400]};
230
+ height: ${props.theme.space[400]};
231
+ border: 1px solid ${props.theme.colors.form.border.base};
232
+ border-radius: 4px;
233
+ background-color: ${props.theme.colors.form.background.base};
234
+ transition: all ${props.theme.duration.fast}
235
+ ${props.theme.easing.ease_in};
236
+ cursor: ${props.disabled ? "not-allowed" : "pointer"};
237
+ flex-shrink: 0;
238
+
239
+ &:not(:checked) {
240
+ ${!props.indeterminate &&
241
+ css`
242
+ border-color: ${props.theme.colors
243
+ .neutral[300]} !important; /* We don't want the focus ring to remove the border */
244
+ background-color: ${props.theme.colors.form.background.base};
245
+ `}
213
246
  }
214
247
 
215
- &:hover:before {
216
- opacity: ${props.disabled && !props.checked ? 0 : 1};
248
+ &:checked {
249
+ border-color: ${props.theme.colors.form.border.selected};
250
+ background-color: ${props.theme.colors.form.background.selected};
217
251
  }
218
252
 
219
- ${props.disabled &&
253
+ ${props.indeterminate &&
254
+ props.checked &&
220
255
  css`
221
- opacity: 0.4;
256
+ border-color: ${props.theme.colors.form.border.selected} !important;
257
+ background-color: ${props.theme.colors.form.background
258
+ .selected} !important;
222
259
  `}
223
260
 
224
- input[type='checkbox'] {
225
- box-sizing: border-box;
226
- appearance: none;
227
- margin: 0;
228
- padding: 0;
229
- width: ${props.theme.space[400]};
230
- height: ${props.theme.space[400]};
231
- border: 1px solid ${props.theme.colors.form.border.base};
232
- border-radius: 4px;
233
- background-color: ${props.theme.colors.form.background.base};
234
- transition: all ${props.theme.duration.fast}
235
- ${props.theme.easing.ease_in};
236
- cursor: ${props.disabled ? "not-allowed" : "pointer"};
237
- flex-shrink: 0;
238
-
239
- &:not(:checked) {
240
- ${!props.indeterminate &&
241
- css`
242
- border-color: ${props.theme.colors
243
- .neutral[300]} !important; /* We don't want the focus ring to remove the border */
244
- background-color: ${props.theme.colors.form.background.base};
245
- `}
246
- }
247
-
248
- &:checked {
249
- border-color: ${props.theme.colors.form.border.selected};
250
- background-color: ${props.theme.colors.form.background.selected};
251
- }
252
-
253
- ${props.indeterminate &&
254
- props.checked &&
255
- css`
256
- border-color: ${props.theme.colors.form.border.selected} !important;
257
- background-color: ${props.theme.colors.form.background
258
- .selected} !important;
259
- `}
260
-
261
- &:focus {
262
- ${focusRing}
263
- }
261
+ &:focus {
262
+ ${focusRing}
264
263
  }
265
264
  }
265
+ }
266
266
 
267
- ${COMMON}
268
- `
269
- );
267
+ ${COMMON}
268
+ `
269
+ );
270
270
 
271
271
  export default Container;
@@ -73,8 +73,9 @@ const Trigger = ({ children, ...rest }) => {
73
73
  };
74
74
 
75
75
  const Panel = ({ children, ...rest }) => {
76
- const { isOpen, id, offset, collapsedHeight, openHeight } =
77
- useContext(CollapsibleContext);
76
+ const { isOpen, id, offset, collapsedHeight, openHeight } = useContext(
77
+ CollapsibleContext
78
+ );
78
79
  const ref = useRef();
79
80
  const measurement = useMeasure(ref);
80
81
  const [isHidden, setIsHidden] = useState(undefined);
@@ -80,8 +80,16 @@ export default class Image extends React.Component<TypeProps, TypeState> {
80
80
  };
81
81
 
82
82
  render() {
83
- const { alt, title, onClick, onError, onLoad, src, qa, ...rest } =
84
- this.props;
83
+ const {
84
+ alt,
85
+ title,
86
+ onClick,
87
+ onError,
88
+ onLoad,
89
+ src,
90
+ qa,
91
+ ...rest
92
+ } = this.props;
85
93
 
86
94
  return (
87
95
  <ImageContainer
@@ -17,8 +17,9 @@ type TypeSegmentedControlContext = {
17
17
  onChange: (e: SyntheticInputEvent<HTMLInputElement>) => void,
18
18
  };
19
19
 
20
- const SegmentedControlContext =
21
- React.createContext<?TypeSegmentedControlContext>(null);
20
+ const SegmentedControlContext = React.createContext<?TypeSegmentedControlContext>(
21
+ null
22
+ );
22
23
 
23
24
  type TypeSegmentedControlItemProps = {
24
25
  /** The value of this item. Should be unique among sibling items. */
@@ -22,8 +22,15 @@ export type TypeTableCell = {
22
22
  */
23
23
  export default class TableCell extends React.Component<TypeTableCell> {
24
24
  render() {
25
- const { id, content, colSpan, width, align, children, ...rest } =
26
- this.props;
25
+ const {
26
+ id,
27
+ content,
28
+ colSpan,
29
+ width,
30
+ align,
31
+ children,
32
+ ...rest
33
+ } = this.props;
27
34
 
28
35
  return (
29
36
  <Container
@@ -32,8 +32,15 @@ export default class ToggleHint extends React.Component<TypeProps> {
32
32
  };
33
33
 
34
34
  render() {
35
- const { icon, isOpen, openString, closeString, qa, className, ...rest } =
36
- this.props;
35
+ const {
36
+ icon,
37
+ isOpen,
38
+ openString,
39
+ closeString,
40
+ qa,
41
+ className,
42
+ ...rest
43
+ } = this.props;
37
44
 
38
45
  return (
39
46
  <Container
@@ -14,8 +14,7 @@ import type {
14
14
 
15
15
  // https://styled-system.com/table#color
16
16
 
17
- type TypeBackgroundColorSystemProp =
18
- TypeResponsiveBaseSystemProp<BackgroundColorProperty>;
17
+ type TypeBackgroundColorSystemProp = TypeResponsiveBaseSystemProp<BackgroundColorProperty>;
19
18
  export type TypeColorSystemProps = $ReadOnly<{|
20
19
  backgroundColor?: TypeBackgroundColorSystemProp,
21
20
  bg?: TypeBackgroundColorSystemProp,
@@ -31,11 +31,23 @@ export const navigation = {
31
31
  },
32
32
  };
33
33
 
34
+ export const datePicker = {
35
+ comparison: {
36
+ background: {
37
+ base: baseDarkTheme.colors.neutral[400],
38
+ },
39
+ text: {
40
+ base: baseDarkTheme.colors.neutral[800],
41
+ },
42
+ },
43
+ };
44
+
34
45
  const darkTheme: TypeSproutTheme = {
35
46
  ...baseDarkTheme,
36
47
  colors: {
37
48
  ...baseDarkTheme.colors,
38
49
  navigation,
50
+ datePicker,
39
51
  },
40
52
  };
41
53
 
@@ -31,11 +31,23 @@ export const navigation = {
31
31
  },
32
32
  };
33
33
 
34
+ export const datePicker = {
35
+ comparison: {
36
+ background: {
37
+ base: baseLightTheme.colors.neutral[400],
38
+ },
39
+ text: {
40
+ base: baseLightTheme.colors.neutral[800],
41
+ },
42
+ },
43
+ };
44
+
34
45
  const lightTheme: TypeSproutTheme = {
35
46
  ...baseLightTheme,
36
47
  colors: {
37
48
  ...baseLightTheme.colors,
38
49
  navigation,
50
+ datePicker,
39
51
  },
40
52
  };
41
53
 
@@ -0,0 +1,119 @@
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
+ // theme.scss is auto-generated based on the JS theme file, ensuring our SCSS theme variables stay in sync.
6
+ // _themed.scss will be copied to each theme folder in /dist, where the theme.scss file for that theme will be.
7
+ @import "./theme.scss";
8
+
9
+ // In the JS theme file, the theme object is exported as "default" (i.e., using "export default"),
10
+ // so we need to map-get "default" to access it.
11
+ $theme: map-get($theme, "default");
12
+
13
+ // FUNCTIONS
14
+ // This function will allow you to get any value from the theme.
15
+ // @param {string} $key - the period-separated path to the value in the theme object. e.g., "colors.text.body"
16
+ @function t($key) {
17
+ $keys: _str-split($key, ".");
18
+ @return _map-deep-get($theme, $keys);
19
+ }
20
+
21
+ // The rest of the functions are convenience methods to get theme values for subsets of the theme.
22
+ // @param {string} $key - the period-separated path to the value in the theme object, with "colors." omitted. e.g., "text.body"
23
+ @function colors($key) {
24
+ $keys: _str-split($key, ".");
25
+ @return _map-deep-get($theme, join("colors", $keys));
26
+ }
27
+
28
+ // @param {string} $key - the period-separated path to the value in the theme object, with "typography." omitted. e.g., "100.fontSize"
29
+ @function typography($key) {
30
+ $keys: _str-split($key, ".");
31
+ @return _map-deep-get($theme, join("typography", $keys));
32
+ }
33
+
34
+ // @param {string} $key - the period-separated path to the value in the theme object, with "fontWeights." omitted. e.g., "normal"
35
+ @function fontWeights($key) {
36
+ $keys: _str-split($key, ".");
37
+ @return _map-deep-get($theme, join("fontWeights", $keys));
38
+ }
39
+
40
+ // @param {string} $key - the period-separated path to the value in the theme object, with "space." omitted. e.g., "100"
41
+ @function space($key) {
42
+ $keys: _str-split($key, ".");
43
+ @return _map-deep-get($theme, join("space", $keys));
44
+ }
45
+
46
+ // @param {string} $key - the period-separated path to the value in the theme object, with "radii." omitted. e.g., "inner"
47
+ @function radii($key) {
48
+ $keys: _str-split($key, ".");
49
+ @return _map-deep-get($theme, join("radii", $keys));
50
+ }
51
+
52
+ // @param {string} $key - the period-separated path to the value in the theme object, with "borders." omitted. e.g., "500"
53
+ @function borders($key) {
54
+ $keys: _str-split($key, ".");
55
+ @return _map-deep-get($theme, join("borders", $keys));
56
+ }
57
+
58
+ // @param {string} $key - the period-separated path to the value in the theme object, with "borderWidths." omitted. e.g., "500"
59
+ @function borderWidths($key) {
60
+ $keys: _str-split($key, ".");
61
+ @return _map-deep-get($theme, join("borderWidths", $keys));
62
+ }
63
+
64
+ // @param {string} $key - the period-separated path to the value in the theme object, with "shadows." omitted. e.g., "low"
65
+ @function shadows($key) {
66
+ $keys: _str-split($key, ".");
67
+ @return _map-deep-get($theme, join("shadows", $keys));
68
+ }
69
+
70
+ // @param {string} $key - the period-separated path to the value in the theme object, with "easing." omitted. e.g., "ease_in"
71
+ @function easing($key) {
72
+ $keys: _str-split($key, ".");
73
+ @return _map-deep-get($theme, join("easing", $keys));
74
+ }
75
+
76
+ // @param {string} $key - the period-separated path to the value in the theme object, with "duration." omitted. e.g., "fast"
77
+ @function duration($key) {
78
+ $keys: _str-split($key, ".");
79
+ @return _map-deep-get($theme, join("duration", $keys));
80
+ }
81
+
82
+ // UTILITIES
83
+ // Helper functions that power the functions above. Not relevant to the theme.
84
+ // If you import this file with @use, these functions will be excluded because they are private.
85
+
86
+ // Via https://stackoverflow.com/a/42295154
87
+ // Used to split period-separated object keys, e.g. "colors.text.body" => ["colors", "text", "body"]
88
+ // Only works with a single-character separator.
89
+ @function _str-split($string, $separator) {
90
+ // empty array/list
91
+ $split-arr: ();
92
+ // first index of separator in string
93
+ $index: str-index($string, $separator);
94
+ // loop through string
95
+ @while $index != null {
96
+ // get the substring from the first character to the separator
97
+ $item: str-slice($string, 1, $index - 1);
98
+ // push item to array
99
+ $split-arr: append($split-arr, $item);
100
+ // remove item and separator from string
101
+ $string: str-slice($string, $index + 1);
102
+ // find new index of separator
103
+ $index: str-index($string, $separator);
104
+ }
105
+ // add the remaining string to list (the last item)
106
+ $split-arr: append($split-arr, $string);
107
+
108
+ @return $split-arr;
109
+ }
110
+
111
+ // Adapted from https://css-tricks.com/snippets/sass/deep-getset-maps/
112
+ // Iterates over a list of keys to read multi-level maps.
113
+ // e.g., _map-deep-get((colors: (text: (body: "#364141"))), ["colors", "text", "body"]) => "#364141"
114
+ @function _map-deep-get($map, $keys) {
115
+ @each $key in $keys {
116
+ $map: map-get($map, $key);
117
+ }
118
+ @return $map;
119
+ }
@@ -13,7 +13,10 @@ import {
13
13
  } from "../themes/light/theme";
14
14
  import type { TypeColors } from "./theme.colors.flow.js";
15
15
  import type { TypeFontFamilyString } from "../themes/light/theme";
16
- import { navigation } from "../themes/extendedThemes/sproutTheme/light/theme";
16
+ import {
17
+ datePicker,
18
+ navigation,
19
+ } from "../themes/extendedThemes/sproutTheme/light/theme";
17
20
 
18
21
  export type TypeThemeUtils = {| interact: (color: string) => string |};
19
22
  export type TypeThemeMode = "light" | "dark";
@@ -53,5 +56,6 @@ export type TypeSproutTheme = {
53
56
  colors: {|
54
57
  ...$Exact<TypeColor>,
55
58
  navigation: typeof navigation,
59
+ datePicker: typeof datePicker,
56
60
  |},
57
61
  };
@@ -19,13 +19,21 @@ describe("normalizeResponsiveProp", () => {
19
19
 
20
20
  it("should handle arrays with 4 values", () => {
21
21
  expect(normalizeResponsiveProp([0, 1, 2, 3])).toMatchObject([
22
- 0, 1, 2, 3, 3,
22
+ 0,
23
+ 1,
24
+ 2,
25
+ 3,
26
+ 3,
23
27
  ]);
24
28
  });
25
29
 
26
30
  it("should handle arrays with 5 values", () => {
27
31
  expect(normalizeResponsiveProp([0, 1, 2, 3, 4])).toMatchObject([
28
- 0, 1, 2, 3, 4,
32
+ 0,
33
+ 1,
34
+ 2,
35
+ 3,
36
+ 4,
29
37
  ]);
30
38
  });
31
39
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.navigation = exports.default = void 0;
4
+ exports.navigation = exports.default = exports.datePicker = void 0;
5
5
 
6
6
  var _theme = _interopRequireDefault(require("../../../dark/theme"));
7
7
 
@@ -38,10 +38,22 @@ var navigation = {
38
38
  }
39
39
  };
40
40
  exports.navigation = navigation;
41
+ var datePicker = {
42
+ comparison: {
43
+ background: {
44
+ base: _theme.default.colors.neutral[400]
45
+ },
46
+ text: {
47
+ base: _theme.default.colors.neutral[800]
48
+ }
49
+ }
50
+ };
51
+ exports.datePicker = datePicker;
41
52
 
42
53
  var darkTheme = _extends({}, _theme.default, {
43
54
  colors: _extends({}, _theme.default.colors, {
44
- navigation: navigation
55
+ navigation: navigation,
56
+ datePicker: datePicker
45
57
  })
46
58
  });
47
59
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.navigation = exports.default = void 0;
4
+ exports.navigation = exports.default = exports.datePicker = void 0;
5
5
 
6
6
  var _theme = _interopRequireDefault(require("../../../light/theme"));
7
7
 
@@ -38,10 +38,22 @@ var navigation = {
38
38
  }
39
39
  };
40
40
  exports.navigation = navigation;
41
+ var datePicker = {
42
+ comparison: {
43
+ background: {
44
+ base: _theme.default.colors.neutral[400]
45
+ },
46
+ text: {
47
+ base: _theme.default.colors.neutral[800]
48
+ }
49
+ }
50
+ };
51
+ exports.datePicker = datePicker;
41
52
 
42
53
  var lightTheme = _extends({}, _theme.default, {
43
54
  colors: _extends({}, _theme.default.colors, {
44
- navigation: navigation
55
+ navigation: navigation,
56
+ datePicker: datePicker
45
57
  })
46
58
  });
47
59
 
@@ -2,12 +2,13 @@
2
2
  // This file is excluded from stylelint, because stylelint is only set up to lint styled-components at the moment.
3
3
 
4
4
  // SET-UP
5
- // This file is auto-generated based on the JS theme file, ensuring our SCSS theme variables stay in sync.
6
- @import "../../../dist/themes/dark/dark.scss";
5
+ // theme.scss is auto-generated based on the JS theme file, ensuring our SCSS theme variables stay in sync.
6
+ // _themed.scss will be copied to each theme folder in /dist, where the theme.scss file for that theme will be.
7
+ @import "./theme.scss";
7
8
 
8
9
  // In the JS theme file, the theme object is exported as "default" (i.e., using "export default"),
9
10
  // so we need to map-get "default" to access it.
10
- $theme: map-get($dark, "default");
11
+ $theme: map-get($theme, "default");
11
12
 
12
13
  // FUNCTIONS
13
14
  // This function will allow you to get any value from the theme.
@@ -1,4 +1,4 @@
1
- $dark: (
1
+ $theme: (
2
2
  __esModule: true,
3
3
  default: (
4
4
  utils: (