From 55c1f2601db686192097bb63199fffb29d452735 Mon Sep 17 00:00:00 2001 From: Federico Biccheddu <433819+FedericoBiccheddu@users.noreply.github.com> Date: Wed, 3 Nov 2021 20:12:58 +0100 Subject: [PATCH 1/2] feat: add styles in bucket based on the strategy --- src/index.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index e434ad3..51697dc 100644 --- a/src/index.js +++ b/src/index.js @@ -252,17 +252,20 @@ const forms = plugin.withOptions(function (options = { strategy: 'base' }) { }, ] - addBase( - rules - .map((rule) => { - if (rule[strategy] === null) { - return null - } + const strategyRules = rules + .map((rule) => { + if (rule[strategy] === null) { + return null + } - return { [rule[strategy]]: rule.styles } - }) - .filter(Boolean) - ) + return { [rule[strategy]]: rule.styles } + }) + .filter(Boolean) + + ;({ + 'base': addBase, + 'class': addComponents + })[strategy](strategyRules) } }) From 246148fbaaa35ae9d8c0eae391dba9b32d192fb7 Mon Sep 17 00:00:00 2001 From: Federico Biccheddu <433819+FedericoBiccheddu@users.noreply.github.com> Date: Wed, 3 Nov 2021 20:21:35 +0100 Subject: [PATCH 2/2] fix: import `addComponents` callback --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 51697dc..02f5394 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,7 @@ const [baseFontSize, { lineHeight: baseLineHeight }] = defaultTheme.fontSize.bas const { spacing, borderWidth, borderRadius } = defaultTheme const forms = plugin.withOptions(function (options = { strategy: 'base' }) { - return function ({ addBase, theme }) { + return function ({ addBase, addComponents, theme }) { const strategy = options.strategy const rules = [