@zendeskgarden/react-buttons 9.0.0-next.9 → 9.1.0
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 +10 -5
- package/dist/esm/elements/Button.js +30 -12
- package/dist/esm/elements/ChevronButton.js +3 -8
- package/dist/esm/elements/IconButton.js +22 -10
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js +1 -1
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +1 -1
- package/dist/esm/styled/StyledAnchor.js +4 -7
- package/dist/esm/styled/StyledButton.js +239 -76
- package/dist/esm/styled/StyledExternalIcon.js +2 -5
- package/dist/esm/styled/StyledIcon.js +2 -5
- package/dist/esm/styled/StyledIconButton.js +38 -16
- package/dist/esm/styled/StyledSplitButton.js +2 -5
- package/dist/index.cjs.js +344 -141
- package/dist/typings/elements/Button.d.ts +3 -1
- package/dist/typings/styled/StyledAnchor.d.ts +1 -8
- package/dist/typings/styled/StyledButton.d.ts +16 -7
- package/dist/typings/styled/StyledIcon.d.ts +1 -2
- package/dist/typings/styled/StyledIconButton.d.ts +4 -3
- package/dist/typings/styled/index.d.ts +2 -2
- package/dist/typings/types/index.d.ts +2 -0
- package/dist/typings/utils/useSplitButtonContext.d.ts +0 -1
- package/package.json +7 -7
|
@@ -17,11 +17,13 @@ import { useText } from '@zendeskgarden/react-theming';
|
|
|
17
17
|
const Anchor = forwardRef((_ref, ref) => {
|
|
18
18
|
let {
|
|
19
19
|
children,
|
|
20
|
-
isExternal,
|
|
21
20
|
externalIconLabel,
|
|
22
|
-
|
|
21
|
+
isDanger,
|
|
22
|
+
isExternal,
|
|
23
|
+
isUnderlined = true,
|
|
24
|
+
...other
|
|
23
25
|
} = _ref;
|
|
24
|
-
let anchorProps =
|
|
26
|
+
let anchorProps = other;
|
|
25
27
|
if (isExternal) {
|
|
26
28
|
anchorProps = {
|
|
27
29
|
target: '_blank',
|
|
@@ -36,8 +38,10 @@ const Anchor = forwardRef((_ref, ref) => {
|
|
|
36
38
|
};
|
|
37
39
|
const iconAriaLabel = useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
|
|
38
40
|
return React__default.createElement(StyledAnchor, Object.assign({
|
|
39
|
-
ref: ref
|
|
40
|
-
|
|
41
|
+
ref: ref,
|
|
42
|
+
$isDanger: isDanger,
|
|
43
|
+
$isUnderlined: isUnderlined
|
|
44
|
+
}, anchorProps), children, !!isExternal &&
|
|
41
45
|
React__default.createElement(StyledExternalIcon, {
|
|
42
46
|
role: "img",
|
|
43
47
|
"aria-label": iconAriaLabel,
|
|
@@ -48,6 +52,7 @@ Anchor.displayName = 'Anchor';
|
|
|
48
52
|
Anchor.propTypes = {
|
|
49
53
|
isExternal: PropTypes.bool,
|
|
50
54
|
isDanger: PropTypes.bool,
|
|
55
|
+
isUnderlined: PropTypes.bool,
|
|
51
56
|
externalIconLabel: PropTypes.string
|
|
52
57
|
};
|
|
53
58
|
|
|
@@ -17,25 +17,43 @@ import { useSplitButtonContext } from '../utils/useSplitButtonContext.js';
|
|
|
17
17
|
import { StartIcon } from './components/StartIcon.js';
|
|
18
18
|
import { EndIcon } from './components/EndIcon.js';
|
|
19
19
|
|
|
20
|
-
const ButtonComponent = forwardRef((
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const ButtonComponent = forwardRef((_ref, ref) => {
|
|
21
|
+
let {
|
|
22
|
+
focusInset,
|
|
23
|
+
isBasic,
|
|
24
|
+
isDanger,
|
|
25
|
+
isLink,
|
|
26
|
+
isNeutral,
|
|
27
|
+
isPill,
|
|
28
|
+
isPrimary,
|
|
29
|
+
isStretched,
|
|
30
|
+
size,
|
|
31
|
+
...other
|
|
32
|
+
} = _ref;
|
|
33
|
+
const splitButtonFocusInset = useSplitButtonContext();
|
|
34
|
+
return React__default.createElement(StyledButton, Object.assign({}, other, {
|
|
35
|
+
$focusInset: focusInset || splitButtonFocusInset,
|
|
36
|
+
$isBasic: isBasic,
|
|
37
|
+
$isDanger: isDanger,
|
|
38
|
+
$isLink: isLink,
|
|
39
|
+
$isNeutral: isNeutral,
|
|
40
|
+
$isPill: isPill,
|
|
41
|
+
$isPrimary: isPrimary,
|
|
42
|
+
$isStretched: isStretched,
|
|
43
|
+
$isUnderlined: isLink,
|
|
44
|
+
$size: size,
|
|
27
45
|
ref: ref
|
|
28
46
|
}));
|
|
29
47
|
});
|
|
30
48
|
ButtonComponent.displayName = 'Button';
|
|
31
49
|
ButtonComponent.propTypes = {
|
|
32
|
-
isNeutral: PropTypes.bool,
|
|
33
|
-
isPrimary: PropTypes.bool,
|
|
34
|
-
isDanger: PropTypes.bool,
|
|
35
|
-
isPill: PropTypes.bool,
|
|
36
|
-
isBasic: PropTypes.bool,
|
|
37
50
|
focusInset: PropTypes.bool,
|
|
51
|
+
isBasic: PropTypes.bool,
|
|
52
|
+
isDanger: PropTypes.bool,
|
|
38
53
|
isLink: PropTypes.bool,
|
|
54
|
+
isNeutral: PropTypes.bool,
|
|
55
|
+
isPill: PropTypes.bool,
|
|
56
|
+
isPrimary: PropTypes.bool,
|
|
39
57
|
isStretched: PropTypes.bool,
|
|
40
58
|
size: PropTypes.oneOf(SIZE)
|
|
41
59
|
};
|
|
@@ -8,14 +8,9 @@ import React__default, { forwardRef } from 'react';
|
|
|
8
8
|
import { IconButton } from './IconButton.js';
|
|
9
9
|
import SvgChevronDownStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js';
|
|
10
10
|
|
|
11
|
-
const ChevronButton = forwardRef((
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref;
|
|
15
|
-
return React__default.createElement(IconButton, Object.assign({
|
|
16
|
-
ref: ref
|
|
17
|
-
}, buttonProps), React__default.createElement(SvgChevronDownStroke, null));
|
|
18
|
-
});
|
|
11
|
+
const ChevronButton = forwardRef((props, ref) => React__default.createElement(IconButton, Object.assign({
|
|
12
|
+
ref: ref
|
|
13
|
+
}, props), React__default.createElement(SvgChevronDownStroke, null)));
|
|
19
14
|
ChevronButton.displayName = 'ChevronButton';
|
|
20
15
|
ChevronButton.propTypes = IconButton.propTypes;
|
|
21
16
|
ChevronButton.defaultProps = {
|
|
@@ -18,28 +18,40 @@ import { useSplitButtonContext } from '../utils/useSplitButtonContext.js';
|
|
|
18
18
|
const IconButton = forwardRef((_ref, ref) => {
|
|
19
19
|
let {
|
|
20
20
|
children,
|
|
21
|
+
focusInset,
|
|
22
|
+
isBasic,
|
|
23
|
+
isDanger,
|
|
24
|
+
isNeutral,
|
|
25
|
+
isPill,
|
|
26
|
+
isPrimary,
|
|
21
27
|
isRotated,
|
|
22
|
-
|
|
28
|
+
size,
|
|
29
|
+
...other
|
|
23
30
|
} = _ref;
|
|
24
|
-
const
|
|
25
|
-
return React__default.createElement(StyledIconButton, Object.assign({
|
|
31
|
+
const splitButtonFocusInset = useSplitButtonContext();
|
|
32
|
+
return React__default.createElement(StyledIconButton, Object.assign({}, other, {
|
|
33
|
+
$isBasic: isBasic,
|
|
34
|
+
$isDanger: isDanger,
|
|
35
|
+
$isNeutral: isNeutral,
|
|
36
|
+
$isPill: isPill,
|
|
37
|
+
$isPrimary: isPrimary,
|
|
38
|
+
$size: size,
|
|
39
|
+
$focusInset: focusInset || splitButtonFocusInset,
|
|
26
40
|
ref: ref
|
|
27
|
-
}, otherProps, {
|
|
28
|
-
focusInset: otherProps.focusInset || focusInset
|
|
29
41
|
}), React__default.createElement(StyledIcon, {
|
|
30
42
|
$isRotated: isRotated
|
|
31
43
|
}, children));
|
|
32
44
|
});
|
|
33
45
|
IconButton.displayName = 'IconButton';
|
|
34
46
|
IconButton.propTypes = {
|
|
47
|
+
focusInset: PropTypes.bool,
|
|
48
|
+
isBasic: PropTypes.bool,
|
|
35
49
|
isDanger: PropTypes.bool,
|
|
36
|
-
size: PropTypes.oneOf(SIZE),
|
|
37
50
|
isNeutral: PropTypes.bool,
|
|
38
|
-
isPrimary: PropTypes.bool,
|
|
39
|
-
isBasic: PropTypes.bool,
|
|
40
51
|
isPill: PropTypes.bool,
|
|
41
|
-
|
|
42
|
-
isRotated: PropTypes.bool
|
|
52
|
+
isPrimary: PropTypes.bool,
|
|
53
|
+
isRotated: PropTypes.bool,
|
|
54
|
+
size: PropTypes.oneOf(SIZE)
|
|
43
55
|
};
|
|
44
56
|
IconButton.defaultProps = {
|
|
45
57
|
isPill: true,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
|
|
9
9
|
var _path;
|
|
10
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
10
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
11
11
|
var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
|
|
12
12
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
13
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
|
|
9
9
|
var _path;
|
|
10
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
10
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
11
11
|
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
12
12
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
13
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -5,23 +5,20 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { retrieveComponentStyles
|
|
8
|
+
import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
|
|
9
9
|
import { StyledButton } from './StyledButton.js';
|
|
10
10
|
|
|
11
11
|
const COMPONENT_ID = 'buttons.anchor';
|
|
12
12
|
const StyledAnchor = styled(StyledButton).attrs(props => ({
|
|
13
13
|
'data-garden-id': COMPONENT_ID,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.1.0',
|
|
15
15
|
as: 'a',
|
|
16
16
|
dir: props.theme.rtl ? 'rtl' : undefined,
|
|
17
|
-
isLink: true,
|
|
17
|
+
$isLink: true,
|
|
18
18
|
type: undefined
|
|
19
19
|
})).withConfig({
|
|
20
20
|
displayName: "StyledAnchor",
|
|
21
21
|
componentId: "sc-xshgmo-0"
|
|
22
|
-
})(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(
|
|
23
|
-
StyledAnchor.defaultProps = {
|
|
24
|
-
theme: DEFAULT_THEME
|
|
25
|
-
};
|
|
22
|
+
})(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(props['data-garden-id'], props));
|
|
26
23
|
|
|
27
24
|
export { StyledAnchor };
|
|
@@ -5,88 +5,248 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
|
-
import {
|
|
9
|
-
import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles,
|
|
8
|
+
import { math, em } from 'polished';
|
|
9
|
+
import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles, getColor, focusStyles, getFocusBoxShadow } from '@zendeskgarden/react-theming';
|
|
10
10
|
import { StyledSplitButton } from './StyledSplitButton.js';
|
|
11
11
|
import { StyledIcon } from './StyledIcon.js';
|
|
12
12
|
|
|
13
13
|
const COMPONENT_ID = 'buttons.button';
|
|
14
14
|
const getBorderRadius = props => {
|
|
15
|
-
if (props
|
|
15
|
+
if (props.$isPill) {
|
|
16
16
|
return '100px';
|
|
17
17
|
}
|
|
18
18
|
return props.theme.borderRadii.md;
|
|
19
19
|
};
|
|
20
|
-
const getDisabledBackgroundColor = props => {
|
|
21
|
-
return getColorV8('neutralHue', 200, props.theme);
|
|
22
|
-
};
|
|
23
20
|
const getHeight = props => {
|
|
24
|
-
if (props
|
|
21
|
+
if (props.$size === 'small') {
|
|
25
22
|
return `${props.theme.space.base * 8}px`;
|
|
26
|
-
} else if (props
|
|
23
|
+
} else if (props.$size === 'large') {
|
|
27
24
|
return `${props.theme.space.base * 12}px`;
|
|
28
25
|
}
|
|
29
26
|
return `${props.theme.space.base * 10}px`;
|
|
30
27
|
};
|
|
31
|
-
const colorStyles =
|
|
28
|
+
const colorStyles = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
theme,
|
|
31
|
+
$isLink,
|
|
32
|
+
$isBasic,
|
|
33
|
+
$isDanger,
|
|
34
|
+
$isNeutral,
|
|
35
|
+
$isPrimary,
|
|
36
|
+
$focusInset
|
|
37
|
+
} = _ref;
|
|
32
38
|
let retVal;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const disabledBackgroundColor = getColor({
|
|
40
|
+
theme,
|
|
41
|
+
variable: 'background.disabled'
|
|
42
|
+
});
|
|
43
|
+
const disabledForegroundColor = getColor({
|
|
44
|
+
theme,
|
|
45
|
+
variable: 'foreground.disabled'
|
|
46
|
+
});
|
|
47
|
+
const offset100 = {
|
|
48
|
+
dark: {
|
|
49
|
+
offset: -100
|
|
50
|
+
},
|
|
51
|
+
light: {
|
|
52
|
+
offset: 100
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const offset200 = {
|
|
56
|
+
dark: {
|
|
57
|
+
offset: -200
|
|
58
|
+
},
|
|
59
|
+
light: {
|
|
60
|
+
offset: 200
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
if ($isLink) {
|
|
64
|
+
const options = {
|
|
65
|
+
theme,
|
|
66
|
+
variable: $isDanger ? 'foreground.danger' : 'foreground.primary'
|
|
67
|
+
};
|
|
68
|
+
const foregroundColor = getColor(options);
|
|
69
|
+
const hoverForegroundColor = getColor({
|
|
70
|
+
...options,
|
|
71
|
+
...offset100
|
|
72
|
+
});
|
|
73
|
+
const activeForegroundColor = getColor({
|
|
74
|
+
...options,
|
|
75
|
+
...offset200
|
|
76
|
+
});
|
|
77
|
+
const focusOutlineColor = getColor({
|
|
78
|
+
theme,
|
|
79
|
+
variable: 'border.primaryEmphasis'
|
|
80
|
+
});
|
|
81
|
+
retVal = css(["outline-color:transparent;background-color:transparent;color:", ";", " &:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}&:disabled{color:", ";}"], foregroundColor, focusStyles({
|
|
82
|
+
theme,
|
|
51
83
|
condition: false,
|
|
52
84
|
styles: {
|
|
53
|
-
color:
|
|
54
|
-
outlineColor:
|
|
85
|
+
color: foregroundColor ,
|
|
86
|
+
outlineColor: focusOutlineColor
|
|
55
87
|
}
|
|
56
|
-
}),
|
|
57
|
-
} else if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
}), hoverForegroundColor, activeForegroundColor, disabledForegroundColor);
|
|
89
|
+
} else if ($isPrimary) {
|
|
90
|
+
let backgroundVariable;
|
|
91
|
+
if ($isDanger) {
|
|
92
|
+
backgroundVariable = 'background.dangerEmphasis';
|
|
93
|
+
} else if ($isNeutral) {
|
|
94
|
+
backgroundVariable = 'background.emphasis';
|
|
95
|
+
} else {
|
|
96
|
+
backgroundVariable = 'background.primaryEmphasis';
|
|
97
|
+
}
|
|
98
|
+
const options = {
|
|
99
|
+
theme,
|
|
100
|
+
variable: backgroundVariable
|
|
101
|
+
};
|
|
102
|
+
const backgroundColor = getColor(options);
|
|
103
|
+
const hoverBackgroundColor = getColor({
|
|
104
|
+
...options,
|
|
105
|
+
...offset100
|
|
106
|
+
});
|
|
107
|
+
const activeBackgroundColor = getColor({
|
|
108
|
+
...options,
|
|
109
|
+
...offset200
|
|
110
|
+
});
|
|
111
|
+
const foregroundColor = getColor({
|
|
112
|
+
theme,
|
|
113
|
+
variable: 'foreground.onEmphasis'
|
|
114
|
+
});
|
|
115
|
+
retVal = css(["outline-color:transparent;background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active,&[aria-pressed='true'],&[aria-pressed='mixed']{background-color:", ";}&:disabled{background-color:", ";color:", ";}"], backgroundColor, foregroundColor, hoverBackgroundColor, focusStyles({
|
|
116
|
+
theme,
|
|
117
|
+
inset: $focusInset,
|
|
118
|
+
shadowWidth: $focusInset ? 'sm' : 'md',
|
|
119
|
+
spacerWidth: $focusInset ? 'sm' : 'xs',
|
|
120
|
+
styles: ($isDanger || $isNeutral) && $focusInset ? {
|
|
121
|
+
borderColor: getColor({
|
|
122
|
+
theme,
|
|
123
|
+
variable: 'border.primaryEmphasis'
|
|
124
|
+
})
|
|
65
125
|
} : undefined
|
|
66
|
-
}),
|
|
126
|
+
}), activeBackgroundColor, disabledBackgroundColor, disabledForegroundColor);
|
|
67
127
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
128
|
+
let borderColor;
|
|
129
|
+
let hoverBorderColor;
|
|
130
|
+
let activeBorderColor;
|
|
131
|
+
let focusBorderColor;
|
|
132
|
+
let backgroundVariable;
|
|
133
|
+
let foregroundVariable;
|
|
134
|
+
if ($isDanger) {
|
|
135
|
+
if (!$isBasic) {
|
|
136
|
+
const borderOptions = {
|
|
137
|
+
theme,
|
|
138
|
+
variable: 'border.dangerEmphasis'
|
|
139
|
+
};
|
|
140
|
+
borderColor = getColor(borderOptions);
|
|
141
|
+
hoverBorderColor = getColor({
|
|
142
|
+
...borderOptions,
|
|
143
|
+
...offset100
|
|
144
|
+
});
|
|
145
|
+
activeBorderColor = getColor({
|
|
146
|
+
...borderOptions,
|
|
147
|
+
...offset200
|
|
148
|
+
});
|
|
149
|
+
if ($isNeutral) {
|
|
150
|
+
focusBorderColor = getColor(borderOptions);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
backgroundVariable = 'background.dangerEmphasis';
|
|
154
|
+
foregroundVariable = $isNeutral ? 'foreground.default' : 'foreground.danger';
|
|
155
|
+
} else {
|
|
156
|
+
if (!$isBasic) {
|
|
157
|
+
const borderOptions = {
|
|
158
|
+
theme,
|
|
159
|
+
variable: 'border.primaryEmphasis'
|
|
160
|
+
};
|
|
161
|
+
if ($isNeutral) {
|
|
162
|
+
borderColor = getColor({
|
|
163
|
+
theme,
|
|
164
|
+
variable: 'border.default',
|
|
165
|
+
...offset100
|
|
166
|
+
});
|
|
167
|
+
hoverBorderColor = getColor(borderOptions);
|
|
168
|
+
focusBorderColor = hoverBorderColor;
|
|
169
|
+
activeBorderColor = getColor({
|
|
170
|
+
...borderOptions,
|
|
171
|
+
...offset100
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
borderColor = getColor(borderOptions);
|
|
175
|
+
hoverBorderColor = getColor({
|
|
176
|
+
...borderOptions,
|
|
177
|
+
...offset100
|
|
178
|
+
});
|
|
179
|
+
activeBorderColor = getColor({
|
|
180
|
+
...borderOptions,
|
|
181
|
+
...offset200
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
backgroundVariable = 'background.primaryEmphasis';
|
|
186
|
+
foregroundVariable = $isNeutral ? 'foreground.default' : 'foreground.primary';
|
|
187
|
+
}
|
|
188
|
+
const hoverBackgroundColor = getColor({
|
|
189
|
+
theme,
|
|
190
|
+
variable: backgroundVariable,
|
|
191
|
+
transparency: theme.opacity[100]
|
|
192
|
+
});
|
|
193
|
+
const activeBackgroundColor = getColor({
|
|
194
|
+
theme,
|
|
195
|
+
variable: backgroundVariable,
|
|
196
|
+
transparency: theme.opacity[200]
|
|
197
|
+
});
|
|
198
|
+
const foregroundOptions = {
|
|
199
|
+
theme,
|
|
200
|
+
variable: foregroundVariable
|
|
201
|
+
};
|
|
202
|
+
const foregroundColor = getColor(foregroundOptions);
|
|
203
|
+
let hoverForegroundColor;
|
|
204
|
+
let activeForegroundColor;
|
|
205
|
+
let iconForegroundColor;
|
|
206
|
+
let hoverIconForegroundColor;
|
|
207
|
+
let activeIconForegroundColor;
|
|
208
|
+
if ($isNeutral) {
|
|
209
|
+
const iconOptions = {
|
|
210
|
+
theme,
|
|
211
|
+
variable: 'foreground.subtle'
|
|
212
|
+
};
|
|
213
|
+
iconForegroundColor = getColor(iconOptions);
|
|
214
|
+
hoverIconForegroundColor = getColor({
|
|
215
|
+
...iconOptions,
|
|
216
|
+
...offset100
|
|
217
|
+
});
|
|
218
|
+
activeIconForegroundColor = getColor({
|
|
219
|
+
...iconOptions,
|
|
220
|
+
...offset200
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
hoverForegroundColor = getColor({
|
|
224
|
+
...foregroundOptions,
|
|
225
|
+
...offset100
|
|
226
|
+
});
|
|
227
|
+
activeForegroundColor = getColor({
|
|
228
|
+
...foregroundOptions,
|
|
229
|
+
...offset200
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
retVal = 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:", ";}"], borderColor, foregroundColor, hoverBorderColor, hoverBackgroundColor, hoverForegroundColor, focusStyles({
|
|
233
|
+
theme,
|
|
234
|
+
inset: $focusInset,
|
|
235
|
+
styles: {
|
|
236
|
+
borderColor: focusBorderColor
|
|
237
|
+
}
|
|
238
|
+
}), activeBorderColor, activeBackgroundColor, activeForegroundColor, disabledBackgroundColor, disabledForegroundColor, StyledIcon, iconForegroundColor, StyledIcon, StyledIcon, hoverIconForegroundColor, StyledIcon, activeIconForegroundColor, StyledIcon, disabledForegroundColor);
|
|
79
239
|
}
|
|
80
240
|
return retVal;
|
|
81
241
|
};
|
|
82
|
-
const groupStyles =
|
|
83
|
-
|
|
242
|
+
const groupStyles = _ref2 => {
|
|
243
|
+
let {
|
|
84
244
|
theme,
|
|
85
|
-
isPrimary,
|
|
86
|
-
isBasic,
|
|
87
|
-
isPill,
|
|
88
|
-
focusInset
|
|
89
|
-
} =
|
|
245
|
+
$isPrimary,
|
|
246
|
+
$isBasic,
|
|
247
|
+
$isPill,
|
|
248
|
+
$focusInset
|
|
249
|
+
} = _ref2;
|
|
90
250
|
const {
|
|
91
251
|
rtl,
|
|
92
252
|
borderWidths,
|
|
@@ -95,14 +255,20 @@ const groupStyles = props => {
|
|
|
95
255
|
const startPosition = rtl ? 'right' : 'left';
|
|
96
256
|
const endPosition = rtl ? 'left' : 'right';
|
|
97
257
|
const marginOffset = borderWidths.sm;
|
|
98
|
-
const marginDisplacement = `${isPrimary || isBasic ? '' : '-'}${marginOffset}`;
|
|
99
|
-
const iconMarginDisplacement = isPill && '-2px';
|
|
100
|
-
const disabledBackgroundColor =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
258
|
+
const marginDisplacement = `${$isPrimary || $isBasic ? '' : '-'}${marginOffset}`;
|
|
259
|
+
const iconMarginDisplacement = $isPill && '-2px';
|
|
260
|
+
const disabledBackgroundColor = !$isPrimary && getColor({
|
|
261
|
+
theme,
|
|
262
|
+
variable: 'background.disabled'
|
|
263
|
+
});
|
|
264
|
+
const borderColor = $isBasic ? 'transparent' : 'revert';
|
|
265
|
+
const focusColor = getColor({
|
|
104
266
|
theme,
|
|
105
|
-
|
|
267
|
+
variable: 'border.primaryEmphasis'
|
|
268
|
+
});
|
|
269
|
+
const focusBoxShadow = $isBasic && !$isPrimary && getFocusBoxShadow({
|
|
270
|
+
theme,
|
|
271
|
+
inset: $focusInset,
|
|
106
272
|
spacerColor: {
|
|
107
273
|
hue: focusColor
|
|
108
274
|
},
|
|
@@ -113,24 +279,24 @@ const groupStyles = props => {
|
|
|
113
279
|
return 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, SELECTOR_FOCUS_VISIBLE, focusColor, focusBoxShadow, SELECTOR_FOCUS_VISIBLE, disabledBackgroundColor, startPosition, marginDisplacement, startPosition, marginOffset, endPosition, endPosition, startPosition, startPosition, StyledIcon, endPosition, iconMarginDisplacement, StyledIcon, startPosition, iconMarginDisplacement);
|
|
114
280
|
};
|
|
115
281
|
const iconStyles = props => {
|
|
116
|
-
const size = props
|
|
117
|
-
return css(["width:", ";min-width:", ";height:", ";vertical-align:", ";"], size, size, size, props
|
|
282
|
+
const $size = props.$size === 'small' ? props.theme.iconSizes.sm : props.theme.iconSizes.md;
|
|
283
|
+
return css(["width:", ";min-width:", ";height:", ";vertical-align:", ";"], $size, $size, $size, props.$isLink && 'middle');
|
|
118
284
|
};
|
|
119
285
|
const sizeStyles = props => {
|
|
120
286
|
let retVal;
|
|
121
|
-
if (props
|
|
287
|
+
if (props.$isLink) {
|
|
122
288
|
retVal = css(["padding:0;font-size:inherit;"]);
|
|
123
289
|
} else {
|
|
124
290
|
const height = getHeight(props);
|
|
125
291
|
const lineHeight = math(`${height} - (${props.theme.borderWidths.sm} * 2)`);
|
|
126
292
|
let padding;
|
|
127
293
|
let fontSize;
|
|
128
|
-
if (props
|
|
294
|
+
if (props.$size === 'small') {
|
|
129
295
|
fontSize = props.theme.fontSizes.sm;
|
|
130
296
|
padding = `${props.theme.space.base * 3}px`;
|
|
131
297
|
} else {
|
|
132
298
|
fontSize = props.theme.fontSizes.md;
|
|
133
|
-
if (props
|
|
299
|
+
if (props.$size === 'large') {
|
|
134
300
|
padding = `${props.theme.space.base * 5}px`;
|
|
135
301
|
} else {
|
|
136
302
|
padding = `${props.theme.space.base * 4}px`;
|
|
@@ -141,15 +307,12 @@ const sizeStyles = props => {
|
|
|
141
307
|
return retVal;
|
|
142
308
|
};
|
|
143
309
|
const StyledButton = styled.button.attrs(props => ({
|
|
144
|
-
'data-garden-id': COMPONENT_ID,
|
|
145
|
-
'data-garden-version': '9.
|
|
310
|
+
'data-garden-id': props['data-garden-id'] || COMPONENT_ID,
|
|
311
|
+
'data-garden-version': '9.1.0',
|
|
146
312
|
type: props.type || 'button'
|
|
147
313
|
})).withConfig({
|
|
148
314
|
displayName: "StyledButton",
|
|
149
315
|
componentId: "sc-qe3ace-0"
|
|
150
|
-
})(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:
|
|
151
|
-
StyledButton.defaultProps = {
|
|
152
|
-
theme: DEFAULT_THEME
|
|
153
|
-
};
|
|
316
|
+
})(["display:", ";align-items:", ";justify-content:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;margin:0;border:", ";border-radius:", ";cursor:pointer;width:", ";overflow:hidden;text-decoration:", ";text-overflow:ellipsis;white-space:", ";font-family:inherit;font-weight:", ";-webkit-font-smoothing:subpixel-antialiased;box-sizing:border-box;user-select:", ";-webkit-touch-callout:none;", ";&::-moz-focus-inner{border:0;padding:0;}", "{text-decoration:none;}&:hover{text-decoration:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{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,outline-color 0.1s ease-in-out,z-index 0.25s ease-in-out;text-decoration:", ";}", ";&:disabled{cursor:default;text-decoration:", ";}& ", "{", "}", " &&{", "}", ""], props => props.$isLink ? 'inline' : 'inline-flex', props => !props.$isLink && 'center', props => !props.$isLink && 'center', props => `${props.$isLink ? `0px solid` : props.theme.borders.sm} transparent`, props => getBorderRadius(props), props => props.$isStretched ? '100%' : '', props => props.$isUnderlined ? 'underline' : 'none', props => !props.$isLink && 'nowrap', props => props.$isLink ? 'inherit' : props.theme.fontWeights.regular, props => !props.$isLink && 'none', props => sizeStyles(props), SELECTOR_FOCUS_VISIBLE, props => props.$isLink ? 'underline' : 'none', props => props.$isLink ? 'underline' : 'none', props => colorStyles(props), props => props.$isLink && 'none', StyledIcon, props => iconStyles(props), StyledSplitButton, props => groupStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
154
317
|
|
|
155
|
-
export { StyledButton, getHeight };
|
|
318
|
+
export { COMPONENT_ID, StyledButton, getHeight };
|
|
@@ -6,18 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import SvgNewWindowStroke from '../node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js';
|
|
9
|
-
import { retrieveComponentStyles
|
|
9
|
+
import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
|
|
10
10
|
|
|
11
11
|
const COMPONENT_ID = 'buttons.external_icon';
|
|
12
12
|
const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
|
|
13
13
|
'data-garden-id': COMPONENT_ID,
|
|
14
|
-
'data-garden-version': '9.
|
|
14
|
+
'data-garden-version': '9.1.0'
|
|
15
15
|
}).withConfig({
|
|
16
16
|
displayName: "StyledExternalIcon",
|
|
17
17
|
componentId: "sc-16oz07e-0"
|
|
18
18
|
})(["transform:", ";margin-bottom:-0.085em;padding-left:0.25em;box-sizing:content-box;width:0.85em;height:0.85em;", ";"], props => props.theme.rtl && 'scaleX(-1)', props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
-
StyledExternalIcon.defaultProps = {
|
|
20
|
-
theme: DEFAULT_THEME
|
|
21
|
-
};
|
|
22
19
|
|
|
23
20
|
export { StyledExternalIcon };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled, { css } from 'styled-components';
|
|
8
|
-
import { StyledBaseIcon, retrieveComponentStyles
|
|
8
|
+
import { StyledBaseIcon, retrieveComponentStyles } from '@zendeskgarden/react-theming';
|
|
9
9
|
|
|
10
10
|
const COMPONENT_ID = 'buttons.icon';
|
|
11
11
|
const sizeStyles = props => {
|
|
@@ -19,13 +19,10 @@ const sizeStyles = props => {
|
|
|
19
19
|
};
|
|
20
20
|
const StyledIcon = styled(StyledBaseIcon).attrs({
|
|
21
21
|
'data-garden-id': COMPONENT_ID,
|
|
22
|
-
'data-garden-version': '9.
|
|
22
|
+
'data-garden-version': '9.1.0'
|
|
23
23
|
}).withConfig({
|
|
24
24
|
displayName: "StyledIcon",
|
|
25
25
|
componentId: "sc-19meqgg-0"
|
|
26
26
|
})(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";"], props => props.$isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
27
|
-
StyledIcon.defaultProps = {
|
|
28
|
-
theme: DEFAULT_THEME
|
|
29
|
-
};
|
|
30
27
|
|
|
31
28
|
export { StyledIcon };
|