@sproutsocial/racine 8.8.0-dar35-beta.0 → 9.1.0-token-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 (47) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/__flow__/Button/styles.js +1 -1
  3. package/__flow__/Card/styles.js +1 -1
  4. package/__flow__/Drawer/index.stories.js +3 -3
  5. package/__flow__/Drawer/styles.js +1 -1
  6. package/__flow__/KeyboardKey/styles.js +1 -1
  7. package/__flow__/Menu/index.stories.js +1 -1
  8. package/__flow__/Modal/__snapshots__/index.test.js.snap +1 -1
  9. package/__flow__/Modal/styles.js +1 -1
  10. package/__flow__/Popout/index.js +1 -1
  11. package/__flow__/Token/index.js +4 -1
  12. package/__flow__/Token/index.stories.js +11 -0
  13. package/__flow__/Token/styles.js +43 -33
  14. package/__flow__/Tooltip/index.js +1 -1
  15. package/__flow__/themes/_themes.scss +23 -25
  16. package/__flow__/themes/dark/theme.js +179 -159
  17. package/__flow__/themes/default/theme.js +15 -8
  18. package/__flow__/themes/utils/interact.js +12 -0
  19. package/__flow__/types/system-props.flow.js +1 -2
  20. package/commonjs/Button/styles.js +1 -1
  21. package/commonjs/Card/styles.js +1 -1
  22. package/commonjs/Drawer/styles.js +1 -1
  23. package/commonjs/KeyboardKey/styles.js +1 -1
  24. package/commonjs/Modal/styles.js +1 -1
  25. package/commonjs/Popout/index.js +1 -1
  26. package/commonjs/Token/index.js +5 -2
  27. package/commonjs/Token/styles.js +19 -50
  28. package/commonjs/Tooltip/index.js +1 -1
  29. package/commonjs/themes/dark/theme.js +178 -157
  30. package/commonjs/themes/default/theme.js +15 -8
  31. package/commonjs/themes/utils/interact.js +19 -0
  32. package/dist/themes/_themes.scss +23 -25
  33. package/dist/themes/dark.scss +18 -11
  34. package/dist/themes/default.scss +14 -15
  35. package/lib/Button/styles.js +1 -1
  36. package/lib/Card/styles.js +1 -1
  37. package/lib/Drawer/styles.js +1 -1
  38. package/lib/KeyboardKey/styles.js +1 -1
  39. package/lib/Modal/styles.js +1 -1
  40. package/lib/Popout/index.js +1 -1
  41. package/lib/Token/index.js +5 -2
  42. package/lib/Token/styles.js +19 -50
  43. package/lib/Tooltip/index.js +1 -1
  44. package/lib/themes/dark/theme.js +173 -156
  45. package/lib/themes/default/theme.js +14 -8
  46. package/lib/themes/utils/interact.js +13 -0
  47. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - a71802f: convert shadow tokens to semantic tokens
8
+
9
+ ## 8.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 2746920: Add SCSS themed mixin and functions
14
+
15
+ ### Patch Changes
16
+
17
+ - 69ddb8e: Replace instances of Icon colors with semantic names
18
+
3
19
  ## 8.7.1
4
20
 
5
21
  ### Patch Changes
@@ -51,7 +51,7 @@ const Container: StyledComponent<any, TypeTheme, *> = styled.button`
51
51
  props.theme.colors.button[props.appearance].background.hover};
52
52
  text-decoration: none;
53
53
  box-shadow: ${(props) =>
54
- props.appearance === "placeholder" ? props.theme.shadows[100] : "none"};
54
+ props.appearance === "placeholder" ? props.theme.shadows.low : "none"};
55
55
  }
56
56
 
57
57
  &:active {
@@ -19,7 +19,7 @@ const Container = styled<typeof Box, *>(Box)`
19
19
  width: 100%;
20
20
  height: 100%;
21
21
  opacity: 0;
22
- box-shadow: ${(props) => props.theme.shadows[100]};
22
+ box-shadow: ${(props) => props.theme.shadows.low};
23
23
  transition: opacity ${(props) => props.theme.duration.medium}
24
24
  ${(props) => props.theme.easing.ease_inout};
25
25
  }
