@elastic/eui-theme-common 4.0.0 → 6.0.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.
Files changed (54) hide show
  1. package/lib/cjs/global_styling/functions/shadows.d.ts +12 -0
  2. package/lib/cjs/global_styling/functions/shadows.js +49 -4
  3. package/lib/cjs/global_styling/mixins/borders.d.ts +23 -0
  4. package/lib/cjs/global_styling/mixins/borders.js +50 -0
  5. package/lib/cjs/global_styling/mixins/index.d.ts +1 -0
  6. package/lib/cjs/global_styling/mixins/index.js +11 -0
  7. package/lib/cjs/global_styling/mixins/shadow.d.ts +22 -14
  8. package/lib/cjs/global_styling/mixins/shadow.js +142 -68
  9. package/lib/cjs/global_styling/variables/borders.d.ts +1 -1
  10. package/lib/cjs/global_styling/variables/components.d.ts +0 -1
  11. package/lib/cjs/global_styling/variables/flags.d.ts +2 -6
  12. package/lib/cjs/global_styling/variables/shadow.d.ts +52 -0
  13. package/lib/cjs/global_styling/variables/shadow.js +8 -2
  14. package/lib/cjs/global_styling/variables/typography.d.ts +1 -1
  15. package/lib/cjs/services/theme/types.d.ts +8 -1
  16. package/lib/cjs/services/vis_color_store.d.ts +3 -7
  17. package/lib/cjs/services/vis_color_store.js +4 -15
  18. package/lib/cjs/services/vis_color_store.test.js +1 -5
  19. package/lib/cjs/utils.d.ts +22 -1
  20. package/lib/cjs/utils.js +39 -1
  21. package/lib/cjs/utils.test.js +38 -0
  22. package/lib/esm/global_styling/functions/shadows.d.ts +12 -0
  23. package/lib/esm/global_styling/functions/shadows.js +40 -1
  24. package/lib/esm/global_styling/mixins/borders.d.ts +23 -0
  25. package/lib/esm/global_styling/mixins/borders.js +50 -0
  26. package/lib/esm/global_styling/mixins/index.d.ts +1 -0
  27. package/lib/esm/global_styling/mixins/index.js +1 -0
  28. package/lib/esm/global_styling/mixins/shadow.d.ts +22 -14
  29. package/lib/esm/global_styling/mixins/shadow.js +126 -81
  30. package/lib/esm/global_styling/variables/borders.d.ts +1 -1
  31. package/lib/esm/global_styling/variables/components.d.ts +0 -1
  32. package/lib/esm/global_styling/variables/flags.d.ts +2 -6
  33. package/lib/esm/global_styling/variables/shadow.d.ts +52 -0
  34. package/lib/esm/global_styling/variables/shadow.js +1 -0
  35. package/lib/esm/global_styling/variables/typography.d.ts +1 -1
  36. package/lib/esm/services/theme/types.d.ts +8 -1
  37. package/lib/esm/services/vis_color_store.d.ts +3 -7
  38. package/lib/esm/services/vis_color_store.js +3 -12
  39. package/lib/esm/services/vis_color_store.test.js +1 -5
  40. package/lib/esm/utils.d.ts +22 -1
  41. package/lib/esm/utils.js +31 -0
  42. package/lib/esm/utils.test.js +22 -1
  43. package/package.json +1 -1
  44. package/src/global_styling/mixins/_index.scss +0 -7
  45. package/src/global_styling/mixins/_states.scss +1 -1
  46. package/src/global_styling/variables/_index.scss +0 -1
  47. package/src/global_styling/mixins/_button.scss +0 -149
  48. package/src/global_styling/mixins/_form.scss +0 -272
  49. package/src/global_styling/mixins/_link.scss +0 -11
  50. package/src/global_styling/mixins/_loading.scss +0 -6
  51. package/src/global_styling/mixins/_panel.scss +0 -55
  52. package/src/global_styling/mixins/_range.scss +0 -59
  53. package/src/global_styling/mixins/_shadow.scss +0 -100
  54. package/src/global_styling/variables/_shadows.scss +0 -2
@@ -5,123 +5,113 @@
5
5
  * in compliance with, at your election, the Elastic License 2.0 or the Server
6
6
  * Side Public License, v 1.
7
7
  */
8
- import { getShadowColor } from '../functions';
8
+ import { boxShadowToFilterDropShadow } from '../functions';
9
+ import { euiShadowFloatingBorderStyles } from './borders';
9
10
  /**
10
- * euiSlightShadow
11
+ * x-small shadow
11
12
  */
