@zendeskgarden/react-theming 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/ThemeProvider.js +38 -0
- package/dist/esm/elements/palette/index.js +149 -0
- package/dist/esm/elements/theme/index.js +127 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/types/index.js +10 -0
- package/dist/esm/utils/arrowStyles.js +64 -0
- package/dist/esm/utils/focusStyles.js +43 -0
- package/dist/esm/utils/getColorV8.js +61 -0
- package/dist/esm/utils/getDocument.js +14 -0
- package/dist/esm/utils/getFocusBoxShadow.js +34 -0
- package/dist/esm/utils/getLineHeight.js +22 -0
- package/dist/esm/utils/isRtl.js +14 -0
- package/dist/esm/utils/mediaQuery.js +56 -0
- package/dist/esm/utils/menuStyles.js +49 -0
- package/dist/esm/utils/retrieveComponentStyles.js +19 -0
- package/dist/esm/utils/useDocument.js +21 -0
- package/dist/esm/utils/useText.js +29 -0
- package/dist/esm/utils/useWindow.js +21 -0
- package/dist/esm/utils/withTheme.js +13 -0
- package/dist/index.cjs.js +6 -22
- package/package.json +3 -3
- package/dist/index.esm.js +0 -648
|
@@ -0,0 +1,38 @@
|
|
|
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, { useRef } from 'react';
|
|
8
|
+
import { ThemeProvider as ThemeProvider$1 } from 'styled-components';
|
|
9
|
+
import { useFocusVisible } from '@zendeskgarden/container-focusvisible';
|
|
10
|
+
import { getControlledValue } from '@zendeskgarden/container-utilities';
|
|
11
|
+
import DEFAULT_THEME from './theme/index.js';
|
|
12
|
+
import { useDocument } from '../utils/useDocument.js';
|
|
13
|
+
|
|
14
|
+
const ThemeProvider = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
theme,
|
|
17
|
+
focusVisibleRef,
|
|
18
|
+
children,
|
|
19
|
+
...other
|
|
20
|
+
} = _ref;
|
|
21
|
+
const scopeRef = useRef(null);
|
|
22
|
+
const relativeDocument = useDocument(theme);
|
|
23
|
+
const controlledScopeRef = focusVisibleRef === null ? React.createRef() : getControlledValue(focusVisibleRef, scopeRef);
|
|
24
|
+
useFocusVisible({
|
|
25
|
+
scope: controlledScopeRef,
|
|
26
|
+
relativeDocument
|
|
27
|
+
});
|
|
28
|
+
return React.createElement(ThemeProvider$1, Object.assign({
|
|
29
|
+
theme: theme
|
|
30
|
+
}, other), focusVisibleRef === undefined ? React.createElement("div", {
|
|
31
|
+
ref: scopeRef
|
|
32
|
+
}, children) : children);
|
|
33
|
+
};
|
|
34
|
+
ThemeProvider.defaultProps = {
|
|
35
|
+
theme: DEFAULT_THEME
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { ThemeProvider };
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
const PALETTE = {
|
|
8
|
+
black: '#000',
|
|
9
|
+
white: '#fff',
|
|
10
|
+
product: {
|
|
11
|
+
support: '#00a656',
|
|
12
|
+
message: '#37b8af',
|
|
13
|
+
explore: '#30aabc',
|
|
14
|
+
gather: '#f6c8be',
|
|
15
|
+
guide: '#eb4962',
|
|
16
|
+
connect: '#ff6224',
|
|
17
|
+
chat: '#f79a3e',
|
|
18
|
+
talk: '#efc93d',
|
|
19
|
+
sell: '#c38f00'
|
|
20
|
+
},
|
|
21
|
+
grey: {
|
|
22
|
+
100: '#f8f9f9',
|
|
23
|
+
200: '#e9ebed',
|
|
24
|
+
300: '#d8dcde',
|
|
25
|
+
400: '#c2c8cc',
|
|
26
|
+
500: '#87929d',
|
|
27
|
+
600: '#68737d',
|
|
28
|
+
700: '#49545c',
|
|
29
|
+
800: '#2f3941'
|
|
30
|
+
},
|
|
31
|
+
blue: {
|
|
32
|
+
100: '#edf7ff',
|
|
33
|
+
200: '#cee2f2',
|
|
34
|
+
300: '#adcce4',
|
|
35
|
+
400: '#5293c7',
|
|
36
|
+
500: '#337fbd',
|
|
37
|
+
600: '#1f73b7',
|
|
38
|
+
700: '#144a75',
|
|
39
|
+
800: '#0f3554'
|
|
40
|
+
},
|
|
41
|
+
red: {
|
|
42
|
+
100: '#fff0f1',
|
|
43
|
+
200: '#f5d5d8',
|
|
44
|
+
300: '#f5b5ba',
|
|
45
|
+
400: '#e35b66',
|
|
46
|
+
500: '#d93f4c',
|
|
47
|
+
600: '#cc3340',
|
|
48
|
+
700: '#8c232c',
|
|
49
|
+
800: '#681219'
|
|
50
|
+
},
|
|
51
|
+
yellow: {
|
|
52
|
+
100: '#fff7ed',
|
|
53
|
+
200: '#ffeedb',
|
|
54
|
+
300: '#fed6a8',
|
|
55
|
+
400: '#ffb057',
|
|
56
|
+
500: '#f79a3e',
|
|
57
|
+
600: '#ed8f1c',
|
|
58
|
+
700: '#ad5918',
|
|
59
|
+
800: '#703815'
|
|
60
|
+
},
|
|
61
|
+
green: {
|
|
62
|
+
100: '#edf8f4',
|
|
63
|
+
200: '#d1e8df',
|
|
64
|
+
300: '#aecfc2',
|
|
65
|
+
400: '#5eae91',
|
|
66
|
+
500: '#228f67',
|
|
67
|
+
600: '#038153',
|
|
68
|
+
700: '#186146',
|
|
69
|
+
800: '#0b3b29'
|
|
70
|
+
},
|
|
71
|
+
kale: {
|
|
72
|
+
100: '#f5fcfc',
|
|
73
|
+
200: '#daeded',
|
|
74
|
+
300: '#bdd9d7',
|
|
75
|
+
400: '#90bbbb',
|
|
76
|
+
500: '#498283',
|
|
77
|
+
600: '#17494d',
|
|
78
|
+
700: '#03363d',
|
|
79
|
+
800: '#012b30'
|
|
80
|
+
},
|
|
81
|
+
fuschia: {
|
|
82
|
+
400: '#d653c2',
|
|
83
|
+
600: '#a81897',
|
|
84
|
+
M400: '#cf62a8',
|
|
85
|
+
M600: '#a8458c'
|
|
86
|
+
},
|
|
87
|
+
pink: {
|
|
88
|
+
400: '#ec4d63',
|
|
89
|
+
600: '#d42054',
|
|
90
|
+
M400: '#d57287',
|
|
91
|
+
M600: '#b23a5d'
|
|
92
|
+
},
|
|
93
|
+
crimson: {
|
|
94
|
+
400: '#e34f32',
|
|
95
|
+
600: '#c72a1c',
|
|
96
|
+
M400: '#cc6c5b',
|
|
97
|
+
M600: '#b24a3c'
|
|
98
|
+
},
|
|
99
|
+
orange: {
|
|
100
|
+
400: '#de701d',
|
|
101
|
+
600: '#bf5000',
|
|
102
|
+
M400: '#d4772c',
|
|
103
|
+
M600: '#b35827'
|
|
104
|
+
},
|
|
105
|
+
lemon: {
|
|
106
|
+
400: '#ffd424',
|
|
107
|
+
600: '#ffbb10',
|
|
108
|
+
M400: '#e7a500',
|
|
109
|
+
M600: '#c38f00'
|
|
110
|
+
},
|
|
111
|
+
lime: {
|
|
112
|
+
400: '#43b324',
|
|
113
|
+
600: '#2e8200',
|
|
114
|
+
M400: '#519e2d',
|
|
115
|
+
M600: '#47782c'
|
|
116
|
+
},
|
|
117
|
+
mint: {
|
|
118
|
+
400: '#00a656',
|
|
119
|
+
600: '#058541',
|
|
120
|
+
M400: '#299c66',
|
|
121
|
+
M600: '#2e8057'
|
|
122
|
+
},
|
|
123
|
+
teal: {
|
|
124
|
+
400: '#02a191',
|
|
125
|
+
600: '#028079',
|
|
126
|
+
M400: '#2d9e8f',
|
|
127
|
+
M600: '#3c7873'
|
|
128
|
+
},
|
|
129
|
+
azure: {
|
|
130
|
+
400: '#3091ec',
|
|
131
|
+
600: '#1371d6',
|
|
132
|
+
M400: '#5f8dcf',
|
|
133
|
+
M600: '#3a70b2'
|
|
134
|
+
},
|
|
135
|
+
royal: {
|
|
136
|
+
400: '#5d7df5',
|
|
137
|
+
600: '#3353e2',
|
|
138
|
+
M400: '#7986d8',
|
|
139
|
+
M600: '#4b61c3'
|
|
140
|
+
},
|
|
141
|
+
purple: {
|
|
142
|
+
400: '#b552e2',
|
|
143
|
+
600: '#6a27b8',
|
|
144
|
+
M400: '#b072cc',
|
|
145
|
+
M600: '#9358b0'
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { PALETTE as default };
|
|
@@ -0,0 +1,127 @@
|
|
|
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 PALETTE from '../palette/index.js';
|
|
8
|
+
|
|
9
|
+
const BASE = 4;
|
|
10
|
+
const borderRadii = {
|
|
11
|
+
sm: `${BASE / 2}px`,
|
|
12
|
+
md: `${BASE}px`
|
|
13
|
+
};
|
|
14
|
+
const borderStyles = {
|
|
15
|
+
solid: 'solid'
|
|
16
|
+
};
|
|
17
|
+
const borderWidths = {
|
|
18
|
+
sm: '1px',
|
|
19
|
+
md: '3px'
|
|
20
|
+
};
|
|
21
|
+
const borders = {
|
|
22
|
+
sm: `${borderWidths.sm} ${borderStyles.solid}`,
|
|
23
|
+
md: `${borderWidths.md} ${borderStyles.solid}`
|
|
24
|
+
};
|
|
25
|
+
const breakpoints = {
|
|
26
|
+
xs: '0px',
|
|
27
|
+
sm: `${BASE * 144}px`,
|
|
28
|
+
md: `${BASE * 192}px`,
|
|
29
|
+
lg: `${BASE * 248}px`,
|
|
30
|
+
xl: `${BASE * 300}px`
|
|
31
|
+
};
|
|
32
|
+
const colors = {
|
|
33
|
+
background: PALETTE.white,
|
|
34
|
+
foreground: PALETTE.grey[800],
|
|
35
|
+
primaryHue: 'blue',
|
|
36
|
+
dangerHue: 'red',
|
|
37
|
+
warningHue: 'yellow',
|
|
38
|
+
successHue: 'green',
|
|
39
|
+
neutralHue: 'grey',
|
|
40
|
+
chromeHue: 'kale'
|
|
41
|
+
};
|
|
42
|
+
const fonts = {
|
|
43
|
+
mono: ['SFMono-Regular' , 'Consolas' , '"Liberation Mono"' , 'Menlo', 'Courier', 'monospace'].join(','),
|
|
44
|
+
system: ['system-ui' , '-apple-system' , 'BlinkMacSystemFont' , '"Segoe UI"' , 'Roboto' , 'Oxygen-Sans' , 'Ubuntu' , 'Cantarell' , '"Helvetica Neue"', 'Arial', 'sans-serif'].join(',')
|
|
45
|
+
};
|
|
46
|
+
const fontSizes = {
|
|
47
|
+
xs: '10px',
|
|
48
|
+
sm: '12px',
|
|
49
|
+
md: '14px',
|
|
50
|
+
lg: '18px',
|
|
51
|
+
xl: '22px',
|
|
52
|
+
xxl: '26px',
|
|
53
|
+
xxxl: '36px'
|
|
54
|
+
};
|
|
55
|
+
const fontWeights = {
|
|
56
|
+
thin: 100,
|
|
57
|
+
extralight: 200,
|
|
58
|
+
light: 300,
|
|
59
|
+
regular: 400,
|
|
60
|
+
medium: 500,
|
|
61
|
+
semibold: 600,
|
|
62
|
+
bold: 700,
|
|
63
|
+
extrabold: 800,
|
|
64
|
+
black: 900
|
|
65
|
+
};
|
|
66
|
+
const iconSizes = {
|
|
67
|
+
sm: '12px',
|
|
68
|
+
md: '16px',
|
|
69
|
+
lg: '26px'
|
|
70
|
+
};
|
|
71
|
+
const lineHeights = {
|
|
72
|
+
sm: `${BASE * 4}px`,
|
|
73
|
+
md: `${BASE * 5}px`,
|
|
74
|
+
lg: `${BASE * 6}px`,
|
|
75
|
+
xl: `${BASE * 7}px`,
|
|
76
|
+
xxl: `${BASE * 8}px`,
|
|
77
|
+
xxxl: `${BASE * 11}px`
|
|
78
|
+
};
|
|
79
|
+
const palette = {
|
|
80
|
+
...PALETTE
|
|
81
|
+
};
|
|
82
|
+
delete palette.product;
|
|
83
|
+
const shadowWidths = {
|
|
84
|
+
xs: '1px',
|
|
85
|
+
sm: '2px',
|
|
86
|
+
md: '3px'
|
|
87
|
+
};
|
|
88
|
+
const shadows = {
|
|
89
|
+
xs: color => `0 0 0 ${shadowWidths.xs} ${color}`,
|
|
90
|
+
sm: color => `0 0 0 ${shadowWidths.sm} ${color}`,
|
|
91
|
+
md: color => `0 0 0 ${shadowWidths.md} ${color}`,
|
|
92
|
+
lg: (offsetY, blurRadius, color) => `0 ${offsetY} ${blurRadius} 0 ${color}`
|
|
93
|
+
};
|
|
94
|
+
const space = {
|
|
95
|
+
base: BASE,
|
|
96
|
+
xxs: `${BASE}px`,
|
|
97
|
+
xs: `${BASE * 2}px`,
|
|
98
|
+
sm: `${BASE * 3}px`,
|
|
99
|
+
md: `${BASE * 5}px`,
|
|
100
|
+
lg: `${BASE * 8}px`,
|
|
101
|
+
xl: `${BASE * 10}px`,
|
|
102
|
+
xxl: `${BASE * 12}px`
|
|
103
|
+
};
|
|
104
|
+
const DEFAULT_THEME = {
|
|
105
|
+
borders,
|
|
106
|
+
borderRadii,
|
|
107
|
+
borderStyles,
|
|
108
|
+
borderWidths,
|
|
109
|
+
breakpoints,
|
|
110
|
+
colors: {
|
|
111
|
+
base: 'light',
|
|
112
|
+
...colors
|
|
113
|
+
},
|
|
114
|
+
components: {},
|
|
115
|
+
fonts,
|
|
116
|
+
fontSizes,
|
|
117
|
+
fontWeights,
|
|
118
|
+
iconSizes,
|
|
119
|
+
lineHeights,
|
|
120
|
+
palette,
|
|
121
|
+
rtl: false,
|
|
122
|
+
shadowWidths,
|
|
123
|
+
shadows,
|
|
124
|
+
space
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export { DEFAULT_THEME as default };
|
|
@@ -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
|
+
export { ThemeProvider } from './elements/ThemeProvider.js';
|
|
8
|
+
export { default as DEFAULT_THEME } from './elements/theme/index.js';
|
|
9
|
+
export { default as PALETTE } from './elements/palette/index.js';
|
|
10
|
+
export { default as isRtl } from './utils/isRtl.js';
|
|
11
|
+
export { default as retrieveComponentStyles, default as retrieveTheme } from './utils/retrieveComponentStyles.js';
|
|
12
|
+
export { default as withTheme } from './utils/withTheme.js';
|
|
13
|
+
export { default as getDocument } from './utils/getDocument.js';
|
|
14
|
+
export { getColorV8 as getColor, getColorV8 } from './utils/getColorV8.js';
|
|
15
|
+
export { getFocusBoxShadow } from './utils/getFocusBoxShadow.js';
|
|
16
|
+
export { default as getLineHeight } from './utils/getLineHeight.js';
|
|
17
|
+
export { default as mediaQuery } from './utils/mediaQuery.js';
|
|
18
|
+
export { default as arrowStyles } from './utils/arrowStyles.js';
|
|
19
|
+
export { useDocument } from './utils/useDocument.js';
|
|
20
|
+
export { useWindow } from './utils/useWindow.js';
|
|
21
|
+
export { useText } from './utils/useText.js';
|
|
22
|
+
export { default as menuStyles } from './utils/menuStyles.js';
|
|
23
|
+
export { SELECTOR_FOCUS_VISIBLE, focusStyles } from './utils/focusStyles.js';
|
|
24
|
+
export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION } from './types/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
8
|
+
const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
9
|
+
|
|
10
|
+
export { ARROW_POSITION, MENU_POSITION };
|
|
@@ -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 { css, keyframes } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
|
|
10
|
+
const exponentialSymbols = {
|
|
11
|
+
symbols: {
|
|
12
|
+
sqrt: {
|
|
13
|
+
func: {
|
|
14
|
+
symbol: 'sqrt',
|
|
15
|
+
f: a => Math.sqrt(a),
|
|
16
|
+
notation: 'func',
|
|
17
|
+
precedence: 0,
|
|
18
|
+
rightToLeft: 0,
|
|
19
|
+
argCount: 1
|
|
20
|
+
},
|
|
21
|
+
symbol: 'sqrt',
|
|
22
|
+
regSymbol: 'sqrt\\b'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const animationStyles = (position, modifier) => {
|
|
27
|
+
const property = position.split('-')[0];
|
|
28
|
+
const animationName = keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
|
|
29
|
+
return css(["&", "::before,&", "::after{animation:0.3s ease-in-out ", ";}"], modifier, modifier, animationName);
|
|
30
|
+
};
|
|
31
|
+
const positionStyles = (position, size, inset) => {
|
|
32
|
+
const margin = math(`${size} / -2`);
|
|
33
|
+
const placement = math(`${margin} + ${inset}`);
|
|
34
|
+
let clipPath;
|
|
35
|
+
let positionCss;
|
|
36
|
+
let propertyRadius;
|
|
37
|
+
if (position.startsWith('top')) {
|
|
38
|
+
propertyRadius = 'border-bottom-right-radius';
|
|
39
|
+
clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
|
|
40
|
+
positionCss = css(["top:", ";right:", ";left:", ";margin-left:", ";"], placement, position === 'top-right' && size, position === 'top' ? '50%' : position === 'top-left' && size, position === 'top' && margin);
|
|
41
|
+
} else if (position.startsWith('right')) {
|
|
42
|
+
propertyRadius = 'border-bottom-left-radius';
|
|
43
|
+
clipPath = 'polygon(100% 0, 100% 100%, calc(100% - 1px) 100%, 0 1px, 0 0)';
|
|
44
|
+
positionCss = css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && size, placement, position === 'right-bottom' && size, position === 'right' && margin);
|
|
45
|
+
} else if (position.startsWith('bottom')) {
|
|
46
|
+
propertyRadius = 'border-top-left-radius';
|
|
47
|
+
clipPath = 'polygon(100% 0, calc(100% - 1px) 0, 0 calc(100% - 1px), 0 100%, 100% 100%)';
|
|
48
|
+
positionCss = css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && size, placement, position === 'bottom' ? '50%' : position === 'bottom-left' && size, position === 'bottom' && margin);
|
|
49
|
+
} else if (position.startsWith('left')) {
|
|
50
|
+
propertyRadius = 'border-top-right-radius';
|
|
51
|
+
clipPath = 'polygon(0 100%, 100% 100%, 100% calc(100% - 1px), 1px 0, 0 0)';
|
|
52
|
+
positionCss = css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && size, size, placement, position === 'left' && margin);
|
|
53
|
+
}
|
|
54
|
+
return css(["&::before{", ":100%;clip-path:", ";}&::before,&::after{", "}"], propertyRadius, clipPath, positionCss);
|
|
55
|
+
};
|
|
56
|
+
function arrowStyles(position) {
|
|
57
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
58
|
+
const size = options.size || '6px';
|
|
59
|
+
const inset = options.inset || '0';
|
|
60
|
+
const squareSize = math(`${size} * 2 / sqrt(2)`, exponentialSymbols);
|
|
61
|
+
return css(["position:relative;&::before{border-width:inherit;border-style:inherit;border-color:transparent;background-clip:content-box;}&::after{z-index:-1;border:inherit;box-shadow:inherit;}&::before,&::after{position:absolute;transform:rotate(45deg);background-color:inherit;box-sizing:inherit;width:", ";height:", ";content:'';}", ";", ";"], squareSize, squareSize, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles(position, options.animationModifier));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { arrowStyles as default, exponentialSymbols };
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { css } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { getFocusBoxShadow } from './getFocusBoxShadow.js';
|
|
10
|
+
|
|
11
|
+
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible, &[data-garden-focus-visible="true"]';
|
|
12
|
+
const focusStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
condition = true,
|
|
15
|
+
selector = SELECTOR_FOCUS_VISIBLE,
|
|
16
|
+
shadowWidth = 'md',
|
|
17
|
+
spacerWidth = 'xs',
|
|
18
|
+
styles: {
|
|
19
|
+
boxShadow,
|
|
20
|
+
...styles
|
|
21
|
+
} = {},
|
|
22
|
+
theme,
|
|
23
|
+
...options
|
|
24
|
+
} = _ref;
|
|
25
|
+
const _boxShadow = condition ? getFocusBoxShadow({
|
|
26
|
+
boxShadow,
|
|
27
|
+
shadowWidth,
|
|
28
|
+
spacerWidth,
|
|
29
|
+
theme,
|
|
30
|
+
...options
|
|
31
|
+
}) : boxShadow;
|
|
32
|
+
let outline;
|
|
33
|
+
let outlineOffset;
|
|
34
|
+
if (spacerWidth === null) {
|
|
35
|
+
outline = theme.shadowWidths[shadowWidth];
|
|
36
|
+
} else {
|
|
37
|
+
outline = `${math(`${theme.shadowWidths[shadowWidth]} - ${theme.shadowWidths[spacerWidth]}`)} solid transparent`;
|
|
38
|
+
outlineOffset = theme.shadowWidths[spacerWidth];
|
|
39
|
+
}
|
|
40
|
+
return css(["&:focus{outline:none;}", "{outline:", ";outline-offset:", ";box-shadow:", ";", "}"], selector, outline, outlineOffset, _boxShadow, styles);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { SELECTOR_FOCUS_VISIBLE, focusStyles };
|
|
@@ -0,0 +1,61 @@
|
|
|
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 DEFAULT_THEME from '../elements/theme/index.js';
|
|
8
|
+
import { rgba, darken, lighten } from 'polished';
|
|
9
|
+
import memoize from 'lodash.memoize';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_SHADE = 600;
|
|
12
|
+
const adjust = (color, expected, actual) => {
|
|
13
|
+
if (expected !== actual) {
|
|
14
|
+
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
15
|
+
return expected > actual ? darken(amount, color) : lighten(amount, color);
|
|
16
|
+
}
|
|
17
|
+
return color;
|
|
18
|
+
};
|
|
19
|
+
const getColorV8 = memoize(function (hue) {
|
|
20
|
+
let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
|
|
21
|
+
let theme = arguments.length > 2 ? arguments[2] : undefined;
|
|
22
|
+
let transparency = arguments.length > 3 ? arguments[3] : undefined;
|
|
23
|
+
let retVal;
|
|
24
|
+
if (isNaN(shade)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const palette = theme && theme.palette ? theme.palette : DEFAULT_THEME.palette;
|
|
28
|
+
const colors = theme && theme.colors ? theme.colors : DEFAULT_THEME.colors;
|
|
29
|
+
let _hue;
|
|
30
|
+
if (typeof hue === 'string') {
|
|
31
|
+
_hue = colors[hue] || hue;
|
|
32
|
+
} else {
|
|
33
|
+
_hue = hue;
|
|
34
|
+
}
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(palette, _hue)) {
|
|
36
|
+
_hue = palette[_hue];
|
|
37
|
+
}
|
|
38
|
+
if (typeof _hue === 'object') {
|
|
39
|
+
retVal = _hue[shade];
|
|
40
|
+
if (!retVal) {
|
|
41
|
+
const _shade = Object.keys(_hue).map(hueKey => parseInt(hueKey, 10)).reduce((previous, current) => {
|
|
42
|
+
return Math.abs(current - shade) < Math.abs(previous - shade) ? current : previous;
|
|
43
|
+
});
|
|
44
|
+
retVal = adjust(_hue[_shade], shade, _shade);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
retVal = adjust(_hue, shade, DEFAULT_SHADE);
|
|
48
|
+
}
|
|
49
|
+
if (transparency) {
|
|
50
|
+
retVal = rgba(retVal, transparency);
|
|
51
|
+
}
|
|
52
|
+
return retVal;
|
|
53
|
+
}, (hue, shade, theme, transparency) => JSON.stringify({
|
|
54
|
+
hue,
|
|
55
|
+
shade,
|
|
56
|
+
palette: theme?.palette,
|
|
57
|
+
colors: theme?.colors,
|
|
58
|
+
transparency
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
export { DEFAULT_SHADE, getColorV8 };
|
|
@@ -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
|
+
function getDocument() {
|
|
8
|
+
let {
|
|
9
|
+
theme
|
|
10
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
|
+
return theme && theme.document || document;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { getDocument as default };
|
|
@@ -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 DEFAULT_THEME from '../elements/theme/index.js';
|
|
8
|
+
import { getColorV8, DEFAULT_SHADE } from './getColorV8.js';
|
|
9
|
+
|
|
10
|
+
const getFocusBoxShadow = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
boxShadow,
|
|
13
|
+
inset = false,
|
|
14
|
+
hue = 'primaryHue',
|
|
15
|
+
shade = DEFAULT_SHADE,
|
|
16
|
+
shadowWidth = 'md',
|
|
17
|
+
spacerHue = 'background',
|
|
18
|
+
spacerShade = DEFAULT_SHADE,
|
|
19
|
+
spacerWidth = 'xs',
|
|
20
|
+
theme = DEFAULT_THEME
|
|
21
|
+
} = _ref;
|
|
22
|
+
const color = getColorV8(hue, shade, theme);
|
|
23
|
+
const shadow = theme.shadows[shadowWidth](color);
|
|
24
|
+
if (spacerWidth === null) {
|
|
25
|
+
return `${inset ? 'inset' : ''} ${shadow}`;
|
|
26
|
+
}
|
|
27
|
+
const spacerColor = getColorV8(spacerHue, spacerShade, theme);
|
|
28
|
+
const retVal = `
|
|
29
|
+
${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](spacerColor)},
|
|
30
|
+
${inset ? 'inset' : ''} ${shadow}`;
|
|
31
|
+
return boxShadow ? `${retVal}, ${boxShadow}` : retVal;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { getFocusBoxShadow };
|
|
@@ -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 { getValueAndUnit } from 'polished';
|
|
8
|
+
|
|
9
|
+
function getLineHeight(height, fontSize) {
|
|
10
|
+
const [heightValue, heightUnit] = getValueAndUnit(height.toString());
|
|
11
|
+
const [fontSizeValue, fontSizeUnit] = getValueAndUnit(fontSize.toString());
|
|
12
|
+
const PIXELS = 'px';
|
|
13
|
+
if (heightUnit && heightUnit !== PIXELS) {
|
|
14
|
+
throw new Error(`Unexpected \`height\` with '${heightUnit}' units.`);
|
|
15
|
+
}
|
|
16
|
+
if (fontSizeUnit && fontSizeUnit !== PIXELS) {
|
|
17
|
+
throw new Error(`Unexpected \`fontSize\` with '${fontSizeUnit}' units.`);
|
|
18
|
+
}
|
|
19
|
+
return heightValue / fontSizeValue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { getLineHeight as default };
|
|
@@ -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
|
+
function isRtl() {
|
|
8
|
+
let {
|
|
9
|
+
theme
|
|
10
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
|
+
return Boolean(theme && theme.rtl);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { isRtl as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
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 DEFAULT_THEME from '../elements/theme/index.js';
|
|
8
|
+
import { getValueAndUnit } from 'polished';
|
|
9
|
+
|
|
10
|
+
const maxWidth = (breakpoints, breakpoint) => {
|
|
11
|
+
const keys = Object.keys(breakpoints);
|
|
12
|
+
const index = keys.indexOf(breakpoint) + 1;
|
|
13
|
+
if (keys[index]) {
|
|
14
|
+
const dimension = getValueAndUnit(breakpoints[keys[index]]);
|
|
15
|
+
const value = dimension[0] - 0.02;
|
|
16
|
+
const unit = dimension[1];
|
|
17
|
+
return `${value}${unit}`;
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
};
|
|
21
|
+
function mediaQuery(query, breakpoint, theme) {
|
|
22
|
+
let retVal;
|
|
23
|
+
let min;
|
|
24
|
+
let max;
|
|
25
|
+
const breakpoints = theme && theme.breakpoints ? theme.breakpoints : DEFAULT_THEME.breakpoints;
|
|
26
|
+
if (typeof breakpoint === 'string') {
|
|
27
|
+
if (query === 'up') {
|
|
28
|
+
min = breakpoints[breakpoint];
|
|
29
|
+
} else if (query === 'down') {
|
|
30
|
+
if (breakpoint === 'xl') {
|
|
31
|
+
min = DEFAULT_THEME.breakpoints.xs;
|
|
32
|
+
} else {
|
|
33
|
+
max = maxWidth(breakpoints, breakpoint);
|
|
34
|
+
}
|
|
35
|
+
} else if (query === 'only') {
|
|
36
|
+
min = breakpoints[breakpoint];
|
|
37
|
+
max = maxWidth(breakpoints, breakpoint);
|
|
38
|
+
}
|
|
39
|
+
} else if (query === 'between') {
|
|
40
|
+
min = breakpoints[breakpoint[0]];
|
|
41
|
+
max = maxWidth(breakpoints, breakpoint[1]);
|
|
42
|
+
}
|
|
43
|
+
if (min) {
|
|
44
|
+
retVal = `@media (min-width: ${min})`;
|
|
45
|
+
if (max) {
|
|
46
|
+
retVal = `${retVal} and (max-width: ${max})`;
|
|
47
|
+
}
|
|
48
|
+
} else if (max) {
|
|
49
|
+
retVal = `@media (max-width: ${max})`;
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error(`Unexpected query and breakpoint combination: '${query}', '${breakpoint}'.`);
|
|
52
|
+
}
|
|
53
|
+
return retVal;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { mediaQuery as default };
|