diff --git a/CHANGELOG.md b/CHANGELOG.md index 44590087346a..b619c72fa7be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [Decouple] Allow plugin manifest config to define semver compatible OpenSearch plugin and verify if it is installed on the cluster([#4612](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4612)) - [Advanced Settings] Consolidate settings into new "Appearance" category and add category IDs ([#4845](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4845)) - Adds Data explorer framework and implements Discover using it ([#4806](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4806)) +- [Theme] Use themes' definitions to render the initial view ([#4936](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4936/)) - [Theme] Make `next` theme the default ([#4854](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4854/)) ### 🐛 Bug Fixes 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 (