12
- export const euiShadowXSmall = ({ euiTheme, colorMode, highContrastMode }, options) => {
13
+ export const euiShadowXSmall = (euiThemeContext, options) => {
14
+ const { euiTheme, highContrastMode } = euiThemeContext;
13
15
  if (highContrastMode) {
14
- return _highContrastBorder(euiTheme, options);
16
+ return _highContrastBorder(euiThemeContext, options);
15
17
  }
16
- const color = options?.color || euiTheme.colors.shadow;
17
- return `
18
- box-shadow:
19
- 0 .8px .8px ${getShadowColor(color, 0.04, colorMode)},
20
- 0 2.3px 2px ${getShadowColor(color, 0.03, colorMode)};
21
- `;
18
+ const direction = options?.direction ?? 'down';
19
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.xs[direction], {
20
+ border: options?.border,
21
+ });
22
22
  };
23
23
  /**
24
- * bottomShadowSmall
24
+ * small shadow
25
25
  */
26
- export const euiShadowSmall = ({ euiTheme, colorMode, highContrastMode }, options) => {
26
+ export const euiShadowSmall = (euiThemeContext, options) => {
27
+ const { euiTheme, highContrastMode } = euiThemeContext;
27
28
  if (highContrastMode) {
28
- return _highContrastBorder(euiTheme, options);
29
+ return _highContrastBorder(euiThemeContext, options);
29
30
  }
30
- const color = options?.color || euiTheme.colors.shadow;
31
- return `
32
- box-shadow:
33
- 0 .7px 1.4px ${getShadowColor(color, 0.07, colorMode)},
34
- 0 1.9px 4px ${getShadowColor(color, 0.05, colorMode)},
35
- 0 4.5px 10px ${getShadowColor(color, 0.05, colorMode)};
36
- `;
31
+ const direction = options?.direction ?? 'down';
32
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.s[direction], {
33
+ border: options?.border,
34
+ });
37
35
  };
38
36
  /**
39
- * bottomShadowMedium
37
+ * medium shadow
40
38
  */
