-
Notifications
You must be signed in to change notification settings - Fork 4k
/
fontSize.js
36 lines (33 loc) · 961 Bytes
/
fontSize.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
import _ from 'lodash'
import nameClass from '../util/nameClass'
export default function() {
return function({ addUtilities, theme, variants }) {
const utilities = _.fromPairs(
_.map(theme('fontSize'), (value, modifier) => {
const [fontSize, options] = Array.isArray(value) ? value : [value]
const { lineHeight, letterSpacing } = _.isPlainObject(options)
? options
: {
lineHeight: options,
}
return [
nameClass('text', modifier),
{
'font-size': fontSize,
...(lineHeight === undefined
? {}
: {
'line-height': lineHeight,
}),
...(letterSpacing === undefined
? {}
: {
'letter-spacing': letterSpacing,
}),
},
]
})
)
addUtilities(utilities, variants('fontSize'))
}
}