mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
const { asLength, nameClass } = require('../pluginUtils')
|
|
const { isPlainObject } = require('../lib/utils')
|
|
|
|
module.exports = function ({ matchUtilities }) {
|
|
matchUtilities({
|
|
text: (modifier, { theme }) => {
|
|
let value = theme.fontSize[modifier]
|
|
|
|
if (value === undefined) {
|
|
value = asLength(modifier, {})
|
|
|
|
return value === undefined
|
|
? []
|
|
: {
|
|
[nameClass('text', modifier)]: {
|
|
'font-size': value,
|
|
},
|
|
}
|
|
}
|
|
|
|
let [fontSize, options] = Array.isArray(value) ? value : [value]
|
|
let { lineHeight, letterSpacing } = isPlainObject(options)
|
|
? options
|
|
: {
|
|
lineHeight: options,
|
|
}
|
|
|
|
return {
|
|
[nameClass('text', modifier)]: {
|
|
'font-size': fontSize,
|
|
...(lineHeight === undefined
|
|
? {}
|
|
: {
|
|
'line-height': lineHeight,
|
|
}),
|
|
...(letterSpacing === undefined
|
|
? {}
|
|
: {
|
|
'letter-spacing': letterSpacing,
|
|
}),
|
|
},
|
|
}
|
|
},
|
|
})
|
|
}
|