-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder_blocks.go
More file actions
1404 lines (1178 loc) · 41 KB
/
builder_blocks.go
File metadata and controls
1404 lines (1178 loc) · 41 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
package myrtle
// ButtonOption configures a ButtonBlock.
type ButtonOption func(*ButtonBlock)
// ButtonTone sets the tone of a button.
func ButtonTone(value Tone) ButtonOption {
return func(block *ButtonBlock) {
block.Tone = value
}
}
// ButtonStyle sets the style of a button.
func ButtonStyle(value ButtonStyleValue) ButtonOption {
return func(block *ButtonBlock) {
block.Style = value
}
}
// ButtonFullWidth toggles full-width rendering for a button.
func ButtonFullWidth(value bool) ButtonOption {
return func(block *ButtonBlock) {
block.FullWidth = value
}
}
// ButtonSize sets the size of a button.
func ButtonSize(value ButtonSizeValue) ButtonOption {
return func(block *ButtonBlock) {
block.Size = value
}
}
// ButtonNoWrap toggles label wrapping for a button.
func ButtonNoWrap(value bool) ButtonOption {
return func(block *ButtonBlock) {
block.NoWrap = value
}
}
// ButtonAlign sets the alignment of a button.
func ButtonAlign(value ButtonAlignmentValue) ButtonOption {
return func(block *ButtonBlock) {
block.Alignment = value
}
}
// ButtonGroupOption configures a ButtonGroupBlock.
type ButtonGroupOption func(*ButtonGroupBlock)
// PanelOption configures a PanelBlock.
type PanelOption func(*PanelBlock)
// GridOption configures a GridBlock.
type GridOption func(*GridBlock)
// CardListOption configures a CardListBlock.
type CardListOption func(*CardListBlock)
// SpacerOption configures a SpacerBlock.
type SpacerOption func(*SpacerBlock)
// DividerOption configures a DividerBlock.
type DividerOption func(*DividerBlock)
// ButtonGroupAlign sets the alignment of buttons in the group.
func ButtonGroupAlign(value ButtonAlignmentValue) ButtonGroupOption {
return func(block *ButtonGroupBlock) {
block.Alignment = value
}
}
// ButtonGroupJoined toggles joined rendering for grouped buttons.
func ButtonGroupJoined(value bool) ButtonGroupOption {
return func(block *ButtonGroupBlock) {
block.Joined = value
}
}
// ButtonGroupStackOnMobile toggles stacking grouped buttons on mobile.
func ButtonGroupStackOnMobile(value bool) ButtonGroupOption {
return func(block *ButtonGroupBlock) {
block.StackOnMobile = value
}
}
// ButtonGroupFullWidthOnMobile toggles full-width grouped buttons on mobile.
func ButtonGroupFullWidthOnMobile(value bool) ButtonGroupOption {
return func(block *ButtonGroupBlock) {
block.FullWidthOnMobile = value
}
}
// ButtonGroupGap sets the horizontal gap between grouped buttons.
func ButtonGroupGap(value int) ButtonGroupOption {
return func(block *ButtonGroupBlock) {
block.Gap = value
}
}
// PanelTitle sets the panel title.
func PanelTitle(value string) PanelOption {
return func(block *PanelBlock) {
block.Title = value
}
}
// PanelSubtitle sets the panel subtitle.
func PanelSubtitle(value string) PanelOption {
return func(block *PanelBlock) {
block.Subtitle = value
}
}
// PanelCategory sets the panel category label.
func PanelCategory(value string) PanelOption {
return func(block *PanelBlock) {
block.Category = value
}
}
// PanelBorder toggles the panel border.
func PanelBorder(value bool) PanelOption {
return func(block *PanelBlock) {
block.Border = value
}
}
// PanelPadding sets panel content padding in pixels.
func PanelPadding(value int) PanelOption {
return func(block *PanelBlock) {
block.Padding = value
}
}
// PanelInsetMode sets the inset mode of the panel.
func PanelInsetMode(value InsetMode) PanelOption {
return func(block *PanelBlock) {
block.InsetMode = value
}
}
// PanelHeaderless toggles rendering the panel without its header section.
func PanelHeaderless(value bool) PanelOption {
return func(block *PanelBlock) {
block.Headerless = value
}
}
// GridColumns sets the number of columns in a grid.
func GridColumns(value int) GridOption {
return func(block *GridBlock) {
block.Columns = value
}
}
// GridGap sets the gap between grid items in pixels.
func GridGap(value int) GridOption {
return func(block *GridBlock) {
block.Gap = value
}
}
// GridBorder toggles the grid border.
func GridBorder(value bool) GridOption {
return func(block *GridBlock) {
block.Border = value
}
}
// GridInsetMode sets the inset mode of the grid.
func GridInsetMode(value InsetMode) GridOption {
return func(block *GridBlock) {
block.InsetMode = value
}
}
// CardListColumns sets the number of columns in a card list.
func CardListColumns(value int) CardListOption {
return func(block *CardListBlock) {
block.Columns = value
}
}
// CardListGap sets the gap between card list items in pixels.
func CardListGap(value int) CardListOption {
return func(block *CardListBlock) {
block.Gap = value
}
}
// CardListBorder toggles borders around cards.
func CardListBorder(value bool) CardListOption {
return func(block *CardListBlock) {
block.Border = value
}
}
// CardListInsetMode sets the inset mode of the card list.
func CardListInsetMode(value InsetMode) CardListOption {
return func(block *CardListBlock) {
block.InsetMode = value
}
}
// SpacerSize sets spacer height in pixels.
func SpacerSize(value int) SpacerOption {
return func(block *SpacerBlock) {
block.Size = value
}
}
// DividerStyle sets the divider variant.
func DividerStyle(value DividerVariant) DividerOption {
return func(block *DividerBlock) {
block.Variant = value
}
}
// DividerThickness sets divider thickness in pixels.
func DividerThickness(value int) DividerOption {
return func(block *DividerBlock) {
block.Thickness = value
}
}
// DividerInset sets divider inset in pixels.
func DividerInset(value int) DividerOption {
return func(block *DividerBlock) {
block.Inset = value
}
}
// DividerLabel sets divider label text.
func DividerLabel(value string) DividerOption {
return func(block *DividerBlock) {
block.Label = value
}
}
// DividerInsetMode sets the inset mode of the divider.
func DividerInsetMode(value InsetMode) DividerOption {
return func(block *DividerBlock) {
block.InsetMode = value
}
}
// CalloutOption configures a CalloutBlock.
type CalloutOption func(*CalloutBlock)
// MessageOption configures a MessageBlock.
type MessageOption func(*MessageBlock)
// MessageDigestOption configures a MessageDigestBlock.
type MessageDigestOption func(*MessageDigestBlock)
// ProgressOption configures a ProgressBlock.
type ProgressOption func(*ProgressBlock)
// DistributionOption configures a DistributionBlock.
type DistributionOption func(*DistributionBlock)
// AttachmentOption configures an AttachmentBlock.
type AttachmentOption func(*AttachmentBlock)
// VerificationCodeOption configures a VerificationCodeBlock.
type VerificationCodeOption func(*VerificationCodeBlock)
// EmptyStateOption configures an EmptyStateBlock.
type EmptyStateOption func(*EmptyStateBlock)
// SummaryCardOption configures a SummaryCardBlock.
type SummaryCardOption func(*SummaryCardBlock)
// PriceSummaryOption configures a PriceSummaryBlock.
type PriceSummaryOption func(*PriceSummaryBlock)
// HeroOption configures a HeroBlock.
type HeroOption func(*HeroBlock)
// CalloutStyle sets the callout variant.
func CalloutStyle(variant CalloutVariant) CalloutOption {
return func(block *CalloutBlock) {
block.Variant = variant
}
}
// CalloutLink sets the callout link label and URL.
func CalloutLink(label, url string) CalloutOption {
return func(block *CalloutBlock) {
block.LinkLabel = label
block.LinkURL = url
}
}
// CalloutInsetMode sets the inset mode of the callout.
func CalloutInsetMode(value InsetMode) CalloutOption {
return func(block *CalloutBlock) {
block.InsetMode = value
}
}
// MessageInsetMode sets the inset mode of the message block.
func MessageInsetMode(value InsetMode) MessageOption {
return func(block *MessageBlock) {
block.InsetMode = value
}
}
// MessageDigestTitle sets the title of a message digest block.
func MessageDigestTitle(value string) MessageDigestOption {
return func(block *MessageDigestBlock) {
block.Title = value
}
}
// MessageDigestSubtitle sets the subtitle of a message digest block.
func MessageDigestSubtitle(value string) MessageDigestOption {
return func(block *MessageDigestBlock) {
block.Subtitle = value
}
}
// MessageDigestFooter sets the footer text of a message digest block.
func MessageDigestFooter(value string) MessageDigestOption {
return func(block *MessageDigestBlock) {
block.Footer = value
}
}
// MessageDigestEmptyText sets empty-state text for a message digest.
func MessageDigestEmptyText(value string) MessageDigestOption {
return func(block *MessageDigestBlock) {
block.EmptyText = value
}
}
// MessageDigestMaxItems sets the maximum number of digest items to render.
func MessageDigestMaxItems(value int) MessageDigestOption {
return func(block *MessageDigestBlock) {
block.MaxItems = value
}
}
// MessageDigestInsetMode sets the inset mode of the message digest block.
func MessageDigestInsetMode(value InsetMode) MessageDigestOption {
return func(block *MessageDigestBlock) {
block.InsetMode = value
}
}
// TimelineOption configures a TimelineBlock.
type TimelineOption func(*TimelineBlock)
// TimelineCurrentIndex sets the currently active timeline index.
func TimelineCurrentIndex(value int) TimelineOption {
return func(block *TimelineBlock) {
block.HasCurrentIndex = true
block.CurrentIndex = value
}
}
// TimelineAggregateHeader sets the aggregate header text for timeline groups.
func TimelineAggregateHeader(value string) TimelineOption {
return func(block *TimelineBlock) {
block.AggregateHeader = value
}
}
// TimelineInsetMode sets the inset mode of the timeline.
func TimelineInsetMode(value InsetMode) TimelineOption {
return func(block *TimelineBlock) {
block.InsetMode = value
}
}
// StackedBarOption configures a StackedBarBlock.
type StackedBarOption func(*StackedBarBlock)
// StackedBarTotal sets the summary label and value shown with the stacked bar.
func StackedBarTotal(label, value string) StackedBarOption {
return func(block *StackedBarBlock) {
block.TotalLabel = label
block.TotalValue = value
}
}
// StackedBarInsetMode sets the inset mode of the stacked bar block.
func StackedBarInsetMode(value InsetMode) StackedBarOption {
return func(block *StackedBarBlock) {
block.InsetMode = value
}
}
// TableOption configures a TableBlock.
type TableOption func(*TableBlock)
// HorizontalBarChartOption configures a HorizontalBarChartBlock.
type HorizontalBarChartOption func(*HorizontalBarChartBlock)
// VerticalBarChartOption configures a VerticalBarChartBlock.
type VerticalBarChartOption func(*VerticalBarChartBlock)
// SparklineOption configures a SparklineBlock.
type SparklineOption func(*SparklineBlock)
// TilesOption configures a TilesBlock.
type TilesOption func(*TilesBlock)
// SparklineDelta sets the delta label shown with the sparkline.
func SparklineDelta(value string) SparklineOption {
return func(block *SparklineBlock) {
block.Delta = value
}
}
// SparklineDeltaSemantic sets semantic styling for the sparkline delta value.
func SparklineDeltaSemantic(value StatDeltaSemantic) SparklineOption {
return func(block *SparklineBlock) {
block.DeltaSemantic = value
}
}
// SparklineTone sets the tone of the sparkline.
func SparklineTone(value Tone) SparklineOption {
return func(block *SparklineBlock) {
block.Tone = value
}
}
// SparklineInsetMode sets the inset mode of the sparkline block.
func SparklineInsetMode(value InsetMode) SparklineOption {
return func(block *SparklineBlock) {
block.InsetMode = value
}
}
// HorizontalBarChartThickness sets bar thickness in pixels.
func HorizontalBarChartThickness(value int) HorizontalBarChartOption {
return func(block *HorizontalBarChartBlock) {
block.Thickness = value
}
}
// HorizontalBarChartLabelsInsideBars toggles labels inside bars.
func HorizontalBarChartLabelsInsideBars(value bool) HorizontalBarChartOption {
return func(block *HorizontalBarChartBlock) {
block.ShowLabelsInsideBars = value
}
}
// HorizontalBarChartTransparentBackground toggles transparent chart background.
func HorizontalBarChartTransparentBackground(value bool) HorizontalBarChartOption {
return func(block *HorizontalBarChartBlock) {
block.TransparentBackground = value
}
}
// HorizontalBarChartTone sets the tone of the horizontal bar chart.
func HorizontalBarChartTone(value Tone) HorizontalBarChartOption {
return func(block *HorizontalBarChartBlock) {
block.Tone = value
}
}
// HorizontalBarChartInsetMode sets the inset mode of the horizontal bar chart.
func HorizontalBarChartInsetMode(value InsetMode) HorizontalBarChartOption {
return func(block *HorizontalBarChartBlock) {
block.InsetMode = value
}
}
// VerticalBarChartHeight sets chart height in pixels.
func VerticalBarChartHeight(value int) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Height = value
}
}
// VerticalBarChartTitle sets the chart title.
func VerticalBarChartTitle(value string) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Title = value
}
}
// VerticalBarChartSubtitle sets the chart subtitle.
func VerticalBarChartSubtitle(value string) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Subtitle = value
}
}
// VerticalBarChartNormalize enables per-column normalization where segment heights
// fill the available positive/negative region in each column.
//
// For mixed-sign datasets (any negative value present), Myrtle automatically
// falls back to magnitude scaling to preserve cross-column comparability.
func VerticalBarChartNormalize(value bool) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Normalize = value
}
}
// VerticalBarChartColumnGap sets spacing between columns in pixels.
func VerticalBarChartColumnGap(value int) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.HasColumnGap = true
block.ColumnGap = value
}
}
// VerticalBarChartOuterGap sets outer chart padding in pixels.
func VerticalBarChartOuterGap(value int) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.HasOuterGap = true
block.OuterGap = value
}
}
// VerticalBarChartCategoryGap is kept as a compatibility alias.
// Prefer VerticalBarChartColumnGap for clarity.
func VerticalBarChartCategoryGap(value int) VerticalBarChartOption {
return VerticalBarChartColumnGap(value)
}
// VerticalBarChartTransparentBackground toggles a transparent chart background.
func VerticalBarChartTransparentBackground(value bool) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.TransparentBackground = value
}
}
// VerticalBarChartTone sets the tone of the vertical bar chart.
func VerticalBarChartTone(value Tone) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Tone = value
}
}
// VerticalBarChartInsetMode sets the inset mode of the vertical bar chart.
func VerticalBarChartInsetMode(value InsetMode) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.InsetMode = value
}
}
// VerticalBarChartLegendPlacement sets where the legend is rendered.
func VerticalBarChartLegendPlacement(value VerticalBarChartLegendPlacementValue) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.LegendPlacement = normalizedLegendPlacement(value)
}
}
// VerticalBarChartLegend sets legend items for the chart.
func VerticalBarChartLegend(items []VerticalBarChartLegendItem) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
if len(items) == 0 {
block.Legend = nil
return
}
block.Legend = append([]VerticalBarChartLegendItem(nil), items...)
}
}
// VerticalBarChartLegendConfigOption sets legend placement and items together.
func VerticalBarChartLegendConfigOption(value VerticalBarChartLegendConfig) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.LegendPlacement = normalizedLegendPlacement(value.Placement)
if len(value.Items) == 0 {
block.Legend = nil
return
}
block.Legend = append([]VerticalBarChartLegendItem(nil), value.Items...)
}
}
// VerticalBarChartAxisShowBaseline toggles rendering the baseline.
func VerticalBarChartAxisShowBaseline(value bool) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.ShowBaseline = value
}
}
// VerticalBarChartAxisShowYTicks toggles rendering Y-axis ticks.
func VerticalBarChartAxisShowYTicks(value bool) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.ShowYTicks = value
}
}
// VerticalBarChartAxisDrawYAxisLine toggles rendering the Y-axis line.
func VerticalBarChartAxisDrawYAxisLine(value bool) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.HasDrawYAxisLine = true
block.Axis.DrawYAxisLine = value
}
}
// VerticalBarChartAxisShowCategoryLabels toggles category labels on the axis.
func VerticalBarChartAxisShowCategoryLabels(value bool) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.HasShowCategoryLabels = true
block.Axis.ShowCategoryLabels = value
}
}
// VerticalBarChartAxisLabelFormat sets axis label formatting style.
func VerticalBarChartAxisLabelFormat(value VerticalBarChartAxisLabelFormatValue) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.LabelFormat = value
}
}
// VerticalBarChartAxisMin sets an explicit minimum axis value.
func VerticalBarChartAxisMin(value float64) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.HasMin = true
block.Axis.Min = value
}
}
// VerticalBarChartAxisMax sets an explicit maximum axis value.
func VerticalBarChartAxisMax(value float64) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis.HasMax = true
block.Axis.Max = value
}
}
// VerticalBarChartAxisConfig replaces the full axis configuration.
func VerticalBarChartAxisConfig(value VerticalBarChartAxis) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.Axis = value
}
}
// VerticalBarChartValueLabelsOption sets value label rendering options.
func VerticalBarChartValueLabelsOption(value VerticalBarChartValueLabels) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.ValueLabels = value
}
}
// VerticalBarChartValueFormatterOption sets value formatting rules.
func VerticalBarChartValueFormatterOption(value VerticalBarChartValueFormatter) VerticalBarChartOption {
return func(block *VerticalBarChartBlock) {
block.ValueFormatter = value
}
}
// TilesColumns sets the number of tile columns.
func TilesColumns(value int) TilesOption {
return func(block *TilesBlock) {
block.Columns = value
}
}
// TilesBorder toggles tile borders.
func TilesBorder(value bool) TilesOption {
return func(block *TilesBlock) {
block.Border = value
}
}
// TilesTransparentBackground toggles transparent tile backgrounds.
func TilesTransparentBackground(value bool) TilesOption {
return func(block *TilesBlock) {
block.TransparentBackground = value
}
}
// TilesAlign sets alignment for tile content.
func TilesAlign(value TileAlignment) TilesOption {
return func(block *TilesBlock) {
block.Alignment = value
}
}
// TilesInsetMode sets the inset mode of the tiles block.
func TilesInsetMode(value InsetMode) TilesOption {
return func(block *TilesBlock) {
block.InsetMode = value
}
}
// TableZebraRows toggles zebra striping for table rows.
func TableZebraRows(value bool) TableOption {
return func(block *TableBlock) {
block.ZebraRows = value
}
}
// TableTitle sets the table header text.
func TableTitle(value string) TableOption {
return func(block *TableBlock) {
block.Header = value
}
}
// TableLegendSwatches sets legend swatch colors for the table.
func TableLegendSwatches(value []string) TableOption {
return func(block *TableBlock) {
block.HasLegendSwatches = true
if len(value) == 0 {
block.LegendSwatches = nil
return
}
block.LegendSwatches = append([]string(nil), value...)
}
}
// TableCompact toggles compact table spacing.
func TableCompact(value bool) TableOption {
return func(block *TableBlock) {
block.Compact = value
}
}
// TableDensity sets the table density mode.
func TableDensity(value TableDensityValue) TableOption {
return func(block *TableBlock) {
block.Density = value
}
}
// TableHeaderTone sets the table header tone.
func TableHeaderTone(value TableHeaderToneValue) TableOption {
return func(block *TableBlock) {
block.HeaderTone = value
}
}
// TableBorderStyle sets the table border style.
func TableBorderStyle(value TableBorderStyleValue) TableOption {
return func(block *TableBlock) {
block.BorderStyle = value
}
}
// TableRightAlignNumericColumns toggles right alignment for numeric columns.
func TableRightAlignNumericColumns(value bool) TableOption {
return func(block *TableBlock) {
block.RightAlignNumericColumns = value
}
}
// TableEmphasizeTotalRow toggles emphasized styling for the total row.
func TableEmphasizeTotalRow(value bool) TableOption {
return func(block *TableBlock) {
block.EmphasizeTotalRow = value
}
}
// TableInsetMode sets the inset mode of the table.
func TableInsetMode(value InsetMode) TableOption {
return func(block *TableBlock) {
block.InsetMode = value
}
}
// TableColumnAlignments sets explicit alignment per table column index.
func TableColumnAlignments(value map[int]TableColumnAlignmentValue) TableOption {
return func(block *TableBlock) {
if len(value) == 0 {
block.ColumnAlignments = nil
return
}
alignments := make(map[int]TableColumnAlignmentValue, len(value))
for index, alignment := range value {
alignments[index] = alignment
}
block.ColumnAlignments = alignments
}
}
// ProgressInsetMode sets the inset mode of the progress block.
func ProgressInsetMode(value InsetMode) ProgressOption {
return func(block *ProgressBlock) {
block.InsetMode = value
}
}
// DistributionInsetMode sets the inset mode of the distribution block.
func DistributionInsetMode(value InsetMode) DistributionOption {
return func(block *DistributionBlock) {
block.InsetMode = value
}
}
// AttachmentInsetMode sets the inset mode of the attachment block.
func AttachmentInsetMode(value InsetMode) AttachmentOption {
return func(block *AttachmentBlock) {
block.InsetMode = value
}
}
// VerificationCodeInsetMode sets the inset mode of the verification code block.
func VerificationCodeInsetMode(value InsetMode) VerificationCodeOption {
return func(block *VerificationCodeBlock) {
block.InsetMode = value
}
}
// VerificationCodeTone sets the semantic tone of the verification code block.
func VerificationCodeTone(value Tone) VerificationCodeOption {
return func(block *VerificationCodeBlock) {
block.Tone = value
}
}
// VerificationCodeMonospace toggles monospace rendering for the code value.
func VerificationCodeMonospace(value bool) VerificationCodeOption {
return func(block *VerificationCodeBlock) {
block.UseMonospace = value
block.useMonospaceSet = true
}
}
// VerificationCodeSpacing sets the code letter spacing in em units.
func VerificationCodeSpacing(value float64) VerificationCodeOption {
return func(block *VerificationCodeBlock) {
block.CharacterSpacingEm = value
block.characterSpacingEmSet = true
}
}
// EmptyStateInsetMode sets the inset mode of the empty state block.
func EmptyStateInsetMode(value InsetMode) EmptyStateOption {
return func(block *EmptyStateBlock) {
block.InsetMode = value
}
}
// EmptyStateTone sets the visual tone of the empty state block.
func EmptyStateTone(value Tone) EmptyStateOption {
return func(block *EmptyStateBlock) {
block.Tone = value
}
}
// SummaryCardInsetMode sets the inset mode of the summary card block.
func SummaryCardInsetMode(value InsetMode) SummaryCardOption {
return func(block *SummaryCardBlock) {
block.InsetMode = value
}
}
// SummaryCardTone sets the visual tone of the summary card block.
func SummaryCardTone(value Tone) SummaryCardOption {
return func(block *SummaryCardBlock) {
block.Tone = value
}
}
// PriceSummaryInsetMode sets the inset mode of the price summary block.
func PriceSummaryInsetMode(value InsetMode) PriceSummaryOption {
return func(block *PriceSummaryBlock) {
block.InsetMode = value
}
}
// HeroInsetMode sets the inset mode of the hero block.
func HeroInsetMode(value InsetMode) HeroOption {
return func(block *HeroBlock) {
block.InsetMode = value
}
}
// HeroTone sets the visual tone of the hero block.
func HeroTone(value Tone) HeroOption {
return func(block *HeroBlock) {
block.Tone = value
}
}
// HeroEyebrow sets the eyebrow text of the hero block.
func HeroEyebrow(value string) HeroOption {
return func(block *HeroBlock) {
block.Eyebrow = value
}
}
// HeroImage sets the hero image URL and alt text.
func HeroImage(url, alt string) HeroOption {
return func(block *HeroBlock) {
block.ImageURL = url
block.ImageAlt = alt
}
}
// Add appends a block to the builder.
// Use this for custom or preconstructed block instances.
func (builder *Builder) Add(block Block) *Builder {
builder.mu.Lock()
defer builder.mu.Unlock()
builder.blocks = append(builder.blocks, block)
return builder
}
// AddText appends a text block to the builder.
// Text blocks render paragraph-style body copy.
func (builder *Builder) AddText(text string, options ...TextOption) *Builder {
block := TextBlock{Text: text}
for _, option := range options {
option(&block)
}
builder.Add(block)
return builder
}
// AddHeading appends a heading block to the builder.
// Heading blocks introduce and structure content sections.
func (builder *Builder) AddHeading(text string, options ...HeadingOption) *Builder {
block := HeadingBlock{Text: text, Level: 2}
for _, option := range options {
option(&block)
}
return builder.Add(block)
}
// AddSpacer appends a spacer block to the builder.
// Spacer blocks create vertical rhythm between nearby sections.
func (builder *Builder) AddSpacer(options ...SpacerOption) *Builder {
block := SpacerBlock{Size: 16}
for _, option := range options {
option(&block)
}
return builder.Add(block)
}
// AddList appends a list block to the builder.
// List blocks render ordered or unordered bullet content.
func (builder *Builder) AddList(items []string, ordered bool) *Builder {
return builder.Add(ListBlock{Items: items, Ordered: ordered})
}
// AddKeyValue appends a key-value block to the builder.
// Key-value blocks present compact labeled facts and values.
func (builder *Builder) AddKeyValue(header string, pairs []KeyValuePair) *Builder {
return builder.Add(KeyValueBlock{Header: header, Pairs: pairs})
}
// AddHorizontalBarChart appends a horizontal bar chart block to the builder.
// This block compares categories with left-to-right bars.
func (builder *Builder) AddHorizontalBarChart(header string, items []HorizontalBarChartItem, options ...HorizontalBarChartOption) *Builder {
block := HorizontalBarChartBlock{Header: header, Items: append([]HorizontalBarChartItem(nil), items...)}
for _, option := range options {
option(&block)
}
return builder.Add(block)
}
// AddVerticalBarChart appends a vertical bar chart block to the builder.
// This block compares categories with bottom-to-top columns.
func (builder *Builder) AddVerticalBarChart(axisLabels []string, series []VerticalBarChartSeries, options ...VerticalBarChartOption) *Builder {
block := VerticalBarChartBlock{
AxisLabels: append([]string(nil), axisLabels...),
Series: append([]VerticalBarChartSeries(nil), series...),
}
for _, option := range options {
option(&block)
}
return builder.Add(block)
}
// AddSparkline appends a sparkline block to the builder.
// Sparkline blocks summarize a short trend inline with key values.
func (builder *Builder) AddSparkline(header, label, value string, points []int, options ...SparklineOption) *Builder {
block := SparklineBlock{Header: header, Label: label, Value: value, Points: append([]int(nil), points...)}
for _, option := range options {
option(&block)
}
return builder.Add(block)
}
// AddStackedBar appends a stacked bar block to the builder.
// Stacked bars show part-to-whole composition per row.
func (builder *Builder) AddStackedBar(header string, rows []StackedBarRow, options ...StackedBarOption) *Builder {
block := StackedBarBlock{Header: header, Rows: append([]StackedBarRow(nil), rows...)}
for _, option := range options {
option(&block)
}
return builder.Add(block)
}
// AddProgress appends a progress block to the builder.
// Progress blocks communicate completion toward one or more goals.