@zendeskgarden/react-colorpickers 8.75.1 → 8.76.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/ColorSwatch/index.js +102 -0
- package/dist/esm/elements/ColorSwatchDialog/index.js +198 -0
- package/dist/esm/elements/Colorpicker/ColorWell.js +109 -0
- package/dist/esm/elements/Colorpicker/index.js +236 -0
- package/dist/esm/elements/Colorpicker/reducer.js +275 -0
- package/dist/esm/elements/ColorpickerDialog/index.js +156 -0
- package/dist/esm/index.js +10 -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/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/styled/ColorSwatch/StyledCell.js +22 -0
- package/dist/esm/styled/ColorSwatch/StyledColorSwatch.js +23 -0
- package/dist/esm/styled/ColorSwatch/StyledIcon.js +48 -0
- package/dist/esm/styled/ColorSwatch/StyledSwatchButton.js +27 -0
- package/dist/esm/styled/Colorpicker/StyledAlphaRange.js +37 -0
- package/dist/esm/styled/Colorpicker/StyledColorPicker.js +25 -0
- package/dist/esm/styled/Colorpicker/StyledColorWell.js +36 -0
- package/dist/esm/styled/Colorpicker/StyledColorWellThumb.js +40 -0
- package/dist/esm/styled/Colorpicker/StyledHexField.js +24 -0
- package/dist/esm/styled/Colorpicker/StyledHueRange.js +23 -0
- package/dist/esm/styled/Colorpicker/StyledInput.js +24 -0
- package/dist/esm/styled/Colorpicker/StyledInputGroup.js +22 -0
- package/dist/esm/styled/Colorpicker/StyledLabel.js +23 -0
- package/dist/esm/styled/Colorpicker/StyledPreview.js +37 -0
- package/dist/esm/styled/Colorpicker/StyledRGBAField.js +32 -0
- package/dist/esm/styled/Colorpicker/StyledSliderGroup.js +22 -0
- package/dist/esm/styled/Colorpicker/StyledSliders.js +23 -0
- package/dist/esm/styled/ColorpickerDialog/StyledButton.js +24 -0
- package/dist/esm/styled/ColorpickerDialog/StyledButtonPreview.js +48 -0
- package/dist/esm/styled/ColorpickerDialog/StyledTooltipBody.js +23 -0
- package/dist/esm/styled/ColorpickerDialog/StyledTooltipModal.js +23 -0
- package/dist/esm/styled/common/StyledRange.js +151 -0
- package/dist/esm/styled/common/checkeredBackground.js +28 -0
- package/dist/esm/utils/conversion.js +34 -0
- package/dist/esm/utils/saturation.js +64 -0
- package/dist/esm/utils/validation.js +12 -0
- package/dist/index.cjs.js +33 -49
- package/package.json +9 -9
- package/dist/index.esm.js +0 -1583
|
@@ -0,0 +1,36 @@
|
|
|
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 { rgba, hsl } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_colorwell';
|
|
12
|
+
const background = props => {
|
|
13
|
+
const blackAlpha = rgba(props.theme.palette.black, 0.9);
|
|
14
|
+
const black = `linear-gradient(0deg, ${props.theme.palette.black}, ${blackAlpha} 1%, transparent 99%)`;
|
|
15
|
+
const whiteAngle = `${props.theme.rtl ? -90 : 90}deg`;
|
|
16
|
+
const white = `linear-gradient(${whiteAngle}, ${props.theme.palette.white} 1%, transparent)`;
|
|
17
|
+
const colorValue = hsl(props.hue, 1, 0.5);
|
|
18
|
+
const color = `linear-gradient(${colorValue}, ${colorValue})`;
|
|
19
|
+
return `${black}, ${white}, ${color}`;
|
|
20
|
+
};
|
|
21
|
+
const StyledColorWell = styled.div.attrs(props => ({
|
|
22
|
+
'data-garden-id': COMPONENT_ID,
|
|
23
|
+
'data-garden-version': '8.76.0',
|
|
24
|
+
'data-test-id': 'colorwell',
|
|
25
|
+
style: {
|
|
26
|
+
background: background(props)
|
|
27
|
+
}
|
|
28
|
+
})).withConfig({
|
|
29
|
+
displayName: "StyledColorWell",
|
|
30
|
+
componentId: "sc-54ly7s-0"
|
|
31
|
+
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
32
|
+
StyledColorWell.defaultProps = {
|
|
33
|
+
theme: DEFAULT_THEME
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { StyledColorWell };
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { stripUnit } from 'polished';
|
|
9
|
+
import { getColorV8, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_colorwell_thumb';
|
|
12
|
+
const sizeStyles = theme => {
|
|
13
|
+
const borderWidth = stripUnit(theme.borderWidths.sm) * 2;
|
|
14
|
+
const size = theme.space.base * 5;
|
|
15
|
+
const translateValue = size / -2;
|
|
16
|
+
return `
|
|
17
|
+
transform: translate(${translateValue}px, ${translateValue}px);
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
border-width: ${borderWidth}px;
|
|
20
|
+
width: ${size}px;
|
|
21
|
+
height: ${size}px;
|
|
22
|
+
`;
|
|
23
|
+
};
|
|
24
|
+
const StyledColorWellThumb = styled.div.attrs(props => ({
|
|
25
|
+
'data-garden-id': COMPONENT_ID,
|
|
26
|
+
'data-garden-version': '8.76.0',
|
|
27
|
+
'data-test-id': 'colorwell-thumb',
|
|
28
|
+
style: {
|
|
29
|
+
top: `${props.top}%`,
|
|
30
|
+
left: `${props.left}%`
|
|
31
|
+
}
|
|
32
|
+
})).withConfig({
|
|
33
|
+
displayName: "StyledColorWellThumb",
|
|
34
|
+
componentId: "sc-1pnz3jz-0"
|
|
35
|
+
})(["position:absolute;border:solid ", ";border-radius:50%;box-shadow:", ";", ";", ";"], props => props.theme.palette.white, props => props.theme.shadows.lg(`${props.theme.space.base}px`, `${props.theme.space.base * 2}px`, getColorV8('neutralHue', 800, props.theme, 0.24)), props => sizeStyles(props.theme), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
36
|
+
StyledColorWellThumb.defaultProps = {
|
|
37
|
+
theme: DEFAULT_THEME
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { StyledColorWellThumb };
|
|
@@ -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 { Field } from '@zendeskgarden/react-forms';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_hex_field';
|
|
12
|
+
const StyledHexField = styled(Field).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0',
|
|
15
|
+
spellcheck: false
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledHexField",
|
|
18
|
+
componentId: "sc-1lk14t4-0"
|
|
19
|
+
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
+
StyledHexField.defaultProps = {
|
|
21
|
+
theme: DEFAULT_THEME
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { StyledHexField };
|
|
@@ -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 { DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { StyledRange, getTrackMargin, getTrackHeight } from '../common/StyledRange.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_hue';
|
|
12
|
+
const StyledHueRange = styled(StyledRange).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledHueRange",
|
|
17
|
+
componentId: "sc-13ly7p-0"
|
|
18
|
+
})(["background:linear-gradient( to ", ",#f00 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,#f00 100% ) no-repeat;background-position:", ";background-size:100% ", "px;"], props => props.theme.rtl ? 'left' : 'right', props => !props.isOpaque && `0 ${getTrackMargin(props)}px`, props => getTrackHeight(props));
|
|
19
|
+
StyledHueRange.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledHueRange };
|
|
@@ -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 { Input } from '@zendeskgarden/react-forms';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_input';
|
|
12
|
+
const StyledInput = styled(Input).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0',
|
|
15
|
+
focusInset: false
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledInput",
|
|
18
|
+
componentId: "sc-1iap93p-0"
|
|
19
|
+
})(["text-align:center;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
+
StyledInput.defaultProps = {
|
|
21
|
+
theme: DEFAULT_THEME
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { StyledInput };
|
|
@@ -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 = 'colorpickers.colorpicker_input_group';
|
|
11
|
+
const StyledInputGroup = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '8.76.0'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledInputGroup",
|
|
16
|
+
componentId: "sc-mmy93w-0"
|
|
17
|
+
})(["display:flex;justify-content:space-between;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledInputGroup.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledInputGroup };
|
|
@@ -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 { Label } from '@zendeskgarden/react-forms';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_label';
|
|
12
|
+
const StyledLabel = styled(Label).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledLabel",
|
|
17
|
+
componentId: "sc-1klhp6m-0"
|
|
18
|
+
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledLabel.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledLabel };
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { rgba } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { checkeredBackground } from '../common/checkeredBackground.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_preview_box';
|
|
13
|
+
const background = props => {
|
|
14
|
+
const alpha = props.alpha ? props.alpha / 100 : 0;
|
|
15
|
+
const color = `rgba(${props.red}, ${props.green}, ${props.blue}, ${alpha})`;
|
|
16
|
+
let retVal = `linear-gradient(${color}, ${color})`;
|
|
17
|
+
if (!props.isOpaque) {
|
|
18
|
+
retVal = `${retVal}, ${checkeredBackground(props.theme, 13)}`;
|
|
19
|
+
}
|
|
20
|
+
return retVal;
|
|
21
|
+
};
|
|
22
|
+
const StyledPreview = styled.div.attrs(props => ({
|
|
23
|
+
style: {
|
|
24
|
+
background: background(props)
|
|
25
|
+
},
|
|
26
|
+
'data-garden-id': COMPONENT_ID,
|
|
27
|
+
'data-garden-version': '8.76.0',
|
|
28
|
+
'data-test-id': 'preview-box'
|
|
29
|
+
})).withConfig({
|
|
30
|
+
displayName: "StyledPreview",
|
|
31
|
+
componentId: "sc-d70mj1-0"
|
|
32
|
+
})(["flex-shrink:0;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.borderRadii.md, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
33
|
+
StyledPreview.defaultProps = {
|
|
34
|
+
theme: DEFAULT_THEME
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { StyledPreview };
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { Field } from '@zendeskgarden/react-forms';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_rgb_field';
|
|
12
|
+
const sizeStyles = theme => {
|
|
13
|
+
const margin = `${theme.space.base * 1.5}px`;
|
|
14
|
+
const width = `${theme.space.base * 12.75}px`;
|
|
15
|
+
return `
|
|
16
|
+
margin-${theme.rtl ? 'right' : 'left'}: ${margin};
|
|
17
|
+
width: ${width};
|
|
18
|
+
min-width: ${width};
|
|
19
|
+
`;
|
|
20
|
+
};
|
|
21
|
+
const StyledRGBAField = styled(Field).attrs({
|
|
22
|
+
'data-garden-id': COMPONENT_ID,
|
|
23
|
+
'data-garden-version': '8.76.0'
|
|
24
|
+
}).withConfig({
|
|
25
|
+
displayName: "StyledRGBAField",
|
|
26
|
+
componentId: "sc-ibo1yw-0"
|
|
27
|
+
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"], props => sizeStyles(props.theme), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
28
|
+
StyledRGBAField.defaultProps = {
|
|
29
|
+
theme: DEFAULT_THEME
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { StyledRGBAField };
|
|
@@ -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 = 'colorpickers.colorpicker_slider_group';
|
|
11
|
+
const StyledSliderGroup = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '8.76.0'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledSliderGroup",
|
|
16
|
+
componentId: "sc-rsq0ak-0"
|
|
17
|
+
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledSliderGroup.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledSliderGroup };
|
|
@@ -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 { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { getTrackMargin, getTrackHeight } from '../common/StyledRange.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_sliders';
|
|
12
|
+
const StyledSliders = styled.div.attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledSliders",
|
|
17
|
+
componentId: "sc-aclca2-0"
|
|
18
|
+
})(["position:relative;margin-", ":", "px;width:100%;& > *{position:absolute;width:100%;height:", "px;}& > :first-child{top:-", "px;}& > :last-child{bottom:-", "px;}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 2, props => getTrackMargin(props) * 2 + getTrackHeight(props), getTrackMargin, getTrackMargin, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledSliders.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledSliders };
|
|
@@ -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 { Button } from '@zendeskgarden/react-buttons';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colordialog_button';
|
|
12
|
+
const StyledButton = styled(Button).attrs({
|
|
13
|
+
isNeutral: true,
|
|
14
|
+
'data-garden-id': COMPONENT_ID,
|
|
15
|
+
'data-garden-version': '8.76.0'
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledButton",
|
|
18
|
+
componentId: "sc-101xjve-0"
|
|
19
|
+
})(["padding:0;width:", "px;max-width:", "px;&:last-of-type:not(:first-child){border-top-", "-radius:", " !important;border-bottom-", "-radius:", " !important;}", ";"], props => props.theme.space.base * 17, props => props.theme.space.base * 17, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
+
StyledButton.defaultProps = {
|
|
21
|
+
theme: DEFAULT_THEME
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { StyledButton };
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { rgba } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { checkeredBackground } from '../common/checkeredBackground.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'colorpickers.colordialog_preview';
|
|
13
|
+
const background = props => {
|
|
14
|
+
const {
|
|
15
|
+
backgroundColor
|
|
16
|
+
} = props;
|
|
17
|
+
let color;
|
|
18
|
+
if (typeof backgroundColor === 'string') {
|
|
19
|
+
color = backgroundColor;
|
|
20
|
+
} else if (backgroundColor === undefined) {
|
|
21
|
+
color = props.theme.palette.white;
|
|
22
|
+
} else {
|
|
23
|
+
const {
|
|
24
|
+
red,
|
|
25
|
+
green,
|
|
26
|
+
blue,
|
|
27
|
+
alpha = 1
|
|
28
|
+
} = backgroundColor;
|
|
29
|
+
color = `rgba(${red}, ${green}, ${blue}, ${alpha ? alpha / 100 : 0})`;
|
|
30
|
+
}
|
|
31
|
+
return `linear-gradient(${color}, ${color})`;
|
|
32
|
+
};
|
|
33
|
+
const StyledButtonPreview = styled.span.attrs(props => ({
|
|
34
|
+
style: {
|
|
35
|
+
background: `${background(props)}, ${checkeredBackground(props.theme, 8)}`
|
|
36
|
+
},
|
|
37
|
+
'data-garden-id': COMPONENT_ID,
|
|
38
|
+
'data-garden-version': '8.76.0',
|
|
39
|
+
'data-test-id': 'dialog-preview'
|
|
40
|
+
})).withConfig({
|
|
41
|
+
displayName: "StyledButtonPreview",
|
|
42
|
+
componentId: "sc-1jzysg3-0"
|
|
43
|
+
})(["display:inline-block;bottom:", "px;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.space.base, props => props.theme.borderRadii.sm, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * 5, props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
44
|
+
StyledButtonPreview.defaultProps = {
|
|
45
|
+
theme: DEFAULT_THEME
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { StyledButtonPreview };
|
|
@@ -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 { TooltipModal } from '@zendeskgarden/react-modals';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colordialog_tooltipmodal_body';
|
|
12
|
+
const StyledTooltipBody = styled(TooltipModal.Body).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledTooltipBody",
|
|
17
|
+
componentId: "sc-6gsgsy-0"
|
|
18
|
+
})(["padding:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledTooltipBody.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledTooltipBody };
|
|
@@ -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 { TooltipModal } from '@zendeskgarden/react-modals';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'colorpickers.colordialog_tooltipmodal';
|
|
12
|
+
const StyledTooltipModal = styled(TooltipModal).attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '8.76.0'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledTooltipModal",
|
|
17
|
+
componentId: "sc-o022s8-0"
|
|
18
|
+
})(["width:auto !important;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledTooltipModal.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledTooltipModal };
|
|
@@ -0,0 +1,151 @@
|
|
|
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 { Range } from '@zendeskgarden/react-forms';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import { stripUnit, math } from 'polished';
|
|
10
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'colorpickers.colorpicker_range';
|
|
13
|
+
const thumbStyles = function (styles) {
|
|
14
|
+
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
15
|
+
return `
|
|
16
|
+
&${modifier}::-moz-range-thumb {
|
|
17
|
+
${styles}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&${modifier}::-ms-thumb {
|
|
21
|
+
${styles}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&${modifier}::-webkit-slider-thumb {
|
|
25
|
+
${styles}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
29
|
+
const trackStyles = function (styles) {
|
|
30
|
+
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
31
|
+
return `
|
|
32
|
+
&${modifier}::-moz-range-track {
|
|
33
|
+
${styles}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&${modifier}::-ms-track {
|
|
37
|
+
${styles}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&${modifier}::-webkit-slider-runnable-track {
|
|
41
|
+
${styles}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
};
|
|
45
|
+
const trackLowerStyles = function (styles) {
|
|
46
|
+
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
47
|
+
return `
|
|
48
|
+
&${modifier}::-moz-range-progress {
|
|
49
|
+
${styles}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&${modifier}::-ms-fill-lower {
|
|
53
|
+
${styles}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
};
|
|
57
|
+
const colorStyles = props => {
|
|
58
|
+
const thumbBackgroundColor = getColorV8('neutralHue', 100, props.theme);
|
|
59
|
+
const thumbBorderColor = thumbBackgroundColor;
|
|
60
|
+
const thumbActiveBackgroundColor = getColorV8('neutralHue', 200, props.theme);
|
|
61
|
+
const thumbActiveBorderColor = getColorV8('primaryHue', 600, props.theme);
|
|
62
|
+
const thumbFocusBorderColor = getColorV8('primaryHue', 400, props.theme);
|
|
63
|
+
const thumbHoverBackgroundColor = thumbActiveBackgroundColor;
|
|
64
|
+
const thumbHoverBorderColor = thumbHoverBackgroundColor;
|
|
65
|
+
return `
|
|
66
|
+
border-color: ${props.isOpaque && getColorV8('background', 600 , props.theme)};
|
|
67
|
+
|
|
68
|
+
${trackStyles(`
|
|
69
|
+
background-color: transparent;
|
|
70
|
+
`)}
|
|
71
|
+
|
|
72
|
+
${thumbStyles(`
|
|
73
|
+
border-color: ${thumbBorderColor};
|
|
74
|
+
background-color: ${thumbBackgroundColor};
|
|
75
|
+
`)}
|
|
76
|
+
|
|
77
|
+
${trackLowerStyles(`
|
|
78
|
+
background-color: transparent;
|
|
79
|
+
`)}
|
|
80
|
+
|
|
81
|
+
${thumbStyles(`
|
|
82
|
+
border-color: ${thumbHoverBorderColor};
|
|
83
|
+
background-color: ${thumbHoverBackgroundColor};
|
|
84
|
+
`, ':hover')}
|
|
85
|
+
|
|
86
|
+
${thumbStyles(`
|
|
87
|
+
background-color: ${thumbBackgroundColor};
|
|
88
|
+
border-color: ${thumbFocusBorderColor};
|
|
89
|
+
`, '[data-garden-focus-visible="true"]')}
|
|
90
|
+
|
|
91
|
+
${thumbStyles(`
|
|
92
|
+
border-color: ${thumbActiveBorderColor};
|
|
93
|
+
background-color: ${thumbActiveBackgroundColor}
|
|
94
|
+
`, ':active')}
|
|
95
|
+
`;
|
|
96
|
+
};
|
|
97
|
+
const getThumbSize = props => props.theme.space.base * (props.isOpaque ? 6 : 4);
|
|
98
|
+
const getTrackHeight = props => props.theme.space.base * (props.isOpaque ? 6 : 3);
|
|
99
|
+
const getTrackMargin = props => (getThumbSize(props) - getTrackHeight(props)) / 2 + stripUnit(props.theme.shadowWidths.md);
|
|
100
|
+
const sizeStyles = props => {
|
|
101
|
+
const thumbSize = getThumbSize(props);
|
|
102
|
+
const trackHeight = getTrackHeight(props);
|
|
103
|
+
const trackMargin = getTrackMargin(props);
|
|
104
|
+
const thumbMargin = (trackHeight - thumbSize) / 2;
|
|
105
|
+
const trackOffset = props.theme.space.base * (props.isOpaque ? -2 : -1);
|
|
106
|
+
const height = props.isOpaque ? trackHeight : trackMargin * 2 + trackHeight;
|
|
107
|
+
let marginHorizontal;
|
|
108
|
+
let border;
|
|
109
|
+
let borderRadius;
|
|
110
|
+
if (props.isOpaque) {
|
|
111
|
+
marginHorizontal = `-${trackMargin}px`;
|
|
112
|
+
border = `${trackMargin}px ${props.theme.borderStyles.solid}`;
|
|
113
|
+
borderRadius = `${trackMargin + stripUnit(props.theme.shadowWidths.md)}px`;
|
|
114
|
+
}
|
|
115
|
+
return `
|
|
116
|
+
/* stylelint-disable-next-line declaration-no-important */
|
|
117
|
+
margin-top: 0 !important;
|
|
118
|
+
margin-${props.theme.rtl ? 'right' : 'left'}: ${marginHorizontal};
|
|
119
|
+
height: ${height}px; /* [1] */
|
|
120
|
+
box-sizing: content-box; /* [2] */
|
|
121
|
+
border: ${border};
|
|
122
|
+
border-radius: ${borderRadius};
|
|
123
|
+
|
|
124
|
+
${trackStyles(`
|
|
125
|
+
margin: ${trackMargin}px ${trackOffset}px;
|
|
126
|
+
height: ${trackHeight}px;
|
|
127
|
+
`)}
|
|
128
|
+
|
|
129
|
+
${thumbStyles(`
|
|
130
|
+
margin: ${thumbMargin}px 0;
|
|
131
|
+
border-width: ${math(`${props.theme.borderWidths.sm} * 2`)};
|
|
132
|
+
height: ${thumbSize}px;
|
|
133
|
+
width: ${thumbSize}px;
|
|
134
|
+
`)};
|
|
135
|
+
`;
|
|
136
|
+
};
|
|
137
|
+
const StyledRange = styled(Range).attrs({
|
|
138
|
+
'data-garden-id': COMPONENT_ID,
|
|
139
|
+
'data-garden-version': '8.76.0',
|
|
140
|
+
hasLowerTrack: false
|
|
141
|
+
}).withConfig({
|
|
142
|
+
displayName: "StyledRange",
|
|
143
|
+
componentId: "sc-ug3wi9-0"
|
|
144
|
+
})(["", ";", " ", ";", ";"], sizeStyles, trackStyles(`
|
|
145
|
+
border-radius: 0;
|
|
146
|
+
`), colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
147
|
+
StyledRange.defaultProps = {
|
|
148
|
+
theme: DEFAULT_THEME
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export { StyledRange, getTrackHeight, getTrackMargin, trackStyles };
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { getColorV8 } from '@zendeskgarden/react-theming';
|
|
8
|
+
|
|
9
|
+
const checkeredBackground = function (theme, size) {
|
|
10
|
+
let positionY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11
|
+
let repeat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'repeat';
|
|
12
|
+
const color = getColorV8('neutralHue', 400, theme);
|
|
13
|
+
const dimensions = `${size}px ${size}px`;
|
|
14
|
+
const positionX1 = theme.rtl ? '100%' : '0';
|
|
15
|
+
const positionX2 = theme.rtl ? `calc(100% - ${size / 2}px)` : `${size / 2}px`;
|
|
16
|
+
const position1 = `${positionX1} ${positionY}px`;
|
|
17
|
+
const position2 = `${positionX2} ${size / 2 + positionY}px`;
|
|
18
|
+
const position3 = `${positionX2} ${positionY}px`;
|
|
19
|
+
const position4 = `${positionX1} ${size / -2 + positionY}px`;
|
|
20
|
+
return `
|
|
21
|
+
linear-gradient(45deg, ${color} 25%, transparent 25%) ${position1} / ${dimensions} ${repeat},
|
|
22
|
+
linear-gradient(45deg, transparent 75%, ${color} 75%) ${position2} / ${dimensions} ${repeat},
|
|
23
|
+
linear-gradient(135deg, ${color} 25%, transparent 25%) ${position3} / ${dimensions} ${repeat},
|
|
24
|
+
linear-gradient(135deg, transparent 75%, ${color} 75%) ${position4} / ${dimensions} ${repeat}
|
|
25
|
+
`;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { checkeredBackground };
|
|
@@ -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
|
+
function hslToHsv(h, s, l) {
|
|
8
|
+
let saturation = s;
|
|
9
|
+
saturation *= (l < 50 ? l : 100 - l) / 100;
|
|
10
|
+
const v = l + saturation;
|
|
11
|
+
return {
|
|
12
|
+
h,
|
|
13
|
+
s: v === 0 ? 0 : 2 * saturation / v * 100,
|
|
14
|
+
v
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function hsvToHsl(h, s, v) {
|
|
18
|
+
let saturation = s;
|
|
19
|
+
let value = v;
|
|
20
|
+
saturation /= 100;
|
|
21
|
+
value /= 100;
|
|
22
|
+
let l = (2 - saturation) * value;
|
|
23
|
+
let sl = saturation * value;
|
|
24
|
+
sl /= l <= 1 ? l : 2 - l;
|
|
25
|
+
sl = sl || 0;
|
|
26
|
+
l /= 2;
|
|
27
|
+
return {
|
|
28
|
+
h,
|
|
29
|
+
s: sl * 100,
|
|
30
|
+
l: l * 100
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { hslToHsv, hsvToHsl };
|