MCPcopy Create free account
hub / github.com/adobe/react-spectrum / toCSS

Method toCSS

packages/@react-spectrum/s2/style/style-macro.ts:913–935  ·  view source on GitHub ↗
(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer = 'a')

Source from the content-addressed store, hash-verified

911 }
912
913 toCSS(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer = 'a') {
914 let prelude = `.${this.className}${this.pseudos}`;
915 preludes.push(prelude);
916
917 // Nest rule in our stack of preludes (e.g. media queries/selectors).
918 let content = ' ';
919 preludes.forEach((p, i) => {
920 content += `${p} {\n${' '.repeat((i + 2) * 2)}`;
921 });
922 content += `${kebab(this.property)}: ${this.value};\n`;
923 preludes.map((_, i) => {
924 content += `${' '.repeat((preludes.length - i) * 2)}}\n`;
925 });
926
927 // Group rule into the appropriate layer.
928 let rules = rulesByLayer.get(layer);
929 if (!rules) {
930 rules = [];
931 rulesByLayer.set(layer, rules);
932 }
933 rules.push(content);
934 preludes.pop();
935 }
936
937 toJS(allowedOverridesSet: Set<string>, indent = ''): string {
938 let res = '';

Callers

nothing calls this directly

Calls 3

pushMethod · 0.80
kebabFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected