-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use themes' definitions to render the initial view. This impacts the …
…loading screen font and colors. (#4936) (#4939) Signed-off-by: Miki <[email protected]> (cherry picked from commit 5eedbb5) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6deddde
commit 1d2987f
Showing
5 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { deepFreeze } from '@osd/std'; | ||
|
||
export enum ThemeColorSchemes { | ||
LIGHT = 'light', | ||
DARK = 'dark', | ||
} | ||
export const THEME_SOURCES: { | ||
[key: string]: { | ||
[key in ThemeColorSchemes]: string; | ||
}; | ||
} = deepFreeze({ | ||
v7: { | ||
[ThemeColorSchemes.LIGHT]: '@elastic/eui/dist/eui_theme_light.json', | ||
[ThemeColorSchemes.DARK]: '@elastic/eui/dist/eui_theme_dark.json', | ||
}, | ||
default: { | ||
[ThemeColorSchemes.LIGHT]: '@elastic/eui/dist/eui_theme_next_light.json', | ||
[ThemeColorSchemes.DARK]: '@elastic/eui/dist/eui_theme_next_dark.json', | ||
}, | ||
}); | ||
|
||
export const getThemeDefinitionSource = ( | ||
theme: string, | ||
colorScheme: ThemeColorSchemes = ThemeColorSchemes.LIGHT | ||
) => { | ||
const themeName = theme in THEME_SOURCES ? theme : 'default'; | ||
return THEME_SOURCES[themeName][colorScheme]; | ||
}; | ||
|
||
export const getThemeDefinition = ( | ||
theme: string, | ||
colorScheme: ThemeColorSchemes = ThemeColorSchemes.LIGHT | ||
) => { | ||
const file = getThemeDefinitionSource(theme, colorScheme); | ||
return require(file); | ||
}; |