From a63e9e513ae2a96d2fd7908fbf624a9db095ae3d Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Fri, 6 Dec 2024 12:20:48 -0500 Subject: [PATCH] Replace euiThemeVars in kbn-grid-layout --- packages/kbn-grid-layout/grid/drag_preview.tsx | 8 ++++---- .../grid/grid_panel/drag_handle.tsx | 17 ++++++++--------- .../grid/grid_panel/grid_panel.tsx | 5 +++-- .../grid/grid_panel/resize_handle.tsx | 15 ++++++++------- .../kbn-grid-layout/grid/grid_row/grid_row.tsx | 9 +++++---- .../grid/use_grid_layout_state.ts | 11 +++++++++-- .../kbn-grid-layout/grid/utils/mobile_view.ts | 7 ++++--- 7 files changed, 41 insertions(+), 31 deletions(-) diff --git a/packages/kbn-grid-layout/grid/drag_preview.tsx b/packages/kbn-grid-layout/grid/drag_preview.tsx index 24aa81ffea1df..83823bf80d64f 100644 --- a/packages/kbn-grid-layout/grid/drag_preview.tsx +++ b/packages/kbn-grid-layout/grid/drag_preview.tsx @@ -10,9 +10,8 @@ import React, { useEffect, useRef } from 'react'; import { combineLatest, skip } from 'rxjs'; -import { transparentize } from '@elastic/eui'; +import { transparentize, useEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; -import { euiThemeVars } from '@kbn/ui-theme'; import { GridLayoutStateManager } from './types'; @@ -24,6 +23,7 @@ export const DragPreview = ({ gridLayoutStateManager: GridLayoutStateManager; }) => { const dragPreviewRef = useRef(null); + const { euiTheme } = useEuiTheme(); useEffect( () => { @@ -62,8 +62,8 @@ export const DragPreview = ({ css={css` display: none; pointer-events: none; - border-radius: ${euiThemeVars.euiBorderRadius}; - background-color: ${transparentize(euiThemeVars.euiColorSuccess, 0.2)}; + border-radius: ${euiTheme.border.radius}; + background-color: ${transparentize(euiTheme.colors.accentSecondary, 0.2)}; transition: opacity 100ms linear; `} /> diff --git a/packages/kbn-grid-layout/grid/grid_panel/drag_handle.tsx b/packages/kbn-grid-layout/grid/grid_panel/drag_handle.tsx index f175cf227a7e5..cd0c085d0faba 100644 --- a/packages/kbn-grid-layout/grid/grid_panel/drag_handle.tsx +++ b/packages/kbn-grid-layout/grid/grid_panel/drag_handle.tsx @@ -11,7 +11,6 @@ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } import { EuiIcon, useEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; -import { euiThemeVars } from '@kbn/ui-theme'; import { i18n } from '@kbn/i18n'; import { GridLayoutStateManager, PanelInteractionEvent } from '../types'; @@ -101,17 +100,17 @@ export const DragHandle = React.forwardRef< position: absolute; align-items: center; justify-content: center; - top: -${euiThemeVars.euiSizeL}; - width: ${euiThemeVars.euiSizeL}; - height: ${euiThemeVars.euiSizeL}; - z-index: ${euiThemeVars.euiZLevel3}; - margin-left: ${euiThemeVars.euiSizeS}; + top: -${euiTheme.size.l}; + width: ${euiTheme.size.l}; + height: ${euiTheme.size.l}; + z-index: ${euiTheme.levels.mask}; // TODO: double check this + margin-left: ${euiTheme.size.s}; border: 1px solid ${euiTheme.border.color}; border-bottom: none; - background-color: ${euiTheme.colors.emptyShade}; - border-radius: ${euiThemeVars.euiBorderRadius} ${euiThemeVars.euiBorderRadius} 0 0; + background-color: ${euiTheme.colors.backgroundBasePlain}; + border-radius: ${euiTheme.border.radius} ${euiTheme.border.radius} 0 0; cursor: grab; - transition: ${euiThemeVars.euiAnimSpeedSlow} opacity; + transition: ${euiTheme.animation.slow} opacity; .kbnGridPanel:hover &, .kbnGridPanel:focus-within &, &:active, diff --git a/packages/kbn-grid-layout/grid/grid_panel/grid_panel.tsx b/packages/kbn-grid-layout/grid/grid_panel/grid_panel.tsx index c30e6ecc996eb..6d7e2c216f00e 100644 --- a/packages/kbn-grid-layout/grid/grid_panel/grid_panel.tsx +++ b/packages/kbn-grid-layout/grid/grid_panel/grid_panel.tsx @@ -10,8 +10,8 @@ import React, { forwardRef, useEffect, useMemo, useState } from 'react'; import { combineLatest, skip } from 'rxjs'; +import { useEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; -import { euiThemeVars } from '@kbn/ui-theme'; import { GridLayoutStateManager, PanelInteractionEvent } from '../types'; import { getKeysInOrder } from '../utils/resolve_grid_row'; @@ -38,6 +38,7 @@ export const GridPanel = forwardRef( panelRef ) => { const [dragHandleApi, setDragHandleApi] = useState(null); + const {euiTheme} = useEuiTheme(); useEffect(() => { const onDropEventHandler = (dropEvent: MouseEvent) => interactionStart('drop', dropEvent); @@ -107,7 +108,7 @@ export const GridPanel = forwardRef( // if the current panel is active, give it fixed positioning depending on the interaction event const { position: draggingPosition } = activePanel; - ref.style.zIndex = `${euiThemeVars.euiZModal}`; + ref.style.zIndex = `${euiTheme.levels.modal}`; if (currentInteractionEvent?.type === 'resize') { // if the current panel is being resized, ensure it is not shrunk past the size of a single cell ref.style.width = `${Math.max( diff --git a/packages/kbn-grid-layout/grid/grid_panel/resize_handle.tsx b/packages/kbn-grid-layout/grid/grid_panel/resize_handle.tsx index ffee2f2764ed0..59e81802651c6 100644 --- a/packages/kbn-grid-layout/grid/grid_panel/resize_handle.tsx +++ b/packages/kbn-grid-layout/grid/grid_panel/resize_handle.tsx @@ -9,8 +9,8 @@ import { transparentize } from '@elastic/eui'; import { css } from '@emotion/react'; +import { useEuiTheme } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { euiThemeVars } from '@kbn/ui-theme'; import React from 'react'; import { PanelInteractionEvent } from '../types'; @@ -22,6 +22,7 @@ export const ResizeHandle = ({ e: MouseEvent | React.MouseEvent ) => void; }) => { + const { euiTheme } = useEuiTheme(); return (