@zendeskgarden/react-buttons 9.0.0-next.6 → 9.0.0-next.8
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/esm/elements/Anchor.js +54 -0
- package/dist/esm/elements/Button.js +49 -0
- package/dist/esm/elements/ChevronButton.js +27 -0
- package/dist/esm/elements/IconButton.js +50 -0
- package/dist/esm/elements/SplitButton.js +29 -0
- package/dist/esm/elements/ToggleButton.js +30 -0
- package/dist/esm/elements/ToggleIconButton.js +32 -0
- package/dist/esm/elements/components/EndIcon.js +21 -0
- package/dist/esm/elements/components/StartIcon.js +21 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/styled/StyledAnchor.js +27 -0
- package/dist/esm/styled/StyledButton.js +155 -0
- package/dist/esm/styled/StyledExternalIcon.js +23 -0
- package/dist/esm/styled/StyledIcon.js +40 -0
- package/dist/esm/styled/StyledIconButton.js +39 -0
- package/dist/esm/styled/StyledSplitButton.js +22 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/utils/useSplitButtonContext.js +14 -0
- package/dist/index.cjs.js +28 -40
- package/package.json +5 -5
- package/dist/index.esm.js +0 -484
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledButton, getHeight } from './StyledButton.js';
|
|
10
|
+
import { StyledIcon } from './StyledIcon.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'buttons.icon_button';
|
|
13
|
+
const iconColorStyles = props => {
|
|
14
|
+
const shade = 600;
|
|
15
|
+
const baseColor = getColorV8('neutralHue', shade, props.theme);
|
|
16
|
+
const hoverColor = getColorV8('neutralHue', shade + 100, props.theme);
|
|
17
|
+
const activeColor = getColorV8('neutralHue', shade + 200, props.theme);
|
|
18
|
+
return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
19
|
+
};
|
|
20
|
+
const iconButtonStyles = props => {
|
|
21
|
+
const width = getHeight(props);
|
|
22
|
+
return css(["border:", ";padding:0;width:", ";min-width:", ";", ";&:disabled{background-color:", ";}"], props.isBasic && 'none', width, width, props.isBasic && !(props.isPrimary || props.isDanger || props.disabled) && iconColorStyles(props), !props.isPrimary && 'transparent');
|
|
23
|
+
};
|
|
24
|
+
const iconStyles = props => {
|
|
25
|
+
const size = props.theme.iconSizes.md;
|
|
26
|
+
return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
|
|
27
|
+
};
|
|
28
|
+
const StyledIconButton = styled(StyledButton).attrs({
|
|
29
|
+
'data-garden-id': COMPONENT_ID,
|
|
30
|
+
'data-garden-version': '9.0.0-next.8'
|
|
31
|
+
}).withConfig({
|
|
32
|
+
displayName: "StyledIconButton",
|
|
33
|
+
componentId: "sc-1t0ughp-0"
|
|
34
|
+
})(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
35
|
+
StyledIconButton.defaultProps = {
|
|
36
|
+
theme: DEFAULT_THEME
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { StyledIconButton };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'buttons.button_group_view';
|
|
11
|
+
const StyledSplitButton = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.8'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledSplitButton",
|
|
16
|
+
componentId: "sc-1u4v04v-0"
|
|
17
|
+
})(["display:inline-flex;position:relative;z-index:0;direction:", ";white-space:nowrap;", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledSplitButton.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledSplitButton };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const SplitButtonContext = createContext(undefined);
|
|
10
|
+
const useSplitButtonContext = () => {
|
|
11
|
+
return useContext(SplitButtonContext);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { SplitButtonContext, useSplitButtonContext };
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
8
7
|
'use strict';
|
|
9
8
|
|
|
10
9
|
var React = require('react');
|
|
@@ -37,27 +36,12 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
37
36
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
38
37
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
39
38
|
|
|
40
|
-
function _extends$2() {
|
|
41
|
-
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
42
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
43
|
-
var source = arguments[i];
|
|
44
|
-
for (var key in source) {
|
|
45
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
46
|
-
target[key] = source[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return target;
|
|
51
|
-
};
|
|
52
|
-
return _extends$2.apply(this, arguments);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
39
|
const SIZE = ['small', 'medium', 'large'];
|
|
56
40
|
|
|
57
41
|
const COMPONENT_ID$5 = 'buttons.button_group_view';
|
|
58
42
|
const StyledSplitButton = styled__default.default.div.attrs({
|
|
59
43
|
'data-garden-id': COMPONENT_ID$5,
|
|
60
|
-
'data-garden-version': '9.0.0-next.
|
|
44
|
+
'data-garden-version': '9.0.0-next.8'
|
|
61
45
|
}).withConfig({
|
|
62
46
|
displayName: "StyledSplitButton",
|
|
63
47
|
componentId: "sc-1u4v04v-0"
|
|
@@ -86,7 +70,7 @@ const StyledIcon = styled__default.default(_ref => {
|
|
|
86
70
|
return React__namespace.default.cloneElement(React.Children.only(children), props);
|
|
87
71
|
}).attrs({
|
|
88
72
|
'data-garden-id': COMPONENT_ID$4,
|
|
89
|
-
'data-garden-version': '9.0.0-next.
|
|
73
|
+
'data-garden-version': '9.0.0-next.8'
|
|
90
74
|
}).withConfig({
|
|
91
75
|
displayName: "StyledIcon",
|
|
92
76
|
componentId: "sc-19meqgg-0"
|
|
@@ -154,13 +138,13 @@ const colorStyles = props => {
|
|
|
154
138
|
const foregroundColor = props.isNeutral ? reactTheming.getColorV8('foreground', 600 , props.theme) : baseColor;
|
|
155
139
|
const hoverBorderColor = props.isNeutral && !props.isDanger ? baseColor : hoverColor;
|
|
156
140
|
const hoverForegroundColor = props.isNeutral ? foregroundColor : hoverColor;
|
|
157
|
-
retVal = styled.css(["outline-color:transparent;border-color:", ";background-color:transparent;color:", ";&:hover{border-color:", ";background-color:", ";color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{border-color:", ";background-color:", ";color:", ";}&:disabled{border-color:transparent;background-color:", ";color:", ";}& ", "{color:", ";}&:hover ", ",&:focus-visible ", "
|
|
141
|
+
retVal = styled.css(["outline-color:transparent;border-color:", ";background-color:transparent;color:", ";&:hover{border-color:", ";background-color:", ";color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{border-color:", ";background-color:", ";color:", ";}&:disabled{border-color:transparent;background-color:", ";color:", ";}& ", "{color:", ";}&:hover ", ",&:focus-visible ", "{color:", ";}&:active ", "{color:", ";}&:disabled ", "{color:", ";}"], !props.isBasic && borderColor, foregroundColor, !props.isBasic && hoverBorderColor, polished.rgba(baseColor, 0.08), hoverForegroundColor, reactTheming.focusStyles({
|
|
158
142
|
theme: props.theme,
|
|
159
143
|
inset: props.focusInset,
|
|
160
144
|
styles: props.isNeutral ? {
|
|
161
145
|
borderColor: baseColor
|
|
162
146
|
} : undefined
|
|
163
|
-
}), !props.isBasic && activeColor, polished.rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && reactTheming.getColorV8('neutralHue', shade, props.theme), StyledIcon, StyledIcon,
|
|
147
|
+
}), !props.isBasic && activeColor, polished.rgba(baseColor, 0.2), !props.isNeutral && activeColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, props.isNeutral && reactTheming.getColorV8('neutralHue', shade, props.theme), StyledIcon, StyledIcon, props.isNeutral && reactTheming.getColorV8('neutralHue', shade + 100, props.theme), StyledIcon, props.isNeutral && foregroundColor, StyledIcon, disabledForegroundColor);
|
|
164
148
|
}
|
|
165
149
|
return retVal;
|
|
166
150
|
};
|
|
@@ -188,8 +172,12 @@ const groupStyles = props => {
|
|
|
188
172
|
const focusBoxShadow = isBasic && !isPrimary && reactTheming.getFocusBoxShadow({
|
|
189
173
|
theme,
|
|
190
174
|
inset: focusInset,
|
|
191
|
-
|
|
192
|
-
|
|
175
|
+
spacerColor: {
|
|
176
|
+
hue: focusColor
|
|
177
|
+
},
|
|
178
|
+
color: {
|
|
179
|
+
hue: 'transparent'
|
|
180
|
+
}
|
|
193
181
|
});
|
|
194
182
|
return styled.css(["position:relative;transition:border-color 0.1s ease-in-out,background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out,color 0.1s ease-in-out,margin-", " 0.1s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;border:", " ", ";", "{border-color:", ";box-shadow:", ";}&:hover,&:active,", "{z-index:1;}&:disabled{z-index:-1;background-color:", ";}&:not(:first-of-type){margin-", ":", ";}&:not(:first-of-type):disabled{margin-", ":", ";}&:not(:first-of-type):not(:last-of-type){border-radius:0;}&:first-of-type:not(:last-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:last-of-type:not(:first-of-type){border-top-", "-radius:0;border-bottom-", "-radius:0;}&:first-of-type:not(:last-of-type) ", "{margin-", ":", ";}&:last-of-type:not(:first-of-type) ", "{margin-", ":", ";}"], startPosition, borders.sm, borderColor, reactTheming.SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, reactTheming.SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
|
|
195
183
|
};
|
|
@@ -223,7 +211,7 @@ const sizeStyles = props => {
|
|
|
223
211
|
};
|
|
224
212
|
const StyledButton = styled__default.default.button.attrs(props => ({
|
|
225
213
|
'data-garden-id': COMPONENT_ID$3,
|
|
226
|
-
'data-garden-version': '9.0.0-next.
|
|
214
|
+
'data-garden-version': '9.0.0-next.8',
|
|
227
215
|
type: props.type || 'button'
|
|
228
216
|
})).withConfig({
|
|
229
217
|
displayName: "StyledButton",
|
|
@@ -236,7 +224,7 @@ StyledButton.defaultProps = {
|
|
|
236
224
|
const COMPONENT_ID$2 = 'buttons.anchor';
|
|
237
225
|
const StyledAnchor = styled__default.default(StyledButton).attrs(props => ({
|
|
238
226
|
'data-garden-id': COMPONENT_ID$2,
|
|
239
|
-
'data-garden-version': '9.0.0-next.
|
|
227
|
+
'data-garden-version': '9.0.0-next.8',
|
|
240
228
|
as: 'a',
|
|
241
229
|
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
242
230
|
isLink: true,
|
|
@@ -270,7 +258,7 @@ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
|
270
258
|
const COMPONENT_ID$1 = 'buttons.external_icon';
|
|
271
259
|
const StyledExternalIcon = styled__default.default(SvgNewWindowStroke).attrs({
|
|
272
260
|
'data-garden-id': COMPONENT_ID$1,
|
|
273
|
-
'data-garden-version': '9.0.0-next.
|
|
261
|
+
'data-garden-version': '9.0.0-next.8'
|
|
274
262
|
}).withConfig({
|
|
275
263
|
displayName: "StyledExternalIcon",
|
|
276
264
|
componentId: "sc-16oz07e-0"
|
|
@@ -297,7 +285,7 @@ const iconStyles = props => {
|
|
|
297
285
|
};
|
|
298
286
|
const StyledIconButton = styled__default.default(StyledButton).attrs({
|
|
299
287
|
'data-garden-id': COMPONENT_ID,
|
|
300
|
-
'data-garden-version': '9.0.0-next.
|
|
288
|
+
'data-garden-version': '9.0.0-next.8'
|
|
301
289
|
}).withConfig({
|
|
302
290
|
displayName: "StyledIconButton",
|
|
303
291
|
componentId: "sc-1t0ughp-0"
|
|
@@ -311,13 +299,13 @@ const useSplitButtonContext = () => {
|
|
|
311
299
|
return React.useContext(SplitButtonContext);
|
|
312
300
|
};
|
|
313
301
|
|
|
314
|
-
const StartIconComponent = props => React__namespace.default.createElement(StyledIcon,
|
|
302
|
+
const StartIconComponent = props => React__namespace.default.createElement(StyledIcon, Object.assign({
|
|
315
303
|
position: "start"
|
|
316
304
|
}, props));
|
|
317
305
|
StartIconComponent.displayName = 'Button.StartIcon';
|
|
318
306
|
const StartIcon = StartIconComponent;
|
|
319
307
|
|
|
320
|
-
const EndIconComponent = props => React__namespace.default.createElement(StyledIcon,
|
|
308
|
+
const EndIconComponent = props => React__namespace.default.createElement(StyledIcon, Object.assign({
|
|
321
309
|
position: "end"
|
|
322
310
|
}, props));
|
|
323
311
|
EndIconComponent.displayName = 'Button.EndIcon';
|
|
@@ -329,7 +317,7 @@ const ButtonComponent = React.forwardRef((props, ref) => {
|
|
|
329
317
|
...props,
|
|
330
318
|
focusInset: props.focusInset || splitButtonContext
|
|
331
319
|
};
|
|
332
|
-
return React__namespace.default.createElement(StyledButton,
|
|
320
|
+
return React__namespace.default.createElement(StyledButton, Object.assign({}, computedProps, {
|
|
333
321
|
ref: ref
|
|
334
322
|
}));
|
|
335
323
|
});
|
|
@@ -373,7 +361,7 @@ const Anchor = React.forwardRef((_ref, ref) => {
|
|
|
373
361
|
noIconLabel: 'true'
|
|
374
362
|
};
|
|
375
363
|
const iconAriaLabel = reactTheming.useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
376
|
-
return React__namespace.default.createElement(StyledAnchor,
|
|
364
|
+
return React__namespace.default.createElement(StyledAnchor, Object.assign({
|
|
377
365
|
ref: ref
|
|
378
366
|
}, anchorProps), children, isExternal &&
|
|
379
367
|
React__namespace.default.createElement(StyledExternalIcon, {
|
|
@@ -396,7 +384,7 @@ const IconButton = React.forwardRef((_ref, ref) => {
|
|
|
396
384
|
...otherProps
|
|
397
385
|
} = _ref;
|
|
398
386
|
const focusInset = useSplitButtonContext();
|
|
399
|
-
return React__namespace.default.createElement(StyledIconButton,
|
|
387
|
+
return React__namespace.default.createElement(StyledIconButton, Object.assign({
|
|
400
388
|
ref: ref
|
|
401
389
|
}, otherProps, {
|
|
402
390
|
focusInset: otherProps.focusInset || focusInset
|
|
@@ -441,7 +429,7 @@ const ChevronButton = React.forwardRef((_ref, ref) => {
|
|
|
441
429
|
let {
|
|
442
430
|
...buttonProps
|
|
443
431
|
} = _ref;
|
|
444
|
-
return React__namespace.default.createElement(IconButton,
|
|
432
|
+
return React__namespace.default.createElement(IconButton, Object.assign({
|
|
445
433
|
ref: ref
|
|
446
434
|
}, buttonProps), React__namespace.default.createElement(SvgChevronDownStroke, null));
|
|
447
435
|
});
|
|
@@ -460,7 +448,7 @@ const SplitButton = React.forwardRef((_ref, ref) => {
|
|
|
460
448
|
} = _ref;
|
|
461
449
|
return React__namespace.default.createElement(SplitButtonContext.Provider, {
|
|
462
450
|
value: true
|
|
463
|
-
}, React__namespace.default.createElement(StyledSplitButton,
|
|
451
|
+
}, React__namespace.default.createElement(StyledSplitButton, Object.assign({
|
|
464
452
|
ref: ref
|
|
465
453
|
}, other), children));
|
|
466
454
|
});
|
|
@@ -471,7 +459,7 @@ const ToggleButton = React.forwardRef((_ref, ref) => {
|
|
|
471
459
|
isPressed,
|
|
472
460
|
...otherProps
|
|
473
461
|
} = _ref;
|
|
474
|
-
return React__namespace.default.createElement(Button,
|
|
462
|
+
return React__namespace.default.createElement(Button, Object.assign({
|
|
475
463
|
"aria-pressed": isPressed,
|
|
476
464
|
ref: ref
|
|
477
465
|
}, otherProps));
|
|
@@ -490,7 +478,7 @@ const ToggleIconButton = React.forwardRef((_ref, ref) => {
|
|
|
490
478
|
isPressed,
|
|
491
479
|
...otherProps
|
|
492
480
|
} = _ref;
|
|
493
|
-
return React__namespace.default.createElement(IconButton,
|
|
481
|
+
return React__namespace.default.createElement(IconButton, Object.assign({
|
|
494
482
|
"aria-pressed": isPressed,
|
|
495
483
|
ref: ref
|
|
496
484
|
}, otherProps));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-buttons",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.8",
|
|
4
4
|
"description": "Components relating to buttons in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "https://github.com/zendeskgarden/react-components/issues"
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.cjs.js",
|
|
13
|
-
"module": "dist/index.
|
|
13
|
+
"module": "dist/esm/index.js",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"react-merge-refs": "^2.0.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@zendeskgarden/react-theming": "
|
|
30
|
+
"@zendeskgarden/react-theming": ">=9.0.0-next",
|
|
31
31
|
"react": ">=16.8.0",
|
|
32
32
|
"react-dom": ">=16.8.0",
|
|
33
33
|
"styled-components": "^5.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@zendeskgarden/react-theming": "^9.0.0-next.
|
|
36
|
+
"@zendeskgarden/react-theming": "^9.0.0-next.8",
|
|
37
37
|
"@zendeskgarden/svg-icons": "7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"zendeskgarden:src": "src/index.ts",
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a3d6534843d5a4f5cb60b52bc67264f3230f2da0"
|
|
50
50
|
}
|