Spaces:
Runtime error
Runtime error
fix: horizontal frame layout + typography text overlap
Browse files- Stack frames left-to-right instead of top-to-bottom
- Replace unreliable sample.height with manual height calculation
based on character count, font size and column width
- Fixes persistent text overlapping in typography section
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
output_json/figma-plugin-extracted/figma-design-token-creator 5/src/code.js
CHANGED
|
@@ -1090,20 +1090,25 @@ figma.ui.onmessage = async function(msg) {
|
|
| 1090 |
var tierName = tierParts.filter(function(p) { return p !== 'desktop' && p !== 'mobile'; }).join('.');
|
| 1091 |
addText(frame, tierName, boldFont, 13, COL_NAME, fy + 4, DARK);
|
| 1092 |
|
| 1093 |
-
// Sample text in actual font
|
| 1094 |
var useBold = (tierName.indexOf('display') > -1 || tierName.indexOf('heading') > -1);
|
|
|
|
| 1095 |
var sample = figma.createText();
|
| 1096 |
sample.fontName = useBold ? sampleFontBold : sampleFont;
|
| 1097 |
sample.fontSize = displaySize;
|
| 1098 |
-
// Set fixed width BEFORE setting characters so text wraps properly
|
| 1099 |
sample.textAutoResize = 'HEIGHT';
|
| 1100 |
sample.resize(540, displaySize * 2);
|
| 1101 |
-
sample.characters =
|
| 1102 |
sample.x = COL_SAMPLE; sample.y = fy;
|
| 1103 |
frame.appendChild(sample);
|
| 1104 |
|
| 1105 |
-
//
|
| 1106 |
-
var
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1107 |
|
| 1108 |
// Specs column β stacked chips
|
| 1109 |
var specY = fy;
|
|
@@ -1284,13 +1289,14 @@ figma.ui.onmessage = async function(msg) {
|
|
| 1284 |
}
|
| 1285 |
|
| 1286 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1287 |
-
// POSITION ALL FRAMES β stack
|
| 1288 |
// This runs AFTER all frames are created and resized to actual content.
|
| 1289 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1290 |
-
var
|
| 1291 |
for (var fi = 0; fi < allFrames.length; fi++) {
|
| 1292 |
-
allFrames[fi].
|
| 1293 |
-
|
|
|
|
| 1294 |
}
|
| 1295 |
|
| 1296 |
figma.ui.postMessage({ type: 'spec-complete', message: 'Visual spec created with ' + allFrames.length + ' section frames!' });
|
|
|
|
| 1090 |
var tierName = tierParts.filter(function(p) { return p !== 'desktop' && p !== 'mobile'; }).join('.');
|
| 1091 |
addText(frame, tierName, boldFont, 13, COL_NAME, fy + 4, DARK);
|
| 1092 |
|
| 1093 |
+
// Sample text in actual font
|
| 1094 |
var useBold = (tierName.indexOf('display') > -1 || tierName.indexOf('heading') > -1);
|
| 1095 |
+
var sampleText = getSampleText(tt.name);
|
| 1096 |
var sample = figma.createText();
|
| 1097 |
sample.fontName = useBold ? sampleFontBold : sampleFont;
|
| 1098 |
sample.fontSize = displaySize;
|
|
|
|
| 1099 |
sample.textAutoResize = 'HEIGHT';
|
| 1100 |
sample.resize(540, displaySize * 2);
|
| 1101 |
+
sample.characters = sampleText;
|
| 1102 |
sample.x = COL_SAMPLE; sample.y = fy;
|
| 1103 |
frame.appendChild(sample);
|
| 1104 |
|
| 1105 |
+
// Manual height calculation β sample.height is unreliable in plugin API
|
| 1106 |
+
var avgCharWidth = displaySize * 0.52;
|
| 1107 |
+
var sampleColW = 540;
|
| 1108 |
+
var charsPerLine = Math.max(1, Math.floor(sampleColW / avgCharWidth));
|
| 1109 |
+
var numLines = Math.ceil(sampleText.length / charsPerLine);
|
| 1110 |
+
var lineH = displaySize * 1.4;
|
| 1111 |
+
var sampleH = Math.max(numLines * lineH, displaySize * 1.5);
|
| 1112 |
|
| 1113 |
// Specs column β stacked chips
|
| 1114 |
var specY = fy;
|
|
|
|
| 1289 |
}
|
| 1290 |
|
| 1291 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1292 |
+
// POSITION ALL FRAMES β stack HORIZONTALLY with proper spacing
|
| 1293 |
// This runs AFTER all frames are created and resized to actual content.
|
| 1294 |
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1295 |
+
var stackX = 0;
|
| 1296 |
for (var fi = 0; fi < allFrames.length; fi++) {
|
| 1297 |
+
allFrames[fi].x = stackX;
|
| 1298 |
+
allFrames[fi].y = 0;
|
| 1299 |
+
stackX += allFrames[fi].width + SECTION_GAP;
|
| 1300 |
}
|
| 1301 |
|
| 1302 |
figma.ui.postMessage({ type: 'spec-complete', message: 'Visual spec created with ' + allFrames.length + ' section frames!' });
|