@zendeskgarden/react-theming 9.0.0-next.12 → 9.0.0-next.14
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/utils/arrowStyles.js +13 -32
- package/dist/esm/utils/getColor.js +73 -15
- package/dist/esm/utils/menuStyles.js +29 -15
- package/dist/index.cjs.js +112 -58
- package/dist/typings/utils/arrowStyles.d.ts +0 -16
- package/package.json +4 -5
|
@@ -5,24 +5,8 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import { css, keyframes } from 'styled-components';
|
|
8
|
-
import { math } from 'polished';
|
|
8
|
+
import { stripUnit, math } from 'polished';
|
|
9
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
10
|
const animationStyles = (position, modifier) => {
|
|
27
11
|
const property = position.split('-')[0];
|
|
28
12
|
const animationName = keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
|
|
@@ -31,34 +15,31 @@ const animationStyles = (position, modifier) => {
|
|
|
31
15
|
const positionStyles = (position, size, inset) => {
|
|
32
16
|
const margin = math(`${size} / -2`);
|
|
33
17
|
const placement = math(`${margin} + ${inset}`);
|
|
34
|
-
let
|
|
18
|
+
let transform;
|
|
35
19
|
let positionCss;
|
|
36
|
-
let propertyRadius;
|
|
37
20
|
if (position.startsWith('top')) {
|
|
38
|
-
|
|
39
|
-
clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
|
|
21
|
+
transform = 'rotate(-135deg)';
|
|
40
22
|
positionCss = css(["top:", ";right:", ";left:", ";margin-left:", ";"], placement, position === 'top-right' && size, position === 'top' ? '50%' : position === 'top-left' && size, position === 'top' && margin);
|
|
41
23
|
} else if (position.startsWith('right')) {
|
|
42
|
-
|
|
43
|
-
clipPath = 'polygon(100% 0, 100% 100%, calc(100% - 1px) 100%, 0 1px, 0 0)';
|
|
24
|
+
transform = 'rotate(-45deg)';
|
|
44
25
|
positionCss = css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && size, placement, position === 'right-bottom' && size, position === 'right' && margin);
|
|
45
26
|
} else if (position.startsWith('bottom')) {
|
|
46
|
-
|
|
47
|
-
clipPath = 'polygon(100% 0, calc(100% - 1px) 0, 0 calc(100% - 1px), 0 100%, 100% 100%)';
|
|
27
|
+
transform = 'rotate(45deg)';
|
|
48
28
|
positionCss = css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && size, placement, position === 'bottom' ? '50%' : position === 'bottom-left' && size, position === 'bottom' && margin);
|
|
49
29
|
} else if (position.startsWith('left')) {
|
|
50
|
-
|
|
51
|
-
clipPath = 'polygon(0 100%, 100% 100%, 100% calc(100% - 1px), 1px 0, 0 0)';
|
|
30
|
+
transform = 'rotate(135deg)';
|
|
52
31
|
positionCss = css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && size, size, placement, position === 'left' && margin);
|
|
53
32
|
}
|
|
54
|
-
return css(["&::before{
|
|
33
|
+
return css(["&::before,&::after{transform:", ";", ";}"], transform, positionCss);
|
|
55
34
|
};
|
|
56
35
|
function arrowStyles(position) {
|
|
57
36
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
58
|
-
const size = options.size || '6px';
|
|
59
37
|
const inset = options.inset || '0';
|
|
60
|
-
const
|
|
61
|
-
|
|
38
|
+
const size = options.size === undefined ? 6 : stripUnit(options.size);
|
|
39
|
+
const squareSize = `${Math.round(size * 2 / Math.sqrt(2))}px`;
|
|
40
|
+
const afterOffset = 0;
|
|
41
|
+
const beforeOffset = afterOffset + 2;
|
|
42
|
+
return css(["position:relative;&::before,&::after{position:absolute;border-width:inherit;border-style:inherit;width:", ";height:", ";content:'';box-sizing:inherit;}&::before{border-color:inherit;background-color:transparent;clip-path:polygon(100% ", "px,", "px 100%,100% 100%);}&::after{border-color:transparent;background-clip:content-box;background-color:inherit;clip-path:polygon(100% ", "px,", "px 100%,100% 100%);}", ";", ";"], squareSize, squareSize, beforeOffset, beforeOffset, afterOffset, afterOffset, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles(position, options.animationModifier));
|
|
62
43
|
}
|
|
63
44
|
|
|
64
|
-
export { arrowStyles as default
|
|
45
|
+
export { arrowStyles as default };
|
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { rgba, darken, lighten } from 'polished';
|
|
7
|
+
import { getScale, parseToRgba } from 'color2k';
|
|
8
|
+
import { getContrast, rgba, darken, lighten } from 'polished';
|
|
9
9
|
import get from 'lodash.get';
|
|
10
10
|
import memoize from 'lodash.memoize';
|
|
11
11
|
import DEFAULT_THEME from '../elements/theme/index.js';
|
|
12
|
-
import PALETTE from '../elements/palette/index.js';
|
|
13
12
|
|
|
14
|
-
const PALETTE_SIZE = Object.keys(PALETTE.blue).length;
|
|
15
13
|
const adjust = (color, expected, actual) => {
|
|
16
14
|
if (expected !== actual) {
|
|
17
15
|
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
@@ -42,6 +40,74 @@ const toHex = (hue, shade, offset, scheme) => {
|
|
|
42
40
|
}
|
|
43
41
|
return retVal;
|
|
44
42
|
};
|
|
43
|
+
const isValidColor = maybeColor => {
|
|
44
|
+
try {
|
|
45
|
+
return !!parseToRgba(maybeColor);
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function findNearestIndex(target, arr) {
|
|
51
|
+
let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
52
|
+
if (typeof target !== 'number' || isNaN(target)) {
|
|
53
|
+
throw new Error('Target must be a number.');
|
|
54
|
+
}
|
|
55
|
+
if (!Array.isArray(arr)) {
|
|
56
|
+
throw new Error('Second argument must be an array.');
|
|
57
|
+
}
|
|
58
|
+
let left = startIndex;
|
|
59
|
+
let right = arr.length - 1;
|
|
60
|
+
if (target < arr[left]) return left;
|
|
61
|
+
if (target > arr[right]) return right;
|
|
62
|
+
while (left <= right) {
|
|
63
|
+
const mid = Math.floor((left + right) / 2);
|
|
64
|
+
if (arr[mid] === target) {
|
|
65
|
+
return mid;
|
|
66
|
+
} else if (arr[mid] < target) {
|
|
67
|
+
left = mid + 1;
|
|
68
|
+
} else {
|
|
69
|
+
right = mid - 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return arr[left] - target < target - arr[right] ? left : right;
|
|
73
|
+
}
|
|
74
|
+
const OFFSET_TO_TARGET_RATIO = {
|
|
75
|
+
100: 1.08,
|
|
76
|
+
200: 1.2,
|
|
77
|
+
300: 1.35,
|
|
78
|
+
400: 2,
|
|
79
|
+
500: 2.8,
|
|
80
|
+
600: 3.3,
|
|
81
|
+
700: 5,
|
|
82
|
+
800: 10,
|
|
83
|
+
900: 13,
|
|
84
|
+
1000: 16,
|
|
85
|
+
1100: 17.5,
|
|
86
|
+
1200: 19
|
|
87
|
+
};
|
|
88
|
+
const generateColorScale = memoize(color => {
|
|
89
|
+
const scaleSize = 200;
|
|
90
|
+
const _scale = getScale('#FFF', color, '#000');
|
|
91
|
+
const scale = x => _scale(x / scaleSize);
|
|
92
|
+
const colors = [];
|
|
93
|
+
const contrastRatios = [];
|
|
94
|
+
for (let i = 0; i <= scaleSize; i++) {
|
|
95
|
+
const _color = scale(i);
|
|
96
|
+
colors.push(_color);
|
|
97
|
+
contrastRatios.push(getContrast('#FFF', _color));
|
|
98
|
+
}
|
|
99
|
+
const palette = {};
|
|
100
|
+
let startIndex = 0;
|
|
101
|
+
for (const offset in OFFSET_TO_TARGET_RATIO) {
|
|
102
|
+
if (Object.prototype.hasOwnProperty.call(OFFSET_TO_TARGET_RATIO, offset)) {
|
|
103
|
+
const ratio = OFFSET_TO_TARGET_RATIO[offset];
|
|
104
|
+
const nearestIndex = findNearestIndex(ratio, contrastRatios, startIndex);
|
|
105
|
+
startIndex = nearestIndex + 1;
|
|
106
|
+
palette[offset] = colors[nearestIndex];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return palette;
|
|
110
|
+
});
|
|
45
111
|
const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transparency) => {
|
|
46
112
|
let retVal;
|
|
47
113
|
let _hue = colors[hue] || hue;
|
|
@@ -50,17 +116,11 @@ const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transpare
|
|
|
50
116
|
}
|
|
51
117
|
if (typeof _hue === 'object') {
|
|
52
118
|
retVal = toHex(_hue, shade, offset, scheme);
|
|
53
|
-
} else if (_hue === 'transparent' ||
|
|
119
|
+
} else if (_hue === 'transparent' || isValidColor(_hue)) {
|
|
54
120
|
if (shade === undefined) {
|
|
55
121
|
retVal = _hue;
|
|
56
122
|
} else {
|
|
57
|
-
|
|
58
|
-
_hue = _colors.reduce((_retVal, color, index) => {
|
|
59
|
-
if (index > 0 && index <= PALETTE_SIZE) {
|
|
60
|
-
_retVal[index * 100] = color;
|
|
61
|
-
}
|
|
62
|
-
return _retVal;
|
|
63
|
-
}, {});
|
|
123
|
+
_hue = generateColorScale(_hue);
|
|
64
124
|
retVal = toHex(_hue, shade, offset, scheme);
|
|
65
125
|
}
|
|
66
126
|
}
|
|
@@ -147,9 +207,7 @@ const getColor = memoize(_ref => {
|
|
|
147
207
|
const value = fromVariable(variable, _variables, palette);
|
|
148
208
|
_hue = value.hue;
|
|
149
209
|
_shade = value.shade;
|
|
150
|
-
|
|
151
|
-
_transparency = value.transparency;
|
|
152
|
-
}
|
|
210
|
+
_transparency = _transparency === undefined ? value.transparency : _transparency;
|
|
153
211
|
}
|
|
154
212
|
if (_hue) {
|
|
155
213
|
const opacity = theme.opacity && Object.keys(theme.opacity).length > 0 ? theme.opacity : DEFAULT_THEME.opacity;
|
|
@@ -26,6 +26,34 @@ const animationStyles = (position, options) => {
|
|
|
26
26
|
const animationName = keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
|
|
27
27
|
return css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
|
|
28
28
|
};
|
|
29
|
+
const colorStyles = theme => {
|
|
30
|
+
const backgroundColor = getColor({
|
|
31
|
+
theme,
|
|
32
|
+
variable: 'background.raised'
|
|
33
|
+
});
|
|
34
|
+
const borderColor = getColor({
|
|
35
|
+
theme,
|
|
36
|
+
variable: 'border.default'
|
|
37
|
+
});
|
|
38
|
+
const boxShadowColor = getColor({
|
|
39
|
+
theme,
|
|
40
|
+
hue: 'neutralHue',
|
|
41
|
+
shade: 1200,
|
|
42
|
+
dark: {
|
|
43
|
+
transparency: theme.opacity[800]
|
|
44
|
+
},
|
|
45
|
+
light: {
|
|
46
|
+
transparency: theme.opacity[200]
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const boxShadowBlurRadius = `${theme.space.base * (theme.colors.base === 'dark' ? 5 : 6)}px`;
|
|
50
|
+
const boxShadowOffsetY = `${theme.space.base * (theme.colors.base === 'dark' ? 4 : 5)}px`;
|
|
51
|
+
const foregroundColor = getColor({
|
|
52
|
+
theme,
|
|
53
|
+
variable: 'foreground.default'
|
|
54
|
+
});
|
|
55
|
+
return css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, theme.shadows.lg(boxShadowOffsetY, boxShadowBlurRadius, boxShadowColor), backgroundColor, foregroundColor);
|
|
56
|
+
};
|
|
29
57
|
const hiddenStyles = options => {
|
|
30
58
|
const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
|
|
31
59
|
return css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
|
|
@@ -43,21 +71,7 @@ function menuStyles(position) {
|
|
|
43
71
|
} else {
|
|
44
72
|
marginProperty = 'margin-right';
|
|
45
73
|
}
|
|
46
|
-
return css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", "
|
|
47
|
-
theme,
|
|
48
|
-
variable: 'border.default'
|
|
49
|
-
}), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor({
|
|
50
|
-
theme,
|
|
51
|
-
hue: 'chromeHue',
|
|
52
|
-
shade: 600,
|
|
53
|
-
transparency: 0.15
|
|
54
|
-
})), getColor({
|
|
55
|
-
theme,
|
|
56
|
-
variable: 'background.raised'
|
|
57
|
-
}), theme.rtl ? 'right' : 'left', getColor({
|
|
58
|
-
theme,
|
|
59
|
-
variable: 'foreground.default'
|
|
60
|
-
}), theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
74
|
+
return css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", ";border-radius:", ";cursor:default;padding:0;text-align:", ";white-space:normal;font-size:", ";font-weight:", ";direction:", ";", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, theme.borderRadii.md, theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', colorStyles(theme), options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
export { menuStyles as default };
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var styled = require('styled-components');
|
|
11
|
-
var
|
|
11
|
+
var color2k = require('color2k');
|
|
12
12
|
var polished = require('polished');
|
|
13
13
|
var get = require('lodash.get');
|
|
14
14
|
var memoize = require('lodash.memoize');
|
|
@@ -688,7 +688,6 @@ const getArrowPosition = (theme, placement) => {
|
|
|
688
688
|
return retVal;
|
|
689
689
|
};
|
|
690
690
|
|
|
691
|
-
const PALETTE_SIZE = Object.keys(PALETTE.blue).length;
|
|
692
691
|
const adjust$1 = (color, expected, actual) => {
|
|
693
692
|
if (expected !== actual) {
|
|
694
693
|
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
@@ -719,6 +718,74 @@ const toHex = (hue, shade, offset, scheme) => {
|
|
|
719
718
|
}
|
|
720
719
|
return retVal;
|
|
721
720
|
};
|
|
721
|
+
const isValidColor = maybeColor => {
|
|
722
|
+
try {
|
|
723
|
+
return !!color2k.parseToRgba(maybeColor);
|
|
724
|
+
} catch {
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
function findNearestIndex(target, arr) {
|
|
729
|
+
let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
730
|
+
if (typeof target !== 'number' || isNaN(target)) {
|
|
731
|
+
throw new Error('Target must be a number.');
|
|
732
|
+
}
|
|
733
|
+
if (!Array.isArray(arr)) {
|
|
734
|
+
throw new Error('Second argument must be an array.');
|
|
735
|
+
}
|
|
736
|
+
let left = startIndex;
|
|
737
|
+
let right = arr.length - 1;
|
|
738
|
+
if (target < arr[left]) return left;
|
|
739
|
+
if (target > arr[right]) return right;
|
|
740
|
+
while (left <= right) {
|
|
741
|
+
const mid = Math.floor((left + right) / 2);
|
|
742
|
+
if (arr[mid] === target) {
|
|
743
|
+
return mid;
|
|
744
|
+
} else if (arr[mid] < target) {
|
|
745
|
+
left = mid + 1;
|
|
746
|
+
} else {
|
|
747
|
+
right = mid - 1;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return arr[left] - target < target - arr[right] ? left : right;
|
|
751
|
+
}
|
|
752
|
+
const OFFSET_TO_TARGET_RATIO = {
|
|
753
|
+
100: 1.08,
|
|
754
|
+
200: 1.2,
|
|
755
|
+
300: 1.35,
|
|
756
|
+
400: 2,
|
|
757
|
+
500: 2.8,
|
|
758
|
+
600: 3.3,
|
|
759
|
+
700: 5,
|
|
760
|
+
800: 10,
|
|
761
|
+
900: 13,
|
|
762
|
+
1000: 16,
|
|
763
|
+
1100: 17.5,
|
|
764
|
+
1200: 19
|
|
765
|
+
};
|
|
766
|
+
const generateColorScale = memoize__default.default(color => {
|
|
767
|
+
const scaleSize = 200;
|
|
768
|
+
const _scale = color2k.getScale('#FFF', color, '#000');
|
|
769
|
+
const scale = x => _scale(x / scaleSize);
|
|
770
|
+
const colors = [];
|
|
771
|
+
const contrastRatios = [];
|
|
772
|
+
for (let i = 0; i <= scaleSize; i++) {
|
|
773
|
+
const _color = scale(i);
|
|
774
|
+
colors.push(_color);
|
|
775
|
+
contrastRatios.push(polished.getContrast('#FFF', _color));
|
|
776
|
+
}
|
|
777
|
+
const palette = {};
|
|
778
|
+
let startIndex = 0;
|
|
779
|
+
for (const offset in OFFSET_TO_TARGET_RATIO) {
|
|
780
|
+
if (Object.prototype.hasOwnProperty.call(OFFSET_TO_TARGET_RATIO, offset)) {
|
|
781
|
+
const ratio = OFFSET_TO_TARGET_RATIO[offset];
|
|
782
|
+
const nearestIndex = findNearestIndex(ratio, contrastRatios, startIndex);
|
|
783
|
+
startIndex = nearestIndex + 1;
|
|
784
|
+
palette[offset] = colors[nearestIndex];
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return palette;
|
|
788
|
+
});
|
|
722
789
|
const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transparency) => {
|
|
723
790
|
let retVal;
|
|
724
791
|
let _hue = colors[hue] || hue;
|
|
@@ -727,17 +794,11 @@ const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transpare
|
|
|
727
794
|
}
|
|
728
795
|
if (typeof _hue === 'object') {
|
|
729
796
|
retVal = toHex(_hue, shade, offset, scheme);
|
|
730
|
-
} else if (_hue === 'transparent' ||
|
|
797
|
+
} else if (_hue === 'transparent' || isValidColor(_hue)) {
|
|
731
798
|
if (shade === undefined) {
|
|
732
799
|
retVal = _hue;
|
|
733
800
|
} else {
|
|
734
|
-
|
|
735
|
-
_hue = _colors.reduce((_retVal, color, index) => {
|
|
736
|
-
if (index > 0 && index <= PALETTE_SIZE) {
|
|
737
|
-
_retVal[index * 100] = color;
|
|
738
|
-
}
|
|
739
|
-
return _retVal;
|
|
740
|
-
}, {});
|
|
801
|
+
_hue = generateColorScale(_hue);
|
|
741
802
|
retVal = toHex(_hue, shade, offset, scheme);
|
|
742
803
|
}
|
|
743
804
|
}
|
|
@@ -824,9 +885,7 @@ const getColor = memoize__default.default(_ref => {
|
|
|
824
885
|
const value = fromVariable(variable, _variables, palette);
|
|
825
886
|
_hue = value.hue;
|
|
826
887
|
_shade = value.shade;
|
|
827
|
-
|
|
828
|
-
_transparency = value.transparency;
|
|
829
|
-
}
|
|
888
|
+
_transparency = _transparency === undefined ? value.transparency : _transparency;
|
|
830
889
|
}
|
|
831
890
|
if (_hue) {
|
|
832
891
|
const opacity = theme.opacity && Object.keys(theme.opacity).length > 0 ? theme.opacity : DEFAULT_THEME.opacity;
|
|
@@ -1100,22 +1159,6 @@ function mediaQuery(query, breakpoint, theme) {
|
|
|
1100
1159
|
return retVal;
|
|
1101
1160
|
}
|
|
1102
1161
|
|
|
1103
|
-
const exponentialSymbols = {
|
|
1104
|
-
symbols: {
|
|
1105
|
-
sqrt: {
|
|
1106
|
-
func: {
|
|
1107
|
-
symbol: 'sqrt',
|
|
1108
|
-
f: a => Math.sqrt(a),
|
|
1109
|
-
notation: 'func',
|
|
1110
|
-
precedence: 0,
|
|
1111
|
-
rightToLeft: 0,
|
|
1112
|
-
argCount: 1
|
|
1113
|
-
},
|
|
1114
|
-
symbol: 'sqrt',
|
|
1115
|
-
regSymbol: 'sqrt\\b'
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
};
|
|
1119
1162
|
const animationStyles$1 = (position, modifier) => {
|
|
1120
1163
|
const property = position.split('-')[0];
|
|
1121
1164
|
const animationName = styled.keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
|
|
@@ -1124,34 +1167,31 @@ const animationStyles$1 = (position, modifier) => {
|
|
|
1124
1167
|
const positionStyles = (position, size, inset) => {
|
|
1125
1168
|
const margin = polished.math(`${size} / -2`);
|
|
1126
1169
|
const placement = polished.math(`${margin} + ${inset}`);
|
|
1127
|
-
let
|
|
1170
|
+
let transform;
|
|
1128
1171
|
let positionCss;
|
|
1129
|
-
let propertyRadius;
|
|
1130
1172
|
if (position.startsWith('top')) {
|
|
1131
|
-
|
|
1132
|
-
clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
|
|
1173
|
+
transform = 'rotate(-135deg)';
|
|
1133
1174
|
positionCss = styled.css(["top:", ";right:", ";left:", ";margin-left:", ";"], placement, position === 'top-right' && size, position === 'top' ? '50%' : position === 'top-left' && size, position === 'top' && margin);
|
|
1134
1175
|
} else if (position.startsWith('right')) {
|
|
1135
|
-
|
|
1136
|
-
clipPath = 'polygon(100% 0, 100% 100%, calc(100% - 1px) 100%, 0 1px, 0 0)';
|
|
1176
|
+
transform = 'rotate(-45deg)';
|
|
1137
1177
|
positionCss = styled.css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && size, placement, position === 'right-bottom' && size, position === 'right' && margin);
|
|
1138
1178
|
} else if (position.startsWith('bottom')) {
|
|
1139
|
-
|
|
1140
|
-
clipPath = 'polygon(100% 0, calc(100% - 1px) 0, 0 calc(100% - 1px), 0 100%, 100% 100%)';
|
|
1179
|
+
transform = 'rotate(45deg)';
|
|
1141
1180
|
positionCss = styled.css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && size, placement, position === 'bottom' ? '50%' : position === 'bottom-left' && size, position === 'bottom' && margin);
|
|
1142
1181
|
} else if (position.startsWith('left')) {
|
|
1143
|
-
|
|
1144
|
-
clipPath = 'polygon(0 100%, 100% 100%, 100% calc(100% - 1px), 1px 0, 0 0)';
|
|
1182
|
+
transform = 'rotate(135deg)';
|
|
1145
1183
|
positionCss = styled.css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && size, size, placement, position === 'left' && margin);
|
|
1146
1184
|
}
|
|
1147
|
-
return styled.css(["&::before{
|
|
1185
|
+
return styled.css(["&::before,&::after{transform:", ";", ";}"], transform, positionCss);
|
|
1148
1186
|
};
|
|
1149
1187
|
function arrowStyles(position) {
|
|
1150
1188
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1151
|
-
const size = options.size || '6px';
|
|
1152
1189
|
const inset = options.inset || '0';
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1190
|
+
const size = options.size === undefined ? 6 : polished.stripUnit(options.size);
|
|
1191
|
+
const squareSize = `${Math.round(size * 2 / Math.sqrt(2))}px`;
|
|
1192
|
+
const afterOffset = 0;
|
|
1193
|
+
const beforeOffset = afterOffset + 2;
|
|
1194
|
+
return styled.css(["position:relative;&::before,&::after{position:absolute;border-width:inherit;border-style:inherit;width:", ";height:", ";content:'';box-sizing:inherit;}&::before{border-color:inherit;background-color:transparent;clip-path:polygon(100% ", "px,", "px 100%,100% 100%);}&::after{border-color:transparent;background-clip:content-box;background-color:inherit;clip-path:polygon(100% ", "px,", "px 100%,100% 100%);}", ";", ";"], squareSize, squareSize, beforeOffset, beforeOffset, afterOffset, afterOffset, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles$1(position, options.animationModifier));
|
|
1155
1195
|
}
|
|
1156
1196
|
|
|
1157
1197
|
const useDocument = theme => {
|
|
@@ -1216,6 +1256,34 @@ const animationStyles = (position, options) => {
|
|
|
1216
1256
|
const animationName = styled.keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
|
|
1217
1257
|
return styled.css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
|
|
1218
1258
|
};
|
|
1259
|
+
const colorStyles = theme => {
|
|
1260
|
+
const backgroundColor = getColor({
|
|
1261
|
+
theme,
|
|
1262
|
+
variable: 'background.raised'
|
|
1263
|
+
});
|
|
1264
|
+
const borderColor = getColor({
|
|
1265
|
+
theme,
|
|
1266
|
+
variable: 'border.default'
|
|
1267
|
+
});
|
|
1268
|
+
const boxShadowColor = getColor({
|
|
1269
|
+
theme,
|
|
1270
|
+
hue: 'neutralHue',
|
|
1271
|
+
shade: 1200,
|
|
1272
|
+
dark: {
|
|
1273
|
+
transparency: theme.opacity[800]
|
|
1274
|
+
},
|
|
1275
|
+
light: {
|
|
1276
|
+
transparency: theme.opacity[200]
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
const boxShadowBlurRadius = `${theme.space.base * (theme.colors.base === 'dark' ? 5 : 6)}px`;
|
|
1280
|
+
const boxShadowOffsetY = `${theme.space.base * (theme.colors.base === 'dark' ? 4 : 5)}px`;
|
|
1281
|
+
const foregroundColor = getColor({
|
|
1282
|
+
theme,
|
|
1283
|
+
variable: 'foreground.default'
|
|
1284
|
+
});
|
|
1285
|
+
return styled.css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, theme.shadows.lg(boxShadowOffsetY, boxShadowBlurRadius, boxShadowColor), backgroundColor, foregroundColor);
|
|
1286
|
+
};
|
|
1219
1287
|
const hiddenStyles = options => {
|
|
1220
1288
|
const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
|
|
1221
1289
|
return styled.css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
|
|
@@ -1233,21 +1301,7 @@ function menuStyles(position) {
|
|
|
1233
1301
|
} else {
|
|
1234
1302
|
marginProperty = 'margin-right';
|
|
1235
1303
|
}
|
|
1236
|
-
return styled.css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", "
|
|
1237
|
-
theme,
|
|
1238
|
-
variable: 'border.default'
|
|
1239
|
-
}), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor({
|
|
1240
|
-
theme,
|
|
1241
|
-
hue: 'chromeHue',
|
|
1242
|
-
shade: 600,
|
|
1243
|
-
transparency: 0.15
|
|
1244
|
-
})), getColor({
|
|
1245
|
-
theme,
|
|
1246
|
-
variable: 'background.raised'
|
|
1247
|
-
}), theme.rtl ? 'right' : 'left', getColor({
|
|
1248
|
-
theme,
|
|
1249
|
-
variable: 'foreground.default'
|
|
1250
|
-
}), theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
1304
|
+
return styled.css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", ";border-radius:", ";cursor:default;padding:0;text-align:", ";white-space:normal;font-size:", ";font-weight:", ";direction:", ";", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, theme.borderRadii.md, theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', colorStyles(theme), options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
1251
1305
|
}
|
|
1252
1306
|
|
|
1253
1307
|
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible';
|
|
@@ -10,22 +10,6 @@ type ArrowOptions = {
|
|
|
10
10
|
inset?: string;
|
|
11
11
|
animationModifier?: string;
|
|
12
12
|
};
|
|
13
|
-
export declare const exponentialSymbols: {
|
|
14
|
-
symbols: {
|
|
15
|
-
sqrt: {
|
|
16
|
-
func: {
|
|
17
|
-
symbol: string;
|
|
18
|
-
f: (a: number) => number;
|
|
19
|
-
notation: string;
|
|
20
|
-
precedence: number;
|
|
21
|
-
rightToLeft: number;
|
|
22
|
-
argCount: number;
|
|
23
|
-
};
|
|
24
|
-
symbol: string;
|
|
25
|
-
regSymbol: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
13
|
/**
|
|
30
14
|
* CSS for an arrow at the given position and with the given size. The arrow is
|
|
31
15
|
* positioned via `::before` and `::after` pseudo-elements and inherits the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.14",
|
|
4
4
|
"description": "Theming utilities and components within the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"types": "dist/typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@floating-ui/react-dom": "^2.0.0",
|
|
25
|
-
"
|
|
25
|
+
"color2k": "^2.0.3",
|
|
26
26
|
"lodash.get": "^4.4.2",
|
|
27
27
|
"lodash.memoize": "^4.1.2",
|
|
28
|
-
"polished": "^4.
|
|
28
|
+
"polished": "^4.3.1",
|
|
29
29
|
"prop-types": "^15.5.7"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"styled-components": "^4.2.0 || ^5.3.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/chroma-js": "2.4.4",
|
|
38
37
|
"@types/lodash.get": "4.4.9",
|
|
39
38
|
"@types/lodash.memoize": "4.1.9"
|
|
40
39
|
},
|
|
@@ -48,5 +47,5 @@
|
|
|
48
47
|
"access": "public"
|
|
49
48
|
},
|
|
50
49
|
"zendeskgarden:src": "src/index.ts",
|
|
51
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4cd4e10839f6d083f0c5e642b99256e390a37ae6"
|
|
52
51
|
}
|