Repository navigation
Expand file tree
/
Copy pathappleSystem.js
More file actions
2269 lines (2135 loc) · 110 KB
/
Copy pathappleSystem.js
File metadata and controls
2269 lines (2135 loc) · 110 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// visionOS / SwiftUI reference data for the AR/VR UI designer.
// The tool targets Apple Vision Pro exclusively — 2D Window mode and
// 3D Volume mode — so device presets are vision-specific.
// 1 scene unit == 1 metre. visionOS uses points (~1360pt = 1m at default
// scaling per Apple's spec) for SwiftUI sizes and metres for RealityKit
// transforms. We unify on metres in canvas space so a 1280pt SwiftUI
// window and a 0.1m RealityKit sphere render at physically correct
// relative scale (≈12.8:1 — matching what designers see on device).
//
// `POINTS_PER_UNIT` (== `POINTS_PER_METER`) is the conversion factor for
// SwiftUI pt-based sizes; `ptToUnits(pt)` returns metres.
// Anything that needs raw metres (RealityKit entities, world positions)
// uses metres directly.
export const POINTS_PER_UNIT = 1360
export const ptToUnits = (pt) => pt / POINTS_PER_UNIT
export const unitsToPt = (u) => Math.round(u * POINTS_PER_UNIT)
// Explicit metres helper for code that wants the conversion direction
// to be obvious. Identity right now (1 unit = 1m) but isolating it as a
// named function lets us re-tune the canvas scale without touching
// every call site.
export const metersToUnits = (m) => m
export const unitsToMeters = (u) => u
// Segmented control frame, fitted to its segment count. Each segment is
// 88pt wide with 4pt gaps between segments and a 4pt edge inset, on a
// fixed 44pt-tall pill: width = 88·n + 4·(n−1) + 4·2 = 92·n + 4. So two
// segments = 188×44 (88px selection thumb + 36 tall after the 4pt inset).
export const SEGMENT_PT = 88
export const SEGMENT_GAP_PT = 4
export const SEGMENT_HEIGHT_PT = 44
export const segmentedFrame = (n) => {
const count = Math.max(1, n || 1)
return [ptToUnits(92 * count + 4), ptToUnits(SEGMENT_HEIGHT_PT)]
}
// SwiftUI Font.TextStyle — authoritative set.
//
// Weights follow Apple's visionOS typography spec (WWDC23 #10076 + Apple
// Design Resources Figma kit). visionOS bumps body weight one step relative
// to iOS for legibility on glass — body is Medium (vs Regular on iOS) and
// titles/headline render Bold by default. `extraLargeTitle` and
// `extraLargeTitle2` are visionOS-only.
export const TEXT_STYLES = {
extraLargeTitle: { label: 'Extra Large Title', pt: 36, weight: 'bold', lineHeight: 44 },
extraLargeTitle2: { label: 'Extra Large Title 2', pt: 28, weight: 'bold', lineHeight: 34 },
largeTitle: { label: 'Large Title', pt: 34, weight: 'bold', lineHeight: 41 },
title: { label: 'Title', pt: 28, weight: 'bold', lineHeight: 34 },
title2: { label: 'Title 2', pt: 22, weight: 'bold', lineHeight: 28 },
title3: { label: 'Title 3', pt: 20, weight: 'semibold',lineHeight: 25 },
headline: { label: 'Headline', pt: 17, weight: 'bold', lineHeight: 22 },
body: { label: 'Body', pt: 17, weight: 'medium', lineHeight: 22 },
callout: { label: 'Callout', pt: 16, weight: 'regular', lineHeight: 21 },
subheadline: { label: 'Subheadline', pt: 15, weight: 'regular', lineHeight: 20 },
footnote: { label: 'Footnote', pt: 13, weight: 'regular', lineHeight: 18 },
caption: { label: 'Caption', pt: 12, weight: 'regular', lineHeight: 16 },
caption2: { label: 'Caption 2', pt: 11, weight: 'regular', lineHeight: 13 }
}
export const TEXT_STYLE_ORDER = [
'extraLargeTitle', 'extraLargeTitle2',
'largeTitle', 'title', 'title2', 'title3', 'headline',
'body', 'callout', 'subheadline', 'footnote', 'caption', 'caption2'
]
// ---- Attachment text ramp (volumetric-window typography) --------------
//
// Apple-standard type ramp scaled for RealityView Attachments inside a
// volumetric window. The wearer's default pose (VOLUME_VR_POS in
// Canvas3D.jsx) sits ~1.5m from the volume centre, so attachments use
// larger equivalent-pt sizes than the 40cm 2D window ramp (TEXT_STYLES)
// to stay legible at wearer distance. Padding and corner radius scale
// with the font so a `body` chip and a `largeTitle` chip both read as
// "Apple standard" — no arbitrary picking of raw metre values.
//
// Horizontal padding is ~1.55× vertical, mirroring SwiftUI's
// `.padding(.horizontal, 20).padding(.vertical, 12)` convention for
// capsule chips. Vertical stays tighter so the chip hugs its cap-height
// while horizontal breathes for glyph shoulder-space.
//
// All values in metres. Approximate on-device pt equivalents in the
// trailing comment for reference (1m ≈ 1360pt at our canvas scale).
export const ATTACHMENT_TEXT_STYLES = {
caption: { label: 'Caption', fontSize: 0.014, hPadding: 0.010, vPadding: 0.006, cornerRadius: 0.010, weight: 'regular' }, // ~19pt
footnote: { label: 'Footnote', fontSize: 0.018, hPadding: 0.012, vPadding: 0.008, cornerRadius: 0.012, weight: 'regular' }, // ~24pt
subheadline: { label: 'Subheadline', fontSize: 0.020, hPadding: 0.014, vPadding: 0.009, cornerRadius: 0.013, weight: 'regular' }, // ~27pt
body: { label: 'Body', fontSize: 0.022, hPadding: 0.016, vPadding: 0.010, cornerRadius: 0.014, weight: 'medium' }, // ~30pt — visionOS body weight
callout: { label: 'Callout', fontSize: 0.024, hPadding: 0.018, vPadding: 0.011, cornerRadius: 0.015, weight: 'medium' }, // ~33pt
headline: { label: 'Headline', fontSize: 0.028, hPadding: 0.020, vPadding: 0.012, cornerRadius: 0.016, weight: 'semibold' }, // ~38pt
title3: { label: 'Title 3', fontSize: 0.032, hPadding: 0.024, vPadding: 0.014, cornerRadius: 0.018, weight: 'semibold' }, // ~44pt
title2: { label: 'Title 2', fontSize: 0.036, hPadding: 0.028, vPadding: 0.016, cornerRadius: 0.020, weight: 'bold' }, // ~49pt
title: { label: 'Title', fontSize: 0.040, hPadding: 0.032, vPadding: 0.018, cornerRadius: 0.022, weight: 'bold' }, // ~54pt
largeTitle: { label: 'Large Title', fontSize: 0.048, hPadding: 0.036, vPadding: 0.020, cornerRadius: 0.024, weight: 'bold' }, // ~65pt
extraLargeTitle: { label: 'Extra Large Title', fontSize: 0.058, hPadding: 0.042, vPadding: 0.024, cornerRadius: 0.028, weight: 'bold' } // ~79pt
}
export const ATTACHMENT_TEXT_STYLE_ORDER = [
'caption', 'footnote', 'subheadline', 'body', 'callout',
'headline', 'title3', 'title2', 'title', 'largeTitle', 'extraLargeTitle'
]
// Attachment shape — matches SwiftUI's `.background(_, in:)` shape options.
// `capsule` auto-computes cornerRadius = half of the frame's short axis so
// the panel caps as a pill (matches SwiftUI's Capsule() shape). `roundedRect`
// uses the resolved cornerRadius from the text-style ramp (or an override).
export const ATTACHMENT_SHAPES = [
{ value: 'roundedRect', label: 'Rounded Rectangle' },
{ value: 'capsule', label: 'Capsule (Pill)' }
]
// Resolve an attachment's effective sizing from its `attachmentTextStyle`
// key + optional explicit overrides. `attachmentFontSize`,
// `attachmentPadding` / `attachmentHPadding` / `attachmentVPadding`,
// `attachmentCornerRadius` still win when set — the ramp is a default,
// not a lock. `attachmentPadding` legacy field forces both axes; the
// H/V split falls back to the ramp otherwise.
export function resolveAttachmentStyle(entity) {
const key = entity?.attachmentTextStyle || 'body'
const style = ATTACHMENT_TEXT_STYLES[key] || ATTACHMENT_TEXT_STYLES.body
const legacyPad = entity?.attachmentPadding
return {
fontSize: entity?.attachmentFontSize ?? style.fontSize,
hPadding: entity?.attachmentHPadding ?? legacyPad ?? style.hPadding,
vPadding: entity?.attachmentVPadding ?? legacyPad ?? style.vPadding,
cornerRadius: entity?.attachmentCornerRadius ?? style.cornerRadius,
weight: entity?.attachmentWeight ?? style.weight
}
}
// Resolve the spec-default weight for a text style. Used by the SwiftUI
// exporter to decide whether to emit `.fontWeight(...)` — if the panel's
// weight matches the visionOS default for its style, the modifier is
// omitted so SwiftUI's own resolution wins on device.
export const textStyleDefaultWeight = (style) =>
TEXT_STYLES[style]?.weight ?? 'regular'
// visionOS window sizes. The Regular preset is the default frame for a
// freshly-created window (or when no window is selected) — 1200×800
// gives a comfortably wide landscape canvas that matches the proportions
// most visionOS reference apps ship with. Other presets stay around for
// designers who want a different starting frame.
export const WINDOW_PRESETS = {
regular: { label: 'Regular', width: 1200, height: 800 },
wide: { label: 'Wide', width: 1280, height: 720 },
tall: { label: 'Tall', width: 720, height: 1080 },
compact: { label: 'Compact', width: 640, height: 480 },
square: { label: 'Square', width: 720, height: 720 }
}
// Volume sizes follow Apple's `.defaultSize(_, _, _, in: .meters)` —
// the canonical example is 0.6 × 0.4 × 0.6 m. We store them in pt
// for the canvas (1360pt = 1m) so they round-trip cleanly through
// the layout engine, then re-emit in metres at export time.
export const VOLUME_PRESETS = {
small: { label: 'Small', width: 544, height: 408, depth: 544 }, // 0.4 × 0.3 × 0.4 m
medium: { label: 'Medium', width: 816, height: 544, depth: 816 }, // 0.6 × 0.4 × 0.6 m (Apple default)
large: { label: 'Large', width: 1224, height: 816, depth: 1224 } // 0.9 × 0.6 × 0.9 m
}
// visionOS uses a glass material for window backgrounds. We approximate with
// a translucent fill + subtle border in the scene.
// Window outer corner radius: 30pt matches Apple's current visionOS Figma
// kit (the standard glass plate component and the separated-sidebar
// plate both ship at 30pt). The earlier 46pt traced to visionOS 1.0
// simulator measurements that have since drifted to the modern value.
export const WINDOW_CORNER_RADIUS = 30 // pt
export const WINDOW_BORDER_RADIUS = 30
// Default inner padding applied to a Window's content stack. Matches the
// 14pt edge inset used by Apple's reference layouts for a regular visionOS
// window at 1636×1142.
export const WINDOW_PADDING = 14
// Default NavigationSplitView sidebar sizing when in 'separated' style —
// the sidebar becomes a standalone rounded dialogue on the leading edge.
// Apple's visionOS Figma kit ships the separated sidebar at 320pt wide.
export const SPLIT_SEPARATED_WIDTH = 320 // pt
export const SPLIT_SEPARATED_RADIUS = 30 // pt
// visionOS ornament placements (attached chrome outside the window).
// All sizes in iOS points. The designer treats each ornament as a Stack
// pinned to one edge of the parent Window with a capsule background.
export const ORNAMENT_PLACEMENTS = {
leading: { label: 'Leading Sidebar' },
trailing: { label: 'Trailing Sidebar' },
top: { label: 'Top Bar' },
bottom: { label: 'Bottom Bar' }
}
// Vertical tab bars (leading / trailing ornaments) follow Apple's visionOS
// Figma kit — 68pt wide, ~180pt tall for a 3-item icon-only bar, with
// tight 6pt inter-icon spacing and 8pt outer padding. Height is the
// ornament's intrinsic size for 3 items; designers grow it by adding
// tabs (the layout engine hugs the contents in 'fit' mode).
export const ORNAMENT_DEFAULTS = {
leading: { stackType: 'vstack', width: 68, height: 180, padding: 8, spacing: 6, name: 'Leading Sidebar' },
trailing: { stackType: 'vstack', width: 68, height: 180, padding: 8, spacing: 6, name: 'Trailing Sidebar' },
top: { stackType: 'hstack', width: 320, height: 56, padding: 10, spacing: 12, name: 'Top Bar' },
bottom: { stackType: 'hstack', width: 320, height: 56, padding: 10, spacing: 12, name: 'Bottom Bar' }
}
// Gap between the window edge and the attached ornament.
// visionOS bottom ornaments overlap the window edge by 20 pt (WWDC23 #10076).
export const ORNAMENT_GAP = 20 // pt
// Button size presets. visionOS surfaces three fixed sizes; each one
// determines the button frame, the text point size, and (via the renderer)
// the leading SF-Symbol inset. Side padding is a constant 12pt, baked into
// the renderer in `Panel3D.jsx`. The numbers below are the single source of
// truth — the inspector reads them when the user picks a size, the canvas
// reads them when rendering, and the SwiftUI exporter reads them when
// emitting `.frame()` (when an override is needed).
export const BUTTON_SIZES = {
small: { label: 'Small', width: 65, height: 32, fontPt: 15 },
regular: { label: 'Regular', width: 86, height: 44, fontPt: 17 },
large: { label: 'Large', width: 101, height: 52, fontPt: 19 }
}
export const BUTTON_SIZE_ORDER = ['small', 'regular', 'large']
// Button shape presets — drives corner radius only. Capsule renders as a
// pill (radius 100pt — effectively the full half-height, which visually
// caps both ends at the spec). Rounded Rect uses a 16pt radius — the
// visionOS Figma kit's secondary button shape.
export const BUTTON_SHAPES = {
capsule: { label: 'Capsule', radiusPt: 100 },
roundedRectangle: { label: 'Rounded Rect', radiusPt: 16 }
}
export const BUTTON_SHAPE_ORDER = ['capsule', 'roundedRectangle']
// Fixed text inset (side padding) inside every button, applied by the
// renderer to the text's horizontal placement. Matches the Apple Figma
// kit's 12pt edge-to-glyph spec.
export const BUTTON_TEXT_INSET_PT = 12
// Measure a string's width in points using a canvas 2D context with
// Inter (the font the canvas renders with via troika). Buttons use this
// to grow their frame so a longer label still fits on a single line
// with the 12pt side padding intact. The 0.58-glyph-advance fallback is
// only used during SSR / when `document` isn't available — the renderer
// always runs in the browser so the canvas path is the live one.
//
// `family` is a CSS font-family list, for the three `.fontDesign(_:)` faces
// that are not Inter. It arrives as a string rather than as a design name so
// this module stays free of `fonts.js` and its 32 asset imports — the caller
// that knows about designs does the lookup. AUDIT #5.
const DEFAULT_MEASURE_FAMILY = 'Inter, system-ui, sans-serif'
let _btnMeasureCanvas = null
export function measureTextWidthPt(text, fontSizePt, weight = 'regular', family = DEFAULT_MEASURE_FAMILY) {
if (!text) return 0
if (typeof document === 'undefined') return text.length * fontSizePt * 0.58
if (!_btnMeasureCanvas) _btnMeasureCanvas = document.createElement('canvas')
const ctx = _btnMeasureCanvas.getContext('2d')
if (!ctx) return text.length * fontSizePt * 0.58
const cssWeight = weight === 'bold' ? 700
: weight === 'semibold' ? 600
: weight === 'medium' ? 500 : 400
ctx.font = `${cssWeight} ${fontSizePt}px ${family || DEFAULT_MEASURE_FAMILY}`
return ctx.measureText(text).width
}
// Resolve a button panel's *effective* frame in points. Height is locked
// to its `buttonSize` preset; width is **always** `textWidth + 2×12pt`
// padding (plus a small reserve when there's a leading SF Symbol) so
// the padding stays exactly 12pt on each side regardless of label
// length. A short label shrinks the button; a long label grows it. The
// only floor is the preset height — keeps an empty button from
// collapsing to a 24pt sliver while it's being authored.
export function computeButtonFramePt(panel) {
const preset = buttonSizePreset(panel?.controlSize || panel?.buttonSize || 'regular')
const fontPt = preset.fontPt
// +1pt safety margin on the measured width — troika's text layout
// and canvas 2D's advance metric can disagree by a fraction at the
// tail of the last glyph, and we'd rather over-pad by half a pt than
// wrap a label.
const labelW = measureTextWidthPt(panel?.text || '', fontPt, panel?.fontWeight) + 1
// Leading-symbol reserve: icon glyph (~fontPt × 1.1) + 4pt gap.
const symbolReserve = panel?.symbolName ? fontPt * 1.1 + 4 : 0
const needed = labelW + symbolReserve + BUTTON_TEXT_INSET_PT * 2
return [Math.max(preset.height, needed), preset.height]
}
// SwiftUI button styles.
// `automatic` is the visionOS default — it resolves to a glass-bordered
// capsule for text/text+icon and to a circle for icon-only buttons.
// `glass` / `glassProminent` are the explicit visionOS 26 styles.
//
// Every key here is emitted verbatim as `.buttonStyle(.<key>)`, so every key
// has to name a real `ButtonStyle`. `destructive` used to sit in this list
// as "a convenience" and produced `.buttonStyle(.destructive)`, which does
// not compile: destructive is a `ButtonRole`, carried by the separate
// `buttonRole` field and emitted as `Button(role: .destructive)`. Scenes
// that still carry it are normalised by `normalizeButton` below.
export const BUTTON_STYLES = {
automatic: { label: 'Automatic (Glass Capsule)' },
plain: { label: 'Plain' },
borderless: { label: 'Borderless' },
bordered: { label: 'Bordered' },
borderedProminent: { label: 'Prominent' },
glass: { label: 'Glass' },
glassProminent: { label: 'Glass Prominent' }
}
// Bring a button's legacy field shapes onto the canonical ones.
//
// Buttons accumulated three pairs of fields that meant one thing each, where
// the canvas read one half and the exporter read the other:
//
// buttonStyle: 'destructive' -> buttonRole: 'destructive'
// Not a ButtonStyle at all. `.buttonStyle(.destructive)` does not
// compile; the role is what the designer meant.
// buttonSize -> controlSize
// Same concept, two vocabularies. `.controlSize` is the real SwiftUI
// spelling, so it wins and the canvas metrics key off it.
// buttonShape -> buttonBorderShape
// Same concept, and `buttonShape` was only ever mirrored into a stored
// `cornerRadius` the renderer read. The radius is derived now.
//
// Shared by the project loader (so the inspector shows the corrected value)
// and by the button emitter (so a scene already in memory, or a template
// that has not been re-seeded, still exports correct Swift).
export function normalizeButton(panel) {
if (!panel) return panel
let out = panel
const set = (patch) => { out = { ...out, ...patch } }
if (out.buttonStyle === 'destructive') {
set({
buttonStyle: 'automatic',
buttonRole: out.buttonRole && out.buttonRole !== 'none' ? out.buttonRole : 'destructive'
})
}
if (out.buttonSize && !out.controlSize) set({ controlSize: out.buttonSize })
if (out.buttonShape && (!out.buttonBorderShape || out.buttonBorderShape === 'automatic')) {
set({ buttonBorderShape: out.buttonShape })
}
return out
}
// visionOS ships three standard button frames. `controlSize` carries five
// cases, because SwiftUI applies it to every control; the two the canvas has
// no spec for collapse onto the nearest one it does. Approximating on the
// canvas is honest — the exported `.controlSize(.mini)` is still exact.
export function buttonSizePreset(controlSize) {
const key = controlSize === 'mini' ? 'small'
: controlSize === 'extraLarge' ? 'large'
: controlSize
return BUTTON_SIZES[key] || BUTTON_SIZES.regular
}
// Corner radius in points for a button's border shape. `automatic` is the
// visionOS default, which draws a capsule for text and text+icon buttons.
export function buttonRadiusPt(buttonBorderShape) {
const key = !buttonBorderShape || buttonBorderShape === 'automatic'
? 'capsule'
: buttonBorderShape
return (BUTTON_SHAPES[key] || BUTTON_SHAPES.capsule).radiusPt
}
// Default `.buttonBorderShape()` shape per visionOS HIG: capsule for
// text/text+icon buttons; circle for icon-only buttons. Other allowed
// values per spec §1.2: `roundedRectangle` (with optional radius) and
// `automatic` (system-decided).
export const BUTTON_BORDER_SHAPES = [
{ value: 'automatic', label: 'Automatic' },
{ value: 'capsule', label: 'Capsule' },
{ value: 'circle', label: 'Circle' },
{ value: 'roundedRectangle', label: 'Rounded Rectangle' }
]
// Apple visionOS Liquid Glass material tiers. Every tier renders as a
// layered liquid-glass stack (drop shadow + frosted base + bright rim +
// top specular). Opacity and rim strength vary with the tier to match
// SwiftUI semantics: lower tiers let more of the world through.
//
// Per-tier constants consumed by the liquid-glass renderer in SceneTree.
// Each material entry carries the full property set the renderer
// needs: base color (single-fill tint), composite opacity, optional
// layered passes (D6D6D6 + #000000-style), a frosted-glass blur toggle
// + radius, and optional inner / drop shadow descriptors. The Scene →
// Materials & Colors editor lets the user override any of these
// per-scene via `scene.materialProps[key]`; the renderer merges the
// override on top of the defaults below at draw time.
const NO_SHADOW = null
export const MATERIALS = {
// Glass — visionOS plate default. Neutral #b8b8b8 at 25% alpha, backed
// by a 40pt backdrop blur. Matches the windowGlass token in
// DEFAULT_SCENE_COLORS so a fresh window lands on Apple's reference
// plate look. Shadows are opt-in: the user toggles them from the
// Materials & Colors editor when they actively want a contact cue.
glass: {
label: 'Glass',
fillType: 'solid',
color: '#b8b8b8',
gradientFrom: '#b8b8b8',
gradientTo: '#cccccc',
gradientAngle: 180,
opacity: 0.25,
blur: true,
blurAmount: 40,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.45,
specularOpacity: 0.30,
shadowOpacity: 0.20
},
// Views/Regular — layered composite plate (D6D6D6 @ 45% + #000000 @ 8%).
// The renderer reads `.layers` and paints both passes; the legacy
// single-`opacity` path still works for every other tier.
viewsRegular: {
label: 'Views Regular',
fillType: 'solid',
color: '#D6D6D6',
gradientFrom: '#D6D6D6',
gradientTo: '#a0a0a0',
gradientAngle: 180,
opacity: 0.45,
blur: false,
blurAmount: 12,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.0,
specularOpacity: 0.0,
shadowOpacity: 0.0,
layers: [
{ color: '#D6D6D6', opacity: 0.45 },
{ color: '#000000', opacity: 0.08 }
]
},
ultraThin: {
label: 'Ultra Thin',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#d0d0d0', gradientAngle: 180,
opacity: 0.42,
blur: true,
blurAmount: 30,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.55,
specularOpacity: 0.35,
shadowOpacity: 0.18
},
thin: {
label: 'Thin',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#c0c0c0', gradientAngle: 180,
opacity: 0.55,
blur: true,
blurAmount: 20,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.60,
specularOpacity: 0.40,
shadowOpacity: 0.22
},
regular: {
label: 'Regular',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#b0b0b0', gradientAngle: 180,
opacity: 0.72,
blur: true,
blurAmount: 16,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.68,
specularOpacity: 0.45,
shadowOpacity: 0.28
},
thick: {
label: 'Thick',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#a0a0a0', gradientAngle: 180,
opacity: 0.88,
blur: true,
blurAmount: 12,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.62,
specularOpacity: 0.42,
shadowOpacity: 0.32
},
ultraThick: {
label: 'Ultra Thick',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#909090', gradientAngle: 180,
opacity: 0.96,
blur: true,
blurAmount: 8,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.55,
specularOpacity: 0.38,
shadowOpacity: 0.36
},
opaque: {
label: 'Opaque',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#888888', gradientAngle: 180,
opacity: 1.0,
blur: false,
blurAmount: 0,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.0,
specularOpacity: 0.0,
shadowOpacity: 0.30
},
// `.bar` material — toolbar / chrome on visionOS.
bar: {
label: 'Bar',
fillType: 'solid',
color: '#ffffff',
gradientFrom: '#ffffff', gradientTo: '#a0a0a0', gradientAngle: 180,
opacity: 0.62,
blur: true,
blurAmount: 18,
innerShadow: NO_SHADOW,
dropShadow: NO_SHADOW,
rimOpacity: 0.58,
specularOpacity: 0.38,
shadowOpacity: 0.20
}
}
export const MATERIAL_ORDER = ['glass', 'viewsRegular', 'ultraThin', 'thin', 'regular', 'thick', 'ultraThick', 'opaque', 'bar']
// SwiftUI material tiers offered as the segmented control's track
// background — the only appearance control for a segmented picker (it
// has no user fill colour). `swift` maps 1:1 to a SwiftUI `Material`
// value for export. `tint` is the 0–1 lerp toward the lighter rim used
// to nudge the recessed-well shade in the preview so the choice reads.
export const SEGMENT_MATERIALS = [
{ value: 'ultraThin', label: 'Ultra Thin', swift: '.ultraThinMaterial', tint: 0.0 },
{ value: 'thin', label: 'Thin', swift: '.thinMaterial', tint: 0.14 },
{ value: 'regular', label: 'Regular', swift: '.regularMaterial', tint: 0.28 },
{ value: 'thick', label: 'Thick', swift: '.thickMaterial', tint: 0.44 },
{ value: 'ultraThick', label: 'Ultra Thick', swift: '.ultraThickMaterial', tint: 0.6 }
]
// Closest SwiftUI Material for each "Views" scene material token (the
// viewRecessed→viewThicker tier the user picks from Scene → Materials &
// Colors). Used only when exporting controls that sit on a view material —
// e.g. the segmented picker's track — to code. The tokens themselves live in
// DEFAULT_SCENE_COLORS / scene.colors and drive the live preview tint.
export const VIEW_MATERIAL_SWIFT = {
viewRecessed: '.regularMaterial',
viewThin: '.thinMaterial',
viewRegular: '.regularMaterial',
viewThicker: '.thickMaterial'
}
// Resolve a material's final property set from MATERIALS defaults +
// optional `scene.materialProps[key]` user overrides. The Materials &
// Colors editor writes overrides; the LiquidGlass renderer + the
// window inspector preview both read through this helper so they stay
// in sync.
export function resolveMaterial(key, sceneMaterialProps) {
const base = MATERIALS[key] || {}
const override = (sceneMaterialProps || {})[key] || {}
return { ...base, ...override }
}
// HDRIs bundled with the app (public/hdri/). Each `file` is loaded by drei's
// <Environment files=...> via the RGBELoader. Keeping them local-first keeps
// preview reliable offline and avoids any first-use latency.
export const HDRI_PRESETS = {
none: { label: 'None', file: null },
sample1: { label: 'Sample 1', file: '/hdri/Sample_01_2k.hdr' },
sample2: { label: 'Sample 2', file: '/hdri/Sample_02_2k.hdr' },
sample3: { label: 'Sample 3', file: '/hdri/Sample_03_2k.hdr' }
}
export const HDRI_ORDER = ['none', 'sample1', 'sample2', 'sample3']
// SwiftUI-equivalent semantic color tokens.
// Stored as pre-blended 6-digit hex for THREE.Color.
export const SYSTEM_COLORS = {
light: {
primary: '#000000',
secondary: '#8e8e93',
tertiary: '#c7c7cc',
quaternary: '#d1d1d6',
systemBackground: '#ffffff',
secondarySystemBackground: '#f2f2f7',
tertiarySystemBackground: '#ffffff',
systemFill: '#e3e3e8',
secondarySystemFill: '#ebebf0',
systemRed: '#ff3b30',
systemOrange: '#ff9500',
systemYellow: '#ffcc00',
systemGreen: '#34c759',
systemMint: '#00c7be',
systemTeal: '#30b0c7',
systemCyan: '#32ade6',
systemBlue: '#007aff',
systemIndigo: '#5856d6',
systemPurple: '#af52de',
systemPink: '#ff2d55',
systemBrown: '#a2845e',
systemGray: '#8e8e93',
// visionOS glass materials (approximated)
glassRegular: '#f2f2f7',
glassThin: '#ffffff',
glassThick: '#e5e5ea',
// Design scheme — the colours a finished Vision Pro layout uses.
// Light scheme: a near-white translucent plate. The 92% alpha
// stamped onto the plate by `LiquidGlass` lets the room peek
// through the way real visionOS glass does.
designWindow: '#ecedef',
designButton: '#b7b6b1',
designButtonText: '#000000'
},
dark: {
primary: '#ffffff',
secondary: '#8e8e93',
tertiary: '#48484a',
quaternary: '#3a3a3c',
systemBackground: '#000000',
secondarySystemBackground: '#1c1c1e',
tertiarySystemBackground: '#2c2c2e',
systemFill: '#545458',
secondarySystemFill: '#4a4a4e',
systemRed: '#ff453a',
systemOrange: '#ff9f0a',
systemYellow: '#ffd60a',
systemGreen: '#30d158',
systemMint: '#66d4cf',
systemTeal: '#40cbe0',
systemCyan: '#64d2ff',
systemBlue: '#0a84ff',
systemIndigo: '#5e5ce6',
systemPurple: '#bf5af2',
systemPink: '#ff375f',
systemBrown: '#ac8e68',
systemGray: '#8e8e93',
glassRegular: '#39393c',
glassThin: '#45454a',
glassThick: '#2c2c2f',
// Design scheme — even in dark mode, visionOS plates are not
// opaque grey. They're a translucent light plate that picks up
// the environment. The 92% fill opacity gives a glassy lift over
// the studio decor / room behind.
designWindow: '#ecedef',
designButton: '#b7b6b1',
designButtonText: '#ffffff'
}
}
export const SEMANTIC_COLOR_ORDER = [
'primary', 'secondary', 'tertiary', 'quaternary',
'systemBackground', 'secondarySystemBackground', 'tertiarySystemBackground',
'systemFill', 'secondarySystemFill', 'tertiarySystemFill', 'quaternarySystemFill',
'systemBlue', 'systemRed', 'systemGreen', 'systemOrange',
'systemYellow', 'systemPurple', 'systemPink', 'systemTeal',
'systemIndigo', 'systemMint', 'systemCyan', 'systemBrown', 'systemGray'
]
// ---- Scene Color Palette ---------------------------------------------
//
// Designer-editable color system. Mirrors the visionOS Figma "Color
// styles" panel — Text/Controls/Views/Windows/Separators + the system
// colour wheel. Each token lives on `scene.colors` so the user can
// retune the whole project from Scene → Colors and every panel that
// references a token tracks the change automatically.
//
// `resolveSemantic(token, sceneOrScheme)` consults `scene.colors[token]`
// first; if absent it falls back to the legacy SYSTEM_COLORS table so
// scheme-aware tokens (systemBackground, glassRegular, …) still work.
export const SCENE_COLOR_LABELS = {
// Text
primary: 'Primary',
secondary: 'Secondary',
tertiary: 'Tertiary',
// Controls (state-driven)
controlIdle: 'Idle',
controlHover: 'Hover',
controlPinch: 'Pinch',
controlSelected: 'Selected',
controlDisabled: 'Disabled',
// Views (material tiers)
viewRecessed: 'Recessed Material View',
viewThin: 'Thin',
viewRegular: 'Regular',
viewThicker: 'Thicker',
// Windows
windowGlass: 'Glass',
windowGlassKeyboard:'Glass — Keyboard',
// Separators
separator: 'Separator',
// System colour wheel
systemRed: 'Red',
systemOrange: 'Orange',
systemYellow: 'Yellow',
systemGreen: 'Green',
systemMint: 'Mint',
systemTeal: 'Teal',
systemCyan: 'Cyan',
systemBlue: 'Blue',
systemIndigo: 'Indigo',
systemPurple: 'Purple',
systemPink: 'Pink',
systemBrown: 'Brown',
systemGray: 'Gray',
black: 'Black',
white: 'White'
}
// Categorical ordering for the inspector picker + Scene → Colors editor.
// Order matches the visionOS Figma kit reading order.
export const SCENE_COLOR_GROUPS = [
{ key: 'colors', label: 'Colors', tokens: ['systemRed', 'systemOrange', 'systemYellow', 'systemGreen', 'systemMint', 'systemTeal', 'systemCyan', 'systemBlue', 'systemIndigo', 'systemPurple', 'systemPink', 'systemBrown', 'systemGray', 'black', 'white'] },
{ key: 'text', label: 'Text', tokens: ['primary', 'secondary', 'tertiary'] },
{ key: 'controls', label: 'Controls', tokens: ['controlIdle', 'controlHover', 'controlPinch', 'controlSelected', 'controlDisabled'] },
{ key: 'views', label: 'Views', tokens: ['viewRecessed', 'viewThin', 'viewRegular', 'viewThicker'] },
{ key: 'windows', label: 'Windows', tokens: ['windowGlass', 'windowGlassKeyboard'] },
{ key: 'separators', label: 'Separators', tokens: ['separator'] }
]
// Default hex values for a fresh scene. Picked from the visionOS Figma
// kit reference (the "Color styles" page in Apple's design system) so
// a brand-new project lands on values matching the spatial UI HIG.
export const DEFAULT_SCENE_COLORS = {
// Text — high-contrast on glass; Apple uses near-white as the
// primary baseline because visionOS plates render translucent.
primary: '#ffffff',
secondary: '#b0b0b3',
tertiary: '#6e6e72',
// Controls — gradient from dim → fully-lit; idle reads as
// a recessed control on glass, selected pops to white.
controlIdle: '#6e6e72',
controlHover: '#8e8e93',
controlPinch: '#545458',
controlSelected: '#ffffff',
controlDisabled: '#48484a',
// Views — material tier tints (visionOS Material approximations).
viewRecessed: '#2c2c2e',
viewThin: '#45454a',
viewRegular: '#39393c',
viewThicker: '#5a5a5e',
// Windows — neutral #b8b8b8 with 25% opacity baked in. Kept in sync
// with MATERIALS.glass so the "Glass" token and the Glass material
// read identically. The renderer blends this over the studio backdrop
// the way visionOS does over the wearer's room. designWindow in
// SYSTEM_COLORS is kept for the legacy scheme tables.
windowGlass: '#b8b8b8',
windowGlassOpacity: 0.25,
windowGlassKeyboard:'#2c2c2e',
// Separators — Apple's tertiary-on-dark hairline.
separator: '#38383a',
// System colour wheel (mirrors the iOS systemX palette).
systemRed: '#ff3b30',
systemOrange: '#ff9500',
systemYellow: '#ffcc00',
systemGreen: '#34c759',
systemMint: '#00c7be',
systemTeal: '#30b0c7',
systemCyan: '#32ade6',
systemBlue: '#007aff',
systemIndigo: '#5856d6',
systemPurple: '#af52de',
systemPink: '#ff2d55',
systemBrown: '#a2845e',
systemGray: '#8e8e93',
black: '#000000',
white: '#ffffff'
}
// Build a fresh defaults map. Cloning so the consumer can mutate the
// returned object without affecting the module-level constant.
export const buildDefaultSceneColors = () => ({ ...DEFAULT_SCENE_COLORS })
// Resolve a semantic color token to a hex string.
//
// Accepts either a scheme string (legacy: 'light' / 'dark') or a scene
// object. When a scene object is passed we consult `scene.colors[token]`
// first — that's how the Scene → Colors editor's overrides propagate
// to every consumer. We then fall back to the per-scheme SYSTEM_COLORS
// table for tokens the scene palette doesn't cover (systemBackground,
// glassRegular, designWindow, …).
export const resolveSemantic = (token, sceneOrScheme) => {
// Caller passed a scene object — check material/color overrides first.
if (sceneOrScheme && typeof sceneOrScheme === 'object') {
// Tokens edited via the Materials editor store their color in
// materialProps[token]; honour that first so a material-color edit
// flows to every consumer that resolves this token.
const matColor = sceneOrScheme.materialProps?.[token]?.color
if (matColor) return matColor
const override = sceneOrScheme.colors?.[token]
if (override) return override
const scheme = sceneOrScheme.designScheme || 'light'
return SYSTEM_COLORS[scheme]?.[token]
|| DEFAULT_SCENE_COLORS[token]
|| SYSTEM_COLORS.light[token]
|| '#000000'
}
// Legacy path — scheme string. Still honours DEFAULT_SCENE_COLORS so
// new tokens (controlIdle, viewRegular, …) resolve even when the
// caller hasn't been migrated to pass the scene.
const scheme = sceneOrScheme || 'light'
return SYSTEM_COLORS[scheme]?.[token]
|| DEFAULT_SCENE_COLORS[token]
|| SYSTEM_COLORS.light[token]
|| '#000000'
}
// ---- Unified material library ----------------------------------------
//
// The SINGLE source of truth behind every "Material" dropdown in the app.
// It mirrors EXACTLY the list the Scene → Materials & Colors detail editor
// builds: every non-system-colour scene token (Text / Controls / Views /
// Windows / Separators — 15 entries) followed by the nine liquid-glass
// tiers (MATERIAL_ORDER). 15 + 9 = the 24 materials the user tunes in
// Scene Settings. Each descriptor is `{ value, label, group }` so a picker
// can render the same grouped list the Scene editor shows.
export const MATERIAL_LIBRARY = [
...SCENE_COLOR_GROUPS
.filter((g) => g.key !== 'colors')
.flatMap((g) => g.tokens.map((t) => ({ value: t, label: SCENE_COLOR_LABELS[t] || t, group: g.label }))),
...MATERIAL_ORDER.map((k) => ({ value: k, label: MATERIALS[k]?.label || k, group: 'Materials' }))
]
// Flat list of the 24 valid material keys — used to validate / clamp a
// stored selection back into the library.
export const MATERIAL_LIBRARY_VALUES = MATERIAL_LIBRARY.map((m) => m.value)
// True when `key` names a liquid-glass tier (a full MATERIALS spec with
// blur / layers / rim). Token-materials (primary, viewRecessed, separator,
// …) return false — they resolve to a flat tinted plate.
export const isGlassMaterialKey = (key) => Object.prototype.hasOwnProperty.call(MATERIALS, key)
// Resolve ANY of the 24 library materials to a full render spec.
//
// • Glass tiers (glass, regular, …) resolve exactly like `resolveMaterial`
// — the MATERIALS default merged with the user's
// `scene.materialProps[key]` overrides — so existing windows / stacks
// render byte-identically.
// • Token-materials (primary, viewRecessed, separator, …) have no MATERIALS
// entry, so we synthesise a flat solid plate: the colour comes from
// `resolveSemantic` (which already honours scene.colors + the Materials
// editor's colour override), and any other detailed setting the user
// tuned (fillType / gradient / opacity / blur / layers / shadows) is
// merged on top from `scene.materialProps[key]`.
//
// This is the helper that makes a detailed-settings edit in Scene →
// Materials propagate to every view that references the material.
export function resolveAnyMaterial(key, scene) {
const sceneMaterialProps = (scene && typeof scene === 'object') ? scene.materialProps : null
if (key && MATERIALS[key]) {
return resolveMaterial(key, sceneMaterialProps)
}
const override = (sceneMaterialProps || {})[key] || {}
const color = resolveSemantic(key, scene)
return {
fillType: 'solid',
gradientFrom: color,
gradientTo: color,
gradientAngle: 180,
opacity: 1,
blur: false,
blurAmount: 0,
layers: null,
innerShadow: null,
dropShadow: null,
rimOpacity: 0,
specularOpacity: 0,
shadowOpacity: 0,
...override,
// resolveSemantic already folds in `override.color`; restate it last so
// the spread above can't leave a stale colour behind.
color: override.color || color
}
}
// Closest SwiftUI ShapeStyle (Material) string for ANY library material —
// used when exporting a control that paints a `.background(...)` from the
// chosen material (segmented track, input plate, …). Glass tiers map to
// their matching `Material`; the four Views tokens use VIEW_MATERIAL_SWIFT;
// every other token falls back to `.regularMaterial` so the export always
// emits a valid ShapeStyle.
const TIER_SWIFT = {
glass: '.regularMaterial',
viewsRegular: '.regularMaterial',
ultraThin: '.ultraThinMaterial',
thin: '.thinMaterial',
regular: '.regularMaterial',
thick: '.thickMaterial',
ultraThick: '.ultraThickMaterial',
opaque: '.thickMaterial',
bar: '.bar'
}
export function materialSwiftValue(key) {
return TIER_SWIFT[key] || VIEW_MATERIAL_SWIFT[key] || '.regularMaterial'
}
// SwiftUI stack types + alignments.
export const STACK_TYPES = {
vstack: {
label: 'VStack',
description: 'Arranges children vertically',
alignments: ['leading', 'center', 'trailing']
},
hstack: {
label: 'HStack',
description: 'Arranges children horizontally',
alignments: ['top', 'center', 'bottom']
},
zstack: {
label: 'ZStack',
description: 'Overlays children',
alignments: [
'topLeading', 'top', 'topTrailing',
'leading', 'center', 'trailing',
'bottomLeading', 'bottom', 'bottomTrailing'
]
},
grid: {
label: 'Grid',
description: 'Arranges children in a 2D grid with N columns',
alignments: ['leading', 'center', 'trailing']
},
lazyvstack: {
label: 'LazyVStack',
description: 'Vertical stack with deferred loading',
alignments: ['leading', 'center', 'trailing']
},
lazyhstack: {
label: 'LazyHStack',
description: 'Horizontal stack with deferred loading',
alignments: ['top', 'center', 'bottom']
},
section: {
label: 'Section',
description: 'Grouped section with header and optional footer',
alignments: ['leading', 'center', 'trailing']
},
disclosure: {
label: 'DisclosureGroup',
description: 'Expandable/collapsible group',
alignments: ['leading', 'center', 'trailing']
},
navigationStack: {
label: 'NavigationStack',
description: 'Push/pop navigation — shows one child at a time',
alignments: ['center']
},
tabView: {
label: 'TabView (Navigation Stack)',
description: 'Shows one Tab at a time — select via the active tab index',
alignments: ['center']
},
tab: {
label: 'Tab',
description: 'A single named tab within a TabView',
alignments: ['leading', 'center', 'trailing']
},
// Spec §1.24 — `ScrollView(_ axes:, showsIndicators:, content:)`. Default
// axis is `.vertical`. Models a scroll container around child content.
scrollView: {
label: 'ScrollView',
description: 'Scroll container — wraps children on the chosen axis',
alignments: ['center']
},
// Spec §1.24 — `LazyVGrid(columns:, alignment:, spacing:, pinnedViews:, content:)`.
// Renders rows lazily as they scroll into view; columns drive item width.
lazyVGrid: {
label: 'LazyVGrid',
description: 'Lazy 2D grid — flows columns vertically',
alignments: ['leading', 'center', 'trailing']
},
lazyHGrid: {
label: 'LazyHGrid',
description: 'Lazy 2D grid — flows rows horizontally',
alignments: ['top', 'center', 'bottom']
},
// Spec §1.24 — `ViewThatFits(in:[.horizontal,.vertical], content:)`.
// Picks the first child that fits in the available space.
viewThatFits: {
label: 'ViewThatFits',
description: 'Picks the first child that fits the available space',
alignments: ['center']
},
// Spec §1.26 — `Toolbar` is a SwiftUI modifier (`.toolbar { ... }`) whose
// body is a builder of `ToolbarItem`/`ToolbarItemGroup`. We model it as
// a stack so designers can drop items into it; the exporter wires it as
// a `.toolbar { … }` modifier on the parent view.
toolbar: {
label: 'Toolbar',
description: 'Attaches a toolbar (top, bottom, or ornament) to the parent view',
alignments: ['center']
},
// ToolbarItem — a single placement (`.principal`, `.bottomOrnament`, etc.).
// `toolbarItem.placement` drives where it lives in the chrome.
toolbarItem: {
label: 'ToolbarItem',