@primer/components 0.0.0-202192724324 → 0.0.0-20219273337
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 +1 -1
- package/dist/browser.esm.js +438 -435
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +447 -444
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionMenu.js +2 -2
- package/lib/Autocomplete/Autocomplete.d.ts +9 -9
- package/lib/Autocomplete/AutocompleteInput.d.ts +9 -9
- package/lib/Button/Button.d.ts +11 -11
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +29 -29
- package/lib/Button/ButtonDanger.d.ts +11 -11
- package/lib/Button/ButtonInvisible.d.ts +11 -11
- package/lib/Button/ButtonOutline.d.ts +11 -11
- package/lib/Button/ButtonPrimary.d.ts +11 -11
- package/lib/Button/ButtonStyles.js +1 -1
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +33 -33
- package/lib/Dialog/Dialog.d.ts +5 -5
- package/lib/Dialog/Dialog.js +22 -13
- package/lib/Dialog.d.ts +35 -35
- package/lib/Dropdown.d.ts +692 -60
- package/lib/Dropdown.js +5 -6
- package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib/FilterList.d.ts +26 -26
- package/lib/Label.d.ts +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +149 -149
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +9 -9
- package/lib/Timeline.d.ts +33 -33
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/_TextInputWrapper.d.ts +1 -1
- package/lib/constants.js +1 -3
- package/lib/utils/testing.d.ts +1 -1
- package/lib-esm/ActionMenu.js +2 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +9 -9
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +9 -9
- package/lib-esm/Button/Button.d.ts +11 -11
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +29 -29
- package/lib-esm/Button/ButtonDanger.d.ts +11 -11
- package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
- package/lib-esm/Button/ButtonOutline.d.ts +11 -11
- package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
- package/lib-esm/Button/ButtonStyles.js +1 -1
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +33 -33
- package/lib-esm/Dialog/Dialog.d.ts +5 -5
- package/lib-esm/Dialog/Dialog.js +21 -13
- package/lib-esm/Dialog.d.ts +35 -35
- package/lib-esm/Dropdown.d.ts +692 -60
- package/lib-esm/Dropdown.js +3 -4
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib-esm/FilterList.d.ts +26 -26
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +149 -149
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +9 -9
- package/lib-esm/Timeline.d.ts +33 -33
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/_TextInputWrapper.d.ts +1 -1
- package/lib-esm/constants.js +1 -3
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package.json +2 -1
- package/lib/NewButton/button.d.ts +0 -24
- package/lib/NewButton/button.js +0 -292
- package/lib/NewButton/counter.d.ts +0 -6
- package/lib/NewButton/counter.js +0 -33
- package/lib/NewButton/index.d.ts +0 -4
- package/lib/NewButton/index.js +0 -21
- package/lib-esm/NewButton/button.d.ts +0 -24
- package/lib-esm/NewButton/button.js +0 -268
- package/lib-esm/NewButton/counter.d.ts +0 -6
- package/lib-esm/NewButton/counter.js +0 -21
- package/lib-esm/NewButton/index.d.ts +0 -4
- package/lib-esm/NewButton/index.js +0 -3
package/lib/NewButton/button.js
DELETED
@@ -1,292 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
|
-
var _octiconsReact = require("@primer/octicons-react");
|
11
|
-
|
12
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
13
|
-
|
14
|
-
var _styledSystem = require("styled-system");
|
15
|
-
|
16
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
17
|
-
|
18
|
-
var _sx = _interopRequireDefault(require("../sx"));
|
19
|
-
|
20
|
-
var _constants = require("../constants");
|
21
|
-
|
22
|
-
var _ButtonStyles = _interopRequireDefault(require("../Button/ButtonStyles"));
|
23
|
-
|
24
|
-
var _counter = _interopRequireDefault(require("./counter"));
|
25
|
-
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
|
-
|
28
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
29
|
-
|
30
|
-
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; }
|
31
|
-
|
32
|
-
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); }
|
33
|
-
|
34
|
-
const sizes = (0, _styledSystem.variant)({
|
35
|
-
prop: 'size',
|
36
|
-
variants: {
|
37
|
-
small: {
|
38
|
-
p: '4px 12px',
|
39
|
-
fontSize: 0
|
40
|
-
},
|
41
|
-
medium: {
|
42
|
-
fontSize: 1
|
43
|
-
},
|
44
|
-
large: {
|
45
|
-
fontSize: 2,
|
46
|
-
p: '10px 20px'
|
47
|
-
}
|
48
|
-
}
|
49
|
-
});
|
50
|
-
|
51
|
-
const getVariantStyles = (theme, variant = 'default') => {
|
52
|
-
const style = {
|
53
|
-
default: `
|
54
|
-
padding: 5px 16px;
|
55
|
-
color: ${(0, _constants.get)('colors.btn.text')({
|
56
|
-
theme
|
57
|
-
})};
|
58
|
-
background-color: ${(0, _constants.get)('colors.btn.bg')({
|
59
|
-
theme
|
60
|
-
})};
|
61
|
-
border-width: 1px;
|
62
|
-
border-style: solid;
|
63
|
-
border-color: ${(0, _constants.get)('colors.btn.border')({
|
64
|
-
theme
|
65
|
-
})};
|
66
|
-
box-shadow: ${((0, _constants.get)('shadows.btn.shadow')({
|
67
|
-
theme
|
68
|
-
}), (0, _constants.get)('shadows.btn.insetShadow')({
|
69
|
-
theme
|
70
|
-
}))};
|
71
|
-
&:hover {
|
72
|
-
background-color: ${(0, _constants.get)('colors.btn.hoverBg')({
|
73
|
-
theme
|
74
|
-
})};
|
75
|
-
}
|
76
|
-
// focus must come before :active so that the active box shadow overrides
|
77
|
-
&:focus {
|
78
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.focusShadow')({
|
79
|
-
theme
|
80
|
-
})};
|
81
|
-
}
|
82
|
-
&:active {
|
83
|
-
background-color: ${(0, _constants.get)('colors.btn.selectedBg')({
|
84
|
-
theme
|
85
|
-
})};
|
86
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.shadowActive')({
|
87
|
-
theme
|
88
|
-
})};
|
89
|
-
}
|
90
|
-
&:disabled {
|
91
|
-
color: ${(0, _constants.get)('colors.primer.fg.disabled')({
|
92
|
-
theme
|
93
|
-
})};
|
94
|
-
}
|
95
|
-
`,
|
96
|
-
primary: `
|
97
|
-
padding: 5px 16px;
|
98
|
-
color: ${(0, _constants.get)('colors.btn.primary.text')({
|
99
|
-
theme
|
100
|
-
})};
|
101
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.bg')({
|
102
|
-
theme
|
103
|
-
})};
|
104
|
-
border-width: 1px;
|
105
|
-
border-style: solid;
|
106
|
-
border-color: ${(0, _constants.get)('colors.border.subtle')({
|
107
|
-
theme
|
108
|
-
})};
|
109
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.primary.shadow')({
|
110
|
-
theme
|
111
|
-
})};
|
112
|
-
|
113
|
-
&:hover {
|
114
|
-
color: ${(0, _constants.get)('colors.btn.primary.hoverText')({
|
115
|
-
theme
|
116
|
-
})};
|
117
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.hoverBg')({
|
118
|
-
theme
|
119
|
-
})};
|
120
|
-
}
|
121
|
-
// focus must come before :active so that the active box shadow overrides
|
122
|
-
&:focus {
|
123
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.primary.focusShadow')({
|
124
|
-
theme
|
125
|
-
})};
|
126
|
-
}
|
127
|
-
|
128
|
-
&:active {
|
129
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.selectedBg')({
|
130
|
-
theme
|
131
|
-
})};
|
132
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.primary.selectedShadow')({
|
133
|
-
theme
|
134
|
-
})};
|
135
|
-
}
|
136
|
-
|
137
|
-
&:disabled {
|
138
|
-
color: ${(0, _constants.get)('colors.btn.primary.disabledText')({
|
139
|
-
theme
|
140
|
-
})};
|
141
|
-
background-color: ${(0, _constants.get)('colors.btn.primary.disabledBg')({
|
142
|
-
theme
|
143
|
-
})};
|
144
|
-
}`,
|
145
|
-
danger: `
|
146
|
-
padding: 5px 16px;
|
147
|
-
color: ${(0, _constants.get)('colors.btn.danger.text')({
|
148
|
-
theme
|
149
|
-
})};
|
150
|
-
border: 1px solid ${(0, _constants.get)('colors.btn.border')({
|
151
|
-
theme
|
152
|
-
})};
|
153
|
-
background-color: ${(0, _constants.get)('colors.btn.bg')({
|
154
|
-
theme
|
155
|
-
})};
|
156
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.shadow')({
|
157
|
-
theme
|
158
|
-
})};
|
159
|
-
|
160
|
-
&:hover {
|
161
|
-
color: ${(0, _constants.get)('colors.btn.danger.hoverText')({
|
162
|
-
theme
|
163
|
-
})};
|
164
|
-
background-color: ${(0, _constants.get)('colors.btn.danger.hoverBg')({
|
165
|
-
theme
|
166
|
-
})};
|
167
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.hoverBorder')({
|
168
|
-
theme
|
169
|
-
})};
|
170
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.danger.hoverShadow')({
|
171
|
-
theme
|
172
|
-
})};
|
173
|
-
}
|
174
|
-
// focus must come before :active so that the active box shadow overrides
|
175
|
-
&:focus {
|
176
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.focusBorder')({
|
177
|
-
theme
|
178
|
-
})};
|
179
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.danger.focusShadow')({
|
180
|
-
theme
|
181
|
-
})};
|
182
|
-
}
|
183
|
-
|
184
|
-
&:active {
|
185
|
-
color: ${(0, _constants.get)('colors.btn.danger.selectedText')({
|
186
|
-
theme
|
187
|
-
})};
|
188
|
-
background-color: ${(0, _constants.get)('colors.btn.danger.selectedBg')({
|
189
|
-
theme
|
190
|
-
})};
|
191
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.danger.selectedShadow')({
|
192
|
-
theme
|
193
|
-
})};
|
194
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.selectedBorder')({
|
195
|
-
theme
|
196
|
-
})};
|
197
|
-
}
|
198
|
-
|
199
|
-
&:disabled {
|
200
|
-
color: ${(0, _constants.get)('colors.btn.danger.disabledText')({
|
201
|
-
theme
|
202
|
-
})};
|
203
|
-
background-color: ${(0, _constants.get)('colors.btn.danger.disabledBg')({
|
204
|
-
theme
|
205
|
-
})};
|
206
|
-
border-color: ${(0, _constants.get)('colors.btn.danger.disabledBorder')({
|
207
|
-
theme
|
208
|
-
})};
|
209
|
-
}
|
210
|
-
`,
|
211
|
-
invisible: `
|
212
|
-
padding: 6px 16px;
|
213
|
-
color: ${(0, _constants.get)('colors.accent.fg')({
|
214
|
-
theme
|
215
|
-
})};
|
216
|
-
background-color: transparent;
|
217
|
-
border: 0;
|
218
|
-
border-radius: ${(0, _constants.get)('radii.2')({
|
219
|
-
theme
|
220
|
-
})};
|
221
|
-
box-shadow: none;
|
222
|
-
|
223
|
-
&:disabled {
|
224
|
-
color: ${(0, _constants.get)('colors.primer.fg.disabled')({
|
225
|
-
theme
|
226
|
-
})};
|
227
|
-
}
|
228
|
-
&:focus {
|
229
|
-
box-shadow: ${(0, _constants.get)('shadows.btn.focusShadow')({
|
230
|
-
theme
|
231
|
-
})};
|
232
|
-
}
|
233
|
-
&:hover {
|
234
|
-
background-color: ${(0, _constants.get)('colors.btn.hoverBg')({
|
235
|
-
theme
|
236
|
-
})};
|
237
|
-
}
|
238
|
-
&:active {
|
239
|
-
background-color: ${(0, _constants.get)('colors.btn.selectedBg')({
|
240
|
-
theme
|
241
|
-
})};
|
242
|
-
}
|
243
|
-
`
|
244
|
-
};
|
245
|
-
return style[variant];
|
246
|
-
};
|
247
|
-
|
248
|
-
const ButtonBase = _styledComponents.default.button.withConfig({
|
249
|
-
displayName: "button__ButtonBase",
|
250
|
-
componentId: "sc-15k5iqk-0"
|
251
|
-
})(["", " ", " ", " ", " ", " ", ""], _ButtonStyles.default, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', _sx.default, _styledSystem.fontSize);
|
252
|
-
|
253
|
-
const Button = /*#__PURE__*/(0, _react.forwardRef)(({
|
254
|
-
icon: Icon,
|
255
|
-
caret,
|
256
|
-
children,
|
257
|
-
...props
|
258
|
-
}) => {
|
259
|
-
let iconOnly = false;
|
260
|
-
|
261
|
-
if (!children) {
|
262
|
-
iconOnly = true;
|
263
|
-
}
|
264
|
-
|
265
|
-
let iconWrapStyles = {
|
266
|
-
display: 'inline-block',
|
267
|
-
...(!iconOnly ? {
|
268
|
-
pr: 3
|
269
|
-
} : {})
|
270
|
-
};
|
271
|
-
return /*#__PURE__*/_react.default.createElement(ButtonBase, _extends({}, props, {
|
272
|
-
iconOnly: iconOnly
|
273
|
-
}), Icon && /*#__PURE__*/_react.default.createElement(_Box.default, {
|
274
|
-
sx: iconWrapStyles,
|
275
|
-
"aria-hidden": !iconOnly
|
276
|
-
}, /*#__PURE__*/_react.default.createElement(Icon, null)), children, caret && /*#__PURE__*/_react.default.createElement(_Box.default, {
|
277
|
-
sx: {
|
278
|
-
display: 'inline-block',
|
279
|
-
pl: 3
|
280
|
-
},
|
281
|
-
"aria-hidden": true
|
282
|
-
}, /*#__PURE__*/_react.default.createElement(_octiconsReact.TriangleDownIcon, null)));
|
283
|
-
});
|
284
|
-
Button.displayName = 'Button';
|
285
|
-
Button.defaultProps = {
|
286
|
-
size: 'medium'
|
287
|
-
};
|
288
|
-
const NewButton = Object.assign(Button, {
|
289
|
-
Counter: _counter.default
|
290
|
-
});
|
291
|
-
var _default = NewButton;
|
292
|
-
exports.default = _default;
|
package/lib/NewButton/counter.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
const styles = {
|
15
|
-
display: 'inline-block',
|
16
|
-
padding: '0px 6px',
|
17
|
-
backgroundColor: 'neutral.muted',
|
18
|
-
borderRadius: '50%',
|
19
|
-
marginLeft: '8px'
|
20
|
-
};
|
21
|
-
|
22
|
-
const Counter = ({
|
23
|
-
count
|
24
|
-
}) => {
|
25
|
-
// get this to announce new count. How? Change aria property for every render? or aria-live?
|
26
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
27
|
-
sx: styles
|
28
|
-
}, count);
|
29
|
-
};
|
30
|
-
|
31
|
-
Counter.displayName = "Counter";
|
32
|
-
var _default = Counter;
|
33
|
-
exports.default = _default;
|
package/lib/NewButton/index.d.ts
DELETED
package/lib/NewButton/index.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "ButtonProps", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _button.ButtonProps;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
exports.default = void 0;
|
13
|
-
|
14
|
-
var _button = _interopRequireWildcard(require("./button"));
|
15
|
-
|
16
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
17
|
-
|
18
|
-
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; }
|
19
|
-
|
20
|
-
var _default = _button.default;
|
21
|
-
exports.default = _default;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import React, { ReactNode } from 'react';
|
2
|
-
import { IconProps } from '@primer/octicons-react';
|
3
|
-
import { FontSizeProps } from 'styled-system';
|
4
|
-
import { SxProp } from '../sx';
|
5
|
-
declare type Variant = 'default' | 'primary' | 'invisible' | 'danger';
|
6
|
-
export declare type ButtonProps = {
|
7
|
-
caret?: boolean;
|
8
|
-
children: ReactNode;
|
9
|
-
variant: Variant;
|
10
|
-
size: 'small' | 'medium' | 'large';
|
11
|
-
icon?: React.FunctionComponent<IconProps>;
|
12
|
-
} & SxProp & FontSizeProps;
|
13
|
-
declare const NewButton: React.ForwardRefExoticComponent<{
|
14
|
-
caret?: boolean | undefined;
|
15
|
-
children: ReactNode;
|
16
|
-
variant: Variant;
|
17
|
-
size: 'small' | 'medium' | 'large';
|
18
|
-
icon?: React.FunctionComponent<IconProps> | undefined;
|
19
|
-
} & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
|
20
|
-
Counter: ({ count }: {
|
21
|
-
count: number;
|
22
|
-
}) => JSX.Element;
|
23
|
-
};
|
24
|
-
export default NewButton;
|
@@ -1,268 +0,0 @@
|
|
1
|
-
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); }
|
2
|
-
|
3
|
-
import React, { forwardRef } from 'react';
|
4
|
-
import { TriangleDownIcon } from '@primer/octicons-react';
|
5
|
-
import Box from '../Box';
|
6
|
-
import { fontSize, variant } from 'styled-system';
|
7
|
-
import styled from 'styled-components';
|
8
|
-
import sx from '../sx';
|
9
|
-
import { get } from '../constants';
|
10
|
-
import buttonBaseStyles from '../Button/ButtonStyles';
|
11
|
-
import Counter from './counter';
|
12
|
-
const sizes = variant({
|
13
|
-
prop: 'size',
|
14
|
-
variants: {
|
15
|
-
small: {
|
16
|
-
p: '4px 12px',
|
17
|
-
fontSize: 0
|
18
|
-
},
|
19
|
-
medium: {
|
20
|
-
fontSize: 1
|
21
|
-
},
|
22
|
-
large: {
|
23
|
-
fontSize: 2,
|
24
|
-
p: '10px 20px'
|
25
|
-
}
|
26
|
-
}
|
27
|
-
});
|
28
|
-
|
29
|
-
const getVariantStyles = (theme, variant = 'default') => {
|
30
|
-
const style = {
|
31
|
-
default: `
|
32
|
-
padding: 5px 16px;
|
33
|
-
color: ${get('colors.btn.text')({
|
34
|
-
theme
|
35
|
-
})};
|
36
|
-
background-color: ${get('colors.btn.bg')({
|
37
|
-
theme
|
38
|
-
})};
|
39
|
-
border-width: 1px;
|
40
|
-
border-style: solid;
|
41
|
-
border-color: ${get('colors.btn.border')({
|
42
|
-
theme
|
43
|
-
})};
|
44
|
-
box-shadow: ${(get('shadows.btn.shadow')({
|
45
|
-
theme
|
46
|
-
}), get('shadows.btn.insetShadow')({
|
47
|
-
theme
|
48
|
-
}))};
|
49
|
-
&:hover {
|
50
|
-
background-color: ${get('colors.btn.hoverBg')({
|
51
|
-
theme
|
52
|
-
})};
|
53
|
-
}
|
54
|
-
// focus must come before :active so that the active box shadow overrides
|
55
|
-
&:focus {
|
56
|
-
box-shadow: ${get('shadows.btn.focusShadow')({
|
57
|
-
theme
|
58
|
-
})};
|
59
|
-
}
|
60
|
-
&:active {
|
61
|
-
background-color: ${get('colors.btn.selectedBg')({
|
62
|
-
theme
|
63
|
-
})};
|
64
|
-
box-shadow: ${get('shadows.btn.shadowActive')({
|
65
|
-
theme
|
66
|
-
})};
|
67
|
-
}
|
68
|
-
&:disabled {
|
69
|
-
color: ${get('colors.primer.fg.disabled')({
|
70
|
-
theme
|
71
|
-
})};
|
72
|
-
}
|
73
|
-
`,
|
74
|
-
primary: `
|
75
|
-
padding: 5px 16px;
|
76
|
-
color: ${get('colors.btn.primary.text')({
|
77
|
-
theme
|
78
|
-
})};
|
79
|
-
background-color: ${get('colors.btn.primary.bg')({
|
80
|
-
theme
|
81
|
-
})};
|
82
|
-
border-width: 1px;
|
83
|
-
border-style: solid;
|
84
|
-
border-color: ${get('colors.border.subtle')({
|
85
|
-
theme
|
86
|
-
})};
|
87
|
-
box-shadow: ${get('shadows.btn.primary.shadow')({
|
88
|
-
theme
|
89
|
-
})};
|
90
|
-
|
91
|
-
&:hover {
|
92
|
-
color: ${get('colors.btn.primary.hoverText')({
|
93
|
-
theme
|
94
|
-
})};
|
95
|
-
background-color: ${get('colors.btn.primary.hoverBg')({
|
96
|
-
theme
|
97
|
-
})};
|
98
|
-
}
|
99
|
-
// focus must come before :active so that the active box shadow overrides
|
100
|
-
&:focus {
|
101
|
-
box-shadow: ${get('shadows.btn.primary.focusShadow')({
|
102
|
-
theme
|
103
|
-
})};
|
104
|
-
}
|
105
|
-
|
106
|
-
&:active {
|
107
|
-
background-color: ${get('colors.btn.primary.selectedBg')({
|
108
|
-
theme
|
109
|
-
})};
|
110
|
-
box-shadow: ${get('shadows.btn.primary.selectedShadow')({
|
111
|
-
theme
|
112
|
-
})};
|
113
|
-
}
|
114
|
-
|
115
|
-
&:disabled {
|
116
|
-
color: ${get('colors.btn.primary.disabledText')({
|
117
|
-
theme
|
118
|
-
})};
|
119
|
-
background-color: ${get('colors.btn.primary.disabledBg')({
|
120
|
-
theme
|
121
|
-
})};
|
122
|
-
}`,
|
123
|
-
danger: `
|
124
|
-
padding: 5px 16px;
|
125
|
-
color: ${get('colors.btn.danger.text')({
|
126
|
-
theme
|
127
|
-
})};
|
128
|
-
border: 1px solid ${get('colors.btn.border')({
|
129
|
-
theme
|
130
|
-
})};
|
131
|
-
background-color: ${get('colors.btn.bg')({
|
132
|
-
theme
|
133
|
-
})};
|
134
|
-
box-shadow: ${get('shadows.btn.shadow')({
|
135
|
-
theme
|
136
|
-
})};
|
137
|
-
|
138
|
-
&:hover {
|
139
|
-
color: ${get('colors.btn.danger.hoverText')({
|
140
|
-
theme
|
141
|
-
})};
|
142
|
-
background-color: ${get('colors.btn.danger.hoverBg')({
|
143
|
-
theme
|
144
|
-
})};
|
145
|
-
border-color: ${get('colors.btn.danger.hoverBorder')({
|
146
|
-
theme
|
147
|
-
})};
|
148
|
-
box-shadow: ${get('shadows.btn.danger.hoverShadow')({
|
149
|
-
theme
|
150
|
-
})};
|
151
|
-
}
|
152
|
-
// focus must come before :active so that the active box shadow overrides
|
153
|
-
&:focus {
|
154
|
-
border-color: ${get('colors.btn.danger.focusBorder')({
|
155
|
-
theme
|
156
|
-
})};
|
157
|
-
box-shadow: ${get('shadows.btn.danger.focusShadow')({
|
158
|
-
theme
|
159
|
-
})};
|
160
|
-
}
|
161
|
-
|
162
|
-
&:active {
|
163
|
-
color: ${get('colors.btn.danger.selectedText')({
|
164
|
-
theme
|
165
|
-
})};
|
166
|
-
background-color: ${get('colors.btn.danger.selectedBg')({
|
167
|
-
theme
|
168
|
-
})};
|
169
|
-
box-shadow: ${get('shadows.btn.danger.selectedShadow')({
|
170
|
-
theme
|
171
|
-
})};
|
172
|
-
border-color: ${get('colors.btn.danger.selectedBorder')({
|
173
|
-
theme
|
174
|
-
})};
|
175
|
-
}
|
176
|
-
|
177
|
-
&:disabled {
|
178
|
-
color: ${get('colors.btn.danger.disabledText')({
|
179
|
-
theme
|
180
|
-
})};
|
181
|
-
background-color: ${get('colors.btn.danger.disabledBg')({
|
182
|
-
theme
|
183
|
-
})};
|
184
|
-
border-color: ${get('colors.btn.danger.disabledBorder')({
|
185
|
-
theme
|
186
|
-
})};
|
187
|
-
}
|
188
|
-
`,
|
189
|
-
invisible: `
|
190
|
-
padding: 6px 16px;
|
191
|
-
color: ${get('colors.accent.fg')({
|
192
|
-
theme
|
193
|
-
})};
|
194
|
-
background-color: transparent;
|
195
|
-
border: 0;
|
196
|
-
border-radius: ${get('radii.2')({
|
197
|
-
theme
|
198
|
-
})};
|
199
|
-
box-shadow: none;
|
200
|
-
|
201
|
-
&:disabled {
|
202
|
-
color: ${get('colors.primer.fg.disabled')({
|
203
|
-
theme
|
204
|
-
})};
|
205
|
-
}
|
206
|
-
&:focus {
|
207
|
-
box-shadow: ${get('shadows.btn.focusShadow')({
|
208
|
-
theme
|
209
|
-
})};
|
210
|
-
}
|
211
|
-
&:hover {
|
212
|
-
background-color: ${get('colors.btn.hoverBg')({
|
213
|
-
theme
|
214
|
-
})};
|
215
|
-
}
|
216
|
-
&:active {
|
217
|
-
background-color: ${get('colors.btn.selectedBg')({
|
218
|
-
theme
|
219
|
-
})};
|
220
|
-
}
|
221
|
-
`
|
222
|
-
};
|
223
|
-
return style[variant];
|
224
|
-
};
|
225
|
-
|
226
|
-
const ButtonBase = styled.button.withConfig({
|
227
|
-
displayName: "button__ButtonBase",
|
228
|
-
componentId: "sc-15k5iqk-0"
|
229
|
-
})(["", " ", " ", " ", " ", " ", ""], buttonBaseStyles, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', sx, fontSize);
|
230
|
-
const Button = /*#__PURE__*/forwardRef(({
|
231
|
-
icon: Icon,
|
232
|
-
caret,
|
233
|
-
children,
|
234
|
-
...props
|
235
|
-
}) => {
|
236
|
-
let iconOnly = false;
|
237
|
-
|
238
|
-
if (!children) {
|
239
|
-
iconOnly = true;
|
240
|
-
}
|
241
|
-
|
242
|
-
let iconWrapStyles = {
|
243
|
-
display: 'inline-block',
|
244
|
-
...(!iconOnly ? {
|
245
|
-
pr: 3
|
246
|
-
} : {})
|
247
|
-
};
|
248
|
-
return /*#__PURE__*/React.createElement(ButtonBase, _extends({}, props, {
|
249
|
-
iconOnly: iconOnly
|
250
|
-
}), Icon && /*#__PURE__*/React.createElement(Box, {
|
251
|
-
sx: iconWrapStyles,
|
252
|
-
"aria-hidden": !iconOnly
|
253
|
-
}, /*#__PURE__*/React.createElement(Icon, null)), children, caret && /*#__PURE__*/React.createElement(Box, {
|
254
|
-
sx: {
|
255
|
-
display: 'inline-block',
|
256
|
-
pl: 3
|
257
|
-
},
|
258
|
-
"aria-hidden": true
|
259
|
-
}, /*#__PURE__*/React.createElement(TriangleDownIcon, null)));
|
260
|
-
});
|
261
|
-
Button.displayName = 'Button';
|
262
|
-
Button.defaultProps = {
|
263
|
-
size: 'medium'
|
264
|
-
};
|
265
|
-
const NewButton = Object.assign(Button, {
|
266
|
-
Counter
|
267
|
-
});
|
268
|
-
export default NewButton;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import Box from '../Box';
|
3
|
-
const styles = {
|
4
|
-
display: 'inline-block',
|
5
|
-
padding: '0px 6px',
|
6
|
-
backgroundColor: 'neutral.muted',
|
7
|
-
borderRadius: '50%',
|
8
|
-
marginLeft: '8px'
|
9
|
-
};
|
10
|
-
|
11
|
-
const Counter = ({
|
12
|
-
count
|
13
|
-
}) => {
|
14
|
-
// get this to announce new count. How? Change aria property for every render? or aria-live?
|
15
|
-
return /*#__PURE__*/React.createElement(Box, {
|
16
|
-
sx: styles
|
17
|
-
}, count);
|
18
|
-
};
|
19
|
-
|
20
|
-
Counter.displayName = "Counter";
|
21
|
-
export default Counter;
|