@elastic/eui-theme-common 4.0.0 → 5.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.
- package/lib/cjs/global_styling/functions/shadows.d.ts +12 -0
- package/lib/cjs/global_styling/functions/shadows.js +49 -4
- package/lib/cjs/global_styling/mixins/borders.d.ts +23 -0
- package/lib/cjs/global_styling/mixins/borders.js +50 -0
- package/lib/cjs/global_styling/mixins/index.d.ts +1 -0
- package/lib/cjs/global_styling/mixins/index.js +11 -0
- package/lib/cjs/global_styling/mixins/shadow.d.ts +23 -14
- package/lib/cjs/global_styling/mixins/shadow.js +143 -68
- package/lib/cjs/global_styling/variables/flags.d.ts +1 -0
- package/lib/cjs/global_styling/variables/shadow.d.ts +52 -0
- package/lib/cjs/global_styling/variables/shadow.js +8 -2
- package/lib/cjs/global_styling/variables/typography.d.ts +1 -1
- package/lib/cjs/services/theme/types.d.ts +3 -1
- package/lib/cjs/utils.d.ts +22 -1
- package/lib/cjs/utils.js +39 -1
- package/lib/cjs/utils.test.js +38 -0
- package/lib/esm/global_styling/functions/shadows.d.ts +12 -0
- package/lib/esm/global_styling/functions/shadows.js +40 -1
- package/lib/esm/global_styling/mixins/borders.d.ts +23 -0
- package/lib/esm/global_styling/mixins/borders.js +50 -0
- package/lib/esm/global_styling/mixins/index.d.ts +1 -0
- package/lib/esm/global_styling/mixins/index.js +1 -0
- package/lib/esm/global_styling/mixins/shadow.d.ts +23 -14
- package/lib/esm/global_styling/mixins/shadow.js +127 -81
- package/lib/esm/global_styling/variables/flags.d.ts +1 -0
- package/lib/esm/global_styling/variables/shadow.d.ts +52 -0
- package/lib/esm/global_styling/variables/shadow.js +1 -0
- package/lib/esm/global_styling/variables/typography.d.ts +1 -1
- package/lib/esm/services/theme/types.d.ts +3 -1
- package/lib/esm/utils.d.ts +22 -1
- package/lib/esm/utils.js +31 -0
- package/lib/esm/utils.test.js +22 -1
- package/package.json +1 -1
- package/src/global_styling/mixins/_index.scss +0 -1
- package/src/global_styling/variables/_index.scss +0 -1
- package/src/global_styling/mixins/_shadow.scss +0 -100
- package/src/global_styling/variables/_shadows.scss +0 -2
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import { EuiThemeColorModeStandard } from '../../services/theme/types';
|
|
2
2
|
export declare const getShadowColor: (color: string, opacity: number, colorMode: EuiThemeColorModeStandard) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Converts a `box-shadow` string to a `filter: drop-shadow()` string.
|
|
5
|
+
*
|
|
6
|
+
* @todo check whether this is actually needed in +2025, the original code replacing
|
|
7
|
+
* box-shadow with filter: drop-shadow() had the following comment:
|
|
8
|
+
* > Using only one drop-shadow filter instead of multiple is more
|
|
9
|
+
* > performant & prevents Safari bugs
|
|
10
|
+
*
|
|
11
|
+
* @param boxShadow The `box-shadow` string to convert.
|
|
12
|
+
* @returns The converted `filter` string.
|
|
13
|
+
*/
|
|
14
|
+
export declare const boxShadowToFilterDropShadow: (boxShadow: string) => string;
|
|
@@ -3,22 +3,67 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getShadowColor = void 0;
|
|
6
|
+
exports.getShadowColor = exports.boxShadowToFilterDropShadow = void 0;
|
|
7
7
|
var _chromaJs = _interopRequireDefault(require("chroma-js"));
|
|
8
8
|
var _types = require("../../services/theme/types");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
|
|
10
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /*
|
|
11
16
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
12
17
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
13
18
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
14
19
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
15
20
|
* Side Public License, v 1.
|
|
16
21
|
*/
|
|
17
|
-
|
|
18
22
|
// Create a CSS color value using whose opacity is determined based
|
|
19
23
|
// on either a light or dark theme. We use a multiplier
|
|
20
|
-
// of 1 for light themes and
|
|
24
|
+
// of 1 for light themes and 3.5 for dark themes
|
|
21
25
|
var getShadowColor = exports.getShadowColor = function getShadowColor(color, opacity, colorMode) {
|
|
22
26
|
var themeOpacity = colorMode === _types.COLOR_MODES_STANDARD.dark ? opacity * 3.5 : opacity * 1;
|
|
23
27
|
return (0, _chromaJs["default"])(color).alpha(themeOpacity).css();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Converts a `box-shadow` string to a `filter: drop-shadow()` string.
|
|
32
|
+
*
|
|
33
|
+
* @todo check whether this is actually needed in +2025, the original code replacing
|
|
34
|
+
* box-shadow with filter: drop-shadow() had the following comment:
|
|
35
|
+
* > Using only one drop-shadow filter instead of multiple is more
|
|
36
|
+
* > performant & prevents Safari bugs
|
|
37
|
+
*
|
|
38
|
+
* @param boxShadow The `box-shadow` string to convert.
|
|
39
|
+
* @returns The converted `filter` string.
|
|
40
|
+
*/
|
|
41
|
+
var boxShadowToFilterDropShadow = exports.boxShadowToFilterDropShadow = function boxShadowToFilterDropShadow(boxShadow) {
|
|
42
|
+
var dropShadows = boxShadow.split(/,(?![^(]*\))/) // split by comma, but not inside parentheses
|
|
43
|
+
.map(function (shadow) {
|
|
44
|
+
shadow = shadow.trim();
|
|
45
|
+
// remove `inset`, not supported by drop-shadow
|
|
46
|
+
if (shadow.startsWith('inset ')) {
|
|
47
|
+
shadow = shadow.slice(6);
|
|
48
|
+
}
|
|
49
|
+
// can be complex (hsl, rgb, etc.), used AI for this
|
|
50
|
+
var colorMatch = shadow.match(/(hsl|rgb)a?\(.*\)|#[0-9a-fA-F]{3,8}|[a-zA-Z]+$/);
|
|
51
|
+
var color;
|
|
52
|
+
var parts;
|
|
53
|
+
if (colorMatch) {
|
|
54
|
+
color = colorMatch[0];
|
|
55
|
+
parts = shadow.substring(0, colorMatch.index).trim().split(/\s+/);
|
|
56
|
+
} else {
|
|
57
|
+
color = '#000'; // fallback to black
|
|
58
|
+
parts = shadow.trim().split(/\s+/);
|
|
59
|
+
}
|
|
60
|
+
// drop-shadow doesn't support spread, so we only take x, y, blur
|
|
61
|
+
var _parts = parts,
|
|
62
|
+
_parts2 = _slicedToArray(_parts, 3),
|
|
63
|
+
x = _parts2[0],
|
|
64
|
+
y = _parts2[1],
|
|
65
|
+
blur = _parts2[2];
|
|
66
|
+
return "drop-shadow(".concat(x, " ").concat(y, " ").concat(blur, " ").concat(color, ")");
|
|
67
|
+
}).join(' ');
|
|
68
|
+
return "filter: ".concat(dropShadows, ";");
|
|
24
69
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UseEuiTheme } from '../../services/theme/types';
|
|
2
|
+
export declare const getBorderSide: (side: BorderSides) => string;
|
|
3
|
+
export declare type BorderSides = 'left' | 'right' | 'top' | 'bottom' | 'horizontal' | 'vertical' | 'all';
|
|
4
|
+
/**
|
|
5
|
+
* Defines styles for floating boarders applied in DARK mode via EUI shadow utils
|
|
6
|
+
*/
|
|
7
|
+
export declare const euiShadowFloatingBorderStyles: (euiThemeContext: UseEuiTheme, options: {
|
|
8
|
+
side?: BorderSides;
|
|
9
|
+
borderColor?: string;
|
|
10
|
+
borderWidth?: string;
|
|
11
|
+
borderStyle?: string;
|
|
12
|
+
}) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Shared style for floating borders.
|
|
15
|
+
* Uses a pseudo element with `border` attribute to prevent both dimension changes due to
|
|
16
|
+
* the border width as well as visible gaps due to the need of a transparent border in LIGHT mode.
|
|
17
|
+
*/
|
|
18
|
+
export declare const euiBorderStyles: (euiThemeContext: UseEuiTheme, options: {
|
|
19
|
+
side?: BorderSides;
|
|
20
|
+
borderColor?: string;
|
|
21
|
+
borderWidth?: string;
|
|
22
|
+
borderStyle?: string;
|
|
23
|
+
}) => string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBorderSide = exports.euiShadowFloatingBorderStyles = exports.euiBorderStyles = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
10
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
11
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
12
|
+
* Side Public License, v 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
var logicalSide = {
|
|
16
|
+
left: 'inline-start',
|
|
17
|
+
right: 'inline-end',
|
|
18
|
+
top: 'block-start',
|
|
19
|
+
bottom: 'block-end',
|
|
20
|
+
horizontal: 'inline',
|
|
21
|
+
vertical: 'block'
|
|
22
|
+
};
|
|
23
|
+
var getBorderSide = exports.getBorderSide = function getBorderSide(side) {
|
|
24
|
+
return side === 'all' ? 'border' : "border-".concat(logicalSide[side]);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Defines styles for floating boarders applied in DARK mode via EUI shadow utils
|
|
28
|
+
*/
|
|
29
|
+
var euiShadowFloatingBorderStyles = exports.euiShadowFloatingBorderStyles = function euiShadowFloatingBorderStyles(euiThemeContext, options) {
|
|
30
|
+
return "\n /* create a containing block without using `position` to prevent CSS specificity issues and unexpected overrides;\n `transform: translateZ(0)` is the least likely to affect other behaviors (overflow, layout) */\n transform: translateZ(0);\n\n ".concat(euiBorderStyles(euiThemeContext, options), "\n ");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Shared style for floating borders.
|
|
35
|
+
* Uses a pseudo element with `border` attribute to prevent both dimension changes due to
|
|
36
|
+
* the border width as well as visible gaps due to the need of a transparent border in LIGHT mode.
|
|
37
|
+
*/
|
|
38
|
+
var euiBorderStyles = exports.euiBorderStyles = function euiBorderStyles(euiThemeContext, options) {
|
|
39
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
40
|
+
var _options$side = options.side,
|
|
41
|
+
side = _options$side === void 0 ? 'all' : _options$side,
|
|
42
|
+
_options$borderColor = options.borderColor,
|
|
43
|
+
borderColor = _options$borderColor === void 0 ? euiTheme.border.color : _options$borderColor,
|
|
44
|
+
_options$borderWidth = options.borderWidth,
|
|
45
|
+
borderWidth = _options$borderWidth === void 0 ? euiTheme.border.width.thin : _options$borderWidth,
|
|
46
|
+
_options$borderStyle = options.borderStyle,
|
|
47
|
+
borderStyle = _options$borderStyle === void 0 ? 'solid' : _options$borderStyle;
|
|
48
|
+
var borderProperty = getBorderSide(side);
|
|
49
|
+
return "\n &::after {\n content: '';\n position: absolute;\n inset: 0;\n /* ensure to keep on top of flush content */\n z-index: 0;\n ".concat(borderProperty, ": ").concat(borderWidth, " ").concat(borderStyle, " ").concat(borderColor, ";\n border-radius: inherit;\n pointer-events: none;\n }\n ");
|
|
50
|
+
};
|
|
@@ -13,4 +13,15 @@ Object.keys(_shadow).forEach(function (key) {
|
|
|
13
13
|
return _shadow[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
+
});
|
|
17
|
+
var _borders = require("./borders");
|
|
18
|
+
Object.keys(_borders).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _borders[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _borders[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
16
27
|
});
|
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
import type { UseEuiTheme } from '../../services/theme/types';
|
|
2
2
|
import { _EuiThemeShadowSize } from '../variables/shadow';
|
|
3
|
+
import { BorderSides } from './borders';
|
|
3
4
|
export interface EuiShadowOptions {
|
|
5
|
+
/** @deprecated */
|
|
4
6
|
color?: string;
|
|
7
|
+
/** @default `down` */
|
|
8
|
+
direction?: 'down' | 'up';
|
|
5
9
|
/**
|
|
6
10
|
* Note: not supported by all shadow utilities.
|
|
7
11
|
*/
|
|
8
12
|
property?: 'box-shadow' | 'filter';
|
|
9
13
|
borderAllInHighContrastMode?: boolean;
|
|
14
|
+
border?: BorderSides | 'none';
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
17
|
+
* x-small shadow
|
|
13
18
|
*/
|
|
14
|
-
export declare const euiShadowXSmall: (
|
|
19
|
+
export declare const euiShadowXSmall: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
21
|
+
* small shadow
|
|
17
22
|
*/
|
|
18
|
-
export declare const euiShadowSmall: (
|
|
23
|
+
export declare const euiShadowSmall: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
25
|
+
* medium shadow
|
|
21
26
|
*/
|
|
22
|
-
export declare const euiShadowMedium: (
|
|
27
|
+
export declare const euiShadowMedium: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
29
|
+
* large shadow
|
|
25
30
|
*/
|
|
26
|
-
export declare const euiShadowLarge: (
|
|
31
|
+
export declare const euiShadowLarge: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
|
|
27
32
|
/**
|
|
28
|
-
*
|
|
33
|
+
* x-large shadow
|
|
29
34
|
*/
|
|
30
35
|
export interface EuiShadowXLarge extends EuiShadowOptions {
|
|
31
36
|
reverse?: boolean;
|
|
32
37
|
}
|
|
33
|
-
export declare const euiShadowXLarge: (
|
|
38
|
+
export declare const euiShadowXLarge: (euiThemeContext: UseEuiTheme, options?: EuiShadowXLarge | undefined) => string;
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
40
|
+
* flat shadow
|
|
41
|
+
* @deprecated - use euiShadowHover instead
|
|
36
42
|
*/
|
|
37
|
-
export declare const euiSlightShadowHover: (
|
|
43
|
+
export declare const euiSlightShadowHover: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
45
|
+
* @deprecated - use euiShadowXSmall instead
|
|
40
46
|
*
|
|
47
|
+
* Remains for backwards compatibility for the Amsterdam theme.
|
|
41
48
|
* Similar to shadow medium but without the bottom depth.
|
|
42
49
|
* Useful for popovers that drop UP rather than DOWN.
|
|
43
50
|
*/
|
|
44
|
-
export declare const euiShadowFlat: (
|
|
51
|
+
export declare const euiShadowFlat: (euiThemeContext: UseEuiTheme, options?: EuiShadowOptions | undefined) => string;
|
|
45
52
|
export declare const euiShadow: (euiThemeContext: UseEuiTheme, size?: _EuiThemeShadowSize, options?: EuiShadowOptions | undefined) => string;
|
|
53
|
+
/** Hover shadows */
|
|
54
|
+
export declare const euiShadowHover: (euiThemeContext: UseEuiTheme, size?: _EuiThemeShadowSize | 'base', options?: EuiShadowOptions | undefined) => string;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.euiSlightShadowHover = exports.euiShadowXSmall = exports.euiShadowXLarge = exports.euiShadowSmall = exports.euiShadowMedium = exports.euiShadowLarge = exports.euiShadowFlat = exports.euiShadow = void 0;
|
|
6
|
+
exports.euiSlightShadowHover = exports.euiShadowXSmall = exports.euiShadowXLarge = exports.euiShadowSmall = exports.euiShadowMedium = exports.euiShadowLarge = exports.euiShadowHover = exports.euiShadowFlat = exports.euiShadow = void 0;
|
|
7
7
|
var _functions = require("../functions");
|
|
8
|
+
var _borders = require("./borders");
|
|
8
9
|
/*
|
|
9
10
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
10
11
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -14,118 +15,135 @@ var _functions = require("../functions");
|
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* x-small shadow
|
|
18
19
|
*/
|
|
19
|
-
var euiShadowXSmall = exports.euiShadowXSmall = function euiShadowXSmall(
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
highContrastMode =
|
|
20
|
+
var euiShadowXSmall = exports.euiShadowXSmall = function euiShadowXSmall(euiThemeContext, options) {
|
|
21
|
+
var _options$direction;
|
|
22
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
23
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
23
24
|
if (highContrastMode) {
|
|
24
|
-
return _highContrastBorder(
|
|
25
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
-
return
|
|
27
|
+
var direction = (_options$direction = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction !== void 0 ? _options$direction : 'down';
|
|
28
|
+
return _shadowStyles(euiThemeContext, euiTheme.shadows.xs[direction], {
|
|
29
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
30
|
+
});
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* small shadow
|
|
32
35
|
*/
|
|
33
|
-
var euiShadowSmall = exports.euiShadowSmall = function euiShadowSmall(
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
highContrastMode =
|
|
36
|
+
var euiShadowSmall = exports.euiShadowSmall = function euiShadowSmall(euiThemeContext, options) {
|
|
37
|
+
var _options$direction2;
|
|
38
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
39
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
37
40
|
if (highContrastMode) {
|
|
38
|
-
return _highContrastBorder(
|
|
41
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
39
42
|
}
|
|
40
|
-
var
|
|
41
|
-
return
|
|
43
|
+
var direction = (_options$direction2 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction2 !== void 0 ? _options$direction2 : 'down';
|
|
44
|
+
return _shadowStyles(euiThemeContext, euiTheme.shadows.s[direction], {
|
|
45
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
46
|
+
});
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
/**
|
|
45
|
-
*
|
|
50
|
+
* medium shadow
|
|
46
51
|
*/
|
|
47
|
-
var euiShadowMedium = exports.euiShadowMedium = function euiShadowMedium(
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
highContrastMode =
|
|
52
|
+
var euiShadowMedium = exports.euiShadowMedium = function euiShadowMedium(euiThemeContext, options) {
|
|
53
|
+
var _options$direction3;
|
|
54
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
55
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
51
56
|
if (highContrastMode) {
|
|
52
|
-
return _highContrastBorder(
|
|
57
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
53
58
|
}
|
|
54
|
-
var
|
|
59
|
+
var direction = (_options$direction3 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction3 !== void 0 ? _options$direction3 : 'down';
|
|
60
|
+
var boxShadow = euiTheme.shadows.m[direction];
|
|
55
61
|
if ((options === null || options === void 0 ? void 0 : options.property) === 'filter') {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
return boxShadow ? _shadowStyles(euiThemeContext, (0, _functions.boxShadowToFilterDropShadow)(boxShadow), {
|
|
63
|
+
border: options === null || options === void 0 ? void 0 : options.border,
|
|
64
|
+
type: 'filter'
|
|
65
|
+
}) : '';
|
|
60
66
|
}
|
|
67
|
+
return _shadowStyles(euiThemeContext, boxShadow, {
|
|
68
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
69
|
+
});
|
|
61
70
|
};
|
|
62
71
|
|
|
63
72
|
/**
|
|
64
|
-
*
|
|
73
|
+
* large shadow
|
|
65
74
|
*/
|
|
66
|
-
var euiShadowLarge = exports.euiShadowLarge = function euiShadowLarge(
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
highContrastMode =
|
|
75
|
+
var euiShadowLarge = exports.euiShadowLarge = function euiShadowLarge(euiThemeContext, options) {
|
|
76
|
+
var _options$direction4;
|
|
77
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
78
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
70
79
|
if (highContrastMode) {
|
|
71
|
-
return _highContrastBorder(
|
|
80
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
72
81
|
}
|
|
73
|
-
var
|
|
74
|
-
return
|
|
82
|
+
var direction = (_options$direction4 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction4 !== void 0 ? _options$direction4 : 'down';
|
|
83
|
+
return _shadowStyles(euiThemeContext, euiTheme.shadows.l[direction], {
|
|
84
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
85
|
+
});
|
|
75
86
|
};
|
|
76
87
|
|
|
77
88
|
/**
|
|
78
|
-
*
|
|
89
|
+
* x-large shadow
|
|
79
90
|
*/
|
|
80
91
|
|
|
81
|
-
var euiShadowXLarge = exports.euiShadowXLarge = function euiShadowXLarge(
|
|
82
|
-
var _options$
|
|
83
|
-
var euiTheme =
|
|
84
|
-
|
|
85
|
-
highContrastMode = _ref5.highContrastMode;
|
|
92
|
+
var euiShadowXLarge = exports.euiShadowXLarge = function euiShadowXLarge(euiThemeContext, options) {
|
|
93
|
+
var _options$direction5;
|
|
94
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
95
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
86
96
|
if (highContrastMode) {
|
|
87
|
-
return _highContrastBorder(
|
|
97
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
88
98
|
}
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
var direction = (_options$direction5 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction5 !== void 0 ? _options$direction5 : 'down';
|
|
100
|
+
return _shadowStyles(euiThemeContext, euiTheme.shadows.xl[direction], {
|
|
101
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
102
|
+
});
|
|
92
103
|
};
|
|
93
104
|
|
|
94
105
|
/**
|
|
95
|
-
*
|
|
106
|
+
* flat shadow
|
|
107
|
+
* @deprecated - use euiShadowHover instead
|
|
96
108
|
*/
|
|
97
|
-
var euiSlightShadowHover = exports.euiSlightShadowHover = function euiSlightShadowHover(
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
highContrastMode =
|
|
109
|
+
var euiSlightShadowHover = exports.euiSlightShadowHover = function euiSlightShadowHover(euiThemeContext, options) {
|
|
110
|
+
var _options$direction6;
|
|
111
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
112
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
101
113
|
if (highContrastMode) {
|
|
102
|
-
return _highContrastBorder(
|
|
114
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
103
115
|
}
|
|
104
|
-
var
|
|
105
|
-
return
|
|
116
|
+
var direction = (_options$direction6 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction6 !== void 0 ? _options$direction6 : 'down';
|
|
117
|
+
return _shadowStyles(euiThemeContext, euiTheme.shadows.s[direction], {
|
|
118
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
119
|
+
});
|
|
106
120
|
};
|
|
107
121
|
|
|
108
122
|
/**
|
|
109
|
-
*
|
|
123
|
+
* @deprecated - use euiShadowXSmall instead
|
|
110
124
|
*
|
|
125
|
+
* Remains for backwards compatibility for the Amsterdam theme.
|
|
111
126
|
* Similar to shadow medium but without the bottom depth.
|
|
112
127
|
* Useful for popovers that drop UP rather than DOWN.
|
|
113
128
|
*/
|
|
114
|
-
var euiShadowFlat = exports.euiShadowFlat = function euiShadowFlat(
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
highContrastMode =
|
|
129
|
+
var euiShadowFlat = exports.euiShadowFlat = function euiShadowFlat(euiThemeContext, options) {
|
|
130
|
+
var _options$direction7, _euiTheme$shadows$fla;
|
|
131
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
132
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
118
133
|
if (highContrastMode) {
|
|
119
|
-
return _highContrastBorder(
|
|
134
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
120
135
|
}
|
|
121
|
-
var
|
|
122
|
-
|
|
136
|
+
var direction = (_options$direction7 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction7 !== void 0 ? _options$direction7 : 'down';
|
|
137
|
+
var value = (_euiTheme$shadows$fla = euiTheme.shadows.flat) === null || _euiTheme$shadows$fla === void 0 ? void 0 : _euiTheme$shadows$fla[direction];
|
|
138
|
+
return _shadowStyles(euiThemeContext, value, {
|
|
139
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
140
|
+
});
|
|
123
141
|
};
|
|
124
142
|
var euiShadow = exports.euiShadow = function euiShadow(euiThemeContext) {
|
|
125
143
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'l';
|
|
126
144
|
var options = arguments.length > 2 ? arguments[2] : undefined;
|
|
127
145
|
if (euiThemeContext.highContrastMode) {
|
|
128
|
-
return _highContrastBorder(euiThemeContext
|
|
146
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
129
147
|
}
|
|
130
148
|
switch (size) {
|
|
131
149
|
case 'xs':
|
|
@@ -144,15 +162,72 @@ var euiShadow = exports.euiShadow = function euiShadow(euiThemeContext) {
|
|
|
144
162
|
}
|
|
145
163
|
};
|
|
146
164
|
|
|
165
|
+
/** Hover shadows */
|
|
166
|
+
var euiShadowHover = exports.euiShadowHover = function euiShadowHover(euiThemeContext) {
|
|
167
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'base';
|
|
168
|
+
var options = arguments.length > 2 ? arguments[2] : undefined;
|
|
169
|
+
if (euiThemeContext.highContrastMode) {
|
|
170
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
171
|
+
}
|
|
172
|
+
switch (size) {
|
|
173
|
+
case 'base':
|
|
174
|
+
return _euiShadowHover(euiThemeContext, 'base', options);
|
|
175
|
+
case 'xs':
|
|
176
|
+
return _euiShadowHover(euiThemeContext, 's', options);
|
|
177
|
+
case 's':
|
|
178
|
+
return _euiShadowHover(euiThemeContext, 'm', options);
|
|
179
|
+
case 'm':
|
|
180
|
+
return _euiShadowHover(euiThemeContext, 'l', options);
|
|
181
|
+
case 'l':
|
|
182
|
+
return _euiShadowHover(euiThemeContext, 'xl', options);
|
|
183
|
+
case 'xl':
|
|
184
|
+
return _euiShadowHover(euiThemeContext, 'xxl', options);
|
|
185
|
+
default:
|
|
186
|
+
console.warn('Please provide a valid size option to useEuiShadow');
|
|
187
|
+
return '';
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var _euiShadowHover = function _euiShadowHover(euiThemeContext) {
|
|
191
|
+
var _options$direction8;
|
|
192
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'l';
|
|
193
|
+
var options = arguments.length > 2 ? arguments[2] : undefined;
|
|
194
|
+
var euiTheme = euiThemeContext.euiTheme,
|
|
195
|
+
highContrastMode = euiThemeContext.highContrastMode;
|
|
196
|
+
if (highContrastMode) {
|
|
197
|
+
return _highContrastBorder(euiThemeContext, options);
|
|
198
|
+
}
|
|
199
|
+
var direction = (_options$direction8 = options === null || options === void 0 ? void 0 : options.direction) !== null && _options$direction8 !== void 0 ? _options$direction8 : 'down';
|
|
200
|
+
var shadow = size === 'base' ? euiTheme.shadows.hover.base[direction] : size === 'xxl' ? euiTheme.shadows.hover.xl[direction] : euiTheme.shadows[size][direction];
|
|
201
|
+
return _shadowStyles(euiThemeContext, shadow, {
|
|
202
|
+
border: options === null || options === void 0 ? void 0 : options.border
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
147
206
|
/**
|
|
148
207
|
* Internal utilities for replacing shadows with high contrast borders instead.
|
|
149
208
|
* NOTE: Windows' high contrast themes ignore *all* `box-shadow` CSS,
|
|
150
209
|
* so we use `border` CSS explicitly instead of shadows
|
|
151
210
|
*/
|
|
152
211
|
|
|
153
|
-
var _highContrastBorder = function _highContrastBorder(
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
212
|
+
var _highContrastBorder = function _highContrastBorder(euiThemeContext) {
|
|
213
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
214
|
+
_ref$border = _ref.border,
|
|
215
|
+
border = _ref$border === void 0 ? 'all' : _ref$border,
|
|
216
|
+
borderAllInHighContrastMode = _ref.borderAllInHighContrastMode;
|
|
217
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
218
|
+
var hasFullBorder = borderAllInHighContrastMode || border && border !== 'none';
|
|
219
|
+
return hasFullBorder ? "border: ".concat(euiTheme.border.thin, ";") : "border-block-end: ".concat(euiTheme.border.thin, ";");
|
|
220
|
+
};
|
|
221
|
+
var _shadowStyles = function _shadowStyles(euiThemeContext, shadow, options) {
|
|
222
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
223
|
+
var isRefreshVariant = euiTheme.flags.shadowVariant === 'refresh';
|
|
224
|
+
var _options$border = options.border,
|
|
225
|
+
border = _options$border === void 0 ? 'all' : _options$border,
|
|
226
|
+
_options$type = options.type,
|
|
227
|
+
type = _options$type === void 0 ? 'box-shadow' : _options$type;
|
|
228
|
+
var borderStyle = euiThemeContext.colorMode === 'DARK' && border !== 'none' ? "".concat((0, _borders.euiShadowFloatingBorderStyles)(euiThemeContext, {
|
|
229
|
+
side: border !== null && border !== void 0 ? border : 'all'
|
|
230
|
+
})) : '';
|
|
231
|
+
var shadowStyle = type === 'filter' ? shadow : "box-shadow: ".concat(shadow, ";");
|
|
232
|
+
return "\n ".concat(shadowStyle, ";\n ").concat(isRefreshVariant && borderStyle, ";\n ");
|
|
158
233
|
};
|
|
@@ -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
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._EuiShadowSizesDescriptions = exports.EuiThemeShadowSizes = void 0;
|
|
6
|
+
exports._EuiShadowSizesDescriptions = exports.EuiThemeShadowSizes = exports.EuiThemeShadowHoverSizes = void 0;
|
|
7
7
|
/*
|
|
8
8
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
9
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -13,6 +13,7 @@ exports._EuiShadowSizesDescriptions = exports.EuiThemeShadowSizes = void 0;
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
var EuiThemeShadowSizes = exports.EuiThemeShadowSizes = ['xs', 's', 'm', 'l', 'xl'];
|
|
16
|
+
var EuiThemeShadowHoverSizes = exports.EuiThemeShadowHoverSizes = ['s', 'm', 'l', 'xl', 'xxl'];
|
|
16
17
|
/**
|
|
17
18
|
* Shadow t-shirt sizes descriptions
|
|
18
19
|
*/
|
|
@@ -22,4 +23,9 @@ var _EuiShadowSizesDescriptions = exports._EuiShadowSizesDescriptions = {
|
|
|
22
23
|
m: 'Used on small sized portalled content like popovers.',
|
|
23
24
|
l: 'Primary shadow used in most cases to add visible depth.',
|
|
24
25
|
xl: 'Very large shadows used for large portalled style containers like modals and flyouts.'
|
|
25
|
-
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Represents a single shadow
|
|
30
|
+
* @see https://tr.designtokens.org/format/#shadow
|
|
31
|
+
*/
|