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

Function getSvelteElementName

packages/backend/src/html/htmlMain.ts:212–232  ·  view source on GitHub ↗
(
  elementType: string,
  nodeName?: string,
)

Source from the content-addressed store, hash-verified

210
211// Get a Svelte-friendly component name
212export function getSvelteElementName(
213 elementType: string,
214 nodeName?: string,
215): string {
216 // For Svelte, use semantic element names where possible
217 if (elementType === "TEXT" || elementType === "p") {
218 return "p";
219 } else if (elementType === "img" || elementType === "IMAGE") {
220 return "img";
221 } else if (
222 nodeName &&
223 (nodeName.toLowerCase().includes("button") ||
224 nodeName.toLowerCase().includes("btn"))
225 ) {
226 return "button";
227 } else if (nodeName && nodeName.toLowerCase().includes("link")) {
228 return "a";
229 } else {
230 return "div"; // Default element
231 }
232}
233
234// Generate semantic class names for Svelte
235export function getSvelteClassName(prefix?: string, nodeType?: string): string {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected