MCPcopy Create free account
hub / github.com/context-dot-dev/designmd-supply / cssTextToObject

Function cssTextToObject

components/loading-canvas.tsx:678–691  ·  view source on GitHub ↗
(css?: string)

Source from the content-addressed store, hash-verified

676// Convert a Context.dev `css` block ("background-color: #x; padding: 8px;")
677// into a React style object so we can apply it without a raw <style> injection.
678function cssTextToObject(css?: string): React.CSSProperties {
679 if (!css) return {};
680 const out: Record<string, string> = {};
681 for (const decl of css.split(";")) {
682 const idx = decl.indexOf(":");
683 if (idx === -1) continue;
684 const prop = decl.slice(0, idx).trim();
685 const val = decl.slice(idx + 1).trim();
686 if (!prop || !val) continue;
687 const camel = prop.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());
688 out[camel] = val;
689 }
690 return out as React.CSSProperties;
691}

Callers 1

LoadingCanvasFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected