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

Function tailwindText

packages/backend/src/tailwind/tailwindMain.ts:127–170  ·  view source on GitHub ↗
(
  node: TextNode,
  settings: TailwindSettings,
)

Source from the content-addressed store, hash-verified

125};
126
127export const tailwindText = (
128 node: TextNode,
129 settings: TailwindSettings,
130): string => {
131 const layoutBuilder = new TailwindTextBuilder(node, settings)
132 .commonPositionStyles()
133 .textAlignHorizontal()
134 .textAlignVertical();
135
136 const styledHtml = layoutBuilder.getTextSegments(node);
137 previousExecutionCache.push(...styledHtml);
138
139 let content = "";
140 if (styledHtml.length === 1) {
141 const segment = styledHtml[0];
142 layoutBuilder.addAttributes(segment.style);
143
144 const getFeatureTag = (features: Record<string, boolean>): string => {
145 if (features.SUBS === true) return "sub";
146 if (features.SUPS === true) return "sup";
147 return "";
148 };
149
150 const additionalTag = getFeatureTag(segment.openTypeFeatures);
151 content = additionalTag
152 ? `<${additionalTag}>${segment.text}</${additionalTag}>`
153 : segment.text;
154 } else {
155 content = styledHtml
156 .map((style) => {
157 const tag =
158 style.openTypeFeatures.SUBS === true
159 ? "sub"
160 : style.openTypeFeatures.SUPS === true
161 ? "sup"
162 : "span";
163
164 return `<${tag} class="${style.style}">${style.text}</${tag}>`;
165 })
166 .join("");
167 }
168
169 return `\n<div${layoutBuilder.build()}>${content}</div>`;
170};
171
172const tailwindFrame = async (
173 node: FrameNode | InstanceNode | ComponentNode | ComponentSetNode,

Callers 1

convertNodeFunction · 0.85

Calls 6

getFeatureTagFunction · 0.85
textAlignVerticalMethod · 0.45
textAlignHorizontalMethod · 0.45
commonPositionStylesMethod · 0.45
getTextSegmentsMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected