MCPcopy Index your code
hub / github.com/bernaferrari/FigmaToCode / convertNode

Function convertNode

packages/backend/src/tailwind/tailwindMain.ts:48–89  ·  view source on GitHub ↗
(settings: TailwindSettings)

Source from the content-addressed store, hash-verified

46
47const convertNode =
48 (settings: TailwindSettings) =>
49 async (node: SceneNode): Promise<string> => {
50 if (settings.embedVectors && (node as any).canBeFlattened) {
51 const altNode = await renderAndAttachSVG(node);
52 if (altNode.svg) {
53 return tailwindWrapSVG(altNode, settings);
54 }
55 }
56
57 switch ((node as any).type) {
58 case "RECTANGLE":
59 case "ELLIPSE":
60 return tailwindContainer(node, "", "", settings);
61 case "GROUP":
62 return tailwindGroup(node, settings);
63 case "FRAME":
64 case "COMPONENT":
65 case "INSTANCE":
66 case "COMPONENT_SET":
67 case "SLOT":
68 return tailwindFrame(node, settings);
69 case "TEXT":
70 return tailwindText(node, settings);
71 case "LINE":
72 return tailwindLine(node, settings);
73 case "SECTION":
74 return tailwindSection(node, settings);
75 case "VECTOR":
76 if (!settings.embedVectors) {
77 addWarning("Vector is not supported");
78 }
79 return tailwindContainer(
80 { ...node, type: "RECTANGLE" } as any,
81 "",
82 "",
83 settings,
84 );
85 default:
86 addWarning(`${node.type} node is not supported`);
87 }
88 return "";
89 };
90
91const tailwindWrapSVG = (
92 node: AltNode<SceneNode>,

Callers 1

tailwindWidgetGeneratorFunction · 0.70

Calls 9

renderAndAttachSVGFunction · 0.90
addWarningFunction · 0.90
tailwindWrapSVGFunction · 0.85
tailwindContainerFunction · 0.85
tailwindGroupFunction · 0.85
tailwindFrameFunction · 0.85
tailwindTextFunction · 0.85
tailwindLineFunction · 0.85
tailwindSectionFunction · 0.85

Tested by

no test coverage detected