-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use theme's definition to render the initial view
This impacts the loading screen font and colors. Signed-off-by: Miki <[email protected]>
- Loading branch information
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); | ||
}; |