@cloudflare/component-button 2.9.53 → 2.9.57
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 +27 -0
- package/es/Button.js +29 -45
- package/lib/Button.js +30 -45
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.9.57](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.9.56...@cloudflare/component-button@2.9.57) (2021-09-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **component-button:** UI-4634 Add missing style-const package ([414af06](http://stash.cfops.it:7999/fe/stratus/commits/414af06))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.9.56](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.9.54...@cloudflare/component-button@2.9.56) (2021-09-15)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @cloudflare/component-button
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [2.9.54](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.9.53...@cloudflare/component-button@2.9.54) (2021-08-25)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @cloudflare/component-button
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [2.9.53](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/component-button@2.9.52...@cloudflare/component-button@2.9.53) (2021-08-20)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @cloudflare/component-button
|
package/es/Button.js
CHANGED
|
@@ -6,9 +6,26 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
+
import { isDarkMode } from '@cloudflare/style-const';
|
|
9
10
|
import { createStyledComponent } from '@cloudflare/style-container';
|
|
10
11
|
import { Icon } from '@cloudflare/component-icon';
|
|
11
12
|
|
|
13
|
+
const standardColors = theme => {
|
|
14
|
+
// The button color is white in both dark and light modes.
|
|
15
|
+
const color = isDarkMode() ? theme.colors.black : theme.colors.white;
|
|
16
|
+
return {
|
|
17
|
+
default: theme.colors.gray[1],
|
|
18
|
+
primary: color,
|
|
19
|
+
success: color,
|
|
20
|
+
warning: color,
|
|
21
|
+
danger: color,
|
|
22
|
+
inverted: {
|
|
23
|
+
danger: theme.colors.red[3],
|
|
24
|
+
primary: theme.colors.blue[4]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
12
29
|
const buttonColors = theme => ({
|
|
13
30
|
// Normal default state colors
|
|
14
31
|
normal: {
|
|
@@ -23,17 +40,7 @@ const buttonColors = theme => ({
|
|
|
23
40
|
primary: 'transparent'
|
|
24
41
|
}
|
|
25
42
|
},
|
|
26
|
-
color:
|
|
27
|
-
default: theme.colors.gray[1],
|
|
28
|
-
primary: theme.colors.white,
|
|
29
|
-
success: theme.colors.white,
|
|
30
|
-
warning: theme.colors.white,
|
|
31
|
-
danger: theme.colors.white,
|
|
32
|
-
inverted: {
|
|
33
|
-
danger: theme.colors.red[3],
|
|
34
|
-
primary: theme.colors.blue[4]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
43
|
+
color: standardColors(theme)
|
|
37
44
|
},
|
|
38
45
|
// Hover
|
|
39
46
|
hover: {
|
|
@@ -48,17 +55,12 @@ const buttonColors = theme => ({
|
|
|
48
55
|
primary: theme.colors.blue[4]
|
|
49
56
|
}
|
|
50
57
|
},
|
|
51
|
-
color: {
|
|
52
|
-
default: theme.colors.gray[1],
|
|
53
|
-
primary: theme.colors.white,
|
|
54
|
-
success: theme.colors.white,
|
|
55
|
-
warning: theme.colors.white,
|
|
56
|
-
danger: theme.colors.white,
|
|
58
|
+
color: _objectSpread({}, standardColors(theme), {
|
|
57
59
|
inverted: {
|
|
58
60
|
danger: theme.colors.white,
|
|
59
61
|
primary: theme.colors.white
|
|
60
62
|
}
|
|
61
|
-
}
|
|
63
|
+
})
|
|
62
64
|
},
|
|
63
65
|
// Active
|
|
64
66
|
active: {
|
|
@@ -73,17 +75,7 @@ const buttonColors = theme => ({
|
|
|
73
75
|
primary: 'transparent'
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
|
-
color:
|
|
77
|
-
default: theme.colors.gray[1],
|
|
78
|
-
primary: theme.colors.white,
|
|
79
|
-
success: theme.colors.white,
|
|
80
|
-
warning: theme.colors.white,
|
|
81
|
-
danger: theme.colors.white,
|
|
82
|
-
inverted: {
|
|
83
|
-
danger: theme.colors.red[3],
|
|
84
|
-
primary: theme.colors.blue[4]
|
|
85
|
-
}
|
|
86
|
-
}
|
|
78
|
+
color: standardColors(theme)
|
|
87
79
|
},
|
|
88
80
|
// Focus
|
|
89
81
|
focus: {
|
|
@@ -98,17 +90,7 @@ const buttonColors = theme => ({
|
|
|
98
90
|
primary: 'transparent'
|
|
99
91
|
}
|
|
100
92
|
},
|
|
101
|
-
color:
|
|
102
|
-
default: theme.colors.gray[1],
|
|
103
|
-
primary: theme.colors.white,
|
|
104
|
-
success: theme.colors.white,
|
|
105
|
-
warning: theme.colors.white,
|
|
106
|
-
danger: theme.colors.white,
|
|
107
|
-
inverted: {
|
|
108
|
-
danger: theme.colors.red[3],
|
|
109
|
-
primary: theme.colors.blue[4]
|
|
110
|
-
}
|
|
111
|
-
}
|
|
93
|
+
color: standardColors(theme)
|
|
112
94
|
}
|
|
113
95
|
});
|
|
114
96
|
|
|
@@ -140,11 +122,13 @@ const styles = props => {
|
|
|
140
122
|
group = props.group,
|
|
141
123
|
spaced = props.spaced;
|
|
142
124
|
const normalStyles = buttonColors(theme).normal;
|
|
143
|
-
return {
|
|
125
|
+
return _objectSpread({
|
|
144
126
|
'&:hover': interactionStyleAccessor('hover', props),
|
|
145
|
-
'&:active': interactionStyleAccessor('active', props)
|
|
146
|
-
|
|
147
|
-
'&:focus
|
|
127
|
+
'&:active': interactionStyleAccessor('active', props)
|
|
128
|
+
}, _objectSpread({}, theme.mixin.focus(), {
|
|
129
|
+
'&:focus': interactionStyleAccessor('focus', props)
|
|
130
|
+
}), {
|
|
131
|
+
'&:focus-within:hover': interactionStyleAccessor('focus', props),
|
|
148
132
|
'&:active:hover': interactionStyleAccessor('active', props),
|
|
149
133
|
'&[title]': {
|
|
150
134
|
pointerEvents: disabled ? 'auto' : 'none'
|
|
@@ -210,7 +194,7 @@ const styles = props => {
|
|
|
210
194
|
float: 'none',
|
|
211
195
|
whiteSpace: 'nowrap',
|
|
212
196
|
width: direction === 'column' ? '100%' : 'auto'
|
|
213
|
-
};
|
|
197
|
+
});
|
|
214
198
|
};
|
|
215
199
|
|
|
216
200
|
const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
package/lib/Button.js
CHANGED
|
@@ -9,6 +9,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _styleConst = require("@cloudflare/style-const");
|
|
13
|
+
|
|
12
14
|
var _styleContainer = require("@cloudflare/style-container");
|
|
13
15
|
|
|
14
16
|
var _componentIcon = require("@cloudflare/component-icon");
|
|
@@ -21,6 +23,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
23
|
|
|
22
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
25
|
|
|
26
|
+
var standardColors = function standardColors(theme) {
|
|
27
|
+
// The button color is white in both dark and light modes.
|
|
28
|
+
var color = (0, _styleConst.isDarkMode)() ? theme.colors.black : theme.colors.white;
|
|
29
|
+
return {
|
|
30
|
+
default: theme.colors.gray[1],
|
|
31
|
+
primary: color,
|
|
32
|
+
success: color,
|
|
33
|
+
warning: color,
|
|
34
|
+
danger: color,
|
|
35
|
+
inverted: {
|
|
36
|
+
danger: theme.colors.red[3],
|
|
37
|
+
primary: theme.colors.blue[4]
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
24
42
|
var buttonColors = function buttonColors(theme) {
|
|
25
43
|
return {
|
|
26
44
|
// Normal default state colors
|
|
@@ -36,17 +54,7 @@ var buttonColors = function buttonColors(theme) {
|
|
|
36
54
|
primary: 'transparent'
|
|
37
55
|
}
|
|
38
56
|
},
|
|
39
|
-
color:
|
|
40
|
-
default: theme.colors.gray[1],
|
|
41
|
-
primary: theme.colors.white,
|
|
42
|
-
success: theme.colors.white,
|
|
43
|
-
warning: theme.colors.white,
|
|
44
|
-
danger: theme.colors.white,
|
|
45
|
-
inverted: {
|
|
46
|
-
danger: theme.colors.red[3],
|
|
47
|
-
primary: theme.colors.blue[4]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
57
|
+
color: standardColors(theme)
|
|
50
58
|
},
|
|
51
59
|
// Hover
|
|
52
60
|
hover: {
|
|
@@ -61,17 +69,12 @@ var buttonColors = function buttonColors(theme) {
|
|
|
61
69
|
primary: theme.colors.blue[4]
|
|
62
70
|
}
|
|
63
71
|
},
|
|
64
|
-
color: {
|
|
65
|
-
default: theme.colors.gray[1],
|
|
66
|
-
primary: theme.colors.white,
|
|
67
|
-
success: theme.colors.white,
|
|
68
|
-
warning: theme.colors.white,
|
|
69
|
-
danger: theme.colors.white,
|
|
72
|
+
color: _objectSpread({}, standardColors(theme), {
|
|
70
73
|
inverted: {
|
|
71
74
|
danger: theme.colors.white,
|
|
72
75
|
primary: theme.colors.white
|
|
73
76
|
}
|
|
74
|
-
}
|
|
77
|
+
})
|
|
75
78
|
},
|
|
76
79
|
// Active
|
|
77
80
|
active: {
|
|
@@ -86,17 +89,7 @@ var buttonColors = function buttonColors(theme) {
|
|
|
86
89
|
primary: 'transparent'
|
|
87
90
|
}
|
|
88
91
|
},
|
|
89
|
-
color:
|
|
90
|
-
default: theme.colors.gray[1],
|
|
91
|
-
primary: theme.colors.white,
|
|
92
|
-
success: theme.colors.white,
|
|
93
|
-
warning: theme.colors.white,
|
|
94
|
-
danger: theme.colors.white,
|
|
95
|
-
inverted: {
|
|
96
|
-
danger: theme.colors.red[3],
|
|
97
|
-
primary: theme.colors.blue[4]
|
|
98
|
-
}
|
|
99
|
-
}
|
|
92
|
+
color: standardColors(theme)
|
|
100
93
|
},
|
|
101
94
|
// Focus
|
|
102
95
|
focus: {
|
|
@@ -111,17 +104,7 @@ var buttonColors = function buttonColors(theme) {
|
|
|
111
104
|
primary: 'transparent'
|
|
112
105
|
}
|
|
113
106
|
},
|
|
114
|
-
color:
|
|
115
|
-
default: theme.colors.gray[1],
|
|
116
|
-
primary: theme.colors.white,
|
|
117
|
-
success: theme.colors.white,
|
|
118
|
-
warning: theme.colors.white,
|
|
119
|
-
danger: theme.colors.white,
|
|
120
|
-
inverted: {
|
|
121
|
-
danger: theme.colors.red[3],
|
|
122
|
-
primary: theme.colors.blue[4]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
107
|
+
color: standardColors(theme)
|
|
125
108
|
}
|
|
126
109
|
};
|
|
127
110
|
};
|
|
@@ -157,11 +140,13 @@ var styles = function styles(props) {
|
|
|
157
140
|
group = props.group,
|
|
158
141
|
spaced = props.spaced;
|
|
159
142
|
var normalStyles = buttonColors(theme).normal;
|
|
160
|
-
return {
|
|
143
|
+
return _objectSpread({
|
|
161
144
|
'&:hover': interactionStyleAccessor('hover', props),
|
|
162
|
-
'&:active': interactionStyleAccessor('active', props)
|
|
163
|
-
|
|
164
|
-
'&:focus
|
|
145
|
+
'&:active': interactionStyleAccessor('active', props)
|
|
146
|
+
}, _objectSpread({}, theme.mixin.focus(), {
|
|
147
|
+
'&:focus': interactionStyleAccessor('focus', props)
|
|
148
|
+
}), {
|
|
149
|
+
'&:focus-within:hover': interactionStyleAccessor('focus', props),
|
|
165
150
|
'&:active:hover': interactionStyleAccessor('active', props),
|
|
166
151
|
'&[title]': {
|
|
167
152
|
pointerEvents: disabled ? 'auto' : 'none'
|
|
@@ -227,7 +212,7 @@ var styles = function styles(props) {
|
|
|
227
212
|
float: 'none',
|
|
228
213
|
whiteSpace: 'nowrap',
|
|
229
214
|
width: direction === 'column' ? '100%' : 'auto'
|
|
230
|
-
};
|
|
215
|
+
});
|
|
231
216
|
};
|
|
232
217
|
|
|
233
218
|
var Button = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
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.9.
|
|
4
|
+
"version": "2.9.57",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"author": "James Kyle <jkyle@cloudflare.com>",
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@cloudflare/component-icon": "^6.1
|
|
16
|
-
"@cloudflare/style-
|
|
15
|
+
"@cloudflare/component-icon": "^6.3.1",
|
|
16
|
+
"@cloudflare/style-const": "^3.0.3",
|
|
17
|
+
"@cloudflare/style-container": "^7.4.0",
|
|
17
18
|
"polished": "^1.9.3",
|
|
18
19
|
"prop-types": "^15.6.0"
|
|
19
20
|
},
|
|
@@ -31,5 +32,5 @@
|
|
|
31
32
|
"test-coverage": "stratus test --coverage",
|
|
32
33
|
"test-watch": "stratus test --watch"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "bc6771eca21284483f36f77a265d7e5ac79a76a8"
|
|
35
36
|
}
|