Skip to content

Commit

Permalink
[feat](@svelteui/core): support refs and other keywords for variant p…
Browse files Browse the repository at this point in the history
…art of the style
  • Loading branch information
BeeMargarida committed Jun 27, 2023
1 parent d7ebc5e commit d6590c7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/svelteui-core/src/styles/engine/create-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,21 @@ function sanitizeCss(object: DirtyObject, theme: SvelteUITheme) {
const refs: string[] = [];
const classMap = {};

const _sanitizeVariants = (obj: Record<string, any>) => {
const variants = Object.keys(obj.variation);
for (const variant of variants) {
_sanitize(obj.variation[variant]);
}
};

const _sanitize = (obj: Record<string, any>) => {
Object.keys(obj).map((value) => {
// transforms certain keywords into the correct CSS selectors

// TODO: also make this transformation for variants
if (value === 'variants') return;
if (value === 'variants') {
_sanitizeVariants(obj[value]);
return;
}

// saves the reference value so that later it can be added
// to reference the CSS selector
Expand Down

0 comments on commit d6590c7

Please sign in to comment.