From 07e330d2bb29ded1902cd0b1217fe7c2b8d18cd9 Mon Sep 17 00:00:00 2001 From: Dan Wood Date: Mon, 29 Jun 2020 10:10:27 +1000 Subject: [PATCH] Allow default letterSpacing in fontSize config Extend the configuration syntax to allow specifying letterSpacing alongside lineHeight in the fontSize config. The syntax looks like ``` module.exports = { theme: { // ... fontSize: { sm: ['14px', { lineHeight: '20px', letterSpacing: '0.01em' }], // ... } } } ``` Also retains backwards compatibility with array syntax of 1.3 --- src/plugins/fontSize.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/fontSize.js b/src/plugins/fontSize.js index ea06168a6..28ebf07ac 100644 --- a/src/plugins/fontSize.js +++ b/src/plugins/fontSize.js @@ -4,7 +4,11 @@ export default function() { return function({ addUtilities, e, theme, variants }) { const utilities = _.fromPairs( _.map(theme('fontSize'), (value, modifier) => { - const [fontSize, lineHeight] = Array.isArray(value) ? value : [value] + const [fontSize, options] = Array.isArray(value) ? value : [value] + // Tailwind 1.3+ syntax allowed line height to be specified in the array like + // ['16px', '24px'], so we can get it from there as well as from object syntax + const lineHeight = options instanceof Object ? options.lineHeight : options + const letterSpacing = options && options.letterSpacing return [ `.${e(`text-${modifier}`)}`, @@ -15,6 +19,11 @@ export default function() { : { 'line-height': lineHeight, }), + ...(letterSpacing === undefined + ? {} + : { + 'letter-spacing': letterSpacing, + }), }, ] })