2019-01-09 13:10:30 -05:00
|
|
|
import _ from 'lodash'
|
2020-10-16 10:24:16 -04:00
|
|
|
import nameClass from '../util/nameClass'
|
2019-01-09 13:10:30 -05:00
|
|
|
|
2020-10-16 13:30:06 -04:00
|
|
|
export default function () {
|
|
|
|
|
return function ({ addUtilities, theme, variants }) {
|
2019-01-11 12:29:33 -05:00
|
|
|
const utilities = _.fromPairs(
|
2019-04-18 23:29:07 +02:00
|
|
|
_.map(theme('fontSize'), (value, modifier) => {
|
2020-06-29 10:10:27 +10:00
|
|
|
const [fontSize, options] = Array.isArray(value) ? value : [value]
|
2020-08-06 15:42:52 -04:00
|
|
|
const { lineHeight, letterSpacing } = _.isPlainObject(options)
|
|
|
|
|
? options
|
|
|
|
|
: {
|
|
|
|
|
lineHeight: options,
|
|
|
|
|
}
|
2020-04-05 14:07:30 -04:00
|
|
|
|
2019-01-11 12:29:33 -05:00
|
|
|
return [
|
2020-10-16 10:24:16 -04:00
|
|
|
nameClass('text', modifier),
|
2019-01-11 12:29:33 -05:00
|
|
|
{
|
2020-04-05 14:07:30 -04:00
|
|
|
'font-size': fontSize,
|
|
|
|
|
...(lineHeight === undefined
|
|
|
|
|
? {}
|
|
|
|
|
: {
|
|
|
|
|
'line-height': lineHeight,
|
|
|
|
|
}),
|
2020-06-29 10:10:27 +10:00
|
|
|
...(letterSpacing === undefined
|
|
|
|
|
? {}
|
|
|
|
|
: {
|
|
|
|
|
'letter-spacing': letterSpacing,
|
|
|
|
|
}),
|
2019-01-11 12:29:33 -05:00
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
)
|
2019-01-09 13:10:30 -05:00
|
|
|
|
2019-04-18 09:42:21 -04:00
|
|
|
addUtilities(utilities, variants('fontSize'))
|
2019-01-09 13:10:30 -05:00
|
|
|
}
|
|
|
|
|
}
|