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

Function emitProperties

packages/@react-spectrum/ai/src/style/prose.ts:221–242  ·  view source on GitHub ↗
(properties: Record<string, any>, indent: string)

Source from the content-addressed store, hash-verified

219 // Emit the declarations (and any conditional sub-rules) for a single element,
220 // indented by `indent`. Nested `&`-conditions are relative to the enclosing rule.
221 let emitProperties = (properties: Record<string, any>, indent: string) => {
222 let css = '';
223 for (let property in properties) {
224 let value = properties[property];
225 let prop = property.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`);
226 if (typeof value === 'object') {
227 if (value.default) {
228 css += `${indent}${prop}: ${value.default};\n`;
229 }
230 for (let condition in value) {
231 // eslint-disable-next-line max-depth
232 if (condition === 'default') {
233 continue;
234 }
235 css += `${indent}${condition.startsWith(':') ? '&' : ''}${condition} { ${prop}: ${value[condition]}; }\n`;
236 }
237 } else {
238 css += `${indent}${prop}: ${value};\n`;
239 }
240 }
241 return css;
242 };
243
244 let css = '.prose {\n';
245 for (let key in rules) {

Callers 1

proseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected