@sproutsocial/racine 11.7.1 → 11.9.0-useInteractiveColor.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/__flow__/Checkbox/index.stories.js +73 -56
- package/__flow__/Checkbox/styles.js +75 -75
- package/__flow__/Collapsible/index.js +3 -2
- package/__flow__/Icon/index.stories.js +41 -36
- package/__flow__/Image/index.js +10 -2
- package/__flow__/Input/index.js +49 -25
- package/__flow__/Input/index.stories.js +59 -33
- package/__flow__/Input/index.test.js +20 -0
- package/__flow__/Input/styles.js +2 -2
- package/__flow__/Loader/index.stories.js +18 -14
- package/__flow__/Numeral/index.stories.js +109 -50
- package/__flow__/Radio/index.stories.js +41 -26
- package/__flow__/SegmentedControl/index.js +3 -2
- package/__flow__/Switch/index.stories.js +26 -18
- package/__flow__/TableCell/index.js +9 -2
- package/__flow__/ToggleHint/index.js +9 -2
- package/__flow__/Token/styles.js +13 -12
- package/__flow__/index.js +1 -0
- package/__flow__/systemProps/color.js +1 -2
- package/__flow__/themes/dark/theme.js +0 -5
- package/__flow__/themes/extendedThemes/sproutTheme/dark/theme.js +9 -0
- package/__flow__/themes/extendedThemes/sproutTheme/light/theme.js +9 -0
- package/__flow__/themes/light/theme.js +0 -5
- package/__flow__/types/theme.flow.js +2 -2
- package/__flow__/utils/responsiveProps/index.test.js +10 -2
- package/__flow__/utils/useInteractiveColor.js +32 -0
- package/commonjs/Input/index.js +45 -23
- package/commonjs/Input/styles.js +2 -2
- package/commonjs/Token/styles.js +9 -7
- package/commonjs/index.js +6 -1
- package/commonjs/themes/dark/theme.js +0 -5
- package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +11 -2
- package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +11 -2
- 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 +14 -3
- package/dist/themes/extendedThemes/sproutTheme/light/theme.scss +14 -3
- package/dist/themes/light/theme.scss +0 -3
- package/lib/Input/index.js +44 -23
- package/lib/Input/styles.js +2 -2
- package/lib/Token/styles.js +8 -7
- package/lib/index.js +1 -0
- package/lib/themes/dark/theme.js +0 -4
- package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +9 -1
- package/lib/themes/extendedThemes/sproutTheme/light/theme.js +9 -1
- package/lib/themes/light/theme.js +0 -4
- package/lib/types/theme.flow.js +1 -1
- package/lib/utils/useInteractiveColor.js +27 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -3208
- package/__flow__/themes/utils/interact.js +0 -12
- package/commonjs/themes/utils/interact.js +0 -19
- package/lib/themes/utils/interact.js +0 -13
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
$theme: (
|
|
2
2
|
__esModule: true,
|
|
3
|
+
analytics: (
|
|
4
|
+
trend: (
|
|
5
|
+
positive: #067c7c,
|
|
6
|
+
neutral: #364141,
|
|
7
|
+
negative: #364141
|
|
8
|
+
)
|
|
9
|
+
),
|
|
3
10
|
datePicker: (
|
|
4
11
|
comparison: (
|
|
5
12
|
background: (
|
|
@@ -11,9 +18,6 @@ $theme: (
|
|
|
11
18
|
)
|
|
12
19
|
),
|
|
13
20
|
default: (
|
|
14
|
-
utils: (
|
|
15
|
-
|
|
16
|
-
),
|
|
17
21
|
breakpoints: (900px, 1200px, 1500px, 1800px),
|
|
18
22
|
colors: (
|
|
19
23
|
app: (
|
|
@@ -478,6 +482,13 @@ $theme: (
|
|
|
478
482
|
base: #364141
|
|
479
483
|
)
|
|
480
484
|
)
|
|
485
|
+
),
|
|
486
|
+
analytics: (
|
|
487
|
+
trend: (
|
|
488
|
+
positive: #067c7c,
|
|
489
|
+
neutral: #364141,
|
|
490
|
+
negative: #364141
|
|
491
|
+
)
|
|
481
492
|
)
|
|
482
493
|
),
|
|
483
494
|
typography: (
|
package/lib/Input/index.js
CHANGED
|
@@ -14,17 +14,17 @@ 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() {
|
|
26
27
|
var _React$useContext = React.useContext(InputContext),
|
|
27
|
-
onClear = _React$useContext.onClear,
|
|
28
28
|
handleClear = _React$useContext.handleClear,
|
|
29
29
|
clearButtonLabel = _React$useContext.clearButtonLabel,
|
|
30
30
|
hasValue = _React$useContext.hasValue,
|
|
@@ -33,13 +33,6 @@ var ClearButton = function ClearButton() {
|
|
|
33
33
|
|
|
34
34
|
if (!hasValue) {
|
|
35
35
|
return null;
|
|
36
|
-
} // Log a warning and hide the button when no onClear callback is provided.
|
|
37
|
-
// If we called handleClear with no onClear prop, all the button would do is focus the Input.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!onClear) {
|
|
41
|
-
console.warn("Warning: No onClear prop provided to Input when using Input.ClearButton. Omitting Input.ClearButton.");
|
|
42
|
-
return null;
|
|
43
36
|
} // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
|
|
44
37
|
|
|
45
38
|
|
|
@@ -78,14 +71,10 @@ var isClearButton = function isClearButton(elem) {
|
|
|
78
71
|
var Input = /*#__PURE__*/function (_React$Component) {
|
|
79
72
|
_inheritsLoose(Input, _React$Component);
|
|
80
73
|
|
|
81
|
-
function Input() {
|
|
74
|
+
function Input(props) {
|
|
82
75
|
var _this;
|
|
83
76
|
|
|
84
|
-
|
|
85
|
-
args[_key] = arguments[_key];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
77
|
+
_this = _React$Component.call(this, props) || this;
|
|
89
78
|
_this.inputRef = /*#__PURE__*/React.createRef();
|
|
90
79
|
|
|
91
80
|
_this.handleBlur = function (e) {
|
|
@@ -93,14 +82,31 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
93
82
|
};
|
|
94
83
|
|
|
95
84
|
_this.handleClear = function (e) {
|
|
96
|
-
var
|
|
85
|
+
var input = _this.inputRef.current;
|
|
86
|
+
|
|
87
|
+
if (input) {
|
|
88
|
+
var _Object$getOwnPropert;
|
|
89
|
+
|
|
90
|
+
// Clear the value via the input prototype, then dispatch an input event in order to trigger handleChange
|
|
91
|
+
var nativeInputValueSetter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")) == null ? void 0 : _Object$getOwnPropert.set;
|
|
92
|
+
nativeInputValueSetter == null ? void 0 : nativeInputValueSetter.call(input, "");
|
|
93
|
+
var inputEvent = new Event("input", {
|
|
94
|
+
bubbles: true
|
|
95
|
+
});
|
|
96
|
+
input.dispatchEvent(inputEvent); // Focus the input, update hasValue, and call any onClear callback
|
|
97
|
+
|
|
98
|
+
input.focus();
|
|
99
|
+
|
|
100
|
+
_this.updateState("");
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
_this.props.onClear == null ? void 0 : _this.props.onClear(e);
|
|
103
|
+
}
|
|
100
104
|
};
|
|
101
105
|
|
|
102
106
|
_this.handleChange = function (e) {
|
|
103
|
-
|
|
107
|
+
_this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
|
|
108
|
+
|
|
109
|
+
_this.updateState(e.currentTarget.value);
|
|
104
110
|
};
|
|
105
111
|
|
|
106
112
|
_this.handleFocus = function (e) {
|
|
@@ -119,6 +125,22 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
119
125
|
return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
|
|
120
126
|
};
|
|
121
127
|
|
|
128
|
+
_this.updateState = function (inputValue) {
|
|
129
|
+
var hasValue = inputValue !== "";
|
|
130
|
+
var previousHasValue = _this.state.hasValue; // Only update state if the value of `hasValue` has changed to avoid unnecessary renders.
|
|
131
|
+
|
|
132
|
+
if (hasValue !== previousHasValue) {
|
|
133
|
+
_this.setState({
|
|
134
|
+
hasValue: hasValue
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
_this.state = {
|
|
140
|
+
// Tracking hasValue in state allows us to hide ClearButton when there is no value to clear
|
|
141
|
+
// for both controlled and uncontrolled inputs.
|
|
142
|
+
hasValue: !!props.value
|
|
143
|
+
};
|
|
122
144
|
return _this;
|
|
123
145
|
}
|
|
124
146
|
|
|
@@ -172,9 +194,9 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
172
194
|
name: "search",
|
|
173
195
|
ariaHidden: true,
|
|
174
196
|
color: "icon.base"
|
|
175
|
-
}) : elemBefore; // Do not add a ClearButton if
|
|
197
|
+
}) : elemBefore; // Do not add a ClearButton if an elemAfter prop was passed.
|
|
176
198
|
|
|
177
|
-
var elementAfter = type === "search" &&
|
|
199
|
+
var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
|
|
178
200
|
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
179
201
|
hasBeforeElement: !!elementBefore,
|
|
180
202
|
hasAfterElement: !!elementAfter,
|
|
@@ -187,9 +209,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
187
209
|
}, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
|
|
188
210
|
value: {
|
|
189
211
|
handleClear: this.handleClear,
|
|
190
|
-
hasValue:
|
|
212
|
+
hasValue: this.state.hasValue,
|
|
191
213
|
clearButtonLabel: clearButtonLabel,
|
|
192
|
-
onClear: onClear,
|
|
193
214
|
size: size
|
|
194
215
|
}
|
|
195
216
|
}, elementBefore && /*#__PURE__*/React.createElement(Accessory, {
|
package/lib/Input/styles.js
CHANGED
|
@@ -71,9 +71,9 @@ export var Accessory = styled.div.withConfig({
|
|
|
71
71
|
})(["position:absolute;top:50%;transform:translateY(-50%);color:", ";display:flex;align-items:center;", ";", ";"], function (props) {
|
|
72
72
|
return props.theme.colors.icon.base;
|
|
73
73
|
}, function (props) {
|
|
74
|
-
return props.before && css(["left:", ";"], props.theme.space[
|
|
74
|
+
return props.before && css(["left:", ";"], props.theme.space[300]);
|
|
75
75
|
}, function (props) {
|
|
76
|
-
return props.after && css(["right:", ";"], props.isClearButton ? 0 : props.theme.space[
|
|
76
|
+
return props.after && css(["right:", ";"], props.isClearButton ? 0 : props.theme.space[300]);
|
|
77
77
|
});
|
|
78
78
|
Container.displayName = "InputContainer";
|
|
79
79
|
Accessory.displayName = "InputAccessory";
|
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
|
|
@@ -39,11 +39,19 @@ export var datePicker = {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
export var analytics = {
|
|
43
|
+
trend: {
|
|
44
|
+
positive: baseDarkTheme.colors.teal[500],
|
|
45
|
+
neutral: baseDarkTheme.colors.neutral[100],
|
|
46
|
+
negative: baseDarkTheme.colors.neutral[100]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
42
49
|
|
|
43
50
|
var darkTheme = _extends({}, baseDarkTheme, {
|
|
44
51
|
colors: _extends({}, baseDarkTheme.colors, {
|
|
45
52
|
navigation: navigation,
|
|
46
|
-
datePicker: datePicker
|
|
53
|
+
datePicker: datePicker,
|
|
54
|
+
analytics: analytics
|
|
47
55
|
})
|
|
48
56
|
});
|
|
49
57
|
|
|
@@ -39,11 +39,19 @@ export var datePicker = {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
export var analytics = {
|
|
43
|
+
trend: {
|
|
44
|
+
positive: baseLightTheme.colors.teal[800],
|
|
45
|
+
neutral: baseLightTheme.colors.neutral[800],
|
|
46
|
+
negative: baseLightTheme.colors.neutral[800]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
42
49
|
|
|
43
50
|
var lightTheme = _extends({}, baseLightTheme, {
|
|
44
51
|
colors: _extends({}, baseLightTheme.colors, {
|
|
45
52
|
navigation: navigation,
|
|
46
|
-
datePicker: datePicker
|
|
53
|
+
datePicker: datePicker,
|
|
54
|
+
analytics: analytics
|
|
47
55
|
})
|
|
48
56
|
});
|
|
49
57
|
|
|
@@ -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, {
|
package/lib/types/theme.flow.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { breakpoints, typography, fontWeights, radii, borders, borderWidths, shadows, space, easing, duration } from "../themes/light/theme";
|
|
2
|
-
import { datePicker, navigation } from "../themes/extendedThemes/sproutTheme/light/theme";
|
|
2
|
+
import { datePicker, navigation, analytics } from "../themes/extendedThemes/sproutTheme/light/theme";
|
|
@@ -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 };
|