MCPcopy Create free account
hub / github.com/bernaferrari/FigmaToCode / getSvelteClassName

Function getSvelteClassName

packages/backend/src/html/htmlMain.ts:235–246  ·  view source on GitHub ↗
(prefix?: string, nodeType?: string)

Source from the content-addressed store, hash-verified

233
234// Generate semantic class names for Svelte
235export function getSvelteClassName(prefix?: string, nodeType?: string): string {
236 if (!prefix) {
237 return nodeType?.toLowerCase() || "element";
238 }
239
240 // Clean and format the prefix
241 return prefix
242 .replace(/[^a-zA-Z0-9_-]/g, "-")
243 .replace(/-{2,}/g, "-") // Replace multiple hyphens with a single one
244 .replace(/^-+|-+$/g, "") // Remove leading/trailing hyphens
245 .toLowerCase();
246}
247
248// Generate component code based on the specified mode
249function generateComponentCode(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected