@cloudflare/component-button 2.11.9 → 2.11.13
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 +32 -0
- package/dist/Button.d.ts +1 -0
- package/es/Button.js +35 -26
- package/es/IconTextButton.js +2 -2
- package/es/TextButton.js +3 -3
- package/lib/Button.js +35 -26
- package/lib/IconTextButton.js +2 -2
- package/lib/TextButton.js +3 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.11.13](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.11.12...@cloudflare/component-button@2.11.13) (2021-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @cloudflare/component-button
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.11.12](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.11.11...@cloudflare/component-button@2.11.12) (2021-11-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @cloudflare/component-button
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.11.11](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.11.10...@cloudflare/component-button@2.11.11) (2021-11-16)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @cloudflare/component-button
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [2.11.10](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.11.9...@cloudflare/component-button@2.11.10) (2021-11-15)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @cloudflare/component-button
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [2.11.9](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.11.8...@cloudflare/component-button@2.11.9) (2021-11-05)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @cloudflare/component-button
|
package/dist/Button.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const _default: React.ComponentType<{
|
|
|
18
18
|
iconType?: IconType | undefined;
|
|
19
19
|
iconLabel?: string | undefined;
|
|
20
20
|
iconSize?: number | undefined;
|
|
21
|
+
ariaLabel?: string | undefined;
|
|
21
22
|
p?: import("csstype").PaddingProperty<string | number> | [import("csstype").PaddingProperty<string | number> | undefined, import("csstype").PaddingProperty<string | number> | undefined] | [import("csstype").PaddingProperty<string | number> | undefined, import("csstype").PaddingProperty<string | number> | undefined, import("csstype").PaddingProperty<string | number> | undefined] | undefined;
|
|
22
23
|
color?: string | [string | undefined, string | undefined] | [string | undefined, string | undefined, string | undefined] | undefined;
|
|
23
24
|
height?: import("csstype").HeightProperty<string | number> | [import("csstype").HeightProperty<string | number> | undefined, import("csstype").HeightProperty<string | number> | undefined] | [import("csstype").HeightProperty<string | number> | undefined, import("csstype").HeightProperty<string | number> | undefined, import("csstype").HeightProperty<string | number> | undefined] | undefined;
|
package/es/Button.js
CHANGED
|
@@ -102,21 +102,24 @@ const buttonColors = theme => {
|
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
const
|
|
106
|
-
var
|
|
105
|
+
const getFocusOutlineColor = (theme, type, inverted) => {
|
|
106
|
+
var _invertedOutlines$typ;
|
|
107
107
|
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
const standardIndex = isDarkMode() ? 3 : 4;
|
|
109
|
+
const FOCUS_OFFSET_INDEX = 2;
|
|
110
|
+
const focusIndex = standardIndex - FOCUS_OFFSET_INDEX;
|
|
111
|
+
const outlines = {
|
|
112
|
+
default: isDarkMode() ? theme.colors.gray[focusIndex] : theme.colors.gray[8 - FOCUS_OFFSET_INDEX],
|
|
113
|
+
primary: theme.colors.blue[focusIndex],
|
|
114
|
+
success: theme.colors.green[focusIndex],
|
|
115
|
+
warning: theme.colors.orange[focusIndex],
|
|
116
|
+
danger: theme.colors.red[focusIndex]
|
|
114
117
|
};
|
|
115
|
-
const
|
|
116
|
-
danger: theme.colors.red[
|
|
117
|
-
primary: theme.colors.blue[
|
|
118
|
+
const invertedOutlines = {
|
|
119
|
+
danger: theme.colors.red[focusIndex],
|
|
120
|
+
primary: theme.colors.blue[focusIndex]
|
|
118
121
|
};
|
|
119
|
-
return inverted ? (
|
|
122
|
+
return inverted ? (_invertedOutlines$typ = invertedOutlines[type]) !== null && _invertedOutlines$typ !== void 0 ? _invertedOutlines$typ : outlines[type] : outlines[type];
|
|
120
123
|
};
|
|
121
124
|
|
|
122
125
|
const colorAccessor = (property, {
|
|
@@ -137,8 +140,6 @@ const interactionStyleAccessor = (interactionState, props) => {
|
|
|
137
140
|
};
|
|
138
141
|
|
|
139
142
|
const styles = props => {
|
|
140
|
-
var _props$type;
|
|
141
|
-
|
|
142
143
|
const theme = props.theme,
|
|
143
144
|
_props$loading = props.loading,
|
|
144
145
|
loading = _props$loading === void 0 ? false : _props$loading,
|
|
@@ -147,19 +148,24 @@ const styles = props => {
|
|
|
147
148
|
_props$inverted = props.inverted,
|
|
148
149
|
inverted = _props$inverted === void 0 ? false : _props$inverted,
|
|
149
150
|
group = props.group,
|
|
150
|
-
spaced = props.spaced
|
|
151
|
+
spaced = props.spaced,
|
|
152
|
+
_props$type = props.type,
|
|
153
|
+
type = _props$type === void 0 ? 'default' : _props$type;
|
|
151
154
|
const normalStyles = buttonColors(theme).normal;
|
|
152
|
-
const
|
|
155
|
+
const hoverStyles = interactionStyleAccessor('hover', props);
|
|
156
|
+
const activeStyles = interactionStyleAccessor('active', props);
|
|
157
|
+
const focusStyles = interactionStyleAccessor('focus', props);
|
|
153
158
|
return {
|
|
154
|
-
'&:hover':
|
|
155
|
-
'&:active':
|
|
156
|
-
'&:focus':
|
|
159
|
+
'&:hover': hoverStyles,
|
|
160
|
+
'&:active': activeStyles,
|
|
161
|
+
'&:focus': focusStyles,
|
|
157
162
|
'&:focus-visible': {
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
outlineOffset: 3,
|
|
164
|
+
outlineStyle: 'auto',
|
|
165
|
+
outlineColor: getFocusOutlineColor(theme, type, inverted)
|
|
160
166
|
},
|
|
161
|
-
'&:focus-within:hover':
|
|
162
|
-
'&:active:hover':
|
|
167
|
+
'&:focus-within:hover': focusStyles,
|
|
168
|
+
'&:active:hover': activeStyles,
|
|
163
169
|
'&[title]': {
|
|
164
170
|
pointerEvents: disabled ? 'auto' : 'none'
|
|
165
171
|
},
|
|
@@ -241,7 +247,8 @@ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
241
247
|
iconLabel = props.iconLabel,
|
|
242
248
|
iconSize = props.iconSize,
|
|
243
249
|
form = props.form,
|
|
244
|
-
tabIndex = props.tabIndex
|
|
250
|
+
tabIndex = props.tabIndex,
|
|
251
|
+
ariaLabel = props.ariaLabel;
|
|
245
252
|
const dataAttributes = Object.keys(props).filter(propName => propName.startsWith('data-')).reduce((memo, dataPropName) => _objectSpread({}, memo, {
|
|
246
253
|
[dataPropName]: props[dataPropName]
|
|
247
254
|
}), {});
|
|
@@ -253,7 +260,8 @@ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
253
260
|
onClick: onClick,
|
|
254
261
|
form: form,
|
|
255
262
|
tabIndex: tabIndex,
|
|
256
|
-
ref: ref
|
|
263
|
+
ref: ref,
|
|
264
|
+
"aria-label": ariaLabel
|
|
257
265
|
}), iconType && /*#__PURE__*/React.createElement(Icon, {
|
|
258
266
|
size: iconSize,
|
|
259
267
|
type: iconType,
|
|
@@ -276,7 +284,8 @@ Button.propTypes = {
|
|
|
276
284
|
iconLabel: PropTypes.string,
|
|
277
285
|
iconSize: PropTypes.number,
|
|
278
286
|
form: PropTypes.string,
|
|
279
|
-
tabIndex: PropTypes.number
|
|
287
|
+
tabIndex: PropTypes.number,
|
|
288
|
+
ariaLabel: PropTypes.string
|
|
280
289
|
};
|
|
281
290
|
Button.displayName = 'Button';
|
|
282
291
|
export default createStyledComponent(styles, Button);
|
package/es/IconTextButton.js
CHANGED
|
@@ -4,8 +4,7 @@ import { Icon } from '@cloudflare/component-icon';
|
|
|
4
4
|
import TextButton from './TextButton';
|
|
5
5
|
const IconTextWrapper = createStyledComponent(() => ({
|
|
6
6
|
display: 'flex',
|
|
7
|
-
alignItems: 'center'
|
|
8
|
-
marginTop: '2px'
|
|
7
|
+
alignItems: 'center'
|
|
9
8
|
}), 'div');
|
|
10
9
|
|
|
11
10
|
const IconTextButton = ({
|
|
@@ -13,6 +12,7 @@ const IconTextButton = ({
|
|
|
13
12
|
iconType,
|
|
14
13
|
children
|
|
15
14
|
}) => /*#__PURE__*/React.createElement(TextButton, {
|
|
15
|
+
type: "button",
|
|
16
16
|
onClick: onClick
|
|
17
17
|
}, /*#__PURE__*/React.createElement(IconTextWrapper, null, /*#__PURE__*/React.createElement(Icon, {
|
|
18
18
|
type: iconType,
|
package/es/TextButton.js
CHANGED
|
@@ -12,6 +12,7 @@ const TextButton = createStyledComponent(({
|
|
|
12
12
|
padding: '0px',
|
|
13
13
|
display: 'inline-block',
|
|
14
14
|
alignItems: 'center',
|
|
15
|
+
lineHeight: '1.5',
|
|
15
16
|
height: 'fit-content',
|
|
16
17
|
fontSize: 2,
|
|
17
18
|
fontWeight: 400,
|
|
@@ -19,10 +20,9 @@ const TextButton = createStyledComponent(({
|
|
|
19
20
|
':hover': {
|
|
20
21
|
color: theme.colors.orange[6]
|
|
21
22
|
},
|
|
22
|
-
':focus': {
|
|
23
|
+
':focus-visible': {
|
|
23
24
|
outline: '-webkit-focus-ring-color auto 1px',
|
|
24
|
-
outlineOffset: '1px'
|
|
25
|
-
paddingBottom: '2px'
|
|
25
|
+
outlineOffset: '1px'
|
|
26
26
|
}
|
|
27
27
|
}), 'button');
|
|
28
28
|
export default TextButton;
|
package/lib/Button.js
CHANGED
|
@@ -115,21 +115,24 @@ var buttonColors = function buttonColors(theme) {
|
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
var
|
|
119
|
-
var
|
|
118
|
+
var getFocusOutlineColor = function getFocusOutlineColor(theme, type, inverted) {
|
|
119
|
+
var _invertedOutlines$typ;
|
|
120
120
|
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
var standardIndex = (0, _styleConst.isDarkMode)() ? 3 : 4;
|
|
122
|
+
var FOCUS_OFFSET_INDEX = 2;
|
|
123
|
+
var focusIndex = standardIndex - FOCUS_OFFSET_INDEX;
|
|
124
|
+
var outlines = {
|
|
125
|
+
default: (0, _styleConst.isDarkMode)() ? theme.colors.gray[focusIndex] : theme.colors.gray[8 - FOCUS_OFFSET_INDEX],
|
|
126
|
+
primary: theme.colors.blue[focusIndex],
|
|
127
|
+
success: theme.colors.green[focusIndex],
|
|
128
|
+
warning: theme.colors.orange[focusIndex],
|
|
129
|
+
danger: theme.colors.red[focusIndex]
|
|
127
130
|
};
|
|
128
|
-
var
|
|
129
|
-
danger: theme.colors.red[
|
|
130
|
-
primary: theme.colors.blue[
|
|
131
|
+
var invertedOutlines = {
|
|
132
|
+
danger: theme.colors.red[focusIndex],
|
|
133
|
+
primary: theme.colors.blue[focusIndex]
|
|
131
134
|
};
|
|
132
|
-
return inverted ? (
|
|
135
|
+
return inverted ? (_invertedOutlines$typ = invertedOutlines[type]) !== null && _invertedOutlines$typ !== void 0 ? _invertedOutlines$typ : outlines[type] : outlines[type];
|
|
133
136
|
};
|
|
134
137
|
|
|
135
138
|
var colorAccessor = function colorAccessor(property, _ref) {
|
|
@@ -153,8 +156,6 @@ var interactionStyleAccessor = function interactionStyleAccessor(interactionStat
|
|
|
153
156
|
};
|
|
154
157
|
|
|
155
158
|
var styles = function styles(props) {
|
|
156
|
-
var _props$type;
|
|
157
|
-
|
|
158
159
|
var theme = props.theme,
|
|
159
160
|
_props$loading = props.loading,
|
|
160
161
|
loading = _props$loading === void 0 ? false : _props$loading,
|
|
@@ -163,19 +164,24 @@ var styles = function styles(props) {
|
|
|
163
164
|
_props$inverted = props.inverted,
|
|
164
165
|
inverted = _props$inverted === void 0 ? false : _props$inverted,
|
|
165
166
|
group = props.group,
|
|
166
|
-
spaced = props.spaced
|
|
167
|
+
spaced = props.spaced,
|
|
168
|
+
_props$type = props.type,
|
|
169
|
+
type = _props$type === void 0 ? 'default' : _props$type;
|
|
167
170
|
var normalStyles = buttonColors(theme).normal;
|
|
168
|
-
var
|
|
171
|
+
var hoverStyles = interactionStyleAccessor('hover', props);
|
|
172
|
+
var activeStyles = interactionStyleAccessor('active', props);
|
|
173
|
+
var focusStyles = interactionStyleAccessor('focus', props);
|
|
169
174
|
return {
|
|
170
|
-
'&:hover':
|
|
171
|
-
'&:active':
|
|
172
|
-
'&:focus':
|
|
175
|
+
'&:hover': hoverStyles,
|
|
176
|
+
'&:active': activeStyles,
|
|
177
|
+
'&:focus': focusStyles,
|
|
173
178
|
'&:focus-visible': {
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
outlineOffset: 3,
|
|
180
|
+
outlineStyle: 'auto',
|
|
181
|
+
outlineColor: getFocusOutlineColor(theme, type, inverted)
|
|
176
182
|
},
|
|
177
|
-
'&:focus-within:hover':
|
|
178
|
-
'&:active:hover':
|
|
183
|
+
'&:focus-within:hover': focusStyles,
|
|
184
|
+
'&:active:hover': activeStyles,
|
|
179
185
|
'&[title]': {
|
|
180
186
|
pointerEvents: disabled ? 'auto' : 'none'
|
|
181
187
|
},
|
|
@@ -257,7 +263,8 @@ var Button = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
257
263
|
iconLabel = props.iconLabel,
|
|
258
264
|
iconSize = props.iconSize,
|
|
259
265
|
form = props.form,
|
|
260
|
-
tabIndex = props.tabIndex
|
|
266
|
+
tabIndex = props.tabIndex,
|
|
267
|
+
ariaLabel = props.ariaLabel;
|
|
261
268
|
var dataAttributes = Object.keys(props).filter(function (propName) {
|
|
262
269
|
return propName.startsWith('data-');
|
|
263
270
|
}).reduce(function (memo, dataPropName) {
|
|
@@ -271,7 +278,8 @@ var Button = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
271
278
|
onClick: onClick,
|
|
272
279
|
form: form,
|
|
273
280
|
tabIndex: tabIndex,
|
|
274
|
-
ref: ref
|
|
281
|
+
ref: ref,
|
|
282
|
+
"aria-label": ariaLabel
|
|
275
283
|
}), iconType && /*#__PURE__*/_react.default.createElement(_componentIcon.Icon, {
|
|
276
284
|
size: iconSize,
|
|
277
285
|
type: iconType,
|
|
@@ -295,7 +303,8 @@ Button.propTypes = {
|
|
|
295
303
|
iconLabel: _propTypes.default.string,
|
|
296
304
|
iconSize: _propTypes.default.number,
|
|
297
305
|
form: _propTypes.default.string,
|
|
298
|
-
tabIndex: _propTypes.default.number
|
|
306
|
+
tabIndex: _propTypes.default.number,
|
|
307
|
+
ariaLabel: _propTypes.default.string
|
|
299
308
|
};
|
|
300
309
|
Button.displayName = 'Button';
|
|
301
310
|
|
package/lib/IconTextButton.js
CHANGED
|
@@ -18,8 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
var IconTextWrapper = (0, _styleContainer.createStyledComponent)(function () {
|
|
19
19
|
return {
|
|
20
20
|
display: 'flex',
|
|
21
|
-
alignItems: 'center'
|
|
22
|
-
marginTop: '2px'
|
|
21
|
+
alignItems: 'center'
|
|
23
22
|
};
|
|
24
23
|
}, 'div');
|
|
25
24
|
|
|
@@ -28,6 +27,7 @@ var IconTextButton = function IconTextButton(_ref) {
|
|
|
28
27
|
iconType = _ref.iconType,
|
|
29
28
|
children = _ref.children;
|
|
30
29
|
return /*#__PURE__*/_react.default.createElement(_TextButton.default, {
|
|
30
|
+
type: "button",
|
|
31
31
|
onClick: onClick
|
|
32
32
|
}, /*#__PURE__*/_react.default.createElement(IconTextWrapper, null, /*#__PURE__*/_react.default.createElement(_componentIcon.Icon, {
|
|
33
33
|
type: iconType,
|
package/lib/TextButton.js
CHANGED
|
@@ -20,6 +20,7 @@ var TextButton = (0, _styleContainer.createStyledComponent)(function (_ref) {
|
|
|
20
20
|
padding: '0px',
|
|
21
21
|
display: 'inline-block',
|
|
22
22
|
alignItems: 'center',
|
|
23
|
+
lineHeight: '1.5',
|
|
23
24
|
height: 'fit-content',
|
|
24
25
|
fontSize: 2,
|
|
25
26
|
fontWeight: 400,
|
|
@@ -27,10 +28,9 @@ var TextButton = (0, _styleContainer.createStyledComponent)(function (_ref) {
|
|
|
27
28
|
':hover': {
|
|
28
29
|
color: theme.colors.orange[6]
|
|
29
30
|
},
|
|
30
|
-
':focus': {
|
|
31
|
+
':focus-visible': {
|
|
31
32
|
outline: '-webkit-focus-ring-color auto 1px',
|
|
32
|
-
outlineOffset: '1px'
|
|
33
|
-
paddingBottom: '2px'
|
|
33
|
+
outlineOffset: '1px'
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
}, 'button');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/component-button",
|
|
3
3
|
"description": "Cloudflare Button Component",
|
|
4
|
-
"version": "2.11.
|
|
4
|
+
"version": "2.11.13",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Kyle <jkyle@cloudflare.com>",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@cloudflare/component-icon": "^6.5.
|
|
16
|
-
"@cloudflare/style-const": "^5.1.
|
|
17
|
-
"@cloudflare/style-container": "^7.5.
|
|
15
|
+
"@cloudflare/component-icon": "^6.5.13",
|
|
16
|
+
"@cloudflare/style-const": "^5.1.13",
|
|
17
|
+
"@cloudflare/style-container": "^7.5.19",
|
|
18
18
|
"polished": "^1.9.3",
|
|
19
19
|
"prop-types": "^15.6.0"
|
|
20
20
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"test-coverage": "stratus test --coverage",
|
|
33
33
|
"test-watch": "stratus test --watch"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "569113c2ab73ce93969008d15ad9e6648d0d3ed0"
|
|
36
36
|
}
|