@elastic/eui 102.2.0 → 102.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eui_theme_borealis_dark.json +1 -1
- package/es/components/badge/color_utils.js +1 -3
- package/es/components/badge/notification_badge/badge_notification.styles.js +6 -1
- package/es/components/basic_table/basic_table.js +4 -1
- package/es/components/basic_table/in_memory_table.js +4 -1
- package/es/components/breadcrumbs/_breadcrumb_content.styles.js +6 -3
- package/es/components/button/button_display/_button_display.js +1 -1
- package/es/components/button/button_display/_button_display.styles.js +11 -2
- package/es/components/button/button_display/_button_display_content.styles.js +6 -3
- package/es/components/button/button_empty/button_empty.styles.js +9 -12
- package/es/components/button/button_group/button_group.styles.js +5 -3
- package/es/components/button/button_group/button_group_button.js +19 -9
- package/es/components/button/button_group/button_group_button.styles.js +43 -19
- package/es/components/button/button_icon/button_icon.js +4 -2
- package/es/components/collapsible_nav/collapsible_nav.js +1 -0
- package/es/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
- package/es/components/datagrid/utils/focus.js +2 -2
- package/es/components/filter_group/filter_button.js +88 -23
- package/es/components/filter_group/filter_button.styles.js +51 -15
- package/es/components/filter_group/filter_group.styles.js +18 -6
- package/es/components/markdown_editor/markdown_editor_footer.js +9 -4
- package/es/components/search_bar/filters/field_value_selection_filter.js +1 -0
- package/es/components/search_bar/filters/field_value_toggle_filter.js +3 -1
- package/es/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
- package/es/components/search_bar/filters/is_filter.js +3 -1
- package/es/components/search_bar/search_bar.a11y.js +3 -3
- package/es/global_styling/mixins/_button.js +95 -28
- package/es/services/theme/index.js +2 -1
- package/es/services/theme/provider.js +28 -2
- package/es/services/theme/theme_variant.js +22 -0
- package/es/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
- package/es/themes/amsterdam/global_styling/variables/_components.js +229 -224
- package/es/themes/amsterdam/theme.js +2 -1
- package/es/themes/json/eui_theme_borealis_dark.json +1 -1
- package/eui.d.ts +194 -161
- package/lib/components/badge/color_utils.js +1 -3
- package/lib/components/badge/notification_badge/badge_notification.styles.js +6 -1
- package/lib/components/basic_table/basic_table.js +4 -1
- package/lib/components/basic_table/in_memory_table.js +4 -1
- package/lib/components/breadcrumbs/_breadcrumb_content.styles.js +5 -2
- package/lib/components/button/button_display/_button_display.js +1 -1
- package/lib/components/button/button_display/_button_display.styles.js +11 -2
- package/lib/components/button/button_display/_button_display_content.styles.js +6 -3
- package/lib/components/button/button_empty/button_empty.styles.js +10 -11
- package/lib/components/button/button_group/button_group.styles.js +5 -3
- package/lib/components/button/button_group/button_group_button.js +18 -8
- package/lib/components/button/button_group/button_group_button.styles.js +41 -17
- package/lib/components/button/button_icon/button_icon.js +3 -1
- package/lib/components/collapsible_nav/collapsible_nav.js +1 -0
- package/lib/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
- package/lib/components/datagrid/utils/focus.js +1 -1
- package/lib/components/filter_group/filter_button.js +86 -21
- package/lib/components/filter_group/filter_button.styles.js +51 -15
- package/lib/components/filter_group/filter_group.styles.js +18 -6
- package/lib/components/markdown_editor/markdown_editor_footer.js +8 -3
- package/lib/components/search_bar/filters/field_value_selection_filter.js +1 -0
- package/lib/components/search_bar/filters/field_value_toggle_filter.js +3 -1
- package/lib/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
- package/lib/components/search_bar/filters/is_filter.js +3 -1
- package/lib/components/search_bar/search_bar.a11y.js +3 -3
- package/lib/global_styling/mixins/_button.js +94 -27
- package/lib/services/theme/index.js +42 -1
- package/lib/services/theme/provider.js +28 -2
- package/lib/services/theme/theme_variant.js +28 -0
- package/lib/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
- package/lib/themes/amsterdam/global_styling/variables/_components.js +229 -224
- package/lib/themes/amsterdam/theme.js +2 -1
- package/lib/themes/json/eui_theme_borealis_dark.json +1 -1
- package/optimize/es/components/badge/color_utils.js +1 -3
- package/optimize/es/components/badge/notification_badge/badge_notification.styles.js +6 -1
- package/optimize/es/components/breadcrumbs/_breadcrumb_content.styles.js +6 -3
- package/optimize/es/components/button/button_display/_button_display.js +1 -1
- package/optimize/es/components/button/button_display/_button_display.styles.js +11 -2
- package/optimize/es/components/button/button_display/_button_display_content.styles.js +6 -3
- package/optimize/es/components/button/button_empty/button_empty.styles.js +9 -12
- package/optimize/es/components/button/button_group/button_group.styles.js +5 -3
- package/optimize/es/components/button/button_group/button_group_button.js +12 -8
- package/optimize/es/components/button/button_group/button_group_button.styles.js +43 -19
- package/optimize/es/components/button/button_icon/button_icon.js +4 -2
- package/optimize/es/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
- package/optimize/es/components/datagrid/utils/focus.js +2 -2
- package/optimize/es/components/filter_group/filter_button.js +78 -21
- package/optimize/es/components/filter_group/filter_button.styles.js +51 -15
- package/optimize/es/components/filter_group/filter_group.styles.js +18 -6
- package/optimize/es/components/markdown_editor/markdown_editor_footer.js +9 -4
- package/optimize/es/components/search_bar/filters/field_value_selection_filter.js +1 -0
- package/optimize/es/components/search_bar/filters/field_value_toggle_filter.js +3 -1
- package/optimize/es/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
- package/optimize/es/components/search_bar/filters/is_filter.js +3 -1
- package/optimize/es/components/search_bar/search_bar.a11y.js +3 -3
- package/optimize/es/global_styling/mixins/_button.js +95 -28
- package/optimize/es/services/theme/index.js +2 -1
- package/optimize/es/services/theme/provider.js +28 -2
- package/optimize/es/services/theme/theme_variant.js +22 -0
- package/optimize/es/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
- package/optimize/es/themes/amsterdam/global_styling/variables/_components.js +229 -224
- package/optimize/es/themes/amsterdam/theme.js +2 -1
- package/optimize/es/themes/json/eui_theme_borealis_dark.json +1 -1
- package/optimize/lib/components/badge/color_utils.js +1 -3
- package/optimize/lib/components/badge/notification_badge/badge_notification.styles.js +6 -1
- package/optimize/lib/components/breadcrumbs/_breadcrumb_content.styles.js +5 -2
- package/optimize/lib/components/button/button_display/_button_display.js +1 -1
- package/optimize/lib/components/button/button_display/_button_display.styles.js +11 -2
- package/optimize/lib/components/button/button_display/_button_display_content.styles.js +6 -3
- package/optimize/lib/components/button/button_empty/button_empty.styles.js +10 -11
- package/optimize/lib/components/button/button_group/button_group.styles.js +5 -3
- package/optimize/lib/components/button/button_group/button_group_button.js +11 -7
- package/optimize/lib/components/button/button_group/button_group_button.styles.js +41 -17
- package/optimize/lib/components/button/button_icon/button_icon.js +3 -1
- package/optimize/lib/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
- package/optimize/lib/components/datagrid/utils/focus.js +1 -1
- package/optimize/lib/components/filter_group/filter_button.js +76 -19
- package/optimize/lib/components/filter_group/filter_button.styles.js +51 -15
- package/optimize/lib/components/filter_group/filter_group.styles.js +18 -6
- package/optimize/lib/components/markdown_editor/markdown_editor_footer.js +8 -3
- package/optimize/lib/components/search_bar/filters/field_value_selection_filter.js +1 -0
- package/optimize/lib/components/search_bar/filters/field_value_toggle_filter.js +3 -1
- package/optimize/lib/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
- package/optimize/lib/components/search_bar/filters/is_filter.js +3 -1
- package/optimize/lib/components/search_bar/search_bar.a11y.js +3 -3
- package/optimize/lib/global_styling/mixins/_button.js +94 -27
- package/optimize/lib/services/theme/index.js +42 -1
- package/optimize/lib/services/theme/provider.js +28 -2
- package/optimize/lib/services/theme/theme_variant.js +28 -0
- package/optimize/lib/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
- package/optimize/lib/themes/amsterdam/global_styling/variables/_components.js +229 -224
- package/optimize/lib/themes/amsterdam/theme.js +2 -1
- package/optimize/lib/themes/json/eui_theme_borealis_dark.json +1 -1
- package/package.json +4 -4
- package/test-env/components/badge/color_utils.js +1 -3
- package/test-env/components/badge/notification_badge/badge_notification.styles.js +6 -1
- package/test-env/components/basic_table/basic_table.js +4 -1
- package/test-env/components/basic_table/in_memory_table.js +4 -1
- package/test-env/components/breadcrumbs/_breadcrumb_content.styles.js +5 -2
- package/test-env/components/button/button_display/_button_display.js +1 -1
- package/test-env/components/button/button_display/_button_display.styles.js +11 -2
- package/test-env/components/button/button_display/_button_display_content.styles.js +6 -3
- package/test-env/components/button/button_empty/button_empty.styles.js +10 -11
- package/test-env/components/button/button_group/button_group.styles.js +5 -3
- package/test-env/components/button/button_group/button_group_button.js +18 -8
- package/test-env/components/button/button_group/button_group_button.styles.js +41 -17
- package/test-env/components/button/button_icon/button_icon.js +3 -1
- package/test-env/components/collapsible_nav/collapsible_nav.js +1 -0
- package/test-env/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
- package/test-env/components/datagrid/utils/focus.js +1 -1
- package/test-env/components/filter_group/filter_button.js +86 -21
- package/test-env/components/filter_group/filter_button.styles.js +51 -15
- package/test-env/components/filter_group/filter_group.styles.js +18 -6
- package/test-env/components/markdown_editor/markdown_editor_footer.js +8 -3
- package/test-env/components/search_bar/filters/field_value_selection_filter.js +1 -0
- package/test-env/components/search_bar/filters/field_value_toggle_filter.js +3 -1
- package/test-env/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
- package/test-env/components/search_bar/filters/is_filter.js +3 -1
- package/test-env/components/search_bar/search_bar.a11y.js +3 -3
- package/test-env/global_styling/mixins/_button.js +94 -27
- package/test-env/services/theme/index.js +42 -1
- package/test-env/services/theme/provider.js +28 -2
- package/test-env/services/theme/theme_variant.js +28 -0
- package/test-env/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
- package/test-env/themes/amsterdam/global_styling/variables/_components.js +229 -224
- package/test-env/themes/amsterdam/theme.js +2 -1
- package/test-env/themes/json/eui_theme_borealis_dark.json +1 -1
|
@@ -13,14 +13,34 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { css, keyframes } from '@emotion/react';
|
|
16
|
-
import { getTokenName, euiCanAnimate } from '@elastic/eui-theme-common';
|
|
17
|
-
import { makeHighContrastColor, useEuiMemoizedStyles } from '../../services';
|
|
16
|
+
import { getTokenName, euiCanAnimate, mathWithUnits } from '@elastic/eui-theme-common';
|
|
17
|
+
import { makeHighContrastColor, useEuiMemoizedStyles, isEuiThemeRefreshVariant } from '../../services';
|
|
18
|
+
import { highContrastModeStyles, logicalCSS } from '../functions';
|
|
18
19
|
|
|
19
20
|
/** Tentative usage; these exist only to be used as button directly when used within other components */
|
|
20
21
|
export var SEVERITY_COLORS = ['neutral', 'risk'];
|
|
21
22
|
export var BUTTON_COLORS = ['text', 'accent', 'accentSecondary', 'primary', 'success', 'warning', 'danger'];
|
|
22
23
|
export var EXTENDED_BUTTON_COLORS = [].concat(BUTTON_COLORS, SEVERITY_COLORS);
|
|
23
24
|
export var BUTTON_DISPLAYS = ['base', 'fill', 'empty'];
|
|
25
|
+
var getButtonVariantTokenValues = function getButtonVariantTokenValues(_ref, color, variant) {
|
|
26
|
+
var euiTheme = _ref.euiTheme,
|
|
27
|
+
highContrastMode = _ref.highContrastMode;
|
|
28
|
+
var backgroundTokenBase = variant === 'base' ? 'background' : "background".concat(variant.charAt(0).toUpperCase() + variant.slice(1));
|
|
29
|
+
var textTokenBase = variant === 'filled' ? 'textColorFilled' : 'textColor';
|
|
30
|
+
var backgroundTokenName = getTokenName(backgroundTokenBase, color);
|
|
31
|
+
var textTokenName = getTokenName(textTokenBase, color);
|
|
32
|
+
var backgroundHoverTokenName = getTokenName(backgroundTokenBase, color, 'hover');
|
|
33
|
+
var backgroundActiveTokenName = getTokenName(backgroundTokenBase, color, 'active');
|
|
34
|
+
var highContrastForeground = ['warning', 'neutral', 'risk'].includes(color) ? euiTheme.colors.ink : color === 'disabled' ? euiTheme.components.buttons[textTokenName] : euiTheme.colors.textInverse;
|
|
35
|
+
var foreground = variant === 'filled' ? highContrastMode ? highContrastForeground : euiTheme.components.buttons[textTokenName] : euiTheme.components.buttons[textTokenName];
|
|
36
|
+
return {
|
|
37
|
+
color: foreground,
|
|
38
|
+
background: euiTheme.components.buttons[backgroundTokenName],
|
|
39
|
+
backgroundHover: euiTheme.components.buttons[backgroundHoverTokenName],
|
|
40
|
+
backgroundActive: euiTheme.components.buttons[backgroundActiveTokenName]
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
24
44
|
/**
|
|
25
45
|
* Creates the `base` version of button styles with proper text contrast.
|
|
26
46
|
* @param euiThemeContext
|
|
@@ -28,11 +48,9 @@ export var BUTTON_DISPLAYS = ['base', 'fill', 'empty'];
|
|
|
28
48
|
* @returns Style object `{ backgroundColor, color }`
|
|
29
49
|
*/
|
|
30
50
|
export var euiButtonColor = function euiButtonColor(euiThemeContext, color) {
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var foreground = euiTheme.components.buttons[textTokenName];
|
|
35
|
-
var background = euiTheme.components.buttons[backgroundTokenName];
|
|
51
|
+
var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'base');
|
|
52
|
+
var foreground = buttonColors.color;
|
|
53
|
+
var background = buttonColors.background;
|
|
36
54
|
return _objectSpread({
|
|
37
55
|
color: background === 'transparent' || color === 'disabled' ? foreground : makeHighContrastColor(foreground)(background),
|
|
38
56
|
backgroundColor: background
|
|
@@ -46,13 +64,9 @@ export var euiButtonColor = function euiButtonColor(euiThemeContext, color) {
|
|
|
46
64
|
* @returns Style object `{ backgroundColor, color }`
|
|
47
65
|
*/
|
|
48
66
|
export var euiButtonFillColor = function euiButtonFillColor(euiThemeContext, color) {
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
var textColorTokenName = getTokenName('textColorFilled', color);
|
|
53
|
-
var highContrastForeground = ['warning', 'neutral', 'risk'].includes(color) ? euiTheme.colors.ink : color === 'disabled' ? euiTheme.components.buttons[textColorTokenName] : euiTheme.colors.textInverse;
|
|
54
|
-
var foreground = highContrastMode ? highContrastForeground : euiTheme.components.buttons[textColorTokenName];
|
|
55
|
-
var background = euiTheme.components.buttons[backgroundTokenName];
|
|
67
|
+
var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'filled');
|
|
68
|
+
var foreground = buttonColors.color;
|
|
69
|
+
var background = buttonColors.background;
|
|
56
70
|
return _objectSpread({
|
|
57
71
|
color: foreground,
|
|
58
72
|
backgroundColor: background
|
|
@@ -76,9 +90,9 @@ export var euiButtonEmptyColor = function euiButtonEmptyColor(euiThemeContext, c
|
|
|
76
90
|
break;
|
|
77
91
|
default:
|
|
78
92
|
{
|
|
79
|
-
var
|
|
93
|
+
var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'empty');
|
|
80
94
|
foreground = euiButtonColor(euiThemeContext, color).color;
|
|
81
|
-
background =
|
|
95
|
+
background = buttonColors.backgroundHover;
|
|
82
96
|
break;
|
|
83
97
|
}
|
|
84
98
|
}
|
|
@@ -101,6 +115,8 @@ export var useEuiButtonColorCSS = function useEuiButtonColorCSS() {
|
|
|
101
115
|
return colorsDisplaysMap[display];
|
|
102
116
|
};
|
|
103
117
|
var euiButtonDisplaysColors = function euiButtonDisplaysColors(euiThemeContext) {
|
|
118
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
119
|
+
var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
|
|
104
120
|
var COLORS = [].concat(_toConsumableArray(EXTENDED_BUTTON_COLORS), ['disabled']);
|
|
105
121
|
var displaysColorsMap = {};
|
|
106
122
|
BUTTON_DISPLAYS.forEach(function (display) {
|
|
@@ -108,14 +124,28 @@ var euiButtonDisplaysColors = function euiButtonDisplaysColors(euiThemeContext)
|
|
|
108
124
|
COLORS.forEach(function (color) {
|
|
109
125
|
switch (display) {
|
|
110
126
|
case 'base':
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
{
|
|
128
|
+
var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'base');
|
|
129
|
+
var borderStyle = color === 'text' && "\n border: ".concat(euiTheme.border.width.thin, " solid ").concat(euiTheme.colors.borderBasePlain, ";\n ");
|
|
130
|
+
var refreshVariantStyles = isRefreshVariant && "\n ".concat(_interactionStyles(euiThemeContext, buttonColors, 'overlay'), "\n ").concat(borderStyle, "\n ");
|
|
131
|
+
displaysColorsMap[display][color] = /*#__PURE__*/css(euiButtonColor(euiThemeContext, color), " ", refreshVariantStyles, ";;label:displaysColorsMap-display-color;");
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
113
134
|
case 'fill':
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
{
|
|
136
|
+
var _buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'filled');
|
|
137
|
+
var _refreshVariantStyles = isRefreshVariant && _interactionStyles(euiThemeContext, _buttonColors);
|
|
138
|
+
displaysColorsMap[display][color] = /*#__PURE__*/css(euiButtonFillColor(euiThemeContext, color), "outline-color:", euiThemeContext.colorMode === 'DARK' && color === 'text' ? 'currentColor' : euiThemeContext.euiTheme.colors.fullShade, ";", _refreshVariantStyles, ";;label:displaysColorsMap-display-color;");
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
116
141
|
case 'empty':
|
|
117
|
-
|
|
118
|
-
|
|
142
|
+
{
|
|
143
|
+
var _buttonColors2 = getButtonVariantTokenValues(euiThemeContext, color, 'empty');
|
|
144
|
+
var classicVariantStyles = !isRefreshVariant && "\n &:focus,\n &:active {\n background-color: ".concat(euiButtonEmptyColor(euiThemeContext, color).backgroundColor, ";\n }\n ");
|
|
145
|
+
var _refreshVariantStyles2 = isRefreshVariant && _interactionStyles(euiThemeContext, _buttonColors2, 'overlay');
|
|
146
|
+
displaysColorsMap[display][color] = /*#__PURE__*/css("color:", euiButtonEmptyColor(euiThemeContext, color).color, ";", classicVariantStyles, " ", _refreshVariantStyles2, ";;label:displaysColorsMap-display-color;");
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
119
149
|
}
|
|
120
150
|
|
|
121
151
|
// Tweak auto-generated Emotion label/className output
|
|
@@ -134,9 +164,10 @@ export var useEuiButtonFocusCSS = function useEuiButtonFocusCSS() {
|
|
|
134
164
|
return useEuiMemoizedStyles(euiButtonFocusCSS);
|
|
135
165
|
};
|
|
136
166
|
var euiButtonFocusAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 50% {\n transform: translateY(1px);\n }\n"])));
|
|
137
|
-
var euiButtonFocusCSS = function euiButtonFocusCSS(
|
|
138
|
-
var euiTheme =
|
|
139
|
-
var
|
|
167
|
+
var euiButtonFocusCSS = function euiButtonFocusCSS(euiThemeContext) {
|
|
168
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
169
|
+
var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
|
|
170
|
+
var focusCSS = isRefreshVariant ? /*#__PURE__*/css(";label:focusCSS;") : /*#__PURE__*/css(euiCanAnimate, "{transition:transform ", euiTheme.animation.normal, " ease-in-out,background-color ", euiTheme.animation.normal, " ease-in-out;&:hover:not(:disabled){transform:translateY(-1px);}&:focus{animation:", euiButtonFocusAnimation, " ", euiTheme.animation.normal, " ", euiTheme.animation.bounce, ";}&:active:not(:disabled){transform:translateY(1px);}};label:focusCSS;");
|
|
140
171
|
// Remove the auto-generated label.
|
|
141
172
|
// We could typically avoid a label by using a plain string `` instead of css``,
|
|
142
173
|
// but we need css`` for keyframes`` to work for the focus animation
|
|
@@ -148,27 +179,63 @@ var euiButtonFocusCSS = function euiButtonFocusCSS(_ref) {
|
|
|
148
179
|
* Map of `size` props to various sizings/scales
|
|
149
180
|
* that should remain consistent across all buttons
|
|
150
181
|
*/
|
|
151
|
-
export var euiButtonSizeMap = function euiButtonSizeMap(
|
|
152
|
-
var euiTheme =
|
|
182
|
+
export var euiButtonSizeMap = function euiButtonSizeMap(euiThemeContext) {
|
|
183
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
184
|
+
var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
|
|
153
185
|
return {
|
|
154
186
|
xs: {
|
|
187
|
+
minWidth: euiTheme.base * (isRefreshVariant ? 6 : 7),
|
|
155
188
|
height: euiTheme.size.l,
|
|
156
189
|
radius: euiTheme.border.radius.small,
|
|
157
190
|
fontScale: 'xs'
|
|
158
191
|
},
|
|
159
192
|
s: {
|
|
193
|
+
minWidth: euiTheme.base * (isRefreshVariant ? 6 : 7),
|
|
160
194
|
height: euiTheme.size.xl,
|
|
161
195
|
radius: euiTheme.border.radius.small,
|
|
162
196
|
fontScale: 's'
|
|
163
197
|
},
|
|
164
198
|
m: {
|
|
199
|
+
minWidth: euiTheme.base * 7,
|
|
165
200
|
height: euiTheme.size.xxl,
|
|
166
|
-
radius: euiTheme.border.radius.medium,
|
|
201
|
+
radius: isRefreshVariant ? euiTheme.border.radius.small : euiTheme.border.radius.medium,
|
|
167
202
|
fontScale: 's'
|
|
168
203
|
}
|
|
169
204
|
};
|
|
170
205
|
};
|
|
171
206
|
|
|
207
|
+
/**
|
|
208
|
+
* internal styles util for applying button background color on hover
|
|
209
|
+
*/
|
|
210
|
+
var _interactionStyles = function _interactionStyles(euiThemeContext, buttonColors) {
|
|
211
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fill';
|
|
212
|
+
var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
|
|
213
|
+
if (!isRefreshVariant) return "";
|
|
214
|
+
var baseStyles = function baseStyles() {
|
|
215
|
+
// button hover is applied as pseudo element with a transparent background-color
|
|
216
|
+
if (type === 'overlay') {
|
|
217
|
+
return "\n position: relative;\n overflow: hidden;\n\n &:hover:not(:disabled) {\n &::before {\n content: '';\n position: absolute;\n /* should stay under the content */\n z-index: 0;\n inset: 0;\n background-color: ".concat(buttonColors.backgroundHover, ";\n pointer-events: none;\n }\n }\n\n &:active:not(:disabled) {\n &::before {\n ").concat(logicalCSS('width', '100%'), "\n ").concat(logicalCSS('height', '100%'), "\n\n content: '';\n position: absolute;\n inset: 0;\n background-color: ").concat(buttonColors.backgroundActive, ";\n }\n }\n ");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// button hover is applied as opaque color
|
|
221
|
+
return "\n &:hover:not(:disabled) {\n background-color: ".concat(buttonColors.backgroundHover, ";\n }\n\n &:active:not(:disabled) {\n background-color: ").concat(buttonColors.backgroundActive, ";\n }\n ");
|
|
222
|
+
};
|
|
223
|
+
return " \n ".concat(highContrastModeStyles(euiThemeContext, {
|
|
224
|
+
none: baseStyles(),
|
|
225
|
+
forced: "\n position: relative;\n overflow: hidden;\n\n ".concat(highContrastHoverIndicatorStyles(euiThemeContext), "\n ")
|
|
226
|
+
}), "\n ");
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* creates a bottom border on hover/focus to ensure a visible change as forced mode removed background colors
|
|
231
|
+
*/
|
|
232
|
+
export var highContrastHoverIndicatorStyles = function highContrastHoverIndicatorStyles(_ref2) {
|
|
233
|
+
var euiTheme = _ref2.euiTheme;
|
|
234
|
+
return "\n &:hover:not(:disabled) {\n transition: none;\n\n /* using pseudo border to be able to control the color */\n &::after {\n content: '';\n position: absolute;\n inset: ".concat(euiTheme.border.width.thin, ";\n border: ").concat(euiTheme.border.width.thick, " solid var(--highContrastHoverIndicatorColor, ").concat(euiTheme.border.color, ");\n border-radius: ").concat(mathWithUnits(euiTheme.border.radius.small, function (x) {
|
|
235
|
+
return x / 2;
|
|
236
|
+
}), ";\n background-color: transparent;\n pointer-events: none;\n }\n }\n");
|
|
237
|
+
};
|
|
238
|
+
|
|
172
239
|
/**
|
|
173
240
|
* Internal util for high contrast button borders
|
|
174
241
|
*/
|
|
@@ -12,4 +12,5 @@ export { EuiThemeProvider } from './provider';
|
|
|
12
12
|
export { useEuiMemoizedStyles, withEuiStylesMemoizer, RenderWithEuiStylesMemoizer } from './style_memoization';
|
|
13
13
|
export { getEuiDevProviderWarning, setEuiDevProviderWarning } from './warning';
|
|
14
14
|
export { buildTheme, computed, isInverseColorMode, getColorMode, getComputed, getOn, mergeDeep, setOn, Computed } from './utils';
|
|
15
|
-
export { COLOR_MODES_STANDARD } from './types';
|
|
15
|
+
export { COLOR_MODES_STANDARD } from './types';
|
|
16
|
+
export * from './theme_variant';
|
|
@@ -134,9 +134,35 @@ export var EuiThemeProvider = function EuiThemeProvider(_ref) {
|
|
|
134
134
|
}, [highContrastMode]);
|
|
135
135
|
useEffect(function () {
|
|
136
136
|
if (!isParentTheme.current) {
|
|
137
|
-
|
|
137
|
+
/* Enables recomputation of component colors when flags are overridden on the provider
|
|
138
|
+
by adding the respective key to modifications to trigger a recomputation. */
|
|
139
|
+
// TODO: remove once visual refresh is completed and flags are obsolete
|
|
140
|
+
var flagsToRecompute = [{
|
|
141
|
+
flag: 'buttonVariant',
|
|
142
|
+
componentKey: 'buttons'
|
|
143
|
+
}];
|
|
144
|
+
var keys = {};
|
|
145
|
+
var forceRecomputeComponents = flagsToRecompute.some(function (item) {
|
|
146
|
+
var _modifications$flags, _modifications$compon;
|
|
147
|
+
if (Object.keys((_modifications$flags = modifications.flags) !== null && _modifications$flags !== void 0 ? _modifications$flags : {}).includes(item.flag) && !Object.keys((_modifications$compon = modifications.components) !== null && _modifications$compon !== void 0 ? _modifications$compon : {}).includes(item.componentKey)) {
|
|
148
|
+
keys[item.componentKey] = {
|
|
149
|
+
LIGHT: {},
|
|
150
|
+
DARK: {}
|
|
151
|
+
};
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
});
|
|
156
|
+
var componentModifications = forceRecomputeComponents ? {
|
|
157
|
+
components: keys
|
|
158
|
+
} : {};
|
|
159
|
+
|
|
160
|
+
// force recomputing of color & component tokens based on flag changes
|
|
161
|
+
var enhancedModifications = _objectSpread(_objectSpread({}, modificationsWithHighContrast), componentModifications);
|
|
162
|
+
var rebuiltTheme = getComputed(system, buildTheme(enhancedModifications, "_".concat(system.key)), colorMode, highContrastMode);
|
|
163
|
+
setTheme(rebuiltTheme);
|
|
138
164
|
}
|
|
139
|
-
}, [colorMode, highContrastMode, system, modificationsWithHighContrast]);
|
|
165
|
+
}, [colorMode, highContrastMode, system, modificationsWithHighContrast, modifications]);
|
|
140
166
|
var _useState9 = useState(),
|
|
141
167
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
142
168
|
themeCSSVariables = _useState10[0],
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
5
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
|
+
* Side Public License, v 1.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useEuiTheme } from './hooks';
|
|
10
|
+
export var isEuiThemeRefreshVariant = function isEuiThemeRefreshVariant(_ref, flag) {
|
|
11
|
+
var euiTheme = _ref.euiTheme;
|
|
12
|
+
return euiTheme.flags[flag] === 'refresh';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Util to retrieve visual variant for UI elements
|
|
17
|
+
* Note: Temporary only - will be removed once the visual refresh is completed.
|
|
18
|
+
*/
|
|
19
|
+
export var useEuiThemeRefreshVariant = function useEuiThemeRefreshVariant(flag) {
|
|
20
|
+
var euiThemeContext = useEuiTheme();
|
|
21
|
+
return isEuiThemeRefreshVariant(euiThemeContext, flag);
|
|
22
|
+
};
|