UNPKG

2.74 kBTypeScriptView Raw
1import { Color, PaletteType } from '..';
2
3export {};
4// use standalone interface over typeof colors/commons
5// to enable module augmentation
6export interface CommonColors {
7 black: string;
8 white: string;
9}
10
11export type ColorPartial = Partial<Color>;
12
13export interface TypeText {
14 primary: string;
15 secondary: string;
16 disabled: string;
17 hint: string;
18}
19
20export interface TypeAction {
21 active: string;
22 hover: string;
23 hoverOpacity: number;
24 selected: string;
25 selectedOpacity: number;
26 disabled: string;
27 disabledOpacity: number;
28 disabledBackground: string;
29 focus: string;
30 focusOpacity: number;
31 activatedOpacity: number;
32}
33
34export interface TypeBackground {
35 default: string;
36 paper: string;
37}
38
39export type TypeDivider = string;
40
41export type PaletteColorOptions = SimplePaletteColorOptions | ColorPartial;
42
43export interface SimplePaletteColorOptions {
44 light?: string;
45 main: string;
46 dark?: string;
47 contrastText?: string;
48}
49
50export interface PaletteColor {
51 light: string;
52 main: string;
53 dark: string;
54 contrastText: string;
55}
56
57export interface TypeObject {
58 text: TypeText;
59 action: TypeAction;
60 divider: TypeDivider;
61 background: TypeBackground;
62}
63
64export type PaletteTonalOffset =
65 | number
66 | {
67 light: number;
68 dark: number;
69 };
70
71export const light: TypeObject;
72export const dark: TypeObject;
73
74export interface Palette {
75 common: CommonColors;
76 type: PaletteType;
77 contrastThreshold: number;
78 tonalOffset: PaletteTonalOffset;
79 primary: PaletteColor;
80 secondary: PaletteColor;
81 error: PaletteColor;
82 warning: PaletteColor;
83 info: PaletteColor;
84 success: PaletteColor;
85 grey: Color;
86 text: TypeText;
87 divider: TypeDivider;
88 action: TypeAction;
89 background: TypeBackground;
90 getContrastText: (background: string) => string;
91 augmentColor: {
92 (
93 color: ColorPartial,
94 mainShade?: number | string,
95 lightShade?: number | string,
96 darkShade?: number | string
97 ): PaletteColor;
98 (color: PaletteColorOptions): PaletteColor;
99 };
100}
101
102export type PartialTypeObject = { [P in keyof TypeObject]?: Partial<TypeObject[P]> };
103
104export interface PaletteOptions {
105 primary?: PaletteColorOptions;
106 secondary?: PaletteColorOptions;
107 error?: PaletteColorOptions;
108 warning?: PaletteColorOptions;
109 info?: PaletteColorOptions;
110 success?: PaletteColorOptions;
111 type?: PaletteType;
112 tonalOffset?: PaletteTonalOffset;
113 contrastThreshold?: number;
114 common?: Partial<CommonColors>;
115 grey?: ColorPartial;
116 text?: Partial<TypeText>;
117 divider?: string;
118 action?: Partial<TypeAction>;
119 background?: Partial<TypeBackground>;
120 getContrastText?: (background: string) => string;
121}
122
123export default function createPalette(palette: PaletteOptions): Palette;