@toghen/figma 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/figcraftApply.ts +9 -0
- package/component-files.md +1 -1
- package/dist/code.js +173 -159
- package/dist/ui.html +12 -12
- package/package.json +1 -1
- package/shared/components/validate.ts +17 -0
package/cli/figcraftApply.ts
CHANGED
|
@@ -351,6 +351,15 @@ function fieldCommands(batch: Batch, build: Build, ref: Ref, layer: Layer, root:
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
for (const name of ['width', 'height']) if (has(name) && value(name).kind !== 'token') writeDimension(name);
|
|
354
|
+
// An instance carries its main's bound size, and FigCraft keeps a bound size fixed whatever sizing is set beside it, so
|
|
355
|
+
// an instance that hugs or fills lets that binding go first; the main keeps it (measured 25 October 2026, 0.10.0).
|
|
356
|
+
for (const [name, size] of [
|
|
357
|
+
['layoutSizingHorizontal', 'width'],
|
|
358
|
+
['layoutSizingVertical', 'height'],
|
|
359
|
+
] as const) {
|
|
360
|
+
if (layer.kind === 'INSTANCE' && has(name) && !(size in f) && ['FILL', 'HUG'].includes(plainOf(value(name)) as string))
|
|
361
|
+
bind(size, null);
|
|
362
|
+
}
|
|
354
363
|
for (const name of ['layoutSizingHorizontal', 'layoutSizingVertical']) if (has(name)) writePlain(name);
|
|
355
364
|
for (const name of ['minWidth', 'maxWidth', 'minHeight', 'maxHeight']) if (has(name)) writeDimension(name);
|
|
356
365
|
for (const name of ['width', 'height']) if (has(name) && value(name).kind === 'token') writeDimension(name);
|
package/component-files.md
CHANGED
|
@@ -459,7 +459,7 @@ The checks run in stages that share one report, and a stage that cannot run says
|
|
|
459
459
|
1. **Reading.** kdlet reads the file, and Toghen reads its five words. A reserved word with the wrong shape, a guard out of scope, a property written twice on a node, a `when` outside a layer, a `define` that is not at the top: kdlet's. The rules under [Top-level nodes](#top-level-nodes), [Properties](#properties) and [Exclusions](#exclusions-and-inclusions): Toghen's.
|
|
460
460
|
2. **Axes from the tokens**, when the file names a token group: its parts, laid out as the file asks, against the design system.
|
|
461
461
|
3. **The document against the axes.** Every guard reads only variant axes and lists only values they have; every `exclude` and `include` names an axis with one of its values; the default member is built; the binding plan of each group the file names is worked out.
|
|
462
|
-
4. **Each member**, after kdlet evaluates it. A problem kdlet finds (a missing value, an unknown tag, an unknown parameter) stops that member's checks. Then the tree: an unknown field for the layer's kind, a value of the wrong kind, an unknown enum value, a bare number or colour where a `(literal)` is wanted, a structured field written as a property; a duplicate address; `GRID` layout needs `gridRowSizes` and `gridColumnSizes`, forbids `primaryAxisAlignItems`, `counterAxisAlignItems` and `itemSpacing`, and every child has `grid`; a `FLEX` track on an axis the grid hugs; any other layout forbids the four grid fields and a child's `grid`; a `SLOT` is never `GRID`; `layoutWrap`, `counterAxisAlignContent` and `counterAxisSpacing` need a `HORIZONTAL` or `VERTICAL` layer, a cell alignment a `GRID` parent, `layoutPositioning` a parent with a layout, and `x` or `y` a layer that is not the root and is not placed by its parent's layout; an `INSTANCE` names its `component`; the root is one `FRAME`, does not fill a parent it does not have and carries no `grid`; wiring, where `(property)` on `visible` names a `BOOLEAN`, on `characters` a `TEXT`, on `component` an `INSTANCE_SWAP`, never on the root; a `SLOT` layer and a `SLOT` property match one to one; no field a text style also sets stands beside `textStyle`, and a literal `maxLines` is a whole number of at least 1; `#null` on a `width` or `height`; a `width` or `height` bound to a token, written or from `tokens=`, beside `HUG` or `FILL` on its axis, or beside a text's `textAutoResize` that sizes that axis (`HEIGHT` or `WIDTH_AND_HEIGHT` for a height, `WIDTH_AND_HEIGHT` for a width), since a bound size is a fixed size and the target would settle on one of the two: `FRAME "Chip": "height" is bound to {chip.height} while layoutSizingVertical=HUG: a bound height is a fixed size; write layoutSizingVertical=HUG and drop the height token, or keep the token and drop HUG`.
|
|
462
|
+
4. **Each member**, after kdlet evaluates it. A problem kdlet finds (a missing value, an unknown tag, an unknown parameter) stops that member's checks. Then the tree: an unknown field for the layer's kind, a value of the wrong kind, an unknown enum value, a bare number or colour where a `(literal)` is wanted, a structured field written as a property; a duplicate address; `GRID` layout needs `gridRowSizes` and `gridColumnSizes`, forbids `primaryAxisAlignItems`, `counterAxisAlignItems` and `itemSpacing`, and every child has `grid`; a `FLEX` track on an axis the grid hugs; any other layout forbids the four grid fields and a child's `grid`; a `SLOT` is never `GRID`; `layoutWrap`, `counterAxisAlignContent` and `counterAxisSpacing` need a `HORIZONTAL` or `VERTICAL` layer, a cell alignment a `GRID` parent, `layoutPositioning` a parent with a layout, and `x` or `y` a layer that is not the root and is not placed by its parent's layout; an `INSTANCE` names its `component`; the root is one `FRAME`, does not fill a parent it does not have and carries no `grid`; wiring, where `(property)` on `visible` names a `BOOLEAN`, on `characters` a `TEXT`, on `component` an `INSTANCE_SWAP`, never on the root; a `SLOT` layer and a `SLOT` property match one to one; no field a text style also sets stands beside `textStyle`, and a literal `maxLines` is a whole number of at least 1; `#null` on a `width` or `height`; a `width` or `height` bound to a token, written or from `tokens=`, beside `HUG` or `FILL` on its axis, or beside a text's `textAutoResize` that sizes that axis (`HEIGHT` or `WIDTH_AND_HEIGHT` for a height, `WIDTH_AND_HEIGHT` for a width), since a bound size is a fixed size and the target would settle on one of the two: `FRAME "Chip": "height" is bound to {chip.height} while layoutSizingVertical=HUG: a bound height is a fixed size; write layoutSizingVertical=HUG and drop the height token, or keep the token and drop HUG`; and a `HORIZONTAL` or `VERTICAL` frame that hugs an axis every child in its flow fills, since nothing is left to size it and the target sets one of the two back: `FRAME "Face" fills the width of FRAME "Card", which hugs it: a frame cannot hug children that only fill it; give "Card" a fixed width, or a child a width of its own`.
|
|
463
463
|
5. **All members together.** Every `BOOLEAN`, `TEXT` and `INSTANCE_SWAP` property is wired by some layer of some member.
|
|
464
464
|
6. **Names against the design system**, by `toghen-figma check` and by the plugin's check before a sync: every token and style a file names is in the design system, and is not a part the fold took into its rest's variable ([How parts become variables](#how-parts-become-variables)). What only Figma holds, such as a variable that is ambiguous between collections, is the dry run's.
|
|
465
465
|
|