@zendeskgarden/react-forms 9.0.0-next.2 → 9.0.0-next.20
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 +4 -4
- package/dist/esm/elements/Checkbox.js +97 -0
- package/dist/esm/elements/FileUpload.js +75 -0
- package/dist/esm/elements/Input.js +93 -0
- package/dist/esm/elements/MediaInput.js +156 -0
- package/dist/esm/elements/Radio.js +81 -0
- package/dist/esm/elements/Range.js +108 -0
- package/dist/esm/elements/Select.js +98 -0
- package/dist/esm/elements/Textarea.js +170 -0
- package/dist/esm/elements/Toggle.js +81 -0
- package/dist/esm/elements/common/Field.js +97 -0
- package/dist/esm/elements/common/Fieldset.js +73 -0
- package/dist/esm/elements/common/Hint.js +92 -0
- package/dist/esm/elements/common/Label.js +134 -0
- package/dist/esm/elements/common/Legend.js +63 -0
- package/dist/esm/elements/common/Message.js +113 -0
- package/dist/esm/elements/faux-input/FauxInput.js +100 -0
- package/dist/esm/elements/faux-input/components/EndIcon.js +72 -0
- package/dist/esm/elements/faux-input/components/StartIcon.js +72 -0
- package/dist/esm/elements/file-list/FileList.js +66 -0
- package/dist/esm/elements/file-list/components/Close.js +75 -0
- package/dist/esm/elements/file-list/components/Delete.js +75 -0
- package/dist/esm/elements/file-list/components/File.js +95 -0
- package/dist/esm/elements/file-list/components/Item.js +64 -0
- package/dist/esm/elements/file-list/utils.js +50 -0
- package/dist/esm/elements/input-group/InputGroup.js +75 -0
- package/dist/esm/elements/tiles/Tiles.js +64 -0
- package/dist/esm/elements/tiles/components/Description.js +64 -0
- package/dist/esm/elements/tiles/components/Icon.js +64 -0
- package/dist/esm/elements/tiles/components/Label.js +73 -0
- package/dist/esm/elements/tiles/components/Tile.js +89 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/check-circle-stroke.svg.js +33 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/check-sm-fill.svg.js +29 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/circle-sm-fill.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/dash-fill.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-document-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-error-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-generic-stroke.svg.js +26 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-image-stroke.svg.js +33 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-pdf-stroke.svg.js +35 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-presentation-stroke.svg.js +26 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-spreadsheet-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/file-zip-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/trash-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/x-stroke.svg.js +26 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js +37 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg.js +32 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/check-circle-stroke.svg.js +33 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/circle-sm-fill.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-document-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-error-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-generic-stroke.svg.js +26 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-image-stroke.svg.js +32 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-pdf-stroke.svg.js +35 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-presentation-stroke.svg.js +26 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-spreadsheet-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/file-zip-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/trash-stroke.svg.js +27 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/x-stroke.svg.js +26 -0
- package/dist/esm/styled/checkbox/StyledCheckHint.js +23 -0
- package/dist/esm/styled/checkbox/StyledCheckInput.js +78 -0
- package/dist/esm/styled/checkbox/StyledCheckLabel.js +23 -0
- package/dist/esm/styled/checkbox/StyledCheckMessage.js +23 -0
- package/dist/esm/styled/checkbox/StyledCheckSvg.js +25 -0
- package/dist/esm/styled/checkbox/StyledDashSvg.js +25 -0
- package/dist/esm/styled/common/StyledField.js +22 -0
- package/dist/esm/styled/common/StyledFieldset.js +24 -0
- package/dist/esm/styled/common/StyledHint.js +25 -0
- package/dist/esm/styled/common/StyledLabel.js +26 -0
- package/dist/esm/styled/common/StyledLegend.js +24 -0
- package/dist/esm/styled/common/StyledMessage.js +57 -0
- package/dist/esm/styled/common/StyledMessageIcon.js +45 -0
- package/dist/esm/styled/file-list/StyledFile.js +97 -0
- package/dist/esm/styled/file-list/StyledFileClose.js +25 -0
- package/dist/esm/styled/file-list/StyledFileDelete.js +26 -0
- package/dist/esm/styled/file-list/StyledFileIcon.js +42 -0
- package/dist/esm/styled/file-list/StyledFileList.js +22 -0
- package/dist/esm/styled/file-list/StyledFileListItem.js +24 -0
- package/dist/esm/styled/file-upload/StyledFileUpload.js +116 -0
- package/dist/esm/styled/input-group/StyledInputGroup.js +35 -0
- package/dist/esm/styled/radio/StyledRadioHint.js +24 -0
- package/dist/esm/styled/radio/StyledRadioInput.js +122 -0
- package/dist/esm/styled/radio/StyledRadioLabel.js +30 -0
- package/dist/esm/styled/radio/StyledRadioMessage.js +24 -0
- package/dist/esm/styled/radio/StyledRadioSvg.js +25 -0
- package/dist/esm/styled/range/StyledRangeInput.js +210 -0
- package/dist/esm/styled/select/StyledSelect.js +60 -0
- package/dist/esm/styled/select/StyledSelectWrapper.js +32 -0
- package/dist/esm/styled/text/StyledTextFauxInput.js +69 -0
- package/dist/esm/styled/text/StyledTextInput.js +152 -0
- package/dist/esm/styled/text/StyledTextMediaFigure.js +68 -0
- package/dist/esm/styled/text/StyledTextMediaInput.js +24 -0
- package/dist/esm/styled/text/StyledTextarea.js +33 -0
- package/dist/esm/styled/tiles/StyledTile.js +114 -0
- package/dist/esm/styled/tiles/StyledTileDescription.js +34 -0
- package/dist/esm/styled/tiles/StyledTileIcon.js +77 -0
- package/dist/esm/styled/tiles/StyledTileInput.js +18 -0
- package/dist/esm/styled/tiles/StyledTileLabel.js +34 -0
- package/dist/esm/styled/toggle/StyledToggleHint.js +24 -0
- package/dist/esm/styled/toggle/StyledToggleInput.js +65 -0
- package/dist/esm/styled/toggle/StyledToggleLabel.js +28 -0
- package/dist/esm/styled/toggle/StyledToggleMessage.js +25 -0
- package/dist/esm/styled/toggle/StyledToggleSvg.js +23 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/utils/useFieldContext.js +15 -0
- package/dist/esm/utils/useFieldsetContext.js +15 -0
- package/dist/esm/utils/useFileContext.js +14 -0
- package/dist/esm/utils/useInputContext.js +14 -0
- package/dist/esm/utils/useInputGroupContext.js +14 -0
- package/dist/esm/utils/useTilesContext.js +14 -0
- package/dist/index.cjs.js +1239 -919
- package/dist/typings/elements/common/Field.d.ts +10 -9
- package/dist/typings/elements/common/Hint.d.ts +2 -0
- package/dist/typings/elements/common/Label.d.ts +2 -0
- package/dist/typings/elements/common/Message.d.ts +2 -0
- package/dist/typings/elements/faux-input/FauxInput.d.ts +1 -11
- package/dist/typings/elements/faux-input/components/EndIcon.d.ts +1 -1
- package/dist/typings/elements/faux-input/components/StartIcon.d.ts +1 -1
- package/dist/typings/index.d.ts +3 -4
- package/dist/typings/styled/file-list/StyledFileIcon.d.ts +8 -2
- package/dist/typings/styled/index.d.ts +0 -4
- package/dist/typings/styled/select/StyledSelect.d.ts +1 -4
- package/dist/typings/styled/select/StyledSelectWrapper.d.ts +3 -1
- package/dist/typings/styled/text/StyledTextFauxInput.d.ts +0 -4
- package/dist/typings/styled/text/StyledTextMediaFigure.d.ts +7 -7
- package/dist/typings/styled/text/StyledTextarea.d.ts +1 -1
- package/dist/typings/styled/tiles/StyledTile.d.ts +4 -7
- package/dist/typings/types/index.d.ts +6 -33
- package/dist/typings/utils/useFieldContext.d.ts +1 -2
- package/package.json +8 -9
- package/dist/index.esm.js +0 -2921
- package/dist/typings/elements/MultiThumbRange.d.ts +0 -14
- package/dist/typings/styled/range/StyledSlider.d.ts +0 -10
- package/dist/typings/styled/range/StyledSliderThumb.d.ts +0 -13
- package/dist/typings/styled/range/StyledSliderTrack.d.ts +0 -14
- package/dist/typings/styled/range/StyledSliderTrackRail.d.ts +0 -11
|
@@ -0,0 +1,152 @@
|
|
|
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 React__default from 'react';
|
|
8
|
+
import { renderToString } from 'react-dom/server';
|
|
9
|
+
import styled, { css } from 'styled-components';
|
|
10
|
+
import { math, em } from 'polished';
|
|
11
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor, focusStyles, getLineHeight } from '@zendeskgarden/react-theming';
|
|
12
|
+
import SvgChevronDownStroke from '../../node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js';
|
|
13
|
+
import { StyledHint } from '../common/StyledHint.js';
|
|
14
|
+
import { StyledLabel } from '../common/StyledLabel.js';
|
|
15
|
+
import { StyledMessage } from '../common/StyledMessage.js';
|
|
16
|
+
|
|
17
|
+
const COMPONENT_ID = 'forms.input';
|
|
18
|
+
const isInvalid = validation => {
|
|
19
|
+
return validation === 'warning' || validation === 'error';
|
|
20
|
+
};
|
|
21
|
+
const colorStyles = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
theme,
|
|
24
|
+
isBare,
|
|
25
|
+
isHovered,
|
|
26
|
+
focusInset,
|
|
27
|
+
validation
|
|
28
|
+
} = _ref;
|
|
29
|
+
const foregroundColor = getColor({
|
|
30
|
+
theme,
|
|
31
|
+
variable: 'foreground.default'
|
|
32
|
+
});
|
|
33
|
+
const backgroundColor = isBare ? 'transparent' : getColor({
|
|
34
|
+
theme,
|
|
35
|
+
variable: 'background.default'
|
|
36
|
+
});
|
|
37
|
+
let borderColor;
|
|
38
|
+
let hoverBorderColor;
|
|
39
|
+
let borderVariable;
|
|
40
|
+
let focusBorderColor;
|
|
41
|
+
if (validation) {
|
|
42
|
+
if (validation === 'success') {
|
|
43
|
+
borderVariable = 'border.successEmphasis';
|
|
44
|
+
} else if (validation === 'warning') {
|
|
45
|
+
borderVariable = 'border.warningEmphasis';
|
|
46
|
+
} else if (validation === 'error') {
|
|
47
|
+
borderVariable = 'border.dangerEmphasis';
|
|
48
|
+
}
|
|
49
|
+
borderColor = getColor({
|
|
50
|
+
theme,
|
|
51
|
+
variable: borderVariable
|
|
52
|
+
});
|
|
53
|
+
hoverBorderColor = borderColor;
|
|
54
|
+
focusBorderColor = borderColor;
|
|
55
|
+
} else {
|
|
56
|
+
borderColor = getColor({
|
|
57
|
+
theme,
|
|
58
|
+
variable: 'border.default',
|
|
59
|
+
dark: {
|
|
60
|
+
offset: -100
|
|
61
|
+
},
|
|
62
|
+
light: {
|
|
63
|
+
offset: 100
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
borderVariable = 'border.primaryEmphasis';
|
|
67
|
+
hoverBorderColor = getColor({
|
|
68
|
+
theme,
|
|
69
|
+
variable: borderVariable
|
|
70
|
+
});
|
|
71
|
+
focusBorderColor = hoverBorderColor;
|
|
72
|
+
}
|
|
73
|
+
const disabledBackgroundColor = isBare ? undefined : getColor({
|
|
74
|
+
theme,
|
|
75
|
+
variable: 'background.disabled'
|
|
76
|
+
});
|
|
77
|
+
const disabledBorderColor = getColor({
|
|
78
|
+
theme,
|
|
79
|
+
variable: 'border.disabled'
|
|
80
|
+
});
|
|
81
|
+
const disabledForegroundColor = getColor({
|
|
82
|
+
theme,
|
|
83
|
+
variable: 'foreground.disabled'
|
|
84
|
+
});
|
|
85
|
+
const placeholderColor = disabledForegroundColor;
|
|
86
|
+
const readOnlyBackgroundColor = disabledBackgroundColor;
|
|
87
|
+
const calendarPickerColor = getColor({
|
|
88
|
+
theme,
|
|
89
|
+
variable: 'foreground.subtle'
|
|
90
|
+
});
|
|
91
|
+
const calendarPickerIcon = renderToString( React__default.createElement(SvgChevronDownStroke, {
|
|
92
|
+
color: calendarPickerColor
|
|
93
|
+
}));
|
|
94
|
+
const calendarPickerBackgroundImage = `url("data:image/svg+xml,${encodeURIComponent(calendarPickerIcon)}")`;
|
|
95
|
+
return css(["border-color:", ";background-color:", ";color:", ";&::placeholder{opacity:1;color:", ";}&::-webkit-datetime-edit{color:", ";}&::-webkit-calendar-picker-indicator{background-image:", ";}&[readonly],&[aria-readonly='true']{background-color:", ";}&:hover{border-color:", ";}", " &::-webkit-calendar-picker-indicator:focus-visible{", "}&:disabled,&[aria-disabled='true']{border-color:", ";background-color:", ";color:", ";}"], isHovered ? hoverBorderColor : borderColor, backgroundColor, foregroundColor, placeholderColor, placeholderColor, calendarPickerBackgroundImage, readOnlyBackgroundColor, hoverBorderColor, focusStyles({
|
|
96
|
+
theme,
|
|
97
|
+
inset: focusInset,
|
|
98
|
+
color: {
|
|
99
|
+
variable: borderVariable
|
|
100
|
+
},
|
|
101
|
+
styles: {
|
|
102
|
+
borderColor: focusBorderColor
|
|
103
|
+
},
|
|
104
|
+
condition: !isBare
|
|
105
|
+
}), focusStyles({
|
|
106
|
+
theme
|
|
107
|
+
}), disabledBorderColor, disabledBackgroundColor, disabledForegroundColor);
|
|
108
|
+
};
|
|
109
|
+
const sizeStyles = _ref2 => {
|
|
110
|
+
let {
|
|
111
|
+
theme,
|
|
112
|
+
isBare,
|
|
113
|
+
isCompact
|
|
114
|
+
} = _ref2;
|
|
115
|
+
const fontSize = theme.fontSizes.md;
|
|
116
|
+
const paddingHorizontal = `${theme.space.base * 3}px`;
|
|
117
|
+
let height;
|
|
118
|
+
let paddingVertical;
|
|
119
|
+
let browseFontSize;
|
|
120
|
+
let swatchHeight;
|
|
121
|
+
if (isCompact) {
|
|
122
|
+
height = `${theme.space.base * 8}px`;
|
|
123
|
+
paddingVertical = `${theme.space.base * 1.5}px`;
|
|
124
|
+
browseFontSize = math(`${theme.fontSizes.sm} - 1`);
|
|
125
|
+
swatchHeight = `${theme.space.base * 6}px`;
|
|
126
|
+
} else {
|
|
127
|
+
height = `${theme.space.base * 10}px`;
|
|
128
|
+
paddingVertical = `${theme.space.base * 2.5}px`;
|
|
129
|
+
browseFontSize = theme.fontSizes.sm;
|
|
130
|
+
swatchHeight = `${theme.space.base * 7}px`;
|
|
131
|
+
}
|
|
132
|
+
const lineHeight = math(`${height} - (${paddingVertical} * 2) - (${theme.borderWidths.sm} * 2)`);
|
|
133
|
+
const padding = isBare ? '0' : `${em(paddingVertical, fontSize)} ${em(paddingHorizontal, fontSize)}`;
|
|
134
|
+
const swatchMarginVertical = math(`(${lineHeight} - ${swatchHeight}) / 2`);
|
|
135
|
+
const swatchMarginHorizontal = math(`${paddingVertical} + ${swatchMarginVertical} - ${paddingHorizontal}`);
|
|
136
|
+
const calendarPickerSize = `${theme.space.base * 5}px`;
|
|
137
|
+
const calendarPickerBackgroundSize = theme.iconSizes.md;
|
|
138
|
+
return css(["padding:", ";min-height:", ";line-height:", ";font-size:", ";&::-ms-browse{font-size:", ";}&[type='date'],&[type='datetime-local'],&[type='file'],&[type='month'],&[type='time'],&[type='week']{max-height:", ";}&[type='file']{line-height:1;}@supports (-ms-ime-align:auto){&[type='color']{padding:", ";}}&::-moz-color-swatch{margin-top:", ";margin-left:", ";width:calc(100% + ", ");height:", ";}&::-webkit-calendar-picker-indicator{background-position:center;background-size:", ";padding:0;width:", ";height:", ";}&::-webkit-color-swatch{margin:", " ", ";}", ":not([hidden]) + &&,", " + &&,", " + &&,&& + ", ",&& ~ ", "{margin-top:", "px;}"], padding, isBare ? '1em' : height, getLineHeight(lineHeight, fontSize), fontSize, browseFontSize, height, isCompact ? '0 2px' : '1px 3px', swatchMarginVertical, swatchMarginHorizontal, math(`${swatchMarginHorizontal} * -2`), swatchHeight, calendarPickerBackgroundSize, calendarPickerSize, calendarPickerSize, swatchMarginVertical, swatchMarginHorizontal, StyledLabel, StyledHint, StyledMessage, StyledHint, StyledMessage, theme.space.base * (isCompact ? 1 : 2));
|
|
139
|
+
};
|
|
140
|
+
const StyledTextInput = styled.input.attrs(props => ({
|
|
141
|
+
'data-garden-id': COMPONENT_ID,
|
|
142
|
+
'data-garden-version': '9.0.0-next.20',
|
|
143
|
+
'aria-invalid': isInvalid(props.validation)
|
|
144
|
+
})).withConfig({
|
|
145
|
+
displayName: "StyledTextInput",
|
|
146
|
+
componentId: "sc-1r6733h-0"
|
|
147
|
+
})(["appearance:none;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,z-index 0.25s ease-in-out;direction:", ";border:", ";border-radius:", ";width:100%;box-sizing:border-box;vertical-align:middle;font-family:inherit;&::-ms-browse{border-radius:", ";}&::-ms-clear,&::-ms-reveal{display:none;}&::-moz-color-swatch{border:none;border-radius:", ";}&::-webkit-color-swatch{border:none;border-radius:", ";}&::-webkit-color-swatch-wrapper{padding:0;}&::-webkit-clear-button,&::-webkit-inner-spin-button,&::-webkit-search-cancel-button,&::-webkit-search-results-button{display:none;}&::-webkit-datetime-edit{direction:", ";line-height:1;}&::-webkit-calendar-picker-indicator{border-radius:100%;}&:invalid{box-shadow:none;}&[type='file']::-ms-value{display:none;}@media screen and (min--moz-device-pixel-ratio:0){&[type='number']{appearance:textfield;}}", ";", ";&:disabled{cursor:default;}", ";"], props => props.theme.rtl && 'rtl', props => props.isBare ? 'none' : props.theme.borders.sm, props => props.isBare ? '0' : props.theme.borderRadii.md, props => props.theme.borderRadii.sm, props => props.theme.borderRadii.sm, props => props.theme.borderRadii.sm, props => props.theme.rtl && 'rtl', sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
148
|
+
StyledTextInput.defaultProps = {
|
|
149
|
+
theme: DEFAULT_THEME
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export { StyledTextInput };
|
|
@@ -0,0 +1,68 @@
|
|
|
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, getColor } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'forms.media_figure';
|
|
11
|
+
const colorStyles = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
theme,
|
|
14
|
+
$isDisabled,
|
|
15
|
+
$isHovered,
|
|
16
|
+
$isFocused
|
|
17
|
+
} = _ref;
|
|
18
|
+
let color;
|
|
19
|
+
if ($isDisabled) {
|
|
20
|
+
color = getColor({
|
|
21
|
+
theme,
|
|
22
|
+
variable: 'foreground.disabled'
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
const options = {
|
|
26
|
+
theme,
|
|
27
|
+
variable: 'foreground.subtle'
|
|
28
|
+
};
|
|
29
|
+
if ($isHovered || $isFocused) {
|
|
30
|
+
color = getColor({
|
|
31
|
+
...options,
|
|
32
|
+
dark: {
|
|
33
|
+
offset: -100
|
|
34
|
+
},
|
|
35
|
+
light: {
|
|
36
|
+
offset: 100
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
color = getColor(options);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return css(["color:", ";"], color);
|
|
44
|
+
};
|
|
45
|
+
const sizeStyles = props => {
|
|
46
|
+
const size = props.theme.iconSizes.md;
|
|
47
|
+
const marginFirst = `1px ${props.theme.space.base * 2}px auto 0`;
|
|
48
|
+
const marginLast = `1px 0 auto ${props.theme.space.base * 2}px`;
|
|
49
|
+
let margin;
|
|
50
|
+
if (props.$position === 'start') {
|
|
51
|
+
margin = props.theme.rtl ? marginLast : marginFirst;
|
|
52
|
+
} else {
|
|
53
|
+
margin = props.theme.rtl ? marginFirst : marginLast;
|
|
54
|
+
}
|
|
55
|
+
return css(["margin:", ";width:", ";height:", ";"], margin, size, size);
|
|
56
|
+
};
|
|
57
|
+
const StyledTextMediaFigure = styled(StyledBaseIcon).attrs({
|
|
58
|
+
'data-garden-id': COMPONENT_ID,
|
|
59
|
+
'data-garden-version': '9.0.0-next.20'
|
|
60
|
+
}).withConfig({
|
|
61
|
+
displayName: "StyledTextMediaFigure",
|
|
62
|
+
componentId: "sc-1qepknj-0"
|
|
63
|
+
})(["transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", " ", ";"], props => props.$isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
64
|
+
StyledTextMediaFigure.defaultProps = {
|
|
65
|
+
theme: DEFAULT_THEME
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { StyledTextMediaFigure };
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { StyledTextInput } from './StyledTextInput.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'forms.media_input';
|
|
12
|
+
const StyledTextMediaInput = styled(StyledTextInput).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.20',
|
|
15
|
+
isBare: true
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledTextMediaInput",
|
|
18
|
+
componentId: "sc-12i9xfi-0"
|
|
19
|
+
})(["flex-grow:1;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
+
StyledTextMediaInput.defaultProps = {
|
|
21
|
+
theme: DEFAULT_THEME
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { StyledTextMediaInput };
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { StyledTextInput } from './StyledTextInput.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'forms.textarea';
|
|
12
|
+
const hiddenStyles = `
|
|
13
|
+
visibility: hidden;
|
|
14
|
+
position: absolute;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
height: 0;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
transform: translateZ(0);
|
|
20
|
+
`;
|
|
21
|
+
const StyledTextarea = styled(StyledTextInput).attrs({
|
|
22
|
+
as: 'textarea',
|
|
23
|
+
'data-garden-id': COMPONENT_ID,
|
|
24
|
+
'data-garden-version': '9.0.0-next.20'
|
|
25
|
+
}).withConfig({
|
|
26
|
+
displayName: "StyledTextarea",
|
|
27
|
+
componentId: "sc-wxschl-0"
|
|
28
|
+
})(["resize:", ";overflow:auto;", ";", ";"], props => props.isResizable ? 'vertical' : 'none', props => props.isHidden && hiddenStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
29
|
+
StyledTextarea.defaultProps = {
|
|
30
|
+
theme: DEFAULT_THEME
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { StyledTextarea };
|
|
@@ -0,0 +1,114 @@
|
|
|
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, focusStyles } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'forms.tile';
|
|
11
|
+
const colorStyles = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
theme
|
|
14
|
+
} = _ref;
|
|
15
|
+
const offset100 = {
|
|
16
|
+
dark: {
|
|
17
|
+
offset: -100
|
|
18
|
+
},
|
|
19
|
+
light: {
|
|
20
|
+
offset: 100
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const offset200 = {
|
|
24
|
+
dark: {
|
|
25
|
+
offset: -200
|
|
26
|
+
},
|
|
27
|
+
light: {
|
|
28
|
+
offset: 200
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const backgroundColor = getColor({
|
|
32
|
+
theme,
|
|
33
|
+
variable: 'background.default'
|
|
34
|
+
});
|
|
35
|
+
const borderColor = getColor({
|
|
36
|
+
theme,
|
|
37
|
+
variable: 'border.default',
|
|
38
|
+
...offset100
|
|
39
|
+
});
|
|
40
|
+
const foregroundColor = getColor({
|
|
41
|
+
theme,
|
|
42
|
+
variable: 'foreground.default'
|
|
43
|
+
});
|
|
44
|
+
const backgroundOptions = {
|
|
45
|
+
theme,
|
|
46
|
+
variable: 'background.primaryEmphasis'
|
|
47
|
+
};
|
|
48
|
+
const hoverBackgroundColor = getColor({
|
|
49
|
+
...backgroundOptions,
|
|
50
|
+
transparency: theme.opacity[100]
|
|
51
|
+
});
|
|
52
|
+
const hoverBorderColor = getColor({
|
|
53
|
+
theme,
|
|
54
|
+
variable: 'border.primaryEmphasis'
|
|
55
|
+
});
|
|
56
|
+
const activeBackgroundColor = getColor({
|
|
57
|
+
...backgroundOptions,
|
|
58
|
+
transparency: theme.opacity[200]
|
|
59
|
+
});
|
|
60
|
+
const focusBorderColor = hoverBorderColor;
|
|
61
|
+
const activeBorderColor = hoverBorderColor;
|
|
62
|
+
const checkedBackgroundColor = getColor(backgroundOptions);
|
|
63
|
+
const checkedForegroundColor = getColor({
|
|
64
|
+
theme,
|
|
65
|
+
variable: 'foreground.onEmphasis'
|
|
66
|
+
});
|
|
67
|
+
const checkedHoverBackgroundColor = getColor({
|
|
68
|
+
...backgroundOptions,
|
|
69
|
+
...offset100
|
|
70
|
+
});
|
|
71
|
+
const checkedActiveBackgroundColor = getColor({
|
|
72
|
+
...backgroundOptions,
|
|
73
|
+
...offset200
|
|
74
|
+
});
|
|
75
|
+
const disabledBackgroundColor = getColor({
|
|
76
|
+
theme,
|
|
77
|
+
variable: 'background.disabled'
|
|
78
|
+
});
|
|
79
|
+
const disabledBorderColor = getColor({
|
|
80
|
+
theme,
|
|
81
|
+
variable: 'border.disabled'
|
|
82
|
+
});
|
|
83
|
+
const disabledForegroundColor = getColor({
|
|
84
|
+
theme,
|
|
85
|
+
variable: 'foreground.disabled'
|
|
86
|
+
});
|
|
87
|
+
return css(["border-color:", ";background-color:", ";color:", ";&:hover{border-color:", ";background-color:", ";}", ";&:active{border-color:", ";background-color:", ";}&:has(:checked){border-color:transparent;background-color:", ";color:", ";}&:hover:has(:checked){background-color:", ";}&:active:has(:checked){background-color:", ";}&[aria-disabled='true']{border-color:", ";background-color:", ";color:", ";}"], borderColor, backgroundColor, foregroundColor, hoverBorderColor, hoverBackgroundColor, focusStyles({
|
|
88
|
+
theme,
|
|
89
|
+
selector: '&:has(:focus-visible)',
|
|
90
|
+
styles: {
|
|
91
|
+
borderColor: focusBorderColor
|
|
92
|
+
}
|
|
93
|
+
}), activeBorderColor, activeBackgroundColor, checkedBackgroundColor, checkedForegroundColor, checkedHoverBackgroundColor, checkedActiveBackgroundColor, disabledBorderColor, disabledBackgroundColor, disabledForegroundColor);
|
|
94
|
+
};
|
|
95
|
+
const sizeStyles = _ref2 => {
|
|
96
|
+
let {
|
|
97
|
+
theme
|
|
98
|
+
} = _ref2;
|
|
99
|
+
const border = theme.borders.sm;
|
|
100
|
+
const padding = `${theme.space.base * 5}px`;
|
|
101
|
+
return css(["border:", ";padding:", ";min-width:132px;"], border, padding);
|
|
102
|
+
};
|
|
103
|
+
const StyledTile = styled.label.attrs({
|
|
104
|
+
'data-garden-id': COMPONENT_ID,
|
|
105
|
+
'data-garden-version': '9.0.0-next.20'
|
|
106
|
+
}).withConfig({
|
|
107
|
+
displayName: "StyledTile",
|
|
108
|
+
componentId: "sc-1jjvmxs-0"
|
|
109
|
+
})(["display:block;position:relative;transition:border-color .25s ease-in-out,box-shadow .1s ease-in-out,background-color .25s ease-in-out,color .25s ease-in-out;border-radius:", ";direction:", ";word-break:break-word;", ";", ";", ";"], props => props.theme.borderRadii.md, props => props.theme.rtl && 'rtl', sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
110
|
+
StyledTile.defaultProps = {
|
|
111
|
+
theme: DEFAULT_THEME
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { StyledTile };
|
|
@@ -0,0 +1,34 @@
|
|
|
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 } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getLineHeight } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'forms.tile_description';
|
|
12
|
+
const sizeStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme,
|
|
15
|
+
isCentered
|
|
16
|
+
} = _ref;
|
|
17
|
+
const marginTop = `${theme.space.base}px`;
|
|
18
|
+
const marginHorizontal = isCentered ? undefined : math(`(${theme.iconSizes.md} * 2) + ${theme.space.base * 5}px`);
|
|
19
|
+
const fontSize = theme.fontSizes.sm;
|
|
20
|
+
const lineHeight = getLineHeight(theme.space.base * 4, fontSize);
|
|
21
|
+
return css(["margin-top:", ";margin-", ":", ";line-height:", ";font-size:", ";"], marginTop, theme.rtl ? 'right' : 'left', marginHorizontal, lineHeight, fontSize);
|
|
22
|
+
};
|
|
23
|
+
const StyledTileDescription = styled.span.attrs({
|
|
24
|
+
'data-garden-id': COMPONENT_ID,
|
|
25
|
+
'data-garden-version': '9.0.0-next.20'
|
|
26
|
+
}).withConfig({
|
|
27
|
+
displayName: "StyledTileDescription",
|
|
28
|
+
componentId: "sc-xfuu7u-0"
|
|
29
|
+
})(["display:block;text-align:", ";", ";", ";"], props => props.isCentered && 'center', sizeStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
30
|
+
StyledTileDescription.defaultProps = {
|
|
31
|
+
theme: DEFAULT_THEME
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { StyledTileDescription };
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { math } from 'polished';
|
|
10
|
+
import { StyledTile } from './StyledTile.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'forms.tile_icon';
|
|
13
|
+
const colorStyles = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
const options = {
|
|
18
|
+
theme,
|
|
19
|
+
variable: 'foreground.subtle'
|
|
20
|
+
};
|
|
21
|
+
const color = 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
|
+
const checkedColor = getColor({
|
|
41
|
+
theme,
|
|
42
|
+
variable: 'foreground.onEmphasis'
|
|
43
|
+
});
|
|
44
|
+
const disabledColor = getColor({
|
|
45
|
+
theme,
|
|
46
|
+
variable: 'foreground.disabled'
|
|
47
|
+
});
|
|
48
|
+
return css(["color:", ";", ":hover &&{color:", ";}", ":active &&{color:", ";}", ":has(:checked) &&{color:", ";}", "[aria-disabled='true'] &&{color:", ";}"], color, StyledTile, hoverColor, StyledTile, activeColor, StyledTile, checkedColor, StyledTile, disabledColor);
|
|
49
|
+
};
|
|
50
|
+
const sizeStyles = _ref2 => {
|
|
51
|
+
let {
|
|
52
|
+
theme,
|
|
53
|
+
isCentered
|
|
54
|
+
} = _ref2;
|
|
55
|
+
const iconSize = math(`${theme.iconSizes.md} * 2`);
|
|
56
|
+
let position;
|
|
57
|
+
let top;
|
|
58
|
+
let horizontal;
|
|
59
|
+
if (!isCentered) {
|
|
60
|
+
position = 'absolute';
|
|
61
|
+
top = `${theme.space.base * 6}px`;
|
|
62
|
+
horizontal = `${theme.space.base * 5}px`;
|
|
63
|
+
}
|
|
64
|
+
return css(["position:", ";top:", ";", ":", ";line-height:0;& > *{width:", ";height:", ";}"], position, top, theme.rtl ? 'right' : 'left', horizontal, iconSize, iconSize);
|
|
65
|
+
};
|
|
66
|
+
const StyledTileIcon = styled.span.attrs({
|
|
67
|
+
'data-garden-id': COMPONENT_ID,
|
|
68
|
+
'data-garden-version': '9.0.0-next.20'
|
|
69
|
+
}).withConfig({
|
|
70
|
+
displayName: "StyledTileIcon",
|
|
71
|
+
componentId: "sc-1wazhg4-0"
|
|
72
|
+
})(["display:block;transition:color 0.25s ease-in-out;text-align:center;", ";", ";", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
73
|
+
StyledTileIcon.defaultProps = {
|
|
74
|
+
theme: DEFAULT_THEME
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { StyledTileIcon };
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const StyledTileInput = styled.input.withConfig({
|
|
11
|
+
displayName: "StyledTileInput",
|
|
12
|
+
componentId: "sc-1nq2m6q-0"
|
|
13
|
+
})(["position:absolute;top:0;left:0;opacity:0;z-index:1;margin:0;cursor:", ";width:100%;height:100%;"], props => props.disabled ? 'default' : 'pointer');
|
|
14
|
+
StyledTileInput.defaultProps = {
|
|
15
|
+
theme: DEFAULT_THEME
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { StyledTileInput };
|
|
@@ -0,0 +1,34 @@
|
|
|
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 } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getLineHeight } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'forms.tile_label';
|
|
12
|
+
const sizeStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
theme,
|
|
15
|
+
isCentered
|
|
16
|
+
} = _ref;
|
|
17
|
+
const marginTop = isCentered ? `${theme.space.base * 2}px` : 0;
|
|
18
|
+
const marginHorizontal = isCentered ? undefined : math(`(${theme.iconSizes.md} * 2) + ${theme.space.base * 5}px`);
|
|
19
|
+
const fontSize = theme.fontSizes.md;
|
|
20
|
+
const lineHeight = getLineHeight(theme.space.base * 5, fontSize);
|
|
21
|
+
return css(["margin-top:", ";margin-", ":", ";line-height:", ";font-size:", ";"], marginTop, theme.rtl ? 'right' : 'left', marginHorizontal, lineHeight, fontSize);
|
|
22
|
+
};
|
|
23
|
+
const StyledTileLabel = styled.span.attrs({
|
|
24
|
+
'data-garden-id': COMPONENT_ID,
|
|
25
|
+
'data-garden-version': '9.0.0-next.20'
|
|
26
|
+
}).withConfig({
|
|
27
|
+
displayName: "StyledTileLabel",
|
|
28
|
+
componentId: "sc-1mypv27-0"
|
|
29
|
+
})(["display:block;text-align:", ";font-weight:", ";", ";", ";"], props => props.isCentered && 'center', props => props.theme.fontWeights.semibold, sizeStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
30
|
+
StyledTileLabel.defaultProps = {
|
|
31
|
+
theme: DEFAULT_THEME
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { StyledTileLabel };
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { StyledHint } from '../common/StyledHint.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'forms.toggle_hint';
|
|
13
|
+
const StyledToggleHint = styled(StyledHint).attrs({
|
|
14
|
+
'data-garden-id': COMPONENT_ID,
|
|
15
|
+
'data-garden-version': '9.0.0-next.20'
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledToggleHint",
|
|
18
|
+
componentId: "sc-nziggu-0"
|
|
19
|
+
})(["padding-", ":", ";", ";"], props => props.theme.rtl ? 'right' : 'left', props => math(`${props.theme.space.base} * 12px`), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
+
StyledToggleHint.defaultProps = {
|
|
21
|
+
theme: DEFAULT_THEME
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { StyledToggleHint };
|
|
@@ -0,0 +1,65 @@
|
|
|
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 } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { StyledCheckInput } from '../checkbox/StyledCheckInput.js';
|
|
11
|
+
import { StyledToggleLabel } from './StyledToggleLabel.js';
|
|
12
|
+
|
|
13
|
+
const COMPONENT_ID = 'forms.toggle';
|
|
14
|
+
const colorStyles = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
theme
|
|
17
|
+
} = _ref;
|
|
18
|
+
const backgroundOptions = {
|
|
19
|
+
theme,
|
|
20
|
+
variable: 'background.emphasis'
|
|
21
|
+
};
|
|
22
|
+
const backgroundColor = getColor(backgroundOptions);
|
|
23
|
+
const hoverBackgroundColor = getColor({
|
|
24
|
+
...backgroundOptions,
|
|
25
|
+
dark: {
|
|
26
|
+
offset: -100
|
|
27
|
+
},
|
|
28
|
+
light: {
|
|
29
|
+
offset: 100
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const activeBackgroundColor = getColor({
|
|
33
|
+
...backgroundOptions,
|
|
34
|
+
dark: {
|
|
35
|
+
offset: -200
|
|
36
|
+
},
|
|
37
|
+
light: {
|
|
38
|
+
offset: 200
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return css(["& ~ ", "::before{background-color:", ";}&:enabled ~ ", ":hover::before{background-color:", ";}&:enabled ~ ", ":active::before{background-color:", ";}"], StyledToggleLabel, backgroundColor, StyledToggleLabel, hoverBackgroundColor, StyledToggleLabel, activeBackgroundColor);
|
|
42
|
+
};
|
|
43
|
+
const sizeStyles = _ref2 => {
|
|
44
|
+
let {
|
|
45
|
+
theme
|
|
46
|
+
} = _ref2;
|
|
47
|
+
const height = `${theme.space.base * 5}px`;
|
|
48
|
+
const width = `${theme.space.base * 10}px`;
|
|
49
|
+
const iconSize = theme.iconSizes.md;
|
|
50
|
+
const iconPosition = math(`(${height} - ${iconSize}) / 2`);
|
|
51
|
+
const checkedIconPosition = math(`${width} - ${iconSize} - ${iconPosition}`);
|
|
52
|
+
return css(["top:0;width:", ";height:", ";& ~ ", "::before{width:", ";height:", ";}& ~ ", " > svg{top:", ";", ":", ";width:", ";height:", ";}&:checked ~ ", " > svg{", ":", ";}"], width, height, StyledToggleLabel, width, height, StyledToggleLabel, iconPosition, theme.rtl ? 'right' : 'left', iconPosition, iconSize, iconSize, StyledToggleLabel, theme.rtl ? 'right' : 'left', checkedIconPosition);
|
|
53
|
+
};
|
|
54
|
+
const StyledToggleInput = styled(StyledCheckInput).attrs({
|
|
55
|
+
'data-garden-id': COMPONENT_ID,
|
|
56
|
+
'data-garden-version': '9.0.0-next.20'
|
|
57
|
+
}).withConfig({
|
|
58
|
+
displayName: "StyledToggleInput",
|
|
59
|
+
componentId: "sc-sgp47s-0"
|
|
60
|
+
})(["& ~ ", "::before{top:0;transition:box-shadow .1s ease-in-out,background-color .15s ease-in-out,color .25s ease-in-out;border:none;border-radius:100px;}", ";", ";", ";"], StyledToggleLabel, sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
61
|
+
StyledToggleInput.defaultProps = {
|
|
62
|
+
theme: DEFAULT_THEME
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { StyledToggleInput };
|