Skip to content

Commit

Permalink
fix: expand on shadowDom support
Browse files Browse the repository at this point in the history
  • Loading branch information
darlanalves authored Aug 29, 2024
1 parent 7e2c767 commit 6679ba8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/presets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const CWD = process.cwd();
const getPresetPath = (name) => join(CWD, "systems", name + ".yml");
const each = (v) => (!v ? [] : Object.entries(v));

function expandRules(items) {
return items.map(item => item[0] + `{\n @apply ${item[1]} ;\n}\n`)
}

function generateComponentParts(name, def, separator) {
return each(def).map(([part, c]) => [`.${name}${separator}${part}`, c]);
}
Expand All @@ -27,7 +31,7 @@ function generateShadowComponentStates(name, def) {

function generateShadowComponentVariants(name, variants) {
return each(variants).map(([variant, c]) => [
`.${name}.${name}-${variant}::part(component)`,
`${name}.${name}-${variant}::part(component)`,
c,
]);
}
Expand All @@ -53,7 +57,8 @@ function defineComponent(name, def, useShadowDom) {
];

return all
.flatMap((item) => item[0] + `{\n @apply ${item[1]} ;\n}\n`)
.map(expandRules)
.flat(2)
.join("");
}

Expand Down

0 comments on commit 6679ba8

Please sign in to comment.