@zendeskgarden/react-buttons 9.0.0-next.2 → 9.0.0-next.21
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/README.md +0 -27
- package/dist/esm/elements/Anchor.js +57 -0
- package/dist/esm/elements/Button.js +50 -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 +28 -0
- package/dist/esm/elements/components/StartIcon.js +28 -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 +321 -0
- package/dist/esm/styled/StyledExternalIcon.js +23 -0
- package/dist/esm/styled/StyledIcon.js +31 -0
- package/dist/esm/styled/StyledIconButton.js +64 -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 +316 -203
- package/dist/typings/elements/Button.d.ts +1 -7
- package/dist/typings/elements/components/EndIcon.d.ts +1 -1
- package/dist/typings/elements/components/StartIcon.d.ts +1 -1
- package/dist/typings/index.d.ts +2 -3
- package/dist/typings/styled/StyledAnchor.d.ts +1 -8
- package/dist/typings/styled/StyledButton.d.ts +6 -7
- package/dist/typings/styled/StyledIcon.d.ts +4 -4
- package/dist/typings/styled/StyledIconButton.d.ts +2 -5
- package/dist/typings/styled/{StyledButtonGroup.d.ts → StyledSplitButton.d.ts} +1 -1
- package/dist/typings/styled/index.d.ts +3 -3
- package/dist/typings/types/index.d.ts +3 -13
- package/package.json +8 -9
- package/dist/index.esm.js +0 -559
- package/dist/typings/elements/ButtonGroup.d.ts +0 -14
- package/dist/typings/utils/useButtonGroupContext.d.ts +0 -14
|
@@ -0,0 +1,321 @@
|
|
|
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 { math, em } from 'polished';
|
|
9
|
+
import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles, DEFAULT_THEME, getColor, focusStyles, getFocusBoxShadow } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { StyledSplitButton } from './StyledSplitButton.js';
|
|
11
|
+
import { StyledIcon } from './StyledIcon.js';
|
|
12
|
+
|
|
13
|
+
const COMPONENT_ID = 'buttons.button';
|
|
14
|
+
const getBorderRadius = props => {
|
|
15
|
+
if (props.isPill) {
|
|
16
|
+
return '100px';
|
|
17
|
+
}
|
|
18
|
+
return props.theme.borderRadii.md;
|
|
19
|
+
};
|
|
20
|
+
const getHeight = props => {
|
|
21
|
+
if (props.size === 'small') {
|
|
22
|
+
return `${props.theme.space.base * 8}px`;
|
|
23
|
+
} else if (props.size === 'large') {
|
|
24
|
+
return `${props.theme.space.base * 12}px`;
|
|
25
|
+
}
|
|
26
|
+
return `${props.theme.space.base * 10}px`;
|
|
27
|
+
};
|
|
28
|
+
const colorStyles = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
theme,
|
|
31
|
+
isLink,
|
|
32
|
+
isBasic,
|
|
33
|
+
isDanger,
|
|
34
|
+
isNeutral,
|
|
35
|
+
isPrimary,
|
|
36
|
+
focusInset
|
|
37
|
+
} = _ref;
|
|
38
|
+
let retVal;
|
|
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,
|
|
83
|
+
condition: false,
|
|
84
|
+
styles: {
|
|
85
|
+
color: foregroundColor ,
|
|
86
|
+
outlineColor: focusOutlineColor
|
|
87
|
+
}
|
|
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
|
+
})
|
|
125
|
+
} : undefined
|
|
126
|
+
}), activeBackgroundColor, disabledBackgroundColor, disabledForegroundColor);
|
|
127
|
+
} else {
|
|
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);
|
|
239
|
+
}
|
|
240
|
+
return retVal;
|
|
241
|
+
};
|
|
242
|
+
const groupStyles = _ref2 => {
|
|
243
|
+
let {
|
|
244
|
+
theme,
|
|
245
|
+
isPrimary,
|
|
246
|
+
isBasic,
|
|
247
|
+
isPill,
|
|
248
|
+
focusInset
|
|
249
|
+
} = _ref2;
|
|
250
|
+
const {
|
|
251
|
+
rtl,
|
|
252
|
+
borderWidths,
|
|
253
|
+
borders
|
|
254
|
+
} = theme;
|
|
255
|
+
const startPosition = rtl ? 'right' : 'left';
|
|
256
|
+
const endPosition = rtl ? 'left' : 'right';
|
|
257
|
+
const marginOffset = borderWidths.sm;
|
|
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({
|
|
266
|
+
theme,
|
|
267
|
+
variable: 'border.primaryEmphasis'
|
|
268
|
+
});
|
|
269
|
+
const focusBoxShadow = isBasic && !isPrimary && getFocusBoxShadow({
|
|
270
|
+
theme,
|
|
271
|
+
inset: focusInset,
|
|
272
|
+
spacerColor: {
|
|
273
|
+
hue: focusColor
|
|
274
|
+
},
|
|
275
|
+
color: {
|
|
276
|
+
hue: 'transparent'
|
|
277
|
+
}
|
|
278
|
+
});
|
|
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);
|
|
280
|
+
};
|
|
281
|
+
const iconStyles = 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');
|
|
284
|
+
};
|
|
285
|
+
const sizeStyles = props => {
|
|
286
|
+
let retVal;
|
|
287
|
+
if (props.isLink) {
|
|
288
|
+
retVal = css(["padding:0;font-size:inherit;"]);
|
|
289
|
+
} else {
|
|
290
|
+
const height = getHeight(props);
|
|
291
|
+
const lineHeight = math(`${height} - (${props.theme.borderWidths.sm} * 2)`);
|
|
292
|
+
let padding;
|
|
293
|
+
let fontSize;
|
|
294
|
+
if (props.size === 'small') {
|
|
295
|
+
fontSize = props.theme.fontSizes.sm;
|
|
296
|
+
padding = `${props.theme.space.base * 3}px`;
|
|
297
|
+
} else {
|
|
298
|
+
fontSize = props.theme.fontSizes.md;
|
|
299
|
+
if (props.size === 'large') {
|
|
300
|
+
padding = `${props.theme.space.base * 5}px`;
|
|
301
|
+
} else {
|
|
302
|
+
padding = `${props.theme.space.base * 4}px`;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
retVal = css(["padding:0 ", ";height:", ";line-height:", ";font-size:", ";"], em(math(`${padding} - ${props.theme.borderWidths.sm}`), fontSize), height, lineHeight, fontSize);
|
|
306
|
+
}
|
|
307
|
+
return retVal;
|
|
308
|
+
};
|
|
309
|
+
const StyledButton = styled.button.attrs(props => ({
|
|
310
|
+
'data-garden-id': props['data-garden-id'] || COMPONENT_ID,
|
|
311
|
+
'data-garden-version': '9.0.0-next.21',
|
|
312
|
+
type: props.type || 'button'
|
|
313
|
+
})).withConfig({
|
|
314
|
+
displayName: "StyledButton",
|
|
315
|
+
componentId: "sc-qe3ace-0"
|
|
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));
|
|
317
|
+
StyledButton.defaultProps = {
|
|
318
|
+
theme: DEFAULT_THEME
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export { COMPONENT_ID, StyledButton, getHeight };
|
|
@@ -0,0 +1,23 @@
|
|
|
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 SvgNewWindowStroke from '../node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'buttons.external_icon';
|
|
12
|
+
const StyledExternalIcon = styled(SvgNewWindowStroke).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.21'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledExternalIcon",
|
|
17
|
+
componentId: "sc-16oz07e-0"
|
|
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
|
+
|
|
23
|
+
export { StyledExternalIcon };
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { StyledBaseIcon, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'buttons.icon';
|
|
11
|
+
const sizeStyles = props => {
|
|
12
|
+
let marginProperty;
|
|
13
|
+
if (props.$position === 'start') {
|
|
14
|
+
marginProperty = `margin-${props.theme.rtl ? 'left' : 'right'}`;
|
|
15
|
+
} else if (props.$position === 'end') {
|
|
16
|
+
marginProperty = `margin-${props.theme.rtl ? 'right' : 'left'}`;
|
|
17
|
+
}
|
|
18
|
+
return marginProperty && css(["", ":", "px;"], marginProperty, props.theme.space.base * 2);
|
|
19
|
+
};
|
|
20
|
+
const StyledIcon = styled(StyledBaseIcon).attrs({
|
|
21
|
+
'data-garden-id': COMPONENT_ID,
|
|
22
|
+
'data-garden-version': '9.0.0-next.21'
|
|
23
|
+
}).withConfig({
|
|
24
|
+
displayName: "StyledIcon",
|
|
25
|
+
componentId: "sc-19meqgg-0"
|
|
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
|
+
|
|
31
|
+
export { StyledIcon };
|
|
@@ -0,0 +1,64 @@
|
|
|
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, getColor } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledButton, COMPONENT_ID as COMPONENT_ID$1, getHeight } from './StyledButton.js';
|
|
10
|
+
import { StyledIcon } from './StyledIcon.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'buttons.icon_button';
|
|
13
|
+
const iconColorStyles = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
const options = {
|
|
18
|
+
theme,
|
|
19
|
+
variable: 'foreground.subtle'
|
|
20
|
+
};
|
|
21
|
+
const baseColor = getColor(options);
|
|
22
|
+
const hoverColor = getColor({
|
|
23
|
+
...options,
|
|
24
|
+
dark: {
|
|
25
|
+
offset: -100
|
|
26
|
+
},
|
|
27
|
+
light: {
|
|
28
|
+
offset: 100
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const activeColor = getColor({
|
|
32
|
+
...options,
|
|
33
|
+
dark: {
|
|
34
|
+
offset: -200
|
|
35
|
+
},
|
|
36
|
+
light: {
|
|
37
|
+
offset: 200
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return css(["color:", ";&:hover{color:", ";}&:active,&[aria-pressed='true'],&[aria-pressed='mixed']{color:", ";}"], baseColor, hoverColor, activeColor);
|
|
41
|
+
};
|
|
42
|
+
const iconButtonStyles = props => {
|
|
43
|
+
const width = getHeight(props);
|
|
44
|
+
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');
|
|
45
|
+
};
|
|
46
|
+
const iconStyles = props => {
|
|
47
|
+
const size = props.theme.iconSizes.md;
|
|
48
|
+
return css(["width:", ";height:", ";& > svg{transition:opacity 0.15s ease-in-out;}"], size, size);
|
|
49
|
+
};
|
|
50
|
+
const StyledIconButton = styled(StyledButton).attrs(props => {
|
|
51
|
+
const externalId = props['data-garden-id'];
|
|
52
|
+
return {
|
|
53
|
+
'data-garden-id': externalId && externalId !== COMPONENT_ID$1 ? externalId : COMPONENT_ID,
|
|
54
|
+
'data-garden-version': '9.0.0-next.21'
|
|
55
|
+
};
|
|
56
|
+
}).withConfig({
|
|
57
|
+
displayName: "StyledIconButton",
|
|
58
|
+
componentId: "sc-1t0ughp-0"
|
|
59
|
+
})(["", ";& ", "{", "}", ";"], props => iconButtonStyles(props), StyledIcon, props => iconStyles(props), props => retrieveComponentStyles(props['data-garden-id'], props));
|
|
60
|
+
StyledIconButton.defaultProps = {
|
|
61
|
+
theme: DEFAULT_THEME
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { COMPONENT_ID, 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.21'
|
|
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 };
|