|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | import transformThemeValue from './transformThemeValue'
|
|---|
| 2 |
|
|---|
| 3 | export default function createUtilityPlugin(
|
|---|
| 4 | themeKey,
|
|---|
| 5 | utilityVariations = [[themeKey, [themeKey]]],
|
|---|
| 6 | { filterDefault = false, ...options } = {}
|
|---|
| 7 | ) {
|
|---|
| 8 | let transformValue = transformThemeValue(themeKey)
|
|---|
| 9 | return function ({ matchUtilities, theme }) {
|
|---|
| 10 | for (let utilityVariation of utilityVariations) {
|
|---|
| 11 | let group = Array.isArray(utilityVariation[0]) ? utilityVariation : [utilityVariation]
|
|---|
| 12 |
|
|---|
| 13 | matchUtilities(
|
|---|
| 14 | group.reduce((obj, [classPrefix, properties]) => {
|
|---|
| 15 | return Object.assign(obj, {
|
|---|
| 16 | [classPrefix]: (value) => {
|
|---|
| 17 | return properties.reduce((obj, name) => {
|
|---|
| 18 | if (Array.isArray(name)) {
|
|---|
| 19 | return Object.assign(obj, { [name[0]]: name[1] })
|
|---|
| 20 | }
|
|---|
| 21 | return Object.assign(obj, { [name]: transformValue(value) })
|
|---|
| 22 | }, {})
|
|---|
| 23 | },
|
|---|
| 24 | })
|
|---|
| 25 | }, {}),
|
|---|
| 26 | {
|
|---|
| 27 | ...options,
|
|---|
| 28 | values: filterDefault
|
|---|
| 29 | ? Object.fromEntries(
|
|---|
| 30 | Object.entries(theme(themeKey) ?? {}).filter(([modifier]) => modifier !== 'DEFAULT')
|
|---|
| 31 | )
|
|---|
| 32 | : theme(themeKey),
|
|---|
| 33 | }
|
|---|
| 34 | )
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.