@khanacademy/wonder-blocks-typography 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/es/index.js +460 -0
- package/dist/index.js +759 -0
- package/dist/index.js.flow +2 -0
- package/docs.md +254 -0
- package/package.json +29 -0
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +1462 -0
- package/src/__tests__/generated-snapshot.test.js +332 -0
- package/src/components/body-monospace.js +26 -0
- package/src/components/body-monospace.md +14 -0
- package/src/components/body-serif-block.js +26 -0
- package/src/components/body-serif.js +26 -0
- package/src/components/body.js +26 -0
- package/src/components/caption.js +26 -0
- package/src/components/footnote.js +26 -0
- package/src/components/heading-large.js +26 -0
- package/src/components/heading-medium.js +26 -0
- package/src/components/heading-small.js +26 -0
- package/src/components/heading-xsmall.js +26 -0
- package/src/components/label-large.js +26 -0
- package/src/components/label-medium.js +26 -0
- package/src/components/label-small.js +26 -0
- package/src/components/label-xsmall.js +26 -0
- package/src/components/tagline.js +26 -0
- package/src/components/title.js +28 -0
- package/src/index.js +78 -0
- package/src/util/styles.js +156 -0
- package/src/util/types.js +6 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {Text} from "@khanacademy/wonder-blocks-core";
|
|
4
|
+
|
|
5
|
+
import styles from "../util/styles.js";
|
|
6
|
+
|
|
7
|
+
import type {Props} from "../util/types.js";
|
|
8
|
+
|
|
9
|
+
type DefaultProps = {|
|
|
10
|
+
tag: $PropertyType<Props, "tag">,
|
|
11
|
+
|};
|
|
12
|
+
|
|
13
|
+
export default class LabelSmall extends React.Component<Props> {
|
|
14
|
+
static defaultProps: DefaultProps = {
|
|
15
|
+
tag: "span",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
render(): React.Node {
|
|
19
|
+
const {style, children, ...otherProps} = this.props;
|
|
20
|
+
return (
|
|
21
|
+
<Text {...otherProps} style={[styles.LabelSmall, style]}>
|
|
22
|
+
{children}
|
|
23
|
+
</Text>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {Text} from "@khanacademy/wonder-blocks-core";
|
|
4
|
+
|
|
5
|
+
import styles from "../util/styles.js";
|
|
6
|
+
|
|
7
|
+
import type {Props} from "../util/types.js";
|
|
8
|
+
|
|
9
|
+
type DefaultProps = {|
|
|
10
|
+
tag: $PropertyType<Props, "tag">,
|
|
11
|
+
|};
|
|
12
|
+
|
|
13
|
+
export default class LabelXSmall extends React.Component<Props> {
|
|
14
|
+
static defaultProps: DefaultProps = {
|
|
15
|
+
tag: "span",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
render(): React.Node {
|
|
19
|
+
const {style, children, ...otherProps} = this.props;
|
|
20
|
+
return (
|
|
21
|
+
<Text {...otherProps} style={[styles.LabelXSmall, style]}>
|
|
22
|
+
{children}
|
|
23
|
+
</Text>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {Text} from "@khanacademy/wonder-blocks-core";
|
|
4
|
+
|
|
5
|
+
import styles from "../util/styles.js";
|
|
6
|
+
|
|
7
|
+
import type {Props} from "../util/types.js";
|
|
8
|
+
|
|
9
|
+
type DefaultProps = {|
|
|
10
|
+
tag: $PropertyType<Props, "tag">,
|
|
11
|
+
|};
|
|
12
|
+
|
|
13
|
+
export default class Tagline extends React.Component<Props> {
|
|
14
|
+
static defaultProps: DefaultProps = {
|
|
15
|
+
tag: "span",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
render(): React.Node {
|
|
19
|
+
const {style, children, ...otherProps} = this.props;
|
|
20
|
+
return (
|
|
21
|
+
<Text {...otherProps} style={[styles.Tagline, style]}>
|
|
22
|
+
{children}
|
|
23
|
+
</Text>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {Text} from "@khanacademy/wonder-blocks-core";
|
|
4
|
+
|
|
5
|
+
import styles from "../util/styles.js";
|
|
6
|
+
|
|
7
|
+
import type {Props} from "../util/types.js";
|
|
8
|
+
|
|
9
|
+
type DefaultProps = {|
|
|
10
|
+
tag: $PropertyType<Props, "tag">,
|
|
11
|
+
|};
|
|
12
|
+
|
|
13
|
+
// TODO(alex): Once style prop validation works, if all of the style prop flow
|
|
14
|
+
// types are the same then switch to using functional components.
|
|
15
|
+
export default class Title extends React.Component<Props> {
|
|
16
|
+
static defaultProps: DefaultProps = {
|
|
17
|
+
tag: "h1",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
render(): React.Node {
|
|
21
|
+
const {style, children, ...otherProps} = this.props;
|
|
22
|
+
return (
|
|
23
|
+
<Text {...otherProps} style={[styles.Title, style]}>
|
|
24
|
+
{children}
|
|
25
|
+
</Text>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import styles from "./util/styles.js";
|
|
3
|
+
|
|
4
|
+
import Title from "./components/title.js";
|
|
5
|
+
import HeadingLarge from "./components/heading-large.js";
|
|
6
|
+
import HeadingMedium from "./components/heading-medium.js";
|
|
7
|
+
import HeadingSmall from "./components/heading-small.js";
|
|
8
|
+
import HeadingXSmall from "./components/heading-xsmall.js";
|
|
9
|
+
import BodySerifBlock from "./components/body-serif-block.js";
|
|
10
|
+
import BodySerif from "./components/body-serif.js";
|
|
11
|
+
import BodyMonospace from "./components/body-monospace.js";
|
|
12
|
+
import Body from "./components/body.js";
|
|
13
|
+
import LabelLarge from "./components/label-large.js";
|
|
14
|
+
import LabelMedium from "./components/label-medium.js";
|
|
15
|
+
import LabelSmall from "./components/label-small.js";
|
|
16
|
+
import LabelXSmall from "./components/label-xsmall.js";
|
|
17
|
+
import Tagline from "./components/tagline.js";
|
|
18
|
+
import Caption from "./components/caption.js";
|
|
19
|
+
import Footnote from "./components/footnote.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Typography components for headings or titles.
|
|
23
|
+
*/
|
|
24
|
+
export type Heading =
|
|
25
|
+
| typeof Title
|
|
26
|
+
| typeof HeadingLarge
|
|
27
|
+
| typeof HeadingMedium
|
|
28
|
+
| typeof HeadingSmall
|
|
29
|
+
| typeof HeadingXSmall;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Typography components for representing body text.
|
|
33
|
+
*/
|
|
34
|
+
export type BodyText =
|
|
35
|
+
| typeof Body
|
|
36
|
+
| typeof BodySerif
|
|
37
|
+
| typeof BodySerifBlock
|
|
38
|
+
| typeof BodyMonospace;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Typography components for labels.
|
|
42
|
+
*/
|
|
43
|
+
export type Label =
|
|
44
|
+
| typeof LabelLarge
|
|
45
|
+
| typeof LabelMedium
|
|
46
|
+
| typeof LabelSmall
|
|
47
|
+
| typeof LabelXSmall;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* All typography components.
|
|
51
|
+
*/
|
|
52
|
+
export type Typography =
|
|
53
|
+
| Heading
|
|
54
|
+
| BodyText
|
|
55
|
+
| Label
|
|
56
|
+
| typeof Tagline
|
|
57
|
+
| typeof Caption
|
|
58
|
+
| typeof Footnote;
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
Title,
|
|
62
|
+
HeadingLarge,
|
|
63
|
+
HeadingMedium,
|
|
64
|
+
HeadingSmall,
|
|
65
|
+
HeadingXSmall,
|
|
66
|
+
BodySerifBlock,
|
|
67
|
+
BodySerif,
|
|
68
|
+
BodyMonospace,
|
|
69
|
+
Body,
|
|
70
|
+
LabelLarge,
|
|
71
|
+
LabelMedium,
|
|
72
|
+
LabelSmall,
|
|
73
|
+
LabelXSmall,
|
|
74
|
+
Tagline,
|
|
75
|
+
Caption,
|
|
76
|
+
Footnote,
|
|
77
|
+
styles,
|
|
78
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import {StyleSheet} from "aphrodite";
|
|
3
|
+
import type {StyleDeclaration} from "aphrodite";
|
|
4
|
+
|
|
5
|
+
const Regular = 400;
|
|
6
|
+
const Bold = 700;
|
|
7
|
+
const Black = 900;
|
|
8
|
+
|
|
9
|
+
const mobile = "@media (max-width: 1023px)";
|
|
10
|
+
const desktop = "@media (min-width: 1024px)";
|
|
11
|
+
|
|
12
|
+
const common = {
|
|
13
|
+
display: "block",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const SansFamily = 'Lato, "Noto Sans", sans-serif';
|
|
17
|
+
// TODO(kevinb): Use Minion Pro here
|
|
18
|
+
const SerifFamily = '"Noto Serif", serif';
|
|
19
|
+
const InconsolataFamily = "Inconsolata, monospace";
|
|
20
|
+
|
|
21
|
+
const styles: StyleDeclaration = StyleSheet.create({
|
|
22
|
+
Title: {
|
|
23
|
+
...common,
|
|
24
|
+
fontFamily: SansFamily,
|
|
25
|
+
fontWeight: Black,
|
|
26
|
+
[desktop]: {
|
|
27
|
+
fontSize: 36,
|
|
28
|
+
lineHeight: "40px",
|
|
29
|
+
},
|
|
30
|
+
[mobile]: {
|
|
31
|
+
fontSize: 28,
|
|
32
|
+
lineHeight: "32px",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
Tagline: {
|
|
36
|
+
...common,
|
|
37
|
+
fontFamily: SansFamily,
|
|
38
|
+
fontWeight: Regular,
|
|
39
|
+
fontSize: 20,
|
|
40
|
+
lineHeight: "24px",
|
|
41
|
+
},
|
|
42
|
+
HeadingLarge: {
|
|
43
|
+
...common,
|
|
44
|
+
fontFamily: SansFamily,
|
|
45
|
+
fontWeight: Bold,
|
|
46
|
+
[desktop]: {
|
|
47
|
+
fontSize: 28,
|
|
48
|
+
lineHeight: "32px",
|
|
49
|
+
},
|
|
50
|
+
[mobile]: {
|
|
51
|
+
fontSize: 24,
|
|
52
|
+
lineHeight: "28px",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
HeadingMedium: {
|
|
56
|
+
...common,
|
|
57
|
+
fontFamily: SansFamily,
|
|
58
|
+
fontWeight: Bold,
|
|
59
|
+
[desktop]: {
|
|
60
|
+
fontSize: 24,
|
|
61
|
+
lineHeight: "28px",
|
|
62
|
+
},
|
|
63
|
+
[mobile]: {
|
|
64
|
+
fontSize: 22,
|
|
65
|
+
lineHeight: "26px",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
HeadingSmall: {
|
|
69
|
+
...common,
|
|
70
|
+
fontFamily: SansFamily,
|
|
71
|
+
fontWeight: Bold,
|
|
72
|
+
fontSize: 20,
|
|
73
|
+
lineHeight: "24px",
|
|
74
|
+
},
|
|
75
|
+
HeadingXSmall: {
|
|
76
|
+
...common,
|
|
77
|
+
fontFamily: SansFamily,
|
|
78
|
+
fontWeight: Bold,
|
|
79
|
+
fontSize: 12,
|
|
80
|
+
lineHeight: "16px",
|
|
81
|
+
letterSpacing: 0.6,
|
|
82
|
+
textTransform: "uppercase",
|
|
83
|
+
},
|
|
84
|
+
BodySerifBlock: {
|
|
85
|
+
...common,
|
|
86
|
+
fontFamily: SerifFamily,
|
|
87
|
+
fontWeight: Regular,
|
|
88
|
+
fontSize: 22,
|
|
89
|
+
lineHeight: "28px",
|
|
90
|
+
},
|
|
91
|
+
BodySerif: {
|
|
92
|
+
...common,
|
|
93
|
+
fontFamily: SerifFamily,
|
|
94
|
+
fontWeight: Regular,
|
|
95
|
+
fontSize: 18,
|
|
96
|
+
lineHeight: "22px",
|
|
97
|
+
},
|
|
98
|
+
BodyMonospace: {
|
|
99
|
+
...common,
|
|
100
|
+
fontFamily: InconsolataFamily,
|
|
101
|
+
fontWeight: Regular,
|
|
102
|
+
fontSize: 17,
|
|
103
|
+
lineHeight: "22px",
|
|
104
|
+
},
|
|
105
|
+
Body: {
|
|
106
|
+
...common,
|
|
107
|
+
fontFamily: SansFamily,
|
|
108
|
+
fontWeight: Regular,
|
|
109
|
+
fontSize: 16,
|
|
110
|
+
lineHeight: "22px",
|
|
111
|
+
},
|
|
112
|
+
LabelLarge: {
|
|
113
|
+
...common,
|
|
114
|
+
fontFamily: SansFamily,
|
|
115
|
+
fontWeight: Bold,
|
|
116
|
+
fontSize: 16,
|
|
117
|
+
lineHeight: "20px",
|
|
118
|
+
},
|
|
119
|
+
LabelMedium: {
|
|
120
|
+
...common,
|
|
121
|
+
fontFamily: SansFamily,
|
|
122
|
+
fontWeight: Regular,
|
|
123
|
+
fontSize: 16,
|
|
124
|
+
lineHeight: "20px",
|
|
125
|
+
},
|
|
126
|
+
LabelSmall: {
|
|
127
|
+
...common,
|
|
128
|
+
fontFamily: SansFamily,
|
|
129
|
+
fontWeight: Regular,
|
|
130
|
+
fontSize: 14,
|
|
131
|
+
lineHeight: "18px",
|
|
132
|
+
},
|
|
133
|
+
LabelXSmall: {
|
|
134
|
+
...common,
|
|
135
|
+
fontFamily: SansFamily,
|
|
136
|
+
fontWeight: Regular,
|
|
137
|
+
fontSize: 12,
|
|
138
|
+
lineHeight: "16px",
|
|
139
|
+
},
|
|
140
|
+
Caption: {
|
|
141
|
+
...common,
|
|
142
|
+
fontFamily: SansFamily,
|
|
143
|
+
fontWeight: Regular,
|
|
144
|
+
fontSize: 14,
|
|
145
|
+
lineHeight: "20px",
|
|
146
|
+
},
|
|
147
|
+
Footnote: {
|
|
148
|
+
...common,
|
|
149
|
+
fontFamily: SansFamily,
|
|
150
|
+
fontWeight: Regular,
|
|
151
|
+
fontSize: 12,
|
|
152
|
+
lineHeight: "18px",
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export {styles as default};
|