Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a73330f
commit c0dac7e
Showing
18 changed files
with
227 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import type { GriffelStaticStyles } from '@griffel/style-types'; | ||
import type { CSSRulesByBucket } from '../types'; | ||
|
||
import type { CSSBucketEntry } from '../types'; | ||
import { compileCSSRules } from './compileCSSRules'; | ||
import { compileStaticCSS } from './compileStaticCSS'; | ||
|
||
export function resolveStaticStyleRules(styles: GriffelStaticStyles, result: CSSRulesByBucket = {}): CSSRulesByBucket { | ||
if (typeof styles === 'string') { | ||
const cssRules = compileCSSRules(styles, false); | ||
export function resolveStaticStyleRules( | ||
stylesSet: GriffelStaticStyles[], | ||
result: CSSBucketEntry[] = [], | ||
): CSSBucketEntry[] { | ||
for (const styles of stylesSet) { | ||
if (typeof styles === 'string') { | ||
const cssRules = compileCSSRules(styles, false); | ||
|
||
for (const rule of cssRules) { | ||
addResolvedStyles(rule, result); | ||
} | ||
} else { | ||
// eslint-disable-next-line guard-for-in | ||
for (const property in styles) { | ||
const value = styles[property]; | ||
const staticCSS = compileStaticCSS(property, value); | ||
for (const rule of cssRules) { | ||
result.push(rule); | ||
} | ||
} else { | ||
// eslint-disable-next-line guard-for-in | ||
for (const property in styles) { | ||
const value = styles[property]; | ||
const staticCSS = compileStaticCSS(property, value); | ||
|
||
addResolvedStyles(staticCSS, result); | ||
result.push(staticCSS); | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
function addResolvedStyles(cssRule: string, result: CSSRulesByBucket = {}): void { | ||
// 👇 static rules should be inserted into default bucket | ||
result.d = result.d || []; | ||
result.d.push(cssRule); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.