From 1d2987f6dcbec1afb9adc632a39588643cd58855 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 17:59:52 -0700 Subject: [PATCH] Use themes' definitions to render the initial view. This impacts the loading screen font and colors. (#4936) (#4939) Signed-off-by: Miki (cherry picked from commit 5eedbb5f91f870baf2ddcd7099998625d0970f1e) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- packages/osd-ui-shared-deps/theme.ts | 1 + src/core/server/rendering/views/fonts.tsx | 2 +- src/core/server/rendering/views/styles.tsx | 23 ++++++----- src/core/server/rendering/views/template.tsx | 2 +- src/core/server/rendering/views/theme.ts | 41 ++++++++++++++++++++ 5 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 src/core/server/rendering/views/theme.ts diff --git a/packages/osd-ui-shared-deps/theme.ts b/packages/osd-ui-shared-deps/theme.ts index f7dfc371c89b..c803a5e37ef7 100644 --- a/packages/osd-ui-shared-deps/theme.ts +++ b/packages/osd-ui-shared-deps/theme.ts @@ -28,6 +28,7 @@ * under the License. */ +// ToDo: Use `THEME_SOURCES` from `src/core/server/rendering/views/theme` to generate the logic below. import LightTheme from '@elastic/eui/dist/eui_theme_light.json'; const globals: any = typeof window === 'undefined' ? {} : window; diff --git a/src/core/server/rendering/views/fonts.tsx b/src/core/server/rendering/views/fonts.tsx index 3f2196b56558..61005f2bf209 100644 --- a/src/core/server/rendering/views/fonts.tsx +++ b/src/core/server/rendering/views/fonts.tsx @@ -36,7 +36,7 @@ import { RenderingMetadata } from '../types'; interface Props { url: RenderingMetadata['uiPublicUrl']; - theme: string; + theme: RenderingMetadata['themeVersion']; } interface FontFace { diff --git a/src/core/server/rendering/views/styles.tsx b/src/core/server/rendering/views/styles.tsx index 6b63924dad5d..c3edbfe01bfd 100644 --- a/src/core/server/rendering/views/styles.tsx +++ b/src/core/server/rendering/views/styles.tsx @@ -33,12 +33,19 @@ import React, { FunctionComponent } from 'react'; import { RenderingMetadata } from '../types'; +import { getThemeDefinition, ThemeColorSchemes } from './theme'; interface Props { darkMode: RenderingMetadata['darkMode']; + theme: RenderingMetadata['themeVersion']; } -export const Styles: FunctionComponent = ({ darkMode }) => { +export const Styles: FunctionComponent = ({ theme, darkMode }) => { + const themeDefinition = getThemeDefinition( + theme, + darkMode ? ThemeColorSchemes.DARK : ThemeColorSchemes.LIGHT + ); + return (