forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createTheme.ts
65 lines (60 loc) · 1.92 KB
/
createTheme.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { createBreakpoints } from './breakpoints';
import { createColors, ThemeColorsInput } from './createColors';
import { createComponents } from './createComponents';
import { createShadows } from './createShadows';
import { createShape, ThemeShapeInput } from './createShape';
import { createSpacing, ThemeSpacingOptions } from './createSpacing';
import { createTransitions } from './createTransitions';
import { createTypography, ThemeTypographyInput } from './createTypography';
import { createV1Theme } from './createV1Theme';
import { createVisualizationColors } from './createVisualizationColors';
import { GrafanaTheme2 } from './types';
import { zIndex } from './zIndex';
/** @internal */
export interface NewThemeOptions {
name?: string;
colors?: ThemeColorsInput;
spacing?: ThemeSpacingOptions;
shape?: ThemeShapeInput;
typography?: ThemeTypographyInput;
}
/** @internal */
export function createTheme(options: NewThemeOptions = {}): GrafanaTheme2 {
const {
colors: colorsInput = {},
spacing: spacingInput = {},
shape: shapeInput = {},
typography: typographyInput = {},
} = options;
const colors = createColors(colorsInput);
const breakpoints = createBreakpoints();
const spacing = createSpacing(spacingInput);
const shape = createShape(shapeInput);
const typography = createTypography(colors, typographyInput);
const shadows = createShadows(colors);
const transitions = createTransitions();
const components = createComponents(colors, shadows);
const visualization = createVisualizationColors(colors);
const theme = {
name: colors.mode === 'dark' ? 'Dark' : 'Light',
isDark: colors.mode === 'dark',
isLight: colors.mode === 'light',
colors,
breakpoints,
spacing,
shape,
components,
typography,
shadows,
transitions,
visualization,
zIndex: {
...zIndex,
},
flags: {},
};
return {
...theme,
v1: createV1Theme(theme),
};
}