1 | import * as React from 'react';
|
2 | import * as CSS from 'csstype';
|
3 | import { Palette } from './createPalette';
|
4 |
|
5 | export 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 |
|
20 | export interface FontStyle {
|
21 | fontFamily: React.CSSProperties['fontFamily'];
|
22 | fontSize: number;
|
23 | fontWeightLight: React.CSSProperties['fontWeight'];
|
24 | fontWeightRegular: React.CSSProperties['fontWeight'];
|
25 | fontWeightMedium: React.CSSProperties['fontWeight'];
|
26 | fontWeightBold: React.CSSProperties['fontWeight'];
|
27 | htmlFontSize: number;
|
28 | }
|
29 |
|
30 | export type NormalCssProperties = CSS.Properties<number | string>;
|
31 | export type Fontface = CSS.AtRule.FontFace & { fallbacks?: CSS.AtRule.FontFace[] };
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export interface BaseCSSProperties extends NormalCssProperties {
|
37 | '@font-face'?: Fontface | Fontface[];
|
38 | }
|
39 |
|
40 | export interface CSSProperties extends BaseCSSProperties {
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | [k: string]: unknown | CSSProperties;
|
50 | }
|
51 |
|
52 | export interface FontStyleOptions extends Partial<FontStyle> {
|
53 | allVariants?: React.CSSProperties;
|
54 | }
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | export type TypographyStyle = CSSProperties;
|
60 | export interface TypographyStyleOptions extends TypographyStyle {}
|
61 |
|
62 | export interface TypographyUtils {
|
63 | pxToRem: (px: number) => string;
|
64 | }
|
65 |
|
66 | export interface Typography extends Record<Variant, TypographyStyle>, FontStyle, TypographyUtils {}
|
67 |
|
68 | export interface TypographyOptions
|
69 | extends Partial<Record<Variant, TypographyStyleOptions> & FontStyleOptions> {}
|
70 |
|
71 | export default function createTypography(
|
72 | palette: Palette,
|
73 | typography: TypographyOptions | ((palette: Palette) => TypographyOptions),
|
74 | ): Typography;
|