From b80980694a30f957fbd97dc57f16334daf59850d Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Thu, 19 Dec 2024 10:12:09 -0800 Subject: [PATCH] [Embeddable] EUI Visual Refresh Integration (#204452) ## Summary Related to https://github.com/elastic/kibana/issues/203132. Part of [#204596](https://github.com/elastic/kibana/issues/204596). This replaces all references to euiThemeVars in favor of the useEuiTheme hook. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine --- .../eui_markdown/eui_markdown_react_embeddable.tsx | 6 +++--- .../field_list/field_list_react_embeddable.tsx | 6 +++--- .../saved_book/saved_book_react_embeddable.tsx | 14 +++++++++++--- .../search/search_react_embeddable.tsx | 6 +++--- examples/embeddable_examples/tsconfig.json | 1 - 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/examples/embeddable_examples/public/react_embeddables/eui_markdown/eui_markdown_react_embeddable.tsx b/examples/embeddable_examples/public/react_embeddables/eui_markdown/eui_markdown_react_embeddable.tsx index 2ad9cd639a22..7c262d744a55 100644 --- a/examples/embeddable_examples/public/react_embeddables/eui_markdown/eui_markdown_react_embeddable.tsx +++ b/examples/embeddable_examples/public/react_embeddables/eui_markdown/eui_markdown_react_embeddable.tsx @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { EuiMarkdownEditor, EuiMarkdownFormat } from '@elastic/eui'; +import { EuiMarkdownEditor, EuiMarkdownFormat, useEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; import { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import { i18n } from '@kbn/i18n'; @@ -16,7 +16,6 @@ import { useInheritedViewMode, useStateFromPublishingSubject, } from '@kbn/presentation-publishing'; -import { euiThemeVars } from '@kbn/ui-theme'; import React from 'react'; import { BehaviorSubject } from 'rxjs'; import { EUI_MARKDOWN_ID } from './constants'; @@ -80,6 +79,7 @@ export const markdownEmbeddableFactory: ReactEmbeddableFactory< // get state for rendering const content = useStateFromPublishingSubject(content$); const viewMode = useInheritedViewMode(api) ?? 'view'; + const { euiTheme } = useEuiTheme(); return viewMode === 'edit' ? ( {content ?? ''} diff --git a/examples/embeddable_examples/public/react_embeddables/field_list/field_list_react_embeddable.tsx b/examples/embeddable_examples/public/react_embeddables/field_list/field_list_react_embeddable.tsx index c6b13d241997..c88219d1fafc 100644 --- a/examples/embeddable_examples/public/react_embeddables/field_list/field_list_react_embeddable.tsx +++ b/examples/embeddable_examples/public/react_embeddables/field_list/field_list_react_embeddable.tsx @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, useEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; import type { Reference } from '@kbn/content-management-utils'; import { CoreStart } from '@kbn/core-lifecycle-browser'; @@ -17,7 +17,6 @@ import { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import { i18n } from '@kbn/i18n'; import { initializeTitles, useBatchedPublishingSubjects } from '@kbn/presentation-publishing'; import { LazyDataViewPicker, withSuspense } from '@kbn/presentation-util-plugin/public'; -import { euiThemeVars } from '@kbn/ui-theme'; import { UnifiedFieldListSidebarContainer, type UnifiedFieldListSidebarContainerProps, @@ -150,6 +149,7 @@ export const getFieldListFactory = ( dataViews$, selectedFieldNames$ ); + const { euiTheme } = useEuiTheme(); const selectedDataView = renderDataViews?.[0]; @@ -165,7 +165,7 @@ export const getFieldListFactory = ( { bookAttributesManager.bookTitle, bookAttributesManager.bookSynopsis ); + const { euiTheme } = useEuiTheme(); return (
{ )}
{ api, Component: () => { const [count, error] = useBatchedPublishingSubjects(count$, blockingError$); + const { euiTheme } = useEuiTheme(); useEffect(() => { return () => { @@ -138,7 +138,7 @@ export const getSearchEmbeddableFactory = (services: Services) => {