tailwindcss/src/plugins/fontSize.js

37 lines
963 B
JavaScript
Raw Normal View History

import _ from 'lodash'
import nameClass from '../util/nameClass'
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(
_.map(theme('fontSize'), (value, modifier) => {
const [fontSize, options] = Array.isArray(value) ? value : [value]
const { lineHeight, letterSpacing } = _.isPlainObject(options)
? options
: {
lineHeight: options,
}
2019-01-11 12:29:33 -05:00
return [
nameClass('text', modifier),
2019-01-11 12:29:33 -05:00
{
'font-size': fontSize,
...(lineHeight === undefined
? {}
: {
'line-height': lineHeight,
}),
...(letterSpacing === undefined
? {}
: {
'letter-spacing': letterSpacing,
}),
2019-01-11 12:29:33 -05:00
},
]
})
)
addUtilities(utilities, variants('fontSize'))
}
}