UNPKG

1.52 kBTypeScriptView Raw
1import { Palette } from './createPalette';
2import * as React from 'react';
3import { CSSProperties } from './withStyles';
4
5export type Variant =
6 | 'h1'
7 | 'h2'
8 | 'h3'
9 | 'h4'
10 | 'h5'
11 | 'h6'
12 | 'subtitle1'
13 | 'subtitle2'
14 | 'body1'
15 | 'body2'
16 | 'caption'
17 | 'button'
18 | 'overline';
19
20export interface FontStyle
21 extends Required<{
22 fontFamily: React.CSSProperties['fontFamily'];
23 fontSize: number;
24 fontWeightLight: React.CSSProperties['fontWeight'];
25 fontWeightRegular: React.CSSProperties['fontWeight'];
26 fontWeightMedium: React.CSSProperties['fontWeight'];
27 fontWeightBold: React.CSSProperties['fontWeight'];
28 }> {}
29
30export interface FontStyleOptions extends Partial<FontStyle> {
31 htmlFontSize?: number;
32 allVariants?: React.CSSProperties;
33}
34
35// TODO: which one should actually be allowed to be subject to module augmentation?
36// current type vs interface decision is kept for historical reasons until we
37// made a decision
38export type TypographyStyle = CSSProperties;
39export interface TypographyStyleOptions extends TypographyStyle {}
40
41export interface TypographyUtils {
42 pxToRem: (px: number) => string;
43}
44
45export interface Typography extends Record<Variant, TypographyStyle>, FontStyle, TypographyUtils {}
46
47export interface TypographyOptions
48 extends Partial<Record<Variant, TypographyStyleOptions> & FontStyleOptions> {}
49
50export default function createTypography(
51 palette: Palette,
52 typography: TypographyOptions | ((palette: Palette) => TypographyOptions)
53): Typography;