@@ -51,7 +51,7 @@ const DrawerComponent = ({ direction, offset }) => {
51
51
  padding={300}
52
52
  >
53
53
  <Button onClick={onOpen}>
54
- <Icon color="neutral.0" name="notifications" />
54
+ <Icon color="icon.inverse" name="notifications" />
55
55
  </Button>
56
56
  </Box>
57
57
  <Drawer
@@ -105,10 +105,10 @@ const NectarDrawerComponent = ({ direction, offset }) => {
105
105
  <Button
106
106
  onClick={isNotificationsOpen ? closeNotifications : openNotifications}
107
107
  >
108
- <Icon color="neutral.800" name="notifications" />
108
+ <Icon color="icon.base" name="notifications" />
109
109
  </Button>
110
110
  <Button onClick={isPoplarOpen ? closePoplar : openPoplar} mt={400}>
111
- <Icon color="neutral.800" name="link" />
111
+ <Icon color="icon.base" name="link" />
112
112
  </Button>
113
113
  </Box>
114
114
  <Drawer
@@ -17,7 +17,7 @@ const Container: StyledComponent<any, TypeTheme, *> = styled.div`
17
17
  height: 100%;
18
18
  width: ${(props) => props.width}px;
19
19
  background-color: ${(props) => props.theme.colors.container.background.base};
20
- box-shadow: ${(props) => props.theme.shadows[400]};
20
+ box-shadow: ${(props) => props.theme.shadows.high};
21
21
  filter: blur(0);
22
22
 
23
23
  ${(props) => css`
@@ -10,7 +10,7 @@ const Container: StyledComponent<{ ... }, TypeTheme, *> = styled.div`
10
10
  background-color: ${(props) => props.theme.colors.container.background.base};
11
11
  border: 1px solid ${(props) => props.theme.colors.container.border.base};
12
12
  border-radius: ${(props) => props.theme.radii[500]};
13
- box-shadow: ${(props) => props.theme.shadows[100]};
13
+ box-shadow: ${(props) => props.theme.shadows.low};
14
14
  padding: 0 ${(props) => props.theme.space[200]};
15
15
  min-width: 20px;
16
16
  justify-content: center;
@@ -213,7 +213,7 @@ export const MenuWithIcons = (props) => {
213
213
  border={500}
214
214
  borderRadius="outer"
215
215
  borderColor="container.border.base"
216
- boxShadow={300}
216
+ boxShadow="medium"
217
217
  backgroundColor="container.background.base"
218
218
  >
219
219
  <Menu {...props}>
@@ -45,7 +45,7 @@ exports[`Modal should render properly 1`] = `
45
45
  flex-direction: column;
46
46
  background: #FFFFFF;
47
47
  border-radius: 6px;
48
- box-shadow: 0px 8px 16px rgba(39,51,51,.24);
48
+ box-shadow: 0px 8px 16px #2733333D;
49
49
  -webkit-filter: blur(0);
50
50
  filter: blur(0);
51
51
  color: #364141;
@@ -84,7 +84,7 @@ export const Container: StyledComponent<any, TypeTheme, *> = styled(ReactModalAd
84
84
  flex-direction: column;
85
85
  background: ${(props) => props.theme.colors.container.background.base};
86
86
  border-radius: ${(props) => props.theme.radii[500]};
87
- box-shadow: ${(props) => props.theme.shadows[300]};
87
+ box-shadow: ${(props) => props.theme.shadows.medium};
88
88
  filter: blur(0);
89
89
  color: ${(props) => props.theme.colors.text.body};
90
90
 
@@ -395,7 +395,7 @@ Popout.Content = ({ children, ...rest }: TypePopoutContentProps) => (
395
395
  border={500}
396
396
  borderColor="container.border.base"
397
397
  borderRadius="outer"
398
- boxShadow={300}
398
+ boxShadow="medium"
399
399
  p={400}
400
400
  m={300}
401
401
  {...rest}
@@ -15,6 +15,7 @@ export type TypeProps = {
15
15
  valid?: boolean,
16
16
  /** Indicates whether the token is disabled */
17
17
  disabled?: boolean,
18
+ palette?: "neutral" | "blue",
18
19
  };
19
20
 
20
21
  const Token = ({
@@ -24,6 +25,7 @@ const Token = ({
24
25
  qa,
25
26
  valid = true,
26
27
  disabled = false,
28
+ palette = "neutral",
27
29
  ...rest
28
30
  }: TypeProps) => {
29
31
  const textContainer = useTextContent("");
@@ -32,8 +34,9 @@ const Token = ({
32
34
  <Container
33
35
  ref={textContainer}
34
36
  valid={valid}
35
- as={closeable || onClick ? "button" : "div"}
37
+ palette={palette}
36
38
  type={closeable || onClick ? "button" : undefined}
39
+ as={closeable || onClick ? "button" : "div"}
37
40
  closeable={closeable || onClick}
38
41
  disabled={disabled}
39
42
  onClick={onClick}
@@ -80,3 +80,14 @@ export const staticWithIcon = () => (
80
80
  staticWithIcon.story = {
81
81
  name: "Static with icon",
82
82
  };
83
+
84
+ export const bluePalette = () => (
85
+ <Token palette="blue" closeable={boolean("closeable", false)}>
86
+ <Icon size="mini" name="twitter" pr={300} />
87
+ <span>I'm blue</span>
88
+ </Token>
89
+ );
90
+
91
+ bluePalette.story = {
92
+ name: "Palette Variation",
93
+ };
@@ -6,68 +6,78 @@ import { focusRing } from "../utils/mixins";
6
6
  import type { TypeTheme } from "../types/theme.flow";
7
7
 
8
8
  const Container: StyledComponent<any, TypeTheme, *> = styled.button`
9
- font-family: ${(props) => props.theme.fontFamily};
10
- ${(props) => props.theme.typography[200]};
11
9
  position: relative;
12
10
  display: inline-block;
13
- padding: ${(props) => props.theme.space[200]}
14
- ${(props) => props.theme.space[300]};
15
11
  margin: 0;
16
- color: ${(props) => props.theme.colors.text.body};
17
- background: ${(props) => props.theme.colors.container.background.base};
18
- border: 1px solid ${(props) => props.theme.colors.container.border.base};
19
- font-weight: ${(props) => props.theme.fontWeights.normal};
20
12
  line-height: 1;
21
13
  vertical-align: middle;
22
- border-radius: ${(props) => props.theme.radii[500]};
23
14
  outline: none;
24
- transition: all ${(props) => props.theme.duration.fast}
25
- ${(props) => props.theme.easing.ease_inout};
15
+ /* Theme Properties */
16
+ ${({ theme }) => css`
17
+ ${theme.typography[200]}
18
+ font-family: ${theme.fontFamily};
19
+ font-weight: ${theme.fontWeights.normal};
20
+ border: 1px solid ${theme.colors.container.border.base};
21
+ border-radius: ${theme.radii[500]};
22
+ color: ${theme.colors.text.body};
23
+ background: ${theme.colors.container.background.base};
24
+ padding: ${theme.space[200]} ${theme.space[300]};
25
+ transition: all ${theme.duration.fast} ${theme.easing.ease_inout};
26
+ `}
26
27
 
27
28
  &:focus {
28
29
  ${focusRing}
29
30
  }
30
31
 
31
- ${(props) =>
32
- props.closeable &&
32
+ ${({ theme, palette }) =>
33
+ palette === "blue" &&
33
34
  css`
34
- cursor: pointer;
35
+ color: ${theme.colors.text.body};
36
+ background: ${theme.colors.container.background.decorative.blue};
37
+ border: 1px solid ${theme.colors.container.border.decorative.blue};
38
+ &:hover,
39
+ &:active {
40
+ cursor: pointer;
41
+ box-shadow: ${theme.shadows.low};
42
+ border: 1px solid
43
+ ${theme.utils.interact(theme.colors.container.border.decorative.blue)};
44
+ }
45
+ `}
35
46
 
47
+ ${({ closeable, theme }) =>
48
+ closeable &&
49
+ css`
50
+ cursor: pointer;
36
51
  &:hover,
37
52
  &:active {
38
- color: ${(props) => props.theme.colors.text.body};
53
+ box-shadow: ${theme.shadows.low};
39
54
  border: 1px solid
40
- ${(props) => props.theme.colors.container.border.decorative.neutral};
41
- background-color: ${(props) =>
42
- props.theme.colors.container.background.decorative.neutral};
55
+ ${theme.utils.interact(theme.colors.container.border.base)};
43
56
  }
44
57
  `}
45
58
 
46
- ${(props) =>
47
- props.disabled &&
59
+ ${({ disabled, theme }) =>
60
+ disabled &&
48
61
  css`
49
62
  opacity: 0.4;
50
63
  cursor: not-allowed;
51
64
  &:hover,
52
65
  &:active {
53
- background: ${(props) => props.theme.colors.container.background.base};
54
- border: 1px solid ${(props) => props.theme.colors.container.border.base};
66
+ box-shadow: none;
67
+ border: 1px solid ${theme.colors.container.border.base};
55
68
  }
56
69
  `}
57
-
58
- ${(props) =>
59
- !props.valid &&
70
+
71
+ ${({ valid, theme }) =>
72
+ !valid &&
60
73
  css`
61
- color: ${(props) => props.theme.colors.text.body};
62
- border-color: ${(props) => props.theme.colors.container.border.error};
63
- background: ${(props) => props.theme.colors.container.background.error};
64
-
74
+ color: ${theme.colors.text.error};
75
+ background: ${theme.colors.container.background.error};
76
+ border: 1px solid ${theme.colors.container.border.error};
65
77
  &:hover {
66
- color: ${(props) => props.theme.colors.text.body};
78
+ box-shadow: ${theme.shadows.low};
67
79
  border: 1px solid
68
- ${(props) => props.theme.colors.container.border.error};
69
- background-color: ${(props) =>
70
- props.theme.colors.container.background.error};
80
+ ${theme.utils.interact(theme.colors.container.border.error)};
71
81
  }
72
82
  `}
73
83
 
@@ -159,7 +159,7 @@ const Content = ({
159
159
  m={200}
160
160
  color="text.body"
161
161
  bg="container.background.base"
162
- boxShadow={300}
162
+ boxShadow="medium"
163
163
  border={500}
164
164
  borderColor="container.border.base"
165
165
  // $FlowIssue - upgrade v0.112.0
@@ -3,25 +3,21 @@
3
3
 
4
4
  // SET-UP
5
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";
6
+ @import "../../dist/themes/default.scss";
7
+ @import "../../dist/themes/dark.scss";
8
8
 
9
9
  // In the JS theme files, the theme object is exported as "default" (i.e., using "export default"),
10
10
  // so we need to map-get "default" to access it.
11
11
  $themes: (
12
- default: map-get($default, "default"),
13
- dark: map-get($dark, "default")
12
+ light: map-get($default, "default"),
13
+ dark: map-get($dark, "default")
14
14
  );
15
15
 
16
16
  // MIXIN
17
17
  // CSS properties that are theme-dependent must be wrapped in this mixin
18
18
  @mixin themed() {
19
19
  @each $theme, $map in $themes {
20
- // ~ selects siblings to the specified selector, * selects all children of those siblings,
21
- // which makes ~ * a kind of nephew selector. Thus we can target all elements on the page even if they are
22
- // not a direct descendent of the element that we apply the theme classname to.
23
- // This is important for pop-ups and modals, since they are often mounted directly to the body.
24
- .theme--#{$theme} ~ * & {
20
+ .theme--#{$theme} & {
25
21
  $theme-map: () !global;
26
22
  @each $key, $submap in $map {
27
23
  $value: map-get(map-get($themes, $theme), "#{$key}");
@@ -37,78 +33,79 @@ $themes: (
37
33
  // This function will allow you to get any value from the theme.
38
34
  // @param {string} $key - the period-separated path to the value in the theme object. e.g., "colors.text.body"
39
35
  @function t($key) {
40
- $keys: _string-split($key, ".");
36
+ $keys: _str-split($key, ".");
41
37
  @return _map-deep-get($theme-map, $keys);
42
38
  }
43
39
 
44
- // These functions are convenience methods to get theme values for subsets of the theme.
40
+ // The rest of the functions are convenience methods to get theme values for subsets of the theme.
45
41
  // @param {string} $key - the period-separated path to the value in the theme object, with "colors." omitted. e.g., "text.body"
46
42
  @function colors($key) {
47
- $keys: _string-split($key, ".");
43
+ $keys: _str-split($key, ".");
48
44
  @return _map-deep-get($theme-map, join("colors", $keys));
49
45
  }
50
46
 
51
47
  // @param {string} $key - the period-separated path to the value in the theme object, with "typography." omitted. e.g., "100.fontSize"
52
48
  @function typography($key) {
53
- $keys: _string-split($key, ".");
49
+ $keys: _str-split($key, ".");
54
50
  @return _map-deep-get($theme-map, join("typography", $keys));
55
51
  }
56
52
 
57
53
  // @param {string} $key - the period-separated path to the value in the theme object, with "fontWeights." omitted. e.g., "normal"
58
54
  @function fontWeights($key) {
59
- $keys: _string-split($key, ".");
55
+ $keys: _str-split($key, ".");
60
56
  @return _map-deep-get($theme-map, join("fontWeights", $keys));
61
57
  }
62
58
 
63
59
  // @param {string} $key - the period-separated path to the value in the theme object, with "space." omitted. e.g., "100"
64
60
  @function space($key) {
65
- $keys: _string-split($key, ".");
61
+ $keys: _str-split($key, ".");
66
62
  @return _map-deep-get($theme-map, join("space", $keys));
67
63
  }
68
64
 
69
65
  // @param {string} $key - the period-separated path to the value in the theme object, with "radii." omitted. e.g., "inner"
70
66
  @function radii($key) {
71
- $keys: _string-split($key, ".");
67
+ $keys: _str-split($key, ".");
72
68
  @return _map-deep-get($theme-map, join("radii", $keys));
73
69
  }
74
70
 
75
71
  // @param {string} $key - the period-separated path to the value in the theme object, with "borders." omitted. e.g., "500"
76
72
  @function borders($key) {
77
- $keys: _string-split($key, ".");
73
+ $keys: _str-split($key, ".");
78
74
  @return _map-deep-get($theme-map, join("borders", $keys));
79
75
  }
80
76
 
81
77
  // @param {string} $key - the period-separated path to the value in the theme object, with "borderWidths." omitted. e.g., "500"
82
78
  @function borderWidths($key) {
83
- $keys: _string-split($key, ".");
79
+ $keys: _str-split($key, ".");
84
80
  @return _map-deep-get($theme-map, join("borderWidths", $keys));
85
81
  }
86
82
 
87
83
  // @param {string} $key - the period-separated path to the value in the theme object, with "shadows." omitted. e.g., "low"
88
84
  @function shadows($key) {
89
- $keys: _string-split($key, ".");
85
+ $keys: _str-split($key, ".");
90
86
  @return _map-deep-get($theme-map, join("shadows", $keys));
91
87
  }
92
88
 
93
89
  // @param {string} $key - the period-separated path to the value in the theme object, with "easing." omitted. e.g., "ease_in"
94
90
  @function easing($key) {
95
- $keys: _string-split($key, ".");
91
+ $keys: _str-split($key, ".");
96
92
  @return _map-deep-get($theme-map, join("easing", $keys));
97
93
  }
98
94
 
99
95
  // @param {string} $key - the period-separated path to the value in the theme object, with "duration." omitted. e.g., "fast"
100
96
  @function duration($key) {
101
- $keys: _string-split($key, ".");
97
+ $keys: _str-split($key, ".");
102
98
  @return _map-deep-get($theme-map, join("duration", $keys));
103
99
  }
104
100
 
105
101
  // UTILITIES
106
102
  // Helper functions that power the functions above. Not relevant to the theme.
107
- // If you import this file with @use, they will not be included.
103
+ // If you import this file with @use, these functions will be excluded because they are private.
108
104
 
109
105
  // Via https://stackoverflow.com/a/42295154
110
- // Only works with a single-character separator
111
- @function _string-split($string, $separator) {
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) {
112
109
  // empty array/list
113
110
  $split-arr: ();
114
111
  // first index of separator in string
@@ -131,7 +128,8 @@ $themes: (
131
128
  }
132
129
 
133
130
  // Adapted from https://css-tricks.com/snippets/sass/deep-getset-maps/
134
- // Iterates over a list of keys to read multi-level 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"
135
133
  @function _map-deep-get($map, $keys) {
136
134
  @each $key in $keys {
137
135
  $map: map-get($map, $key);