Skip to content

Commit 807cd40

Browse files
authored
Use addComponents for class strategy (#91)
* feat: add styles in bucket based on the strategy * fix: import `addComponents` callback
1 parent bb5315c commit 807cd40

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/index.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const [baseFontSize, { lineHeight: baseLineHeight }] = defaultTheme.fontSize.bas
66
const { spacing, borderWidth, borderRadius } = defaultTheme
77

88
const forms = plugin.withOptions(function (options = { strategy: 'base' }) {
9-
return function ({ addBase, theme }) {
9+
return function ({ addBase, addComponents, theme }) {
1010
const strategy = options.strategy
1111

1212
const rules = [
@@ -252,17 +252,20 @@ const forms = plugin.withOptions(function (options = { strategy: 'base' }) {
252252
},
253253
]
254254

255-
addBase(
256-
rules
257-
.map((rule) => {
258-
if (rule[strategy] === null) {
259-
return null
260-
}
255+
const strategyRules = rules
256+
.map((rule) => {
257+
if (rule[strategy] === null) {
258+
return null
259+
}
261260

262-
return { [rule[strategy]]: rule.styles }
263-
})
264-
.filter(Boolean)
265-
)
261+
return { [rule[strategy]]: rule.styles }
262+
})
263+
.filter(Boolean)
264+
265+
;({
266+
'base': addBase,
267+
'class': addComponents
268+
})[strategy](strategyRules)
266269
}
267270
})
268271

0 commit comments

Comments
 (0)