Skip to content

Commit

Permalink
handle undefined __kbnThemeTag__ globals caused by test runners
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jul 2, 2020
1 parent 4bea131 commit ca991fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/kbn-ui-shared-deps/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ const globals: any = typeof window === 'undefined' ? {} : window;

export type Theme = typeof LightTheme;

export const version: 7 | 8 = globals.__kbnThemeTag__.startsWith('v7') ? 7 : 8;
export const darkMode: boolean = globals.__kbnThemeTag__.endsWith('dark');
// in the Kibana app we can rely on this global being defined, but in
// some cases (like jest, or karma tests) the global is undefined
export const tag: string = globals.__kbnThemeTag__ || 'v7light';
export const version = tag.startsWith('v7') ? 7 : 8;
export const darkMode = tag.endsWith('dark');

export let euiLightVars: Theme;
export let euiDarkVars: Theme;
Expand Down

0 comments on commit ca991fc

Please sign in to comment.