Skip to content

AI-native design editor. Open-source Figma alternative.

Add progress bar pattern, divider placement rules, w+grow conflict check

Anton A Sce5433da86bd
diff --git a/packages/core/src/tools/describe.ts b/packages/core/src/tools/describe.ts
index 6847c46e2..e127a2c36 100644
--- a/packages/core/src/tools/describe.ts
+++ b/packages/core/src/tools/describe.ts
@@ -226,6 +226,26 @@ function detectLayoutIssues(node: SceneNode, graph: SceneGraph, issues: Describe
.map((id) => graph.getNode(id))
.filter((c): c is SceneNode => c != null && c.visible && c.layoutPositioning !== 'ABSOLUTE')
+ // Vertical divider (thin tall rectangle) outside a flex="row" parent
+ if (isAutoLayout) {
+ for (const child of children) {
+ const isVerticalDivider = child.width <= 2 && child.height > 10 && child.type === 'RECTANGLE'
+ const isHorizontalDivider = child.height <= 2 && child.width > 10 && child.type === 'RECTANGLE'
+ if (isVerticalDivider && !isRow) {
+ issues.push({
+ message: `Vertical divider "${child.name}" (${child.width}×${child.height}) is inside a column layout — should be inside flex="row"`,
+ suggestion: 'Move the divider inside the row container it separates, or change to a horizontal divider'
+ })
+ }
+ if (isHorizontalDivider && isRow) {
+ issues.push({
+ message: `Horizontal divider "${child.name}" (${child.width}×${child.height}) is inside a row layout — should be inside flex="col"`,
+ suggestion: 'Move the divider inside the column container it separates'
+ })
+ }
+ }
+ }
+
if (isAutoLayout) {
const primarySizing = node.primaryAxisSizing
const primaryDim = isRow ? node.width : node.height
@@ -247,6 +267,36 @@ function detectLayoutIssues(node: SceneNode, graph: SceneGraph, issues: Describe
}
}
+ // w and grow conflict — grow overrides width
+ for (const child of children) {
+ if (child.layoutGrow > 0 && child.layoutMode === 'NONE') {
+ const fixedDim = isRow ? child.width : child.height
+ if (fixedDim > 0 && fixedDim !== 100) {
+ issues.push({
+ message: `"${child.name}" has both fixed ${isRow ? 'width' : 'height'}=${fixedDim} and grow=${child.layoutGrow} — grow overrides the size`,
+ suggestion: 'Remove the fixed size or remove grow'
+ })
+ }
+ }
+ }
+
+ // Child Rectangle/fill overflows its parent (e.g. bar fill wider than bar bg)
+ for (const child of children) {
+ if (child.layoutPositioning === 'ABSOLUTE') continue
+ for (const grandchildId of child.childIds) {
+ const gc = graph.getNode(grandchildId)
+ if (!gc || !gc.visible) continue
+ const gcDim = isRow ? gc.width : gc.height
+ const parentDim = isRow ? child.width : child.height
+ if (gcDim > parentDim + 1 && !child.clipsContent && parentDim > 0) {
+ issues.push({
+ message: `"${gc.name}" (${Math.round(gcDim)}px) overflows parent "${child.name}" (${Math.round(parentDim)}px)`,
+ suggestion: `Reduce size or add overflow="hidden" on "${child.name}"`
+ })
+ }
+ }
+ }
+
// Children overflow parent on primary axis (compare actual computed sizes)
if (primarySizing === 'FIXED' && !node.clipsContent) {
let totalChildren = 0
diff --git a/src/ai/system-prompt.md b/src/ai/system-prompt.md
index a2f9a8339..f94730f29 100644
--- a/src/ai/system-prompt.md
+++ b/src/ai/system-prompt.md
@@ -133,6 +133,35 @@ Left-align body text (default for Latin/Cyrillic). Center only for hero headings
No style={{}}, className, CSS. No named colors or rgb(). No percentage values. No TypeScript casts (as any, as const) — JSX is parsed by sucrase. No template literals in prop values. No Math.random(). No w/h on Text (unless fixed-width wrapping needed).
+## Common patterns
+
+**Progress bar / rating bar:**
+```
+<Frame name="Bar" flex="row" w="fill" gap={10} items="center">
+ <Text w={80} size={13} color="#6B7280">Label</Text>
+ <Frame grow={1} h={6} bg="#F3F4F6" rounded={3} overflow="hidden">
+ <Rectangle w={percent * maxWidth} h={6} bg="#F5C518" rounded={3} />
+ </Frame>
+ <Text w={36} size={13} weight="bold" textAlign="right" color="#111827">8.8</Text>
+</Frame>
+```
+Key rules: bar background uses `grow={1}` (no fixed `w`), `overflow="hidden"` to clip the fill. Fill width is a fraction of the bar — calculate from the score. Label is plain Text with `w`, not a Frame wrapper. Never set `h` on label containers to match the row — let items="center" handle vertical alignment.
+
+**Don't mix `w={N}` and `grow={N}`** on the same node — grow overrides width. Use one or the other.
+
+**Don't wrap Text in Frame just for sizing.** If you need `w={80}` on a label, set it directly: `<Text w={80}>`. Only wrap in Frame when you need padding, background, or nested layout.
+
+**Dividers between columns (vertical dividers):**
+A vertical divider (`w={1} h={N}`) must be a sibling inside the same `flex="row"` container as the columns it separates. Use `h="fill"` instead of fixed height so it matches the row height. Example:
+```
+<Frame flex="row" items="center">
+ <Frame grow={1}>…</Frame>
+ <Rectangle w={1} h="fill" bg="#E5E7EB" />
+ <Frame grow={1}>…</Frame>
+</Frame>
+```
+Never place vertical dividers outside their row container. Horizontal dividers (`h={1} w="fill"`) go between sections in a `flex="col"` parent.
+
## Icons and shapes
All visual elements (Rectangle, Ellipse, Star, Polygon, Line) have **no fill by default** — they render as invisible without `bg="#hex"` or `stroke="#hex"`.