41
- export const euiShadowMedium = ({ euiTheme, colorMode, highContrastMode }, options) => {
39
+ export const euiShadowMedium = (euiThemeContext, options) => {
40
+ const { euiTheme, highContrastMode } = euiThemeContext;
42
41
  if (highContrastMode) {
43
- return _highContrastBorder(euiTheme, options);
42
+ return _highContrastBorder(euiThemeContext, options);
44
43
  }
45
- const color = options?.color || euiTheme.colors.shadow;
44
+ const direction = options?.direction ?? 'down';
45
+ const boxShadow = euiTheme.shadows.m[direction];
46
46
  if (options?.property === 'filter') {
47
- // Using only one drop-shadow filter instead of multiple is more performant & prevents Safari bugs
48
- return `filter: drop-shadow(0 5.7px 9px ${getShadowColor(color, 0.2, colorMode)});`;
49
- }
50
- else {
51
- return `box-shadow:
52
- 0 .9px 4px ${getShadowColor(color, 0.08, colorMode)},
53
- 0 2.6px 8px ${getShadowColor(color, 0.06, colorMode)},
54
- 0 5.7px 12px ${getShadowColor(color, 0.05, colorMode)},
55
- 0 15px 15px ${getShadowColor(color, 0.04, colorMode)};`;
47
+ return boxShadow
48
+ ? _shadowStyles(euiThemeContext, boxShadowToFilterDropShadow(boxShadow), {
49
+ border: options?.border,
50
+ type: 'filter',
51
+ })
52
+ : '';
56
53
  }
54
+ return _shadowStyles(euiThemeContext, boxShadow, {
55
+ border: options?.border,
56
+ });
57
57
  };
58
58
  /**
59
- * bottomShadow
59
+ * large shadow
60
60
  */
61
- export const euiShadowLarge = ({ euiTheme, colorMode, highContrastMode }, options) => {
61
+ export const euiShadowLarge = (euiThemeContext, options) => {
62
+ const { euiTheme, highContrastMode } = euiThemeContext;
62
63
  if (highContrastMode) {
63
- return _highContrastBorder(euiTheme, options);
64
+ return _highContrastBorder(euiThemeContext, options);
64
65
  }
65
- const color = options?.color || euiTheme.colors.shadow;
66
- return `
67
- box-shadow:
68
- 0 1px 5px ${getShadowColor(color, 0.1, colorMode)},
69
- 0 3.6px 13px ${getShadowColor(color, 0.07, colorMode)},
70
- 0 8.4px 23px ${getShadowColor(color, 0.06, colorMode)},
71
- 0 23px 35px ${getShadowColor(color, 0.05, colorMode)};
72
- `;
66
+ const direction = options?.direction ?? 'down';
67
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.l[direction], {
68
+ border: options?.border,
69
+ });
73
70
  };
74
- export const euiShadowXLarge = ({ euiTheme, colorMode, highContrastMode }, options) => {
71
+ export const euiShadowXLarge = (euiThemeContext, options) => {
72
+ const { euiTheme, highContrastMode } = euiThemeContext;
75
73
  if (highContrastMode) {
76
- return _highContrastBorder(euiTheme, options);
74
+ return _highContrastBorder(euiThemeContext, options);
77
75
  }
78
- const color = options?.color || euiTheme.colors.shadow;
79
- const reverse = options?.reverse ?? false;
80
- return `
81
- box-shadow:
82
- 0 ${reverse ? '-' : ''}2.7px 9px ${getShadowColor(color, 0.13, colorMode)},
83
- 0 ${reverse ? '-' : ''}9.4px 24px ${getShadowColor(color, 0.09, colorMode)},
84
- 0 ${reverse ? '-' : ''}21.8px 43px ${getShadowColor(color, 0.08, colorMode)};
85
- `;
76
+ const direction = options?.direction ?? 'down';
77
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.xl[direction], {
78
+ border: options?.border,
79
+ });
86
80
  };
87
81
  /**
88
- * slightShadowHover
82
+ * flat shadow
83
+ * @deprecated - use euiShadowHover instead
89
84
  */
90
- export const euiSlightShadowHover = ({ euiTheme, colorMode, highContrastMode }, options) => {
85
+ export const euiSlightShadowHover = (euiThemeContext, options) => {
86
+ const { euiTheme, highContrastMode } = euiThemeContext;
91
87
  if (highContrastMode) {
92
- return _highContrastBorder(euiTheme, options);
88
+ return _highContrastBorder(euiThemeContext, options);
93
89
  }
94
- const color = options?.color || euiTheme.colors.shadow;
95
- return `
96
- box-shadow:
97
- 0 1px 5px ${getShadowColor(color, 0.1, colorMode)},
98
- 0 3.6px 13px ${getShadowColor(color, 0.07, colorMode)},
99
- 0 8.4px 23px ${getShadowColor(color, 0.06, colorMode)},
100
- 0 23px 35px ${getShadowColor(color, 0.05, colorMode)};
101
- `;
90
+ const direction = options?.direction ?? 'down';
91
+ return _shadowStyles(euiThemeContext, euiTheme.shadows.s[direction], {
92
+ border: options?.border,
93
+ });
102
94
  };
103
95
  /**
104
- * bottomShadowFlat
96
+ * @deprecated - use euiShadowXSmall instead
105
97
  *
106
98
  * Similar to shadow medium but without the bottom depth.
107
99
  * Useful for popovers that drop UP rather than DOWN.
108
100
  */
109
- export const euiShadowFlat = ({ euiTheme, colorMode, highContrastMode }, options) => {
101
+ export const euiShadowFlat = (euiThemeContext, options) => {
102
+ const { euiTheme, highContrastMode } = euiThemeContext;
110
103
  if (highContrastMode) {
111
- return _highContrastBorder(euiTheme, options);
104
+ return _highContrastBorder(euiThemeContext, options);
112
105
  }
113
- const color = options?.color || euiTheme.colors.shadow;
114
- return `
115
- box-shadow:
116
- 0 0 .8px ${getShadowColor(color, 0.06, colorMode)},
117
- 0 0 2px ${getShadowColor(color, 0.04, colorMode)},
118
- 0 0 5px ${getShadowColor(color, 0.04, colorMode)},
119
- 0 0 17px ${getShadowColor(color, 0.03, colorMode)};
120
- `;
106
+ const direction = options?.direction ?? 'down';
107
+ const value = euiTheme.shadows.flat?.[direction];
108
+ return _shadowStyles(euiThemeContext, value, {
109
+ border: options?.border,
110
+ });
121
111
  };
122
112
  export const euiShadow = (euiThemeContext, size = 'l', options) => {
123
113
  if (euiThemeContext.highContrastMode) {
124
- return _highContrastBorder(euiThemeContext.euiTheme, options);
114
+ return _highContrastBorder(euiThemeContext, options);
125
115
  }
126
116
  switch (size) {
127
117
  case 'xs':
@@ -139,13 +129,68 @@ export const euiShadow = (euiThemeContext, size = 'l', options) => {
139
129
  return '';
140
130
  }
141
131
  };
132
+ /** Hover shadows */
133
+ export const euiShadowHover = (euiThemeContext, size = 'base', options) => {
134
+ if (euiThemeContext.highContrastMode) {
135
+ return _highContrastBorder(euiThemeContext, options);
136
+ }
137
+ switch (size) {
138
+ case 'base':
139
+ return _euiShadowHover(euiThemeContext, 'base', options);
140
+ case 'xs':
141
+ return _euiShadowHover(euiThemeContext, 's', options);
142
+ case 's':
143
+ return _euiShadowHover(euiThemeContext, 'm', options);
144
+ case 'm':
145
+ return _euiShadowHover(euiThemeContext, 'l', options);
146
+ case 'l':
147
+ return _euiShadowHover(euiThemeContext, 'xl', options);
148
+ case 'xl':
149
+ return _euiShadowHover(euiThemeContext, 'xxl', options);
150
+ default:
151
+ console.warn('Please provide a valid size option to useEuiShadow');
152
+ return '';
153
+ }
154
+ };
155
+ const _euiShadowHover = (euiThemeContext, size = 'l', options) => {
156
+ const { euiTheme, highContrastMode } = euiThemeContext;
157
+ if (highContrastMode) {
158
+ return _highContrastBorder(euiThemeContext, options);
159
+ }
160
+ const direction = options?.direction ?? 'down';
161
+ const shadow = size === 'base'
162
+ ? euiTheme.shadows.hover.base[direction]
163
+ : size === 'xxl'
164
+ ? euiTheme.shadows.hover.xl[direction]
165
+ : euiTheme.shadows[size][direction];
166
+ return _shadowStyles(euiThemeContext, shadow, {
167
+ border: options?.border,
168
+ });
169
+ };
142
170
  /**
143
171
  * Internal utilities for replacing shadows with high contrast borders instead.
144
172
  * NOTE: Windows' high contrast themes ignore *all* `box-shadow` CSS,
145
173
  * so we use `border` CSS explicitly instead of shadows
146
174
  */
147
- const _highContrastBorder = ({ border }, { borderAllInHighContrastMode } = {}) => {
148
- return borderAllInHighContrastMode
149
- ? `border: ${border.thin};`
150
- : `border-block-end: ${border.thin};`;
175
+ const _highContrastBorder = (euiThemeContext, { border = 'all', borderAllInHighContrastMode } = {}) => {
176
+ const { euiTheme } = euiThemeContext;
177
+ const hasFullBorder = borderAllInHighContrastMode || (border && border !== 'none');
178
+ return hasFullBorder
179
+ ? `border: ${euiTheme.border.thin};`
180
+ : `border-block-end: ${euiTheme.border.thin};`;
181
+ };
182
+ const _shadowStyles = (euiThemeContext, shadow, options) => {
183
+ const { euiTheme } = euiThemeContext;
184
+ const isRefreshVariant = euiTheme.flags.shadowVariant === 'refresh';
185
+ const { border = 'all', type = 'box-shadow' } = options;
186
+ const borderStyle = euiThemeContext.colorMode === 'DARK' && border !== 'none'
187
+ ? `${euiShadowFloatingBorderStyles(euiThemeContext, {
188
+ side: border ?? 'all',
189
+ })}`
190
+ : '';
191
+ const shadowStyle = type === 'filter' ? shadow : `box-shadow: ${shadow};`;
192
+ return `
193
+ ${shadowStyle};
194
+ ${isRefreshVariant && borderStyle};
195
+ `;
151
196
  };
@@ -15,7 +15,7 @@ export interface _EuiThemeBorderWidthValues {
15
15
  export interface _EuiThemeBorderRadiusValues {
16
16
  /**
17
17
  * Primary corner radius size
18
- * - Default value: 4px (6px in Amsterdam)
18
+ * - Default value: 4px
19
19
  */
20
20
  medium: CSSProperties['borderRadius'];
21
21
  /**
@@ -67,7 +67,6 @@ export declare type _EuiThemeComponentColors = {
67
67
  filterSelectItemBackgroundFocusDisabled: ColorModeSwitch;
68
68
  flyoutFooterBackground: ColorModeSwitch;
69
69
  flyoutCloseButtonInsideBackground: ColorModeSwitch;
70
- keyPadMenuItemBackgroundDisabledSelect: ColorModeSwitch;
71
70
  listGroupItemBackgroundPrimaryActive: ColorModeSwitch;
72
71
  listGroupItemBackgroundSubduedActive: ColorModeSwitch;
73
72
  listGroupItemBackgroundHover: ColorModeSwitch;
@@ -1,11 +1,7 @@
1
1
  export declare type EuiThemeVariantFlags = {
2
- buttonVariant: 'classic' | 'refresh';
3
- formVariant: 'classic' | 'refresh';
2
+ shadowVariant: 'classic' | 'refresh';
4
3
  };
5
4
  /**
6
5
  * Theme specific setting flags
7
6
  */
8
- export declare type _EuiThemeFlags = {
9
- hasGlobalFocusColor: boolean;
10
- hasVisColorAdjustment: boolean;
11
- } & EuiThemeVariantFlags;
7
+ export declare type _EuiThemeFlags = EuiThemeVariantFlags;
@@ -1,5 +1,9 @@
1
+ import { CSSProperties } from 'react';
2
+ import { ColorModeSwitch } from '../../services/theme/types';
1
3
  export declare const EuiThemeShadowSizes: readonly ["xs", "s", "m", "l", "xl"];
2
4
  export declare type _EuiThemeShadowSize = (typeof EuiThemeShadowSizes)[number];
5
+ export declare const EuiThemeShadowHoverSizes: readonly ["s", "m", "l", "xl", "xxl"];
6
+ export declare type _EuiThemeShadowHoverSize = (typeof EuiThemeShadowHoverSizes)[number];
3
7
  /**
4
8
  * Shadow t-shirt sizes descriptions
5
9
  */
@@ -9,3 +13,51 @@ export interface _EuiThemeShadowCustomColor {
9
13
  property?: 'box-shadow' | 'filter';
10
14
  borderAllInHighContrastMode?: boolean;
11
15
  }
16
+ export declare type _EuiThemeShadow = {
17
+ /** Default direction of the shadow */
18
+ down: CSSProperties['boxShadow'];
19
+ /** Reverse direction */
20
+ up: CSSProperties['boxShadow'];
21
+ };
22
+ export declare type _EuiThemeShadows = ColorModeSwitch<{
23
+ colors: {
24
+ base: string;
25
+ };
26
+ xs: _EuiThemeShadow;
27
+ s: _EuiThemeShadow;
28
+ m: _EuiThemeShadow;
29
+ l: _EuiThemeShadow;
30
+ xl: _EuiThemeShadow;
31
+ hover: {
32
+ base: _EuiThemeShadow;
33
+ xl: _EuiThemeShadow;
34
+ };
35
+ /** @deprecated - Defined only to support the legacy `euiShadowFlat` mixin;
36
+ * will be removed in the future
37
+ */
38
+ flat: _EuiThemeShadow;
39
+ }>;
40
+ /**
41
+ * Represents a single shadow
42
+ * @see https://tr.designtokens.org/format/#shadow
43
+ */
44
+ export declare type _EuiThemeShadowLayer = {
45
+ opacity: number;
46
+ x: number;
47
+ y: number;
48
+ blur: number;
49
+ spread: number;
50
+ };
51
+ export declare type _EuiThemeShadowPrimitive = {
52
+ light: _EuiThemeShadowLayer[];
53
+ dark: _EuiThemeShadowLayer[];
54
+ };
55
+ export declare type _EuiThemeShadowPrimitives = {
56
+ xs: _EuiThemeShadowPrimitive;
57
+ s: _EuiThemeShadowPrimitive;
58
+ m: _EuiThemeShadowPrimitive;
59
+ l: _EuiThemeShadowPrimitive;
60
+ xl: _EuiThemeShadowPrimitive;
61
+ xxl: _EuiThemeShadowPrimitive;
62
+ flat: _EuiThemeShadowPrimitive;
63
+ };
@@ -6,6 +6,7 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
  export const EuiThemeShadowSizes = ['xs', 's', 'm', 'l', 'xl'];
9
+ export const EuiThemeShadowHoverSizes = ['s', 'm', 'l', 'xl', 'xxl'];
9
10
  /**
10
11
  * Shadow t-shirt sizes descriptions
11
12
  */
@@ -84,7 +84,7 @@ export interface _EuiThemeTitle {
84
84
  export declare type _EuiThemeFont = _EuiThemeFontBase & {
85
85
  scale: _EuiThemeFontScales;
86
86
  /**
87
- * See {@link https://eui.elastic.co/#/theming/typography/values%23font-weight | Reference} for more information
87
+ * See {@link https://eui.elastic.co/docs/getting-started/theming/tokens/typography/font-weight/ | Reference} for more information
88
88
  */
89
89
  weight: _EuiThemeFontWeights;
90
90
  body: _EuiThemeBody;
@@ -7,6 +7,7 @@ import type { _EuiThemeColors } from '../../global_styling/variables/colors';
7
7
  import type { _EuiThemeBase, _EuiThemeSizes } from '../../global_styling/variables/size';
8
8
  import type { _EuiThemeFont } from '../../global_styling/variables/typography';
9
9
  import type { _EuiThemeFocus } from '../../global_styling/variables/states';
10
+ import type { _EuiThemeShadows } from '../../global_styling/variables/shadow';
10
11
  import type { _EuiThemeLevels } from '../../global_styling/variables/levels';
11
12
  import type { _EuiThemeComponents } from '../../global_styling/variables/components';
12
13
  import type { _EuiThemeFlags } from '../../global_styling/variables';
@@ -34,7 +35,7 @@ export declare type EuiThemeShapeBase = {
34
35
  /** - Default value: 16 */
35
36
  base: _EuiThemeBase;
36
37
  /**
37
- * See {@link https://eui.elastic.co/#/theming/sizing | Reference} for more information
38
+ * See {@link https://eui.elastic.co/docs/getting-started/theming/tokens/sizing/ | Reference} for more information
38
39
  */
39
40
  size: _EuiThemeSizes;
40
41
  font: _EuiThemeFont;
@@ -43,6 +44,7 @@ export declare type EuiThemeShapeBase = {
43
44
  animation: _EuiThemeAnimation;
44
45
  breakpoint: _EuiThemeBreakpoints;
45
46
  levels: _EuiThemeLevels;
47
+ shadows: _EuiThemeShadows;
46
48
  components: _EuiThemeComponents;
47
49
  flags: _EuiThemeFlags;
48
50
  };
@@ -79,3 +81,8 @@ export interface UseEuiTheme<T extends {} = {}> {
79
81
  highContrastMode: EuiThemeHighContrastMode;
80
82
  modifications: EuiThemeModifications<T>;
81
83
  }
84
+ export interface EUI_THEME {
85
+ text: string;
86
+ value: string;
87
+ provider?: EuiThemeSystem;
88
+ }
@@ -6,28 +6,24 @@ export declare type VisColorStoreEvents = keyof typeof VIS_COLOR_STORE_EVENTS;
6
6
  declare type EventId = string;
7
7
  export declare type _EuiVisColorStore = {
8
8
  visColors: _EuiThemeVisColors;
9
- hasVisColorAdjustment: boolean;
10
- setVisColors: (colors: _EuiThemeVisColors, hasVisColorAdjustment?: boolean) => void;
9
+ setVisColors: (colors: _EuiThemeVisColors) => void;
11
10
  subscribe: (eventName: VisColorStoreEvents, callback: any) => EventId;
12
11
  unsubscribe: (eventName: VisColorStoreEvents, id: EventId) => void;
13
12
  };
14
13
  declare class EuiVisColorStoreImpl implements _EuiVisColorStore {
15
14
  private _visColors;
16
- private _hasVisColorAdjustment;
17
15
  private events;
18
16
  constructor(dependencies: {
19
17
  defaultColors: _EuiThemeVisColors;
20
- hasVisColorAdjustment: boolean;
21
18
  });
22
19
  get visColors(): _EuiVisColorStore['visColors'];
23
- get hasVisColorAdjustment(): _EuiVisColorStore['hasVisColorAdjustment'];
24
- setVisColors: (colors: _EuiThemeVisColors, hasColorAdjustment?: boolean | undefined) => void;
20
+ setVisColors: (colors: _EuiThemeVisColors) => void;
25
21
  subscribe: (eventName: VisColorStoreEvents, callback: NonNullable<any>) => string;
26
22
  unsubscribe: (eventName: VisColorStoreEvents, id: EventId) => void;
27
23
  private publishUpdate;
28
24
  }
29
25
  export declare class EuiVisColorStore {
30
26
  private static instance;
31
- static getInstance(defaultColors: _EuiThemeVisColors, hasVisColorAdjustment: boolean): EuiVisColorStoreImpl;
27
+ static getInstance(defaultColors: _EuiThemeVisColors): EuiVisColorStoreImpl;
32
28
  }
33
29
  export {};
@@ -13,13 +13,9 @@ export const VIS_COLOR_STORE_EVENTS = {
13
13
  class EuiVisColorStoreImpl {
14
14
  constructor(dependencies) {
15
15
  this.events = {};
16
- this.setVisColors = (colors, hasColorAdjustment) => {
17
- if (!isEqual(this._visColors, colors) ||
18
- hasColorAdjustment !== this._hasVisColorAdjustment) {
16
+ this.setVisColors = (colors) => {
17
+ if (!isEqual(this._visColors, colors)) {
19
18
  this._visColors = colors;
20
- if (hasColorAdjustment != null) {
21
- this._hasVisColorAdjustment = hasColorAdjustment;
22
- }
23
19
  this.publishUpdate(VIS_COLOR_STORE_EVENTS.UPDATE, this._visColors);
24
20
  }
25
21
  };
@@ -46,21 +42,16 @@ class EuiVisColorStoreImpl {
46
42
  });
47
43
  };
48
44
  this._visColors = dependencies.defaultColors;
49
- this._hasVisColorAdjustment = dependencies.hasVisColorAdjustment;
50
45
  }
51
46
  get visColors() {
52
47
  return this._visColors;
53
48
  }
54
- get hasVisColorAdjustment() {
55
- return this._hasVisColorAdjustment;
56
- }
57
49
  }
58
50
  export class EuiVisColorStore {
59
- static getInstance(defaultColors, hasVisColorAdjustment) {
51
+ static getInstance(defaultColors) {
60
52
  if (!this.instance) {
61
53
  this.instance = new EuiVisColorStoreImpl({
62
54
  defaultColors,
63
- hasVisColorAdjustment,
64
55
  });
65
56
  }
66
57
  return this.instance;
@@ -11,7 +11,7 @@ const visColors = {
11
11
  euiColorVis0: '#aabbcc',
12
12
  };
13
13
  describe('EuiVisColorStore', () => {
14
- const visColorStore = EuiVisColorStore.getInstance(visColors, false);
14
+ const visColorStore = EuiVisColorStore.getInstance(visColors);
15
15
  let updateFn;
16
16
  beforeEach(() => {
17
17
  updateFn = jest.fn();
@@ -31,10 +31,6 @@ describe('EuiVisColorStore', () => {
31
31
  visColorStore.setVisColors(customColors);
32
32
  expect(visColorStore.visColors).toEqual(customColors);
33
33
  });
34
- it('updates hasVisColorAdjustment', () => {
35
- visColorStore.setVisColors(customColors, true);
36
- expect(visColorStore.hasVisColorAdjustment).toEqual(true);
37
- });
38
34
  });
39
35
  describe('subcribe and unsubscribe', () => {
40
36
  it('subscribes to store updates', () => {
@@ -1,4 +1,4 @@
1
- import { EuiThemeColorMode, EuiThemeColorModeStandard, EuiThemeSystem, EuiThemeShape, EuiThemeComputed, EuiThemeHighContrastMode } from './global_styling';
1
+ import { EuiThemeColorMode, EuiThemeColorModeStandard, EuiThemeSystem, EuiThemeShape, EuiThemeComputed, _EuiThemeShadowLayer, EuiThemeHighContrastMode } from './global_styling';
2
2
  export declare const DEFAULT_COLOR_MODE: "LIGHT";
3
3
  /**
4
4
  * Returns whether the provided color mode is `inverse`
@@ -104,3 +104,24 @@ export declare const mergeDeep: (_target: {
104
104
  * and additional prefix/suffix
105
105
  */
106
106
  export declare const getTokenName: (prefix: string, variant?: string | undefined, suffix?: string | undefined) => string;
107
+ /**
108
+ * Format an array of shadow "objects" into a string for CSS.
109
+ * The "up" direction is built by making the y offset from layers
110
+ * two and any subsequent layers, negative.
111
+ *
112
+ * It will add `inset` to the first layer when color mode is "DARK"
113
+ * and `spread` is 1, to ensure the dark mode-only floating border
114
+ * is rendered inside the container to match the position of the
115
+ * regular panel border (implemented with a pseudo element).
116
+ *
117
+ * @todo add a color space param to replace the hard-coded `hsl`
118
+ *
119
+ * @param layers
120
+ * @param options
121
+ * @param options.up - Modifies some values in order to get the "up" direction
122
+ * @returns - A value for the CSS `box-shadow` property
123
+ */
124
+ export declare function formatMultipleBoxShadow(layers: _EuiThemeShadowLayer[], options?: {
125
+ direction?: 'down' | 'up';
126
+ color: string;
127
+ }): string;
package/lib/esm/utils.js CHANGED
@@ -5,6 +5,7 @@
5
5
  * in compliance with, at your election, the Elastic License 2.0 or the Server
6
6
  * Side Public License, v 1.
7
7
  */
8
+ import chroma from 'chroma-js';
8
9
  import { COLOR_MODES_STANDARD, COLOR_MODES_INVERSE, EUI_THEME_OVERRIDES_KEY, EUI_THEME_HIGH_CONTRAST_MODE_KEY, } from './global_styling';
9
10
  export const DEFAULT_COLOR_MODE = COLOR_MODES_STANDARD.light;
10
11
  /**
@@ -331,3 +332,33 @@ export const getTokenName = (prefix, variant, suffix) => {
331
332
  const colorName = variant.charAt(0).toUpperCase() + variant.slice(1);
332
333
  return `${prefix}${getCapitalized(colorName)}${_suffix}`;
333
334
  };
335
+ /**
336
+ * Format an array of shadow "objects" into a string for CSS.
337
+ * The "up" direction is built by making the y offset from layers
338
+ * two and any subsequent layers, negative.
339
+ *
340
+ * It will add `inset` to the first layer when color mode is "DARK"
341
+ * and `spread` is 1, to ensure the dark mode-only floating border
342
+ * is rendered inside the container to match the position of the
343
+ * regular panel border (implemented with a pseudo element).
344
+ *
345
+ * @todo add a color space param to replace the hard-coded `hsl`
346
+ *
347
+ * @param layers
348
+ * @param options
349
+ * @param options.up - Modifies some values in order to get the "up" direction
350
+ * @returns - A value for the CSS `box-shadow` property
351
+ */
352
+ export function formatMultipleBoxShadow(layers, options) {
353
+ if (layers.length === 0) {
354
+ return 'none';
355
+ }
356
+ const { direction = 'down', color = '#000' } = options ?? {};
357
+ /* prettier-ignore */
358
+ const shadowLayers = layers.map((layer, i) => {
359
+ const y = (direction === 'up' && i > 0) ? -layer.y : layer.y;
360
+ const shadowColor = chroma(color).alpha(layer.opacity).css('hsl');
361
+ return `${layer.x}px ${y}px ${layer.blur}px ${layer.spread}px ${shadowColor}`;
362
+ });
363
+ return shadowLayers.join(', ');
364
+ }
@@ -5,7 +5,7 @@
5
5
  * in compliance with, at your election, the Elastic License 2.0 or the Server
6
6
  * Side Public License, v 1.
7
7
  */
8
- import { isInverseColorMode, getColorMode, getOn, setOn, computed, Computed, getComputed, buildTheme, mergeDeep, getTokenName, } from './utils';
8
+ import { isInverseColorMode, getColorMode, getOn, setOn, computed, Computed, getComputed, buildTheme, mergeDeep, getTokenName, formatMultipleBoxShadow, } from './utils';
9
9
  describe('isInverseColorMode', () => {
10
10
  it("true only if 'inverse'", () => {
11
11
  expect(isInverseColorMode('LIGHT')).toBe(false);
@@ -233,3 +233,24 @@ describe('getTokenName', () => {
233
233
  expect(getTokenName('backgroundBase', 'primary', 'hovered')).toEqual('backgroundBasePrimaryHovered');
234
234
  });
235
235
  });
236
+ describe('formatMultipleBoxShadow', () => {
237
+ const layers = [
238
+ { x: 0, y: 4, blur: 8, spread: 0, opacity: 0.1 },
239
+ { x: 0, y: 2, blur: 4, spread: 0, opacity: 0.05 },
240
+ ];
241
+ const options = {
242
+ color: '#000000',
243
+ };
244
+ it('returns a valid CSS box-shadow value', () => {
245
+ expect(formatMultipleBoxShadow(layers, options)).toEqual('0px 4px 8px 0px hsla(0,0%,0%,0.1), 0px 2px 4px 0px hsla(0,0%,0%,0.05)');
246
+ });
247
+ it('handles a single layer', () => {
248
+ expect(formatMultipleBoxShadow([layers[0]], options)).toEqual('0px 4px 8px 0px hsla(0,0%,0%,0.1)');
249
+ });
250
+ it('formats the "up" variant', () => {
251
+ expect(formatMultipleBoxShadow(layers, { ...options, direction: 'up' })).toEqual('0px 4px 8px 0px hsla(0,0%,0%,0.1), 0px -2px 4px 0px hsla(0,0%,0%,0.05)');
252
+ });
253
+ it('return "none" for no layers', () => {
254
+ expect(formatMultipleBoxShadow([], options)).toEqual('none');
255
+ });
256
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/eui-theme-common",
3
- "version": "4.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "EUI theme common",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "scripts": {
@@ -1,14 +1,7 @@
1
1
  @import 'responsive';
2
- @import 'shadow';
3
2
  @import 'size';
4
3
  @import 'typography';
5
4
  @import 'helpers';
6
5
  @import 'states';
7
6
 
8
- @import 'button';
9
- @import 'form';
10
- @import 'loading';
11
- @import 'link';
12
- @import 'panel';
13
- @import 'range';
14
7
  @import 'tool_tip';
@@ -1,4 +1,4 @@
1
- @mixin euiFocusRing($size: 'small', $amsterdamOnlyProp: null) {
1
+ @mixin euiFocusRing($size: 'small') {
2
2
  @if $size == 'large' {
3
3
  // It's always OK to use the focus animation. This will take precedence over times we turn it off individually like EuiButtonEmpty
4
4
  // stylelint-disable-next-line declaration-no-important
@@ -14,7 +14,6 @@
14
14
  @import 'typography';
15
15
  @import 'borders';
16
16
  @import 'responsive';
17
- @import 'shadows';
18
17
  @import 'states';
19
18
  @import 'z_index';
20
19