tailwindcss/src/plugins/fontSize.js

28 lines
780 B
JavaScript
Raw Normal View History

import isPlainObject from '../util/isPlainObject'
2020-10-16 13:30:06 -04:00
export default function () {
return function ({ matchUtilities, theme, variants }) {
matchUtilities(
{
text: (value) => {
let [fontSize, options] = Array.isArray(value) ? value : [value]
let { lineHeight, letterSpacing } = isPlainObject(options)
? options
: { lineHeight: options }
return {
'font-size': fontSize,
...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
}
},
},
{
values: theme('fontSize'),
variants: variants('fontSize'),
type: 'length',
}
)
}
}