@sproutsocial/racine 11.9.0 → 12.0.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.
- package/CHANGELOG.md +23 -0
- package/__flow__/Input/index.js +2 -2
- package/__flow__/Token/styles.js +13 -12
- package/__flow__/index.js +1 -0
- package/__flow__/themes/dark/theme.js +0 -5
- package/__flow__/themes/light/theme.js +0 -5
- package/__flow__/types/theme.flow.js +0 -2
- package/__flow__/utils/useInteractiveColor.js +32 -0
- package/commonjs/Input/index.js +3 -1
- package/commonjs/Token/styles.js +9 -7
- package/commonjs/index.js +6 -1
- package/commonjs/themes/dark/theme.js +0 -5
- package/commonjs/themes/light/theme.js +0 -5
- package/commonjs/utils/useInteractiveColor.js +33 -0
- package/dist/themes/dark/theme.scss +0 -3
- package/dist/themes/extendedThemes/sproutTheme/dark/theme.scss +0 -3
- package/dist/themes/extendedThemes/sproutTheme/light/theme.scss +0 -3
- package/dist/themes/light/theme.scss +0 -3
- package/lib/Input/index.js +2 -1
- package/lib/Token/styles.js +8 -7
- package/lib/index.js +1 -0
- package/lib/themes/dark/theme.js +0 -4
- package/lib/themes/light/theme.js +0 -4
- package/lib/utils/useInteractiveColor.js +27 -0
- package/package.json +1 -1
- package/__flow__/themes/utils/interact.js +0 -12
- package/commonjs/themes/utils/interact.js +0 -19
- package/lib/themes/utils/interact.js +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 12.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 54639f5: Moved `theme.util.interact()` to a hook called `useInteractiveColor()`
|
|
8
|
+
|
|
9
|
+
- `theme.util.interact()` will no longer be available on the theme object and is moved to a hook called `useInteractiveColor()`
|
|
10
|
+
- To import the hook, use `import { useInteractiveColor } from '@sproutsocial/racine'`
|
|
11
|
+
- `useInteractiveColor()` accepts a theme color option and returns a lighten or darken version of that color depending on the theme mode currently in use('light' or 'dark')
|
|
12
|
+
- `useInteractiveColor()` can only be utilized within a theme context.
|
|
13
|
+
|
|
14
|
+
example:
|
|
15
|
+
|
|
16
|
+
```jsx
|
|
17
|
+
import { useInteractiveColor } from '@sproutsocial/racine'
|
|
18
|
+
|
|
19
|
+
....
|
|
20
|
+
&:hover,
|
|
21
|
+
&:active {
|
|
22
|
+
color: ${({theme}) => useInteract(theme.colors.icon.base)};
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
3
26
|
## 11.9.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/__flow__/Input/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import styled from "styled-components";
|
|
|
7
7
|
import type { StyledComponent } from "styled-components";
|
|
8
8
|
import type { TypeTheme } from "../types/theme.flow";
|
|
9
9
|
import { mergeRefs } from "../utils";
|
|
10
|
+
import { useInteractiveColor } from "../utils/useInteractiveColor";
|
|
10
11
|
|
|
11
12
|
type TypeProps = {
|
|
12
13
|
/** ID of the form element, should match the "for" value of the associated label */
|
|
@@ -90,8 +91,7 @@ const InputContext = React.createContext<TypeInputContext>({});
|
|
|
90
91
|
const StyledButton: StyledComponent<any, TypeTheme, *> = styled(Button)`
|
|
91
92
|
&:hover,
|
|
92
93
|
&:active {
|
|
93
|
-
color: ${(props) =>
|
|
94
|
-
props.theme.utils.interact(props.theme.colors.icon.base)};
|
|
94
|
+
color: ${(props) => useInteractiveColor(props.theme.colors.icon.base)};
|
|
95
95
|
}
|
|
96
96
|
`;
|
|
97
97
|
|
package/__flow__/Token/styles.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import styled, { css, type StyledComponent } from "styled-components";
|
|
3
3
|
import { COMMON } from "../utils/system-props";
|
|
4
4
|
import { focusRing } from "../utils/mixins";
|
|
5
|
+
import { useInteractiveColor } from "../utils/useInteractiveColor";
|
|
5
6
|
|
|
6
7
|
import type { TypeTheme } from "../types/theme.flow";
|
|
7
8
|
|
|
@@ -29,30 +30,30 @@ const Container: StyledComponent<any, TypeTheme, *> = styled.button`
|
|
|
29
30
|
${focusRing}
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
${({
|
|
33
|
-
|
|
33
|
+
${({ closeable, theme }) =>
|
|
34
|
+
closeable &&
|
|
34
35
|
css`
|
|
35
|
-
|
|
36
|
-
background: ${theme.colors.container.background.decorative.blue};
|
|
37
|
-
border: 1px solid ${theme.colors.container.border.decorative.blue};
|
|
36
|
+
cursor: pointer;
|
|
38
37
|
&:hover,
|
|
39
38
|
&:active {
|
|
40
|
-
cursor: pointer;
|
|
41
39
|
box-shadow: ${theme.shadows.low};
|
|
42
40
|
border: 1px solid
|
|
43
|
-
${
|
|
41
|
+
${useInteractiveColor(theme.colors.container.border.base)};
|
|
44
42
|
}
|
|
45
43
|
`}
|
|
46
44
|
|
|
47
|
-
${({
|
|
48
|
-
|
|
45
|
+
${({ theme, palette }) =>
|
|
46
|
+
palette === "blue" &&
|
|
49
47
|
css`
|
|
50
|
-
|
|
48
|
+
color: ${theme.colors.text.body};
|
|
49
|
+
background: ${theme.colors.container.background.decorative.blue};
|
|
50
|
+
border: 1px solid ${theme.colors.container.border.decorative.blue};
|
|
51
51
|
&:hover,
|
|
52
52
|
&:active {
|
|
53
|
+
cursor: pointer;
|
|
53
54
|
box-shadow: ${theme.shadows.low};
|
|
54
55
|
border: 1px solid
|
|
55
|
-
${
|
|
56
|
+
${useInteractiveColor(theme.colors.container.border.decorative.blue)};
|
|
56
57
|
}
|
|
57
58
|
`}
|
|
58
59
|
|
|
@@ -77,7 +78,7 @@ const Container: StyledComponent<any, TypeTheme, *> = styled.button`
|
|
|
77
78
|
&:hover {
|
|
78
79
|
box-shadow: ${theme.shadows.low};
|
|
79
80
|
border: 1px solid
|
|
80
|
-
${
|
|
81
|
+
${useInteractiveColor(theme.colors.container.border.error)};
|
|
81
82
|
}
|
|
82
83
|
`}
|
|
83
84
|
|
package/__flow__/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export type { TypeTheme, TypeSproutTheme } from "./types/theme.flow";
|
|
|
4
4
|
export * from "./systemProps";
|
|
5
5
|
export { visuallyHidden, focusRing, disabled } from "./utils/mixins";
|
|
6
6
|
export { useSelect, useMultiselect, useTextContent } from "./utils/hooks";
|
|
7
|
+
export { useInteractiveColor } from "./utils/useInteractiveColor";
|
|
7
8
|
export { default as theme } from "./themes/light/theme";
|
|
8
9
|
export { default as darkTheme } from "./themes/dark/theme";
|
|
9
10
|
export {
|
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
} from "./decorative-palettes";
|
|
16
16
|
import { transparentize } from "polished";
|
|
17
17
|
|
|
18
|
-
import interact from "../utils/interact";
|
|
19
|
-
|
|
20
18
|
const MODE = "dark";
|
|
21
19
|
|
|
22
20
|
export const shadows = {
|
|
@@ -235,9 +233,6 @@ const colors = {
|
|
|
235
233
|
|
|
236
234
|
const darkTheme = {
|
|
237
235
|
...lightTheme,
|
|
238
|
-
utils: {
|
|
239
|
-
interact: interact(MODE),
|
|
240
|
-
},
|
|
241
236
|
colors,
|
|
242
237
|
shadows,
|
|
243
238
|
mode: MODE,
|
|
@@ -20,8 +20,6 @@ import MOTION from "@sproutsocial/seeds-motion";
|
|
|
20
20
|
import BORDER from "@sproutsocial/seeds-border";
|
|
21
21
|
import { transparentize } from "polished";
|
|
22
22
|
|
|
23
|
-
import interact from "../utils/interact";
|
|
24
|
-
|
|
25
23
|
export const breakpoints = ["900px", "1200px", "1500px", "1800px"];
|
|
26
24
|
|
|
27
25
|
const MODE = "light";
|
|
@@ -350,9 +348,6 @@ export const duration = {
|
|
|
350
348
|
};
|
|
351
349
|
|
|
352
350
|
const theme = {
|
|
353
|
-
utils: {
|
|
354
|
-
interact: interact(MODE),
|
|
355
|
-
},
|
|
356
351
|
breakpoints,
|
|
357
352
|
colors,
|
|
358
353
|
typography: {
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
analytics,
|
|
20
20
|
} from "../themes/extendedThemes/sproutTheme/light/theme";
|
|
21
21
|
|
|
22
|
-
export type TypeThemeUtils = {| interact: (color: string) => string |};
|
|
23
22
|
export type TypeThemeMode = "light" | "dark";
|
|
24
23
|
export type TypeBreakpoint = typeof breakpoints;
|
|
25
24
|
export type TypeTypography = typeof typography;
|
|
@@ -36,7 +35,6 @@ export type TypeDuration = typeof duration;
|
|
|
36
35
|
|
|
37
36
|
export type TypeTheme = {
|
|
38
37
|
mode: TypeThemeMode,
|
|
39
|
-
utils: TypeThemeUtils,
|
|
40
38
|
breakpoints: TypeBreakpoint,
|
|
41
39
|
colors: TypeColor,
|
|
42
40
|
typography: TypeTypography,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//@flow strict-local
|
|
2
|
+
import { darken, lighten } from "polished";
|
|
3
|
+
import { useTheme } from "styled-components";
|
|
4
|
+
import type { TypeColors } from "../types/theme.colors.flow.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The useInteractiveColor hook has context of theme mode (light or dark)
|
|
8
|
+
* and can be used to lighten or darken a color dynamically
|
|
9
|
+
*
|
|
10
|
+
* note: colors are limited to our theme colors
|
|
11
|
+
*/
|
|
12
|
+
const useInteractiveColor = (themeColor: TypeColors): string => {
|
|
13
|
+
// Throw error if used outside of a ThemeProvider (styled-components)
|
|
14
|
+
if (!useTheme()) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
"useInteractiveColor() must be used within a Styled Components ThemeProvider"
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Get the current theme mode ie. 'light' or 'dark'
|
|
21
|
+
const themeMode = useTheme().mode;
|
|
22
|
+
|
|
23
|
+
// If the theme mode is dark, return a lightened version of the themeValue
|
|
24
|
+
if (themeMode === "dark") {
|
|
25
|
+
return lighten(0.2, themeColor);
|
|
26
|
+
} else {
|
|
27
|
+
// If the theme mode is light, return a darkened version of the themeValue
|
|
28
|
+
return darken(0.2, themeColor);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useInteractiveColor };
|
package/commonjs/Input/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
|
|
18
|
+
var _useInteractiveColor = require("../utils/useInteractiveColor");
|
|
19
|
+
|
|
18
20
|
var _excluded = ["autoComplete", "autoFocus", "disabled", "readOnly", "isInvalid", "hasWarning", "id", "name", "placeholder", "type", "required", "value", "elemBefore", "elemAfter", "maxLength", "ariaLabel", "ariaDescribedby", "clearButtonLabel", "innerRef", "onBlur", "onChange", "onClear", "onFocus", "onKeyDown", "onKeyUp", "onPaste", "inputProps", "qa", "appearance", "size"];
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -36,7 +38,7 @@ var StyledButton = (0, _styledComponents.default)(_Button.default).withConfig({
|
|
|
36
38
|
displayName: "Input__StyledButton",
|
|
37
39
|
componentId: "sc-1ck1dnm-0"
|
|
38
40
|
})(["&:hover,&:active{color:", ";}"], function (props) {
|
|
39
|
-
return
|
|
41
|
+
return (0, _useInteractiveColor.useInteractiveColor)(props.theme.colors.icon.base);
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
var ClearButton = function ClearButton() {
|
package/commonjs/Token/styles.js
CHANGED
|
@@ -9,6 +9,8 @@ var _systemProps = require("../utils/system-props");
|
|
|
9
9
|
|
|
10
10
|
var _mixins = require("../utils/mixins");
|
|
11
11
|
|
|
12
|
+
var _useInteractiveColor = require("../utils/useInteractiveColor");
|
|
13
|
+
|
|
12
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
15
|
|
|
14
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -20,13 +22,13 @@ var Container = _styledComponents.default.button.withConfig({
|
|
|
20
22
|
var theme = _ref.theme;
|
|
21
23
|
return (0, _styledComponents.css)(["", " font-family:", ";font-weight:", ";border:1px solid ", ";border-radius:", ";color:", ";background:", ";padding:", " ", ";transition:all ", " ", ";"], theme.typography[200], theme.fontFamily, theme.fontWeights.normal, theme.colors.container.border.base, theme.radii[500], theme.colors.text.body, theme.colors.container.background.base, theme.space[200], theme.space[300], theme.duration.fast, theme.easing.ease_inout);
|
|
22
24
|
}, _mixins.focusRing, function (_ref2) {
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
return
|
|
25
|
+
var closeable = _ref2.closeable,
|
|
26
|
+
theme = _ref2.theme;
|
|
27
|
+
return closeable && (0, _styledComponents.css)(["cursor:pointer;&:hover,&:active{box-shadow:", ";border:1px solid ", ";}"], theme.shadows.low, (0, _useInteractiveColor.useInteractiveColor)(theme.colors.container.border.base));
|
|
26
28
|
}, function (_ref3) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
return
|
|
29
|
+
var theme = _ref3.theme,
|
|
30
|
+
palette = _ref3.palette;
|
|
31
|
+
return palette === "blue" && (0, _styledComponents.css)(["color:", ";background:", ";border:1px solid ", ";&:hover,&:active{cursor:pointer;box-shadow:", ";border:1px solid ", ";}"], theme.colors.text.body, theme.colors.container.background.decorative.blue, theme.colors.container.border.decorative.blue, theme.shadows.low, (0, _useInteractiveColor.useInteractiveColor)(theme.colors.container.border.decorative.blue));
|
|
30
32
|
}, function (_ref4) {
|
|
31
33
|
var disabled = _ref4.disabled,
|
|
32
34
|
theme = _ref4.theme;
|
|
@@ -34,7 +36,7 @@ var Container = _styledComponents.default.button.withConfig({
|
|
|
34
36
|
}, function (_ref5) {
|
|
35
37
|
var valid = _ref5.valid,
|
|
36
38
|
theme = _ref5.theme;
|
|
37
|
-
return !valid && (0, _styledComponents.css)(["color:", ";background:", ";border:1px solid ", ";&:hover{box-shadow:", ";border:1px solid ", ";}"], theme.colors.text.error, theme.colors.container.background.error, theme.colors.container.border.error, theme.shadows.low,
|
|
39
|
+
return !valid && (0, _styledComponents.css)(["color:", ";background:", ";border:1px solid ", ";&:hover{box-shadow:", ";border:1px solid ", ";}"], theme.colors.text.error, theme.colors.container.background.error, theme.colors.container.border.error, theme.shadows.low, (0, _useInteractiveColor.useInteractiveColor)(theme.colors.container.border.error));
|
|
38
40
|
}, _systemProps.COMMON);
|
|
39
41
|
|
|
40
42
|
var _default = Container;
|
package/commonjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var _exportNames = {
|
|
|
8
8
|
useSelect: true,
|
|
9
9
|
useMultiselect: true,
|
|
10
10
|
useTextContent: true,
|
|
11
|
+
useInteractiveColor: true,
|
|
11
12
|
theme: true,
|
|
12
13
|
darkTheme: true,
|
|
13
14
|
Icon: true,
|
|
@@ -72,7 +73,7 @@ var _exportNames = {
|
|
|
72
73
|
DateRangePicker: true,
|
|
73
74
|
VisuallyHidden: true
|
|
74
75
|
};
|
|
75
|
-
exports.visuallyHidden = exports.useTextContent = exports.useSelect = exports.useMultiselect = exports.toast = exports.theme = exports.sproutLightTheme = exports.sproutDarkTheme = exports.focusRing = exports.disabled = exports.darkTheme = exports.VisuallyHidden = exports.Tooltip = exports.TokenInput = exports.Token = exports.ToggleHint = exports.ToastContainer = exports.ThemeProvider = exports.Textarea = exports.Text = exports.Tabs = exports.TableRowAccordion = exports.TableHeaderCell = exports.TableCell = exports.Table = exports.Switch = exports.Stack = exports.Skeleton = exports.SingleDatePicker = exports.Select = exports.SegmentedControl = exports.Radio = exports.Popout = exports.OverflowList = exports.Numeral = exports.Modal = exports.Message = exports.MenuItemContainer = exports.MenuButtonContext = exports.MenuButton = exports.Menu = exports.LoaderButton = exports.Loader = exports.ListboxButton = exports.Listbox = exports.Link = exports.Label = exports.KeyboardKey = exports.Input = exports.Indicator = exports.Image = exports.Icon = exports.FormField = exports.Fieldset = exports.EmptyState = exports.Drawer = exports.DateRangePicker = exports.Collapsible = exports.Checkbox = exports.ChartLegend = exports.CharacterCounter = exports.Card = exports.Button = exports.Breadcrumb = exports.Box = exports.Banner = exports.Badge = exports.Avatar = exports.Alert = void 0;
|
|
76
|
+
exports.visuallyHidden = exports.useTextContent = exports.useSelect = exports.useMultiselect = exports.useInteractiveColor = exports.toast = exports.theme = exports.sproutLightTheme = exports.sproutDarkTheme = exports.focusRing = exports.disabled = exports.darkTheme = exports.VisuallyHidden = exports.Tooltip = exports.TokenInput = exports.Token = exports.ToggleHint = exports.ToastContainer = exports.ThemeProvider = exports.Textarea = exports.Text = exports.Tabs = exports.TableRowAccordion = exports.TableHeaderCell = exports.TableCell = exports.Table = exports.Switch = exports.Stack = exports.Skeleton = exports.SingleDatePicker = exports.Select = exports.SegmentedControl = exports.Radio = exports.Popout = exports.OverflowList = exports.Numeral = exports.Modal = exports.Message = exports.MenuItemContainer = exports.MenuButtonContext = exports.MenuButton = exports.Menu = exports.LoaderButton = exports.Loader = exports.ListboxButton = exports.Listbox = exports.Link = exports.Label = exports.KeyboardKey = exports.Input = exports.Indicator = exports.Image = exports.Icon = exports.FormField = exports.Fieldset = exports.EmptyState = exports.Drawer = exports.DateRangePicker = exports.Collapsible = exports.Checkbox = exports.ChartLegend = exports.CharacterCounter = exports.Card = exports.Button = exports.Breadcrumb = exports.Box = exports.Banner = exports.Badge = exports.Avatar = exports.Alert = void 0;
|
|
76
77
|
|
|
77
78
|
var _systemProps = require("./systemProps");
|
|
78
79
|
|
|
@@ -95,6 +96,10 @@ exports.useSelect = _hooks.useSelect;
|
|
|
95
96
|
exports.useMultiselect = _hooks.useMultiselect;
|
|
96
97
|
exports.useTextContent = _hooks.useTextContent;
|
|
97
98
|
|
|
99
|
+
var _useInteractiveColor = require("./utils/useInteractiveColor");
|
|
100
|
+
|
|
101
|
+
exports.useInteractiveColor = _useInteractiveColor.useInteractiveColor;
|
|
102
|
+
|
|
98
103
|
var _theme = _interopRequireDefault(require("./themes/light/theme"));
|
|
99
104
|
|
|
100
105
|
exports.theme = _theme.default;
|
|
@@ -15,8 +15,6 @@ var _decorativePalettes = require("./decorative-palettes");
|
|
|
15
15
|
|
|
16
16
|
var _polished = require("polished");
|
|
17
17
|
|
|
18
|
-
var _interact = _interopRequireDefault(require("../utils/interact"));
|
|
19
|
-
|
|
20
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
19
|
|
|
22
20
|
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); }
|
|
@@ -234,9 +232,6 @@ var colors = _extends({}, _theme.default.colors, {
|
|
|
234
232
|
}, _datavizPalette.datavizPalette);
|
|
235
233
|
|
|
236
234
|
var darkTheme = _extends({}, _theme.default, {
|
|
237
|
-
utils: {
|
|
238
|
-
interact: (0, _interact.default)(MODE)
|
|
239
|
-
},
|
|
240
235
|
colors: colors,
|
|
241
236
|
shadows: shadows,
|
|
242
237
|
mode: MODE
|
|
@@ -25,8 +25,6 @@ var _seedsBorder = _interopRequireDefault(require("@sproutsocial/seeds-border"))
|
|
|
25
25
|
|
|
26
26
|
var _polished = require("polished");
|
|
27
27
|
|
|
28
|
-
var _interact = _interopRequireDefault(require("../utils/interact"));
|
|
29
|
-
|
|
30
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
29
|
|
|
32
30
|
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); }
|
|
@@ -338,9 +336,6 @@ var duration = {
|
|
|
338
336
|
};
|
|
339
337
|
exports.duration = duration;
|
|
340
338
|
var theme = {
|
|
341
|
-
utils: {
|
|
342
|
-
interact: (0, _interact.default)(MODE)
|
|
343
|
-
},
|
|
344
339
|
breakpoints: breakpoints,
|
|
345
340
|
colors: colors,
|
|
346
341
|
typography: _extends({}, typography, {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useInteractiveColor = void 0;
|
|
5
|
+
|
|
6
|
+
var _polished = require("polished");
|
|
7
|
+
|
|
8
|
+
var _styledComponents = require("styled-components");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The useInteractiveColor hook has context of theme mode (light or dark)
|
|
12
|
+
* and can be used to lighten or darken a color dynamically
|
|
13
|
+
*
|
|
14
|
+
* note: colors are limited to our theme colors
|
|
15
|
+
*/
|
|
16
|
+
var useInteractiveColor = function useInteractiveColor(themeColor) {
|
|
17
|
+
// Throw error if used outside of a ThemeProvider (styled-components)
|
|
18
|
+
if (!(0, _styledComponents.useTheme)()) {
|
|
19
|
+
throw new Error("useInteractiveColor() must be used within a Styled Components ThemeProvider");
|
|
20
|
+
} // Get the current theme mode ie. 'light' or 'dark'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var themeMode = (0, _styledComponents.useTheme)().mode; // If the theme mode is dark, return a lightened version of the themeValue
|
|
24
|
+
|
|
25
|
+
if (themeMode === "dark") {
|
|
26
|
+
return (0, _polished.lighten)(0.2, themeColor);
|
|
27
|
+
} else {
|
|
28
|
+
// If the theme mode is light, return a darkened version of the themeValue
|
|
29
|
+
return (0, _polished.darken)(0.2, themeColor);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.useInteractiveColor = useInteractiveColor;
|
package/lib/Input/index.js
CHANGED
|
@@ -14,12 +14,13 @@ import Button from "../Button";
|
|
|
14
14
|
import Icon from "../Icon";
|
|
15
15
|
import styled from "styled-components";
|
|
16
16
|
import { mergeRefs } from "../utils";
|
|
17
|
+
import { useInteractiveColor } from "../utils/useInteractiveColor";
|
|
17
18
|
var InputContext = /*#__PURE__*/React.createContext({});
|
|
18
19
|
var StyledButton = styled(Button).withConfig({
|
|
19
20
|
displayName: "Input__StyledButton",
|
|
20
21
|
componentId: "sc-1ck1dnm-0"
|
|
21
22
|
})(["&:hover,&:active{color:", ";}"], function (props) {
|
|
22
|
-
return
|
|
23
|
+
return useInteractiveColor(props.theme.colors.icon.base);
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
var ClearButton = function ClearButton() {
|
package/lib/Token/styles.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { COMMON } from "../utils/system-props";
|
|
3
3
|
import { focusRing } from "../utils/mixins";
|
|
4
|
+
import { useInteractiveColor } from "../utils/useInteractiveColor";
|
|
4
5
|
var Container = styled.button.withConfig({
|
|
5
6
|
displayName: "styles__Container",
|
|
6
7
|
componentId: "sc-nyn5zy-0"
|
|
@@ -8,13 +9,13 @@ var Container = styled.button.withConfig({
|
|
|
8
9
|
var theme = _ref.theme;
|
|
9
10
|
return css(["", " font-family:", ";font-weight:", ";border:1px solid ", ";border-radius:", ";color:", ";background:", ";padding:", " ", ";transition:all ", " ", ";"], theme.typography[200], theme.fontFamily, theme.fontWeights.normal, theme.colors.container.border.base, theme.radii[500], theme.colors.text.body, theme.colors.container.background.base, theme.space[200], theme.space[300], theme.duration.fast, theme.easing.ease_inout);
|
|
10
11
|
}, focusRing, function (_ref2) {
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
return
|
|
12
|
+
var closeable = _ref2.closeable,
|
|
13
|
+
theme = _ref2.theme;
|
|
14
|
+
return closeable && css(["cursor:pointer;&:hover,&:active{box-shadow:", ";border:1px solid ", ";}"], theme.shadows.low, useInteractiveColor(theme.colors.container.border.base));
|
|
14
15
|
}, function (_ref3) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
return
|
|
16
|
+
var theme = _ref3.theme,
|
|
17
|
+
palette = _ref3.palette;
|
|
18
|
+
return palette === "blue" && css(["color:", ";background:", ";border:1px solid ", ";&:hover,&:active{cursor:pointer;box-shadow:", ";border:1px solid ", ";}"], theme.colors.text.body, theme.colors.container.background.decorative.blue, theme.colors.container.border.decorative.blue, theme.shadows.low, useInteractiveColor(theme.colors.container.border.decorative.blue));
|
|
18
19
|
}, function (_ref4) {
|
|
19
20
|
var disabled = _ref4.disabled,
|
|
20
21
|
theme = _ref4.theme;
|
|
@@ -22,6 +23,6 @@ var Container = styled.button.withConfig({
|
|
|
22
23
|
}, function (_ref5) {
|
|
23
24
|
var valid = _ref5.valid,
|
|
24
25
|
theme = _ref5.theme;
|
|
25
|
-
return !valid && css(["color:", ";background:", ";border:1px solid ", ";&:hover{box-shadow:", ";border:1px solid ", ";}"], theme.colors.text.error, theme.colors.container.background.error, theme.colors.container.border.error, theme.shadows.low,
|
|
26
|
+
return !valid && css(["color:", ";background:", ";border:1px solid ", ";&:hover{box-shadow:", ";border:1px solid ", ";}"], theme.colors.text.error, theme.colors.container.background.error, theme.colors.container.border.error, theme.shadows.low, useInteractiveColor(theme.colors.container.border.error));
|
|
26
27
|
}, COMMON);
|
|
27
28
|
export default Container;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./systemProps";
|
|
2
2
|
export { visuallyHidden, focusRing, disabled } from "./utils/mixins";
|
|
3
3
|
export { useSelect, useMultiselect, useTextContent } from "./utils/hooks";
|
|
4
|
+
export { useInteractiveColor } from "./utils/useInteractiveColor";
|
|
4
5
|
export { default as theme } from "./themes/light/theme";
|
|
5
6
|
export { default as darkTheme } from "./themes/dark/theme";
|
|
6
7
|
export { sproutLightTheme, sproutDarkTheme } from "./themes/extendedThemes/sproutTheme";
|
package/lib/themes/dark/theme.js
CHANGED
|
@@ -6,7 +6,6 @@ import lightTheme from "../light/theme";
|
|
|
6
6
|
import { datavizPalette } from "./dataviz-palette";
|
|
7
7
|
import { green, blue, purple, yellow, orange, red, neutral } from "./decorative-palettes";
|
|
8
8
|
import { transparentize } from "polished";
|
|
9
|
-
import interact from "../utils/interact";
|
|
10
9
|
var MODE = "dark";
|
|
11
10
|
export var shadows = {
|
|
12
11
|
low: DEPTH.ELEVATION_LEVEL_100 + " " + COLORS.COLOR_NEUTRAL_1100 + "FF",
|
|
@@ -218,9 +217,6 @@ var colors = _extends({}, lightTheme.colors, {
|
|
|
218
217
|
}, datavizPalette);
|
|
219
218
|
|
|
220
219
|
var darkTheme = _extends({}, lightTheme, {
|
|
221
|
-
utils: {
|
|
222
|
-
interact: interact(MODE)
|
|
223
|
-
},
|
|
224
220
|
colors: colors,
|
|
225
221
|
shadows: shadows,
|
|
226
222
|
mode: MODE
|
|
@@ -11,7 +11,6 @@ import DEPTH from "@sproutsocial/seeds-depth";
|
|
|
11
11
|
import MOTION from "@sproutsocial/seeds-motion";
|
|
12
12
|
import BORDER from "@sproutsocial/seeds-border";
|
|
13
13
|
import { transparentize } from "polished";
|
|
14
|
-
import interact from "../utils/interact";
|
|
15
14
|
export var breakpoints = ["900px", "1200px", "1500px", "1800px"];
|
|
16
15
|
var MODE = "light"; // If you are making changes to the colors in the theme file tag the Design Systems team on your PR! Thank you!!
|
|
17
16
|
|
|
@@ -308,9 +307,6 @@ export var duration = {
|
|
|
308
307
|
slow: MOTION.MOTION_DURATION_SLOW
|
|
309
308
|
};
|
|
310
309
|
var theme = {
|
|
311
|
-
utils: {
|
|
312
|
-
interact: interact(MODE)
|
|
313
|
-
},
|
|
314
310
|
breakpoints: breakpoints,
|
|
315
311
|
colors: colors,
|
|
316
312
|
typography: _extends({}, typography, {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { darken, lighten } from "polished";
|
|
2
|
+
import { useTheme } from "styled-components";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The useInteractiveColor hook has context of theme mode (light or dark)
|
|
6
|
+
* and can be used to lighten or darken a color dynamically
|
|
7
|
+
*
|
|
8
|
+
* note: colors are limited to our theme colors
|
|
9
|
+
*/
|
|
10
|
+
var useInteractiveColor = function useInteractiveColor(themeColor) {
|
|
11
|
+
// Throw error if used outside of a ThemeProvider (styled-components)
|
|
12
|
+
if (!useTheme()) {
|
|
13
|
+
throw new Error("useInteractiveColor() must be used within a Styled Components ThemeProvider");
|
|
14
|
+
} // Get the current theme mode ie. 'light' or 'dark'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var themeMode = useTheme().mode; // If the theme mode is dark, return a lightened version of the themeValue
|
|
18
|
+
|
|
19
|
+
if (themeMode === "dark") {
|
|
20
|
+
return lighten(0.2, themeColor);
|
|
21
|
+
} else {
|
|
22
|
+
// If the theme mode is light, return a darkened version of the themeValue
|
|
23
|
+
return darken(0.2, themeColor);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { useInteractiveColor };
|
package/package.json
CHANGED
|
@@ -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 === "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 === "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;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { darken, lighten } from "polished";
|
|
2
|
-
|
|
3
|
-
var interact = function interact(mode) {
|
|
4
|
-
return function (themeValue) {
|
|
5
|
-
if (mode === "dark") {
|
|
6
|
-
return lighten(0.2, themeValue);
|
|
7
|
-
} else {
|
|
8
|
-
return darken(0.2, themeValue);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default interact;
|