-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathfont-helper.js
41 lines (36 loc) · 1.43 KB
/
font-helper.js
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
import _ from 'lodash';
// use post script names for font families
const SFProDisplay = {
100: { fontFamily: 'SFProDisplay-Ultralight' },
'100italic': { fontFamily: 'SFProDisplay-UltralightItalic' },
200: { fontFamily: 'SFProDisplay-Thin' },
'200italic': { fontFamily: 'SFProDisplay-ThinItalic' },
300: { fontFamily: 'SFProDisplay-Light' },
'300italic': { fontFamily: 'SFProDisplay-LightItalic' },
400: { fontFamily: 'SFProDisplay-Regular' },
'400italic': { fontFamily: 'SFProDisplay-RegularItalic' },
500: { fontFamily: 'SFProDisplay-Medium' },
'500italic': { fontFamily: 'SFProDisplay-MediumItalic' },
600: { fontFamily: 'SFProDisplay-Semibold' },
'600italic': { fontFamily: 'SFProDisplay-SemiboldItalic' },
700: { fontFamily: 'SFProDisplay-Bold' },
'700italic': { fontFamily: 'SFProDisplay-BoldItalic' },
800: { fontFamily: 'SFProDisplay-Heavy' },
'800italic': { fontFamily: 'SFProDisplay-HeavyItalic' },
900: { fontFamily: 'SFProDisplay-Black' },
'900italic': { fontFamily: 'SFProDisplay-BlackItalic' },
};
const FONTS = {
SFProDisplay,
};
export function FontHelper(fontParams) {
let { fontFamily, fontWeight, fontStyle } = fontParams;
fontFamily = fontFamily || 'SFProDisplay';
fontWeight = fontWeight || '400';
fontStyle = fontStyle || '';
const styles = {
..._.omit(fontParams, ['fontFamily', 'fontWeight', 'fontStyle']),
...FONTS[fontFamily][fontWeight + fontStyle],
};
return styles;
}