Files
grafana/packages/grafana-data/src/themes/createTheme.ts
Torkel Ödegaard 567bbdf6e6 Theme: New visualization colors model (#33973)
* Initial design for new viz colors

* added unit tests

* Progress

* Updated selected color

* Use old named color names and colors to begin with

* Updates

* Fixing tests

* Progress

* Updates

* updating

* fixing tests

* Using some named colors

* renames && fixes

* remove plural

* fixed tests
2021-05-13 07:32:13 +02:00

66 lines
1.9 KiB
TypeScript

import { createBreakpoints } from './breakpoints';
import { createComponents } from './createComponents';
import { createColors, ThemeColorsInput } from './createColors';
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 { GrafanaTheme2 } from './types';
import { zIndex } from './zIndex';
import { createVisualizationColors } from './createVisualizationColors';
/** @internal */
export interface NewThemeOptions {
name?: string;
colors?: ThemeColorsInput;
spacing?: ThemeSpacingOptions;
shape?: ThemeShapeInput;
typography?: ThemeTypographyInput;
}
/** @internal */
export function createTheme(options: NewThemeOptions = {}): GrafanaTheme2 {
const {
name = 'Dark',
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,
isDark: colors.mode === 'dark',
isLight: colors.mode === 'light',
colors,
breakpoints,
spacing,
shape,
components,
typography,
shadows,
transitions,
visualization,
zIndex: {
...zIndex,
},
};
return {
...theme,
v1: createV1Theme(theme),
};
}