@planningcenter/tapestry-react 2.9.0 → 2.9.2
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/dist/cjs/Box/Box.js +1 -1
- package/dist/cjs/FilterLayout/FilterLayout.js +5 -4
- package/dist/cjs/GridView/GridView.js +1 -1
- package/dist/cjs/ItemList/ItemList.js +4 -1
- package/dist/cjs/StackView/StackView.js +1 -1
- package/dist/cjs/Text/Text.js +1 -1
- package/dist/cjs/TileView/TileView.js +1 -1
- package/dist/cjs/TimeField/TimeField.js +7 -2
- package/dist/cjs/ToggleSwitch/ToggleSwitch.js +2 -0
- package/dist/cjs/ToggleSwitch/ToggleSwitch.test.js +37 -15
- package/dist/cjs/system/button-themes.js +21 -21
- package/dist/cjs/system/colors/utils.js +3 -1
- package/dist/cjs/vendor/react-measure/Measure.js +3 -1
- package/dist/esm/FilterLayout/FilterLayout.js +5 -4
- package/dist/esm/ItemList/ItemList.js +4 -1
- package/dist/esm/TimeField/TimeField.js +7 -2
- package/dist/esm/ToggleSwitch/ToggleSwitch.js +2 -0
- package/dist/esm/ToggleSwitch/ToggleSwitch.test.js +37 -15
- package/dist/esm/system/button-themes.js +21 -21
- package/dist/esm/system/colors/utils.js +2 -1
- package/dist/esm/vendor/react-measure/Measure.js +3 -1
- package/package.json +1 -1
- package/src/Button/Button.mdx +1 -0
- package/src/FilterLayout/FilterLayout.tsx +3 -3
- package/src/TimeField/TimeField.tsx +7 -2
- package/src/ToggleSwitch/ToggleSwitch.test.tsx +25 -7
- package/src/ToggleSwitch/ToggleSwitch.tsx +2 -0
- package/src/system/button-themes.js +21 -21
- package/src/system/colors/utils.js +2 -1
package/dist/cjs/Box/Box.js
CHANGED
|
@@ -23,7 +23,7 @@ var _VariantProvider = require("../VariantProvider");
|
|
|
23
23
|
|
|
24
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
25
25
|
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } /** @jsxRuntime classic */ /** @jsx jsx */
|
|
27
27
|
|
|
28
28
|
var defaultElement = 'div';
|
|
29
29
|
/**
|
|
@@ -80,8 +80,7 @@ function FilterLayout(props) {
|
|
|
80
80
|
shrink: 1
|
|
81
81
|
}, header)), /*#__PURE__*/React.createElement(_Divider["default"], null), /*#__PURE__*/React.createElement(_StackView["default"], {
|
|
82
82
|
axis: "horizontal",
|
|
83
|
-
grow: 1
|
|
84
|
-
overflow: "hidden"
|
|
83
|
+
grow: 1
|
|
85
84
|
}, /*#__PURE__*/React.createElement(_StackView["default"], {
|
|
86
85
|
visible: sidebarOpen,
|
|
87
86
|
basis: fill ? '100%' : sidebarWidth + 'px',
|
|
@@ -92,7 +91,9 @@ function FilterLayout(props) {
|
|
|
92
91
|
visibility: sidebarOpen && fill ? 'hidden' : 'visible',
|
|
93
92
|
maxHeight: sidebarOpen && fill ? 0 : 'initial',
|
|
94
93
|
grow: 1,
|
|
95
|
-
shrink:
|
|
94
|
+
shrink: 1,
|
|
96
95
|
basis: "100%"
|
|
97
|
-
},
|
|
96
|
+
}, /*#__PURE__*/React.createElement(_Box["default"], {
|
|
97
|
+
overflow: "hidden"
|
|
98
|
+
}, toolbar), /*#__PURE__*/React.createElement(_Divider["default"], null), table)));
|
|
98
99
|
}
|
|
@@ -25,7 +25,7 @@ var _VariantProvider = require("../VariantProvider");
|
|
|
25
25
|
|
|
26
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
27
|
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } /** @jsxRuntime classic */ /** @jsx jsx */
|
|
29
29
|
|
|
30
30
|
function getTemplateValue(value) {
|
|
31
31
|
return value ? value.constructor === Array ? value.map(function (v) {
|
|
@@ -244,7 +244,10 @@ var ItemList = /*#__PURE__*/function (_Component) {
|
|
|
244
244
|
return typeof selected === 'function' ? selected(data) : selected === data;
|
|
245
245
|
});
|
|
246
246
|
return _this;
|
|
247
|
-
}
|
|
247
|
+
} // String Search
|
|
248
|
+
// Highlight
|
|
249
|
+
// Select
|
|
250
|
+
|
|
248
251
|
|
|
249
252
|
var _proto = ItemList.prototype;
|
|
250
253
|
|
|
@@ -27,7 +27,7 @@ var _VariantProvider = require("../VariantProvider");
|
|
|
27
27
|
|
|
28
28
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
29
29
|
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } /** @jsxRuntime classic */ /** @jsx jsx */
|
|
31
31
|
|
|
32
32
|
var BASELINE = 'baseline';
|
|
33
33
|
var CENTER = 'center';
|
package/dist/cjs/Text/Text.js
CHANGED
|
@@ -25,7 +25,7 @@ var _VariantProvider = require("../VariantProvider");
|
|
|
25
25
|
|
|
26
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
27
|
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } /** @jsxRuntime classic */ /** @jsx jsx */
|
|
29
29
|
|
|
30
30
|
var textPlugin = {
|
|
31
31
|
styleProps: ['italic', 'truncate', 'size', 'underline', 'weight', 'wrap'],
|
|
@@ -25,7 +25,7 @@ var _VariantProvider = require("../VariantProvider");
|
|
|
25
25
|
|
|
26
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
27
|
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } /** @jsxRuntime classic */ /** @jsx jsx */
|
|
29
29
|
|
|
30
30
|
var tileViewPlugin = {
|
|
31
31
|
styleProps: ['minCellWidth', 'spacing'],
|
|
@@ -188,8 +188,13 @@ var TimeField = function TimeField(_ref) {
|
|
|
188
188
|
setHours(updatedHoursValue);
|
|
189
189
|
setHoursDisplay(updatedHoursValue);
|
|
190
190
|
} else {
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
if (updatedHoursValue === 12) {
|
|
192
|
+
setHours(12);
|
|
193
|
+
setHoursDisplay(12);
|
|
194
|
+
} else {
|
|
195
|
+
setHours(updatedHoursValue + 12);
|
|
196
|
+
setHoursDisplay(updatedHoursValue);
|
|
197
|
+
}
|
|
193
198
|
}
|
|
194
199
|
} else {
|
|
195
200
|
setHours(updatedHoursValue);
|
|
@@ -72,12 +72,14 @@ function ToggleSwitch(props) {
|
|
|
72
72
|
axis: "horizontal",
|
|
73
73
|
spacing: size === 'xs' ? 0.5 : size === 'sm' ? 0.75 : 1
|
|
74
74
|
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], (0, _extends2["default"])({
|
|
75
|
+
"aria-checked": isChecked,
|
|
75
76
|
as: "button",
|
|
76
77
|
backgroundColor: disabled ? _colors.colors.grays.light.neutral81 : isChecked ? backgroundColor : _colors.colors.grays.light.neutral62,
|
|
77
78
|
onClick: onClick,
|
|
78
79
|
opacity: 1,
|
|
79
80
|
position: "relative",
|
|
80
81
|
radius: "pill",
|
|
82
|
+
role: "switch",
|
|
81
83
|
theme: false,
|
|
82
84
|
disabled: disabled,
|
|
83
85
|
tooltip: tooltip
|
|
@@ -20,7 +20,7 @@ describe('ToggleSwitch component', function () {
|
|
|
20
20
|
})),
|
|
21
21
|
getByRole = _render.getByRole;
|
|
22
22
|
|
|
23
|
-
var toggleButton = getByRole('
|
|
23
|
+
var toggleButton = getByRole('switch');
|
|
24
24
|
expect(toggleButton).toBeInTheDocument();
|
|
25
25
|
});
|
|
26
26
|
it('should call onClick when clicked', function () {
|
|
@@ -33,7 +33,7 @@ describe('ToggleSwitch component', function () {
|
|
|
33
33
|
})),
|
|
34
34
|
getByRole = _render2.getByRole;
|
|
35
35
|
|
|
36
|
-
var toggleButton = getByRole('
|
|
36
|
+
var toggleButton = getByRole('switch');
|
|
37
37
|
|
|
38
38
|
_react2.fireEvent.click(toggleButton);
|
|
39
39
|
|
|
@@ -62,21 +62,43 @@ describe('ToggleSwitch component', function () {
|
|
|
62
62
|
})),
|
|
63
63
|
getByRole = _render4.getByRole;
|
|
64
64
|
|
|
65
|
-
var toggleButton = getByRole('
|
|
65
|
+
var toggleButton = getByRole('switch');
|
|
66
66
|
expect(toggleButton).toHaveStyle("background-color: " + activeColor);
|
|
67
67
|
});
|
|
68
|
+
it('should apply aria-checked="true" when isChecked is true', function () {
|
|
69
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleSwitch["default"], {
|
|
70
|
+
isChecked: true,
|
|
71
|
+
label: "Toggle me",
|
|
72
|
+
onClick: function onClick() {}
|
|
73
|
+
})),
|
|
74
|
+
getByRole = _render5.getByRole;
|
|
75
|
+
|
|
76
|
+
var toggleButton = getByRole('switch');
|
|
77
|
+
expect(toggleButton).toHaveAttribute('aria-checked', 'true');
|
|
78
|
+
});
|
|
79
|
+
it('should apply aria-checked="false" when isChecked is false', function () {
|
|
80
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleSwitch["default"], {
|
|
81
|
+
isChecked: false,
|
|
82
|
+
label: "Toggle me",
|
|
83
|
+
onClick: function onClick() {}
|
|
84
|
+
})),
|
|
85
|
+
getByRole = _render6.getByRole;
|
|
86
|
+
|
|
87
|
+
var toggleButton = getByRole('switch');
|
|
88
|
+
expect(toggleButton).toHaveAttribute('aria-checked', 'false');
|
|
89
|
+
});
|
|
68
90
|
it('should not be clickable when disabled', function () {
|
|
69
91
|
var mockOnClick = jest.fn();
|
|
70
92
|
|
|
71
|
-
var
|
|
93
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleSwitch["default"], {
|
|
72
94
|
disabled: true,
|
|
73
95
|
isChecked: false,
|
|
74
96
|
label: "Toggle me",
|
|
75
97
|
onClick: mockOnClick
|
|
76
98
|
})),
|
|
77
|
-
getByRole =
|
|
99
|
+
getByRole = _render7.getByRole;
|
|
78
100
|
|
|
79
|
-
var toggleButton = getByRole('
|
|
101
|
+
var toggleButton = getByRole('switch');
|
|
80
102
|
|
|
81
103
|
_react2.fireEvent.click(toggleButton);
|
|
82
104
|
|
|
@@ -84,41 +106,41 @@ describe('ToggleSwitch component', function () {
|
|
|
84
106
|
});
|
|
85
107
|
describe('it should apply the correct size', function () {
|
|
86
108
|
it("should apply the correct size for xs", function () {
|
|
87
|
-
var
|
|
109
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleSwitch["default"], {
|
|
88
110
|
isChecked: false,
|
|
89
111
|
label: "Toggle me",
|
|
90
112
|
onClick: function onClick() {},
|
|
91
113
|
size: "xs"
|
|
92
114
|
})),
|
|
93
|
-
getByRole =
|
|
115
|
+
getByRole = _render8.getByRole;
|
|
94
116
|
|
|
95
|
-
var toggleButton = getByRole('
|
|
117
|
+
var toggleButton = getByRole('switch');
|
|
96
118
|
expect(toggleButton).toHaveStyle("height: " + base * 2 + "px");
|
|
97
119
|
expect(toggleButton).toHaveStyle("width: " + base * 3.5 + "px");
|
|
98
120
|
});
|
|
99
121
|
it("should apply the correct size for sm", function () {
|
|
100
|
-
var
|
|
122
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleSwitch["default"], {
|
|
101
123
|
isChecked: false,
|
|
102
124
|
label: "Toggle me",
|
|
103
125
|
onClick: function onClick() {},
|
|
104
126
|
size: "sm"
|
|
105
127
|
})),
|
|
106
|
-
getByRole =
|
|
128
|
+
getByRole = _render9.getByRole;
|
|
107
129
|
|
|
108
|
-
var toggleButton = getByRole('
|
|
130
|
+
var toggleButton = getByRole('switch');
|
|
109
131
|
expect(toggleButton).toHaveStyle("height: " + base * 2.25 + "px");
|
|
110
132
|
expect(toggleButton).toHaveStyle("width: " + base * 4 + "px");
|
|
111
133
|
});
|
|
112
134
|
it("should apply the correct default size (md)", function () {
|
|
113
|
-
var
|
|
135
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleSwitch["default"], {
|
|
114
136
|
isChecked: false,
|
|
115
137
|
label: "Toggle me",
|
|
116
138
|
onClick: function onClick() {},
|
|
117
139
|
size: "md"
|
|
118
140
|
})),
|
|
119
|
-
getByRole =
|
|
141
|
+
getByRole = _render10.getByRole;
|
|
120
142
|
|
|
121
|
-
var toggleButton = getByRole('
|
|
143
|
+
var toggleButton = getByRole('switch');
|
|
122
144
|
expect(toggleButton).toHaveStyle("height: " + base * 2.5 + "px");
|
|
123
145
|
expect(toggleButton).toHaveStyle("width: " + base * 4.375 + "px");
|
|
124
146
|
});
|
|
@@ -191,63 +191,63 @@ var buttonThemes = {
|
|
|
191
191
|
},
|
|
192
192
|
error: {
|
|
193
193
|
fill: {
|
|
194
|
-
color: '
|
|
195
|
-
backgroundColor: '
|
|
194
|
+
color: 'white',
|
|
195
|
+
backgroundColor: 'error',
|
|
196
196
|
hover: {
|
|
197
|
-
backgroundColor: '
|
|
197
|
+
backgroundColor: 'error-dark'
|
|
198
198
|
},
|
|
199
199
|
active: {
|
|
200
|
-
backgroundColor: '
|
|
200
|
+
backgroundColor: 'error-darker'
|
|
201
201
|
}
|
|
202
202
|
},
|
|
203
203
|
outline: {
|
|
204
|
-
stroke: '
|
|
205
|
-
color: '
|
|
204
|
+
stroke: 'error',
|
|
205
|
+
color: 'error',
|
|
206
206
|
hover: {
|
|
207
|
-
backgroundColor: '
|
|
207
|
+
backgroundColor: 'error-lightest'
|
|
208
208
|
},
|
|
209
209
|
active: {
|
|
210
|
-
backgroundColor: '
|
|
210
|
+
backgroundColor: 'error-lighter'
|
|
211
211
|
}
|
|
212
212
|
},
|
|
213
213
|
naked: {
|
|
214
214
|
color: 'error',
|
|
215
215
|
hover: {
|
|
216
|
-
backgroundColor: '
|
|
216
|
+
backgroundColor: 'error-lightest'
|
|
217
217
|
},
|
|
218
218
|
active: {
|
|
219
|
-
backgroundColor: '
|
|
219
|
+
backgroundColor: 'error-lighter'
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
success: {
|
|
224
224
|
fill: {
|
|
225
|
-
color: '
|
|
226
|
-
backgroundColor: '
|
|
225
|
+
color: 'white',
|
|
226
|
+
backgroundColor: 'success',
|
|
227
227
|
hover: {
|
|
228
|
-
backgroundColor: '
|
|
228
|
+
backgroundColor: 'success-dark'
|
|
229
229
|
},
|
|
230
230
|
active: {
|
|
231
|
-
backgroundColor: '
|
|
231
|
+
backgroundColor: 'success-darker'
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
outline: {
|
|
235
|
-
stroke: '
|
|
236
|
-
color: '
|
|
235
|
+
stroke: 'success',
|
|
236
|
+
color: 'success',
|
|
237
237
|
hover: {
|
|
238
|
-
backgroundColor: '
|
|
238
|
+
backgroundColor: 'success-lightest'
|
|
239
239
|
},
|
|
240
240
|
active: {
|
|
241
|
-
backgroundColor: '
|
|
241
|
+
backgroundColor: 'success-lighter'
|
|
242
242
|
}
|
|
243
243
|
},
|
|
244
244
|
naked: {
|
|
245
|
-
color: '
|
|
245
|
+
color: 'success',
|
|
246
246
|
hover: {
|
|
247
|
-
backgroundColor: '
|
|
247
|
+
backgroundColor: 'success-lightest'
|
|
248
248
|
},
|
|
249
249
|
active: {
|
|
250
|
-
backgroundColor: '
|
|
250
|
+
backgroundColor: 'success-lighter'
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
},
|
|
@@ -19,6 +19,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
19
19
|
|
|
20
20
|
var _polished = require("polished");
|
|
21
21
|
|
|
22
|
+
var _utils = require("../../utils");
|
|
23
|
+
|
|
22
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
23
25
|
|
|
24
26
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -101,7 +103,7 @@ function flattenPalette(palette) {
|
|
|
101
103
|
|
|
102
104
|
var value = parsedPalette[key];
|
|
103
105
|
var aliasValue = parsedPalette[value];
|
|
104
|
-
return _objectSpread(_objectSpread({}, collection), {}, (_objectSpread5 = {}, _objectSpread5[key] = aliasValue ?
|
|
106
|
+
return _objectSpread(_objectSpread({}, collection), {}, (_objectSpread5 = {}, _objectSpread5[key] = aliasValue ? (0, _utils.getCSSProperty)('colors', value) : value, _objectSpread5));
|
|
105
107
|
}, {});
|
|
106
108
|
} // ported from ChromaJS
|
|
107
109
|
// https://github.com/gka/chroma.js/blob/d2c6d917df4ba2b87d8a740de116a0656bcbdfd5/src/io/lightness.coffee
|
|
@@ -111,7 +111,9 @@ var Measure = /*#__PURE__*/function (_Component) {
|
|
|
111
111
|
}
|
|
112
112
|
}));
|
|
113
113
|
return _this;
|
|
114
|
-
}
|
|
114
|
+
} // prevent firing two renders when component mounts, getting measurements in bind
|
|
115
|
+
// is faster than attaching a ResizeObserver and waiting for the first callback
|
|
116
|
+
|
|
115
117
|
|
|
116
118
|
var _proto = Measure.prototype;
|
|
117
119
|
|
|
@@ -67,8 +67,7 @@ export function FilterLayout(props) {
|
|
|
67
67
|
shrink: 1
|
|
68
68
|
}, header)), _ref, /*#__PURE__*/React.createElement(StackView, {
|
|
69
69
|
axis: "horizontal",
|
|
70
|
-
grow: 1
|
|
71
|
-
overflow: "hidden"
|
|
70
|
+
grow: 1
|
|
72
71
|
}, /*#__PURE__*/React.createElement(StackView, {
|
|
73
72
|
visible: sidebarOpen,
|
|
74
73
|
basis: fill ? '100%' : sidebarWidth + 'px',
|
|
@@ -79,7 +78,9 @@ export function FilterLayout(props) {
|
|
|
79
78
|
visibility: sidebarOpen && fill ? 'hidden' : 'visible',
|
|
80
79
|
maxHeight: sidebarOpen && fill ? 0 : 'initial',
|
|
81
80
|
grow: 1,
|
|
82
|
-
shrink:
|
|
81
|
+
shrink: 1,
|
|
83
82
|
basis: "100%"
|
|
84
|
-
},
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
84
|
+
overflow: "hidden"
|
|
85
|
+
}, toolbar), _ref2, table)));
|
|
85
86
|
}
|
|
@@ -177,8 +177,13 @@ var TimeField = function TimeField(_ref) {
|
|
|
177
177
|
setHours(updatedHoursValue);
|
|
178
178
|
setHoursDisplay(updatedHoursValue);
|
|
179
179
|
} else {
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
if (updatedHoursValue === 12) {
|
|
181
|
+
setHours(12);
|
|
182
|
+
setHoursDisplay(12);
|
|
183
|
+
} else {
|
|
184
|
+
setHours(updatedHoursValue + 12);
|
|
185
|
+
setHoursDisplay(updatedHoursValue);
|
|
186
|
+
}
|
|
182
187
|
}
|
|
183
188
|
} else {
|
|
184
189
|
setHours(updatedHoursValue);
|
|
@@ -55,12 +55,14 @@ export function ToggleSwitch(props) {
|
|
|
55
55
|
axis: "horizontal",
|
|
56
56
|
spacing: size === 'xs' ? 0.5 : size === 'sm' ? 0.75 : 1
|
|
57
57
|
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
58
|
+
"aria-checked": isChecked,
|
|
58
59
|
as: "button",
|
|
59
60
|
backgroundColor: disabled ? colors.grays.light.neutral81 : isChecked ? backgroundColor : colors.grays.light.neutral62,
|
|
60
61
|
onClick: onClick,
|
|
61
62
|
opacity: 1,
|
|
62
63
|
position: "relative",
|
|
63
64
|
radius: "pill",
|
|
65
|
+
role: "switch",
|
|
64
66
|
theme: false,
|
|
65
67
|
disabled: disabled,
|
|
66
68
|
tooltip: tooltip
|
|
@@ -12,7 +12,7 @@ describe('ToggleSwitch component', function () {
|
|
|
12
12
|
})),
|
|
13
13
|
getByRole = _render.getByRole;
|
|
14
14
|
|
|
15
|
-
var toggleButton = getByRole('
|
|
15
|
+
var toggleButton = getByRole('switch');
|
|
16
16
|
expect(toggleButton).toBeInTheDocument();
|
|
17
17
|
});
|
|
18
18
|
it('should call onClick when clicked', function () {
|
|
@@ -25,7 +25,7 @@ describe('ToggleSwitch component', function () {
|
|
|
25
25
|
})),
|
|
26
26
|
getByRole = _render2.getByRole;
|
|
27
27
|
|
|
28
|
-
var toggleButton = getByRole('
|
|
28
|
+
var toggleButton = getByRole('switch');
|
|
29
29
|
fireEvent.click(toggleButton);
|
|
30
30
|
expect(mockOnClick).toHaveBeenCalled();
|
|
31
31
|
});
|
|
@@ -52,61 +52,83 @@ describe('ToggleSwitch component', function () {
|
|
|
52
52
|
})),
|
|
53
53
|
getByRole = _render4.getByRole;
|
|
54
54
|
|
|
55
|
-
var toggleButton = getByRole('
|
|
55
|
+
var toggleButton = getByRole('switch');
|
|
56
56
|
expect(toggleButton).toHaveStyle("background-color: " + activeColor);
|
|
57
57
|
});
|
|
58
|
+
it('should apply aria-checked="true" when isChecked is true', function () {
|
|
59
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
60
|
+
isChecked: true,
|
|
61
|
+
label: "Toggle me",
|
|
62
|
+
onClick: function onClick() {}
|
|
63
|
+
})),
|
|
64
|
+
getByRole = _render5.getByRole;
|
|
65
|
+
|
|
66
|
+
var toggleButton = getByRole('switch');
|
|
67
|
+
expect(toggleButton).toHaveAttribute('aria-checked', 'true');
|
|
68
|
+
});
|
|
69
|
+
it('should apply aria-checked="false" when isChecked is false', function () {
|
|
70
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
71
|
+
isChecked: false,
|
|
72
|
+
label: "Toggle me",
|
|
73
|
+
onClick: function onClick() {}
|
|
74
|
+
})),
|
|
75
|
+
getByRole = _render6.getByRole;
|
|
76
|
+
|
|
77
|
+
var toggleButton = getByRole('switch');
|
|
78
|
+
expect(toggleButton).toHaveAttribute('aria-checked', 'false');
|
|
79
|
+
});
|
|
58
80
|
it('should not be clickable when disabled', function () {
|
|
59
81
|
var mockOnClick = jest.fn();
|
|
60
82
|
|
|
61
|
-
var
|
|
83
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
62
84
|
disabled: true,
|
|
63
85
|
isChecked: false,
|
|
64
86
|
label: "Toggle me",
|
|
65
87
|
onClick: mockOnClick
|
|
66
88
|
})),
|
|
67
|
-
getByRole =
|
|
89
|
+
getByRole = _render7.getByRole;
|
|
68
90
|
|
|
69
|
-
var toggleButton = getByRole('
|
|
91
|
+
var toggleButton = getByRole('switch');
|
|
70
92
|
fireEvent.click(toggleButton);
|
|
71
93
|
expect(mockOnClick).not.toHaveBeenCalled();
|
|
72
94
|
});
|
|
73
95
|
describe('it should apply the correct size', function () {
|
|
74
96
|
it("should apply the correct size for xs", function () {
|
|
75
|
-
var
|
|
97
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
76
98
|
isChecked: false,
|
|
77
99
|
label: "Toggle me",
|
|
78
100
|
onClick: function onClick() {},
|
|
79
101
|
size: "xs"
|
|
80
102
|
})),
|
|
81
|
-
getByRole =
|
|
103
|
+
getByRole = _render8.getByRole;
|
|
82
104
|
|
|
83
|
-
var toggleButton = getByRole('
|
|
105
|
+
var toggleButton = getByRole('switch');
|
|
84
106
|
expect(toggleButton).toHaveStyle("height: " + base * 2 + "px");
|
|
85
107
|
expect(toggleButton).toHaveStyle("width: " + base * 3.5 + "px");
|
|
86
108
|
});
|
|
87
109
|
it("should apply the correct size for sm", function () {
|
|
88
|
-
var
|
|
110
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
89
111
|
isChecked: false,
|
|
90
112
|
label: "Toggle me",
|
|
91
113
|
onClick: function onClick() {},
|
|
92
114
|
size: "sm"
|
|
93
115
|
})),
|
|
94
|
-
getByRole =
|
|
116
|
+
getByRole = _render9.getByRole;
|
|
95
117
|
|
|
96
|
-
var toggleButton = getByRole('
|
|
118
|
+
var toggleButton = getByRole('switch');
|
|
97
119
|
expect(toggleButton).toHaveStyle("height: " + base * 2.25 + "px");
|
|
98
120
|
expect(toggleButton).toHaveStyle("width: " + base * 4 + "px");
|
|
99
121
|
});
|
|
100
122
|
it("should apply the correct default size (md)", function () {
|
|
101
|
-
var
|
|
123
|
+
var _render10 = render( /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
102
124
|
isChecked: false,
|
|
103
125
|
label: "Toggle me",
|
|
104
126
|
onClick: function onClick() {},
|
|
105
127
|
size: "md"
|
|
106
128
|
})),
|
|
107
|
-
getByRole =
|
|
129
|
+
getByRole = _render10.getByRole;
|
|
108
130
|
|
|
109
|
-
var toggleButton = getByRole('
|
|
131
|
+
var toggleButton = getByRole('switch');
|
|
110
132
|
expect(toggleButton).toHaveStyle("height: " + base * 2.5 + "px");
|
|
111
133
|
expect(toggleButton).toHaveStyle("width: " + base * 4.375 + "px");
|
|
112
134
|
});
|
|
@@ -187,63 +187,63 @@ export var buttonThemes = {
|
|
|
187
187
|
},
|
|
188
188
|
error: {
|
|
189
189
|
fill: {
|
|
190
|
-
color: '
|
|
191
|
-
backgroundColor: '
|
|
190
|
+
color: 'white',
|
|
191
|
+
backgroundColor: 'error',
|
|
192
192
|
hover: {
|
|
193
|
-
backgroundColor: '
|
|
193
|
+
backgroundColor: 'error-dark'
|
|
194
194
|
},
|
|
195
195
|
active: {
|
|
196
|
-
backgroundColor: '
|
|
196
|
+
backgroundColor: 'error-darker'
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
outline: {
|
|
200
|
-
stroke: '
|
|
201
|
-
color: '
|
|
200
|
+
stroke: 'error',
|
|
201
|
+
color: 'error',
|
|
202
202
|
hover: {
|
|
203
|
-
backgroundColor: '
|
|
203
|
+
backgroundColor: 'error-lightest'
|
|
204
204
|
},
|
|
205
205
|
active: {
|
|
206
|
-
backgroundColor: '
|
|
206
|
+
backgroundColor: 'error-lighter'
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
209
|
naked: {
|
|
210
210
|
color: 'error',
|
|
211
211
|
hover: {
|
|
212
|
-
backgroundColor: '
|
|
212
|
+
backgroundColor: 'error-lightest'
|
|
213
213
|
},
|
|
214
214
|
active: {
|
|
215
|
-
backgroundColor: '
|
|
215
|
+
backgroundColor: 'error-lighter'
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
},
|
|
219
219
|
success: {
|
|
220
220
|
fill: {
|
|
221
|
-
color: '
|
|
222
|
-
backgroundColor: '
|
|
221
|
+
color: 'white',
|
|
222
|
+
backgroundColor: 'success',
|
|
223
223
|
hover: {
|
|
224
|
-
backgroundColor: '
|
|
224
|
+
backgroundColor: 'success-dark'
|
|
225
225
|
},
|
|
226
226
|
active: {
|
|
227
|
-
backgroundColor: '
|
|
227
|
+
backgroundColor: 'success-darker'
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
230
|
outline: {
|
|
231
|
-
stroke: '
|
|
232
|
-
color: '
|
|
231
|
+
stroke: 'success',
|
|
232
|
+
color: 'success',
|
|
233
233
|
hover: {
|
|
234
|
-
backgroundColor: '
|
|
234
|
+
backgroundColor: 'success-lightest'
|
|
235
235
|
},
|
|
236
236
|
active: {
|
|
237
|
-
backgroundColor: '
|
|
237
|
+
backgroundColor: 'success-lighter'
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
240
|
naked: {
|
|
241
|
-
color: '
|
|
241
|
+
color: 'success',
|
|
242
242
|
hover: {
|
|
243
|
-
backgroundColor: '
|
|
243
|
+
backgroundColor: 'success-lightest'
|
|
244
244
|
},
|
|
245
245
|
active: {
|
|
246
|
-
backgroundColor: '
|
|
246
|
+
backgroundColor: 'success-lighter'
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
},
|
|
@@ -5,6 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
6
|
|
|
7
7
|
import { darken, setLightness, parseToRgb, parseToHsl, rgba, mix, getLuminance, toColorString } from 'polished';
|
|
8
|
+
import { getCSSProperty } from '../../utils';
|
|
8
9
|
|
|
9
10
|
function capitalizeFirstLetter(string) {
|
|
10
11
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -81,7 +82,7 @@ export function flattenPalette(palette) {
|
|
|
81
82
|
|
|
82
83
|
var value = parsedPalette[key];
|
|
83
84
|
var aliasValue = parsedPalette[value];
|
|
84
|
-
return _objectSpread(_objectSpread({}, collection), {}, (_objectSpread5 = {}, _objectSpread5[key] = aliasValue ?
|
|
85
|
+
return _objectSpread(_objectSpread({}, collection), {}, (_objectSpread5 = {}, _objectSpread5[key] = aliasValue ? getCSSProperty('colors', value) : value, _objectSpread5));
|
|
85
86
|
}, {});
|
|
86
87
|
} // ported from ChromaJS
|
|
87
88
|
// https://github.com/gka/chroma.js/blob/d2c6d917df4ba2b87d8a740de116a0656bcbdfd5/src/io/lightness.coffee
|
|
@@ -109,7 +109,9 @@ var Measure = /*#__PURE__*/function (_Component) {
|
|
|
109
109
|
}));
|
|
110
110
|
|
|
111
111
|
return _this;
|
|
112
|
-
}
|
|
112
|
+
} // prevent firing two renders when component mounts, getting measurements in bind
|
|
113
|
+
// is faster than attaching a ResizeObserver and waiting for the first callback
|
|
114
|
+
|
|
113
115
|
|
|
114
116
|
var _proto = Measure.prototype;
|
|
115
117
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.2",
|
|
4
4
|
"description": "A collection of flexible React components to help you build resilient, accessible user interfaces quickly and effectively.",
|
|
5
5
|
"author": "Front End Systems Engineering <frontend@pco.bz>",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
package/src/Button/Button.mdx
CHANGED
|
@@ -10,6 +10,7 @@ isParent: true
|
|
|
10
10
|
const themes = [
|
|
11
11
|
{ title: 'Default' },
|
|
12
12
|
{ title: 'Primary', theme: 'primary' },
|
|
13
|
+
{ title: 'Success', theme: 'success' },
|
|
13
14
|
{ title: 'Warning', theme: 'warning' },
|
|
14
15
|
{ title: 'Error', theme: 'error' },
|
|
15
16
|
{ title: 'Info', theme: 'info' },
|
|
@@ -72,7 +72,7 @@ export function FilterLayout(props: Props) {
|
|
|
72
72
|
</Box>
|
|
73
73
|
</StackView>
|
|
74
74
|
<Divider />
|
|
75
|
-
<StackView axis="horizontal" grow={1}
|
|
75
|
+
<StackView axis="horizontal" grow={1}>
|
|
76
76
|
<StackView
|
|
77
77
|
visible={sidebarOpen}
|
|
78
78
|
basis={fill ? '100%' : sidebarWidth + 'px'}
|
|
@@ -86,10 +86,10 @@ export function FilterLayout(props: Props) {
|
|
|
86
86
|
visibility={sidebarOpen && fill ? 'hidden' : 'visible'}
|
|
87
87
|
maxHeight={sidebarOpen && fill ? 0 : 'initial'}
|
|
88
88
|
grow={1}
|
|
89
|
-
shrink={
|
|
89
|
+
shrink={1}
|
|
90
90
|
basis="100%"
|
|
91
91
|
>
|
|
92
|
-
{toolbar}
|
|
92
|
+
<Box overflow="hidden">{toolbar}</Box>
|
|
93
93
|
<Divider />
|
|
94
94
|
{table}
|
|
95
95
|
</StackView>
|
|
@@ -198,8 +198,13 @@ const TimeField = ({
|
|
|
198
198
|
setHours(updatedHoursValue)
|
|
199
199
|
setHoursDisplay(updatedHoursValue)
|
|
200
200
|
} else {
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
if (updatedHoursValue === 12) {
|
|
202
|
+
setHours(12)
|
|
203
|
+
setHoursDisplay(12)
|
|
204
|
+
} else {
|
|
205
|
+
setHours(updatedHoursValue + 12)
|
|
206
|
+
setHoursDisplay(updatedHoursValue)
|
|
207
|
+
}
|
|
203
208
|
}
|
|
204
209
|
} else {
|
|
205
210
|
setHours(updatedHoursValue)
|
|
@@ -11,7 +11,7 @@ describe('ToggleSwitch component', () => {
|
|
|
11
11
|
<ToggleSwitch isChecked={false} label="Toggle me" onClick={() => {}} />
|
|
12
12
|
)
|
|
13
13
|
|
|
14
|
-
const toggleButton = getByRole('
|
|
14
|
+
const toggleButton = getByRole('switch')
|
|
15
15
|
expect(toggleButton).toBeInTheDocument()
|
|
16
16
|
})
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ describe('ToggleSwitch component', () => {
|
|
|
21
21
|
<ToggleSwitch isChecked={false} label="Toggle me" onClick={mockOnClick} />
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
const toggleButton = getByRole('
|
|
24
|
+
const toggleButton = getByRole('switch')
|
|
25
25
|
fireEvent.click(toggleButton)
|
|
26
26
|
|
|
27
27
|
expect(mockOnClick).toHaveBeenCalled()
|
|
@@ -47,10 +47,28 @@ describe('ToggleSwitch component', () => {
|
|
|
47
47
|
/>
|
|
48
48
|
)
|
|
49
49
|
|
|
50
|
-
const toggleButton = getByRole('
|
|
50
|
+
const toggleButton = getByRole('switch')
|
|
51
51
|
expect(toggleButton).toHaveStyle(`background-color: ${activeColor}`)
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
+
it('should apply aria-checked="true" when isChecked is true', () => {
|
|
55
|
+
const { getByRole } = render(
|
|
56
|
+
<ToggleSwitch isChecked={true} label="Toggle me" onClick={() => {}} />
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
const toggleButton = getByRole('switch')
|
|
60
|
+
expect(toggleButton).toHaveAttribute('aria-checked', 'true')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('should apply aria-checked="false" when isChecked is false', () => {
|
|
64
|
+
const { getByRole } = render(
|
|
65
|
+
<ToggleSwitch isChecked={false} label="Toggle me" onClick={() => {}} />
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
const toggleButton = getByRole('switch')
|
|
69
|
+
expect(toggleButton).toHaveAttribute('aria-checked', 'false')
|
|
70
|
+
})
|
|
71
|
+
|
|
54
72
|
it('should not be clickable when disabled', () => {
|
|
55
73
|
const mockOnClick = jest.fn()
|
|
56
74
|
const { getByRole } = render(
|
|
@@ -62,7 +80,7 @@ describe('ToggleSwitch component', () => {
|
|
|
62
80
|
/>
|
|
63
81
|
)
|
|
64
82
|
|
|
65
|
-
const toggleButton = getByRole('
|
|
83
|
+
const toggleButton = getByRole('switch')
|
|
66
84
|
fireEvent.click(toggleButton)
|
|
67
85
|
|
|
68
86
|
expect(mockOnClick).not.toHaveBeenCalled()
|
|
@@ -79,7 +97,7 @@ describe('ToggleSwitch component', () => {
|
|
|
79
97
|
/>
|
|
80
98
|
)
|
|
81
99
|
|
|
82
|
-
const toggleButton = getByRole('
|
|
100
|
+
const toggleButton = getByRole('switch')
|
|
83
101
|
expect(toggleButton).toHaveStyle(`height: ${base * 2}px`)
|
|
84
102
|
expect(toggleButton).toHaveStyle(`width: ${base * 3.5}px`)
|
|
85
103
|
})
|
|
@@ -93,7 +111,7 @@ describe('ToggleSwitch component', () => {
|
|
|
93
111
|
/>
|
|
94
112
|
)
|
|
95
113
|
|
|
96
|
-
const toggleButton = getByRole('
|
|
114
|
+
const toggleButton = getByRole('switch')
|
|
97
115
|
expect(toggleButton).toHaveStyle(`height: ${base * 2.25}px`)
|
|
98
116
|
expect(toggleButton).toHaveStyle(`width: ${base * 4}px`)
|
|
99
117
|
})
|
|
@@ -107,7 +125,7 @@ describe('ToggleSwitch component', () => {
|
|
|
107
125
|
/>
|
|
108
126
|
)
|
|
109
127
|
|
|
110
|
-
const toggleButton = getByRole('
|
|
128
|
+
const toggleButton = getByRole('switch')
|
|
111
129
|
expect(toggleButton).toHaveStyle(`height: ${base * 2.5}px`)
|
|
112
130
|
expect(toggleButton).toHaveStyle(`width: ${base * 4.375}px`)
|
|
113
131
|
})
|
|
@@ -66,6 +66,7 @@ export function ToggleSwitch(props: Props) {
|
|
|
66
66
|
spacing={size === 'xs' ? 0.5 : size === 'sm' ? 0.75 : 1}
|
|
67
67
|
>
|
|
68
68
|
<Button
|
|
69
|
+
aria-checked={isChecked}
|
|
69
70
|
as="button"
|
|
70
71
|
backgroundColor={
|
|
71
72
|
disabled
|
|
@@ -78,6 +79,7 @@ export function ToggleSwitch(props: Props) {
|
|
|
78
79
|
opacity={1}
|
|
79
80
|
position="relative"
|
|
80
81
|
radius="pill"
|
|
82
|
+
role="switch"
|
|
81
83
|
theme={false}
|
|
82
84
|
{...{ disabled, tooltip }}
|
|
83
85
|
{...toggleButtonProps}
|
|
@@ -115,40 +115,40 @@ export const buttonThemes = {
|
|
|
115
115
|
},
|
|
116
116
|
error: {
|
|
117
117
|
fill: {
|
|
118
|
-
color: '
|
|
119
|
-
backgroundColor: '
|
|
120
|
-
hover: { backgroundColor: '
|
|
121
|
-
active: { backgroundColor: '
|
|
118
|
+
color: 'white',
|
|
119
|
+
backgroundColor: 'error',
|
|
120
|
+
hover: { backgroundColor: 'error-dark' },
|
|
121
|
+
active: { backgroundColor: 'error-darker' },
|
|
122
122
|
},
|
|
123
123
|
outline: {
|
|
124
|
-
stroke: '
|
|
125
|
-
color: '
|
|
126
|
-
hover: { backgroundColor: '
|
|
127
|
-
active: { backgroundColor: '
|
|
124
|
+
stroke: 'error',
|
|
125
|
+
color: 'error',
|
|
126
|
+
hover: { backgroundColor: 'error-lightest' },
|
|
127
|
+
active: { backgroundColor: 'error-lighter' },
|
|
128
128
|
},
|
|
129
129
|
naked: {
|
|
130
130
|
color: 'error',
|
|
131
|
-
hover: { backgroundColor: '
|
|
132
|
-
active: { backgroundColor: '
|
|
131
|
+
hover: { backgroundColor: 'error-lightest' },
|
|
132
|
+
active: { backgroundColor: 'error-lighter' },
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
success: {
|
|
136
136
|
fill: {
|
|
137
|
-
color: '
|
|
138
|
-
backgroundColor: '
|
|
139
|
-
hover: { backgroundColor: '
|
|
140
|
-
active: { backgroundColor: '
|
|
137
|
+
color: 'white',
|
|
138
|
+
backgroundColor: 'success',
|
|
139
|
+
hover: { backgroundColor: 'success-dark' },
|
|
140
|
+
active: { backgroundColor: 'success-darker' },
|
|
141
141
|
},
|
|
142
142
|
outline: {
|
|
143
|
-
stroke: '
|
|
144
|
-
color: '
|
|
145
|
-
hover: { backgroundColor: '
|
|
146
|
-
active: { backgroundColor: '
|
|
143
|
+
stroke: 'success',
|
|
144
|
+
color: 'success',
|
|
145
|
+
hover: { backgroundColor: 'success-lightest' },
|
|
146
|
+
active: { backgroundColor: 'success-lighter' },
|
|
147
147
|
},
|
|
148
148
|
naked: {
|
|
149
|
-
color: '
|
|
150
|
-
hover: { backgroundColor: '
|
|
151
|
-
active: { backgroundColor: '
|
|
149
|
+
color: 'success',
|
|
150
|
+
hover: { backgroundColor: 'success-lightest' },
|
|
151
|
+
active: { backgroundColor: 'success-lighter' },
|
|
152
152
|
},
|
|
153
153
|
},
|
|
154
154
|
info: {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getLuminance,
|
|
9
9
|
toColorString,
|
|
10
10
|
} from 'polished'
|
|
11
|
+
import { getCSSProperty } from '../../utils'
|
|
11
12
|
|
|
12
13
|
function capitalizeFirstLetter(string) {
|
|
13
14
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
@@ -91,7 +92,7 @@ export function flattenPalette(palette) {
|
|
|
91
92
|
const aliasValue = parsedPalette[value]
|
|
92
93
|
return {
|
|
93
94
|
...collection,
|
|
94
|
-
[key]: aliasValue ?
|
|
95
|
+
[key]: aliasValue ? getCSSProperty('colors', value) : value,
|
|
95
96
|
}
|
|
96
97
|
}, {})
|
|
97
98
|
}
|