MCPcopy
hub / github.com/kuma-ui/kuma-ui / parseCSS

Method parseCSS

packages/sheet/src/sheet.ts:235–255  ·  view source on GitHub ↗

* parseCSS takes in raw CSS and parses it to valid CSS using Stylis. * It's useful for handling complex CSS such as media queries and pseudo selectors.

(style: string)

Source from the content-addressed store, hash-verified

233 * It's useful for handling complex CSS such as media queries and pseudo selectors.
234 */
235 parseCSS(style: string): string {
236 style = this._processCSS(style);
237
238 const globalOperators = new Set(extractOperators(":global", style));
239 const id = Sheet.getClassNamePrefix() + generateHash(style);
240 const breakpoints = theme.getUserTheme().breakpoints ?? {};
241 const elements: Element[] = [];
242
243 compile(`.${id}{${style}}`).forEach((element) => {
244 this.normalizeMediaQueries(element, breakpoints);
245
246 if (this.normalizeGlobalOperatorSelectors(element, id, globalOperators)) {
247 elements.push(element);
248 }
249 });
250
251 const css = serialize(elements, stringify);
252
253 this.css.push(css);
254 return id;
255 }
256
257 removeDuplicates() {
258 this.base = [...new Set(this.base)];

Callers 3

extractClassNameFunction · 0.80
sheet.test.tsFile · 0.80
TaggedTemplateExpressionFunction · 0.80

Calls 8

_processCSSMethod · 0.95
normalizeMediaQueriesMethod · 0.95
generateHashFunction · 0.90
extractOperatorsFunction · 0.85
compileFunction · 0.85
getUserThemeMethod · 0.80
getClassNamePrefixMethod · 0.45

Tested by

no test coverage detected