From 175ebde6ed5b8f1c0685285380f1f77e84d6702c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 5 Sep 2023 23:50:25 +0000 Subject: [PATCH] Use themes' definitions to render the initial view. This impacts the loading screen font and colors. (#4936) Signed-off-by: Miki (cherry picked from commit 5eedbb5f91f870baf2ddcd7099998625d0970f1e) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md --- 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 (