All files / src/theme palette.ts

100% Statements 3/3
100% Branches 14/14
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 66 67 68 69 70 71 72 73 74 75 76            75x                   1446x                                                                                                       1446x              
// @ts-ignore
import _get from 'lodash/get';
 
import { PaletteThemeConfig } from '../types';
import { darken, lighten, shade, generateColorVariants, generateTextVariants } from '../utils';
 
const defaultPalette: { [key: string]: string } = {
  text: '#212121',
  primary: '#574feb',
  secondary: '#9e46d8',
  info: '#1e67d5',
  success: '#0a7d33',
  danger: '#da1717',
  warning: '#ed9c22'
};
 
export default (overrides: PaletteThemeConfig) => ({
  ...generateTextVariants(_get(overrides, 'text') || defaultPalette.text),
 
  background: 'white',
 
  black: 'black',
  black500: 'black',
 
  white: 'white',
  white500: 'white',
  white600: darken(0.03, 'white'),
  white700: darken(0.05, 'white'),
  white800: darken(0.1, 'white'),
  white900: darken(0.15, 'white'),
 
  gray100: lighten(0.2, 'gray'),
  gray200: lighten(0.15, 'gray'),
  gray300: lighten(0.1, 'gray'),
  gray400: lighten(0.05, 'gray'),
  gray: 'gray',
  gray500: 'gray',
  gray600: darken(0.05, 'gray'),
  gray700: darken(0.1, 'gray'),
  gray800: darken(0.15, 'gray'),
  gray900: darken(0.2, 'gray'),
 
  default: darken(0.01, 'white'),
  defaultInverted: '#212121',
 
  ...generateColorVariants({
    paletteKey: 'primary',
    color: overrides.primary || defaultPalette.primary
  }),
  ...generateColorVariants({
    paletteKey: 'secondary',
    color: overrides.secondary || defaultPalette.secondary
  }),
  ...generateColorVariants({
    paletteKey: 'info',
    color: overrides.info || defaultPalette.info
  }),
  ...generateColorVariants({
    paletteKey: 'success',
    color: overrides.success || defaultPalette.success
  }),
  ...generateColorVariants({
    paletteKey: 'danger',
    color: overrides.danger || defaultPalette.danger
  }),
  ...generateColorVariants({
    paletteKey: 'warning',
    color: overrides.warning || defaultPalette.warning,
    paletteOverrides: ({ color }) => ({
      warningTintInverted: shade(0.7, color)
    })
  }),
 
  ...overrides
});