@vev/silke 1.1.6 → 1.1.8

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.js +34 -34
  3. package/dist/index.js.LEGAL.txt +12 -12
  4. package/dist/styles.css +4416 -4020
  5. package/dist/types/components/index.d.ts +3 -2
  6. package/dist/types/components/silke-button/silke-dropdown-button.d.ts +8 -13
  7. package/dist/types/components/silke-card/silke-card-grid.d.ts +33 -1
  8. package/dist/types/components/silke-command-text-field/image-utils.d.ts +20 -0
  9. package/dist/types/components/silke-command-text-field/index.d.ts +4 -0
  10. package/dist/types/components/silke-command-text-field/silke-command-parser.d.ts +3 -0
  11. package/dist/types/components/silke-command-text-field/silke-command-parser.spec.d.ts +1 -0
  12. package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +46 -0
  13. package/dist/types/components/silke-command-text-field/utils.d.ts +61 -0
  14. package/dist/types/components/silke-command-text-field/utils.spec.d.ts +1 -0
  15. package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
  16. package/dist/types/components/silke-form-schema/fields/color-field.d.ts +3 -0
  17. package/dist/types/components/silke-form-schema/schema-utils.d.ts +6 -1
  18. package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +1 -0
  19. package/dist/types/components/silke-image/silke-image.d.ts +2 -1
  20. package/dist/types/components/silke-list/index.d.ts +1 -0
  21. package/dist/types/components/silke-list/silke-list-item.d.ts +24 -6
  22. package/dist/types/components/silke-list/silke-list.d.ts +9 -9
  23. package/dist/types/components/silke-list/types.d.ts +19 -0
  24. package/dist/types/components/silke-list/utils.d.ts +3 -0
  25. package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +1 -0
  26. package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +6 -1
  27. package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +3 -1
  28. package/dist/types/components/silke-shortcut-button/index.d.ts +1 -0
  29. package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +15 -0
  30. package/dist/types/components/silke-tag/silke-tag.d.ts +1 -1
  31. package/dist/types/icons.d.ts +32 -0
  32. package/jest.config.js +2 -3
  33. package/package.json +7 -2
  34. package/src/_variables.scss +125 -129
  35. package/src/components/index.ts +3 -2
  36. package/src/components/silke-action-box/silke-action-box.scss +2 -3
  37. package/src/components/silke-alert-banner/silke-alert-banner.scss +9 -10
  38. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +2 -2
  39. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -12
  40. package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +3 -2
  41. package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +63 -44
  42. package/src/components/silke-box/silke-box.mdx +321 -21
  43. package/src/components/silke-box/silke-box.scss +5 -5
  44. package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +147 -9
  45. package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
  46. package/src/components/silke-button/silke-big-button.scss +1 -1
  47. package/src/components/silke-button/silke-button.scss +24 -15
  48. package/src/components/silke-button/silke-dropdown-button.mdx +67 -0
  49. package/src/components/silke-button/silke-dropdown-button.tsx +40 -122
  50. package/src/components/silke-card/silke-card-grid.tsx +5 -3
  51. package/src/components/silke-card/silke-card.scss +8 -7
  52. package/src/components/silke-card/silke-card.tsx +7 -1
  53. package/src/components/silke-checkbox/silke-checkbox.mdx +139 -14
  54. package/src/components/silke-checkbox/silke-checkbox.scss +11 -11
  55. package/src/components/silke-color-picker/color-picker.scss +8 -8
  56. package/src/components/silke-color-swatches/silke-color-swatches.mdx +130 -0
  57. package/src/components/silke-command-text-field/image-utils.ts +71 -0
  58. package/src/components/silke-command-text-field/index.ts +12 -0
  59. package/src/components/silke-command-text-field/silke-command-parser.spec.ts +89 -0
  60. package/src/components/silke-command-text-field/silke-command-parser.ts +47 -0
  61. package/src/components/silke-command-text-field/silke-command-text-field.mdx +301 -0
  62. package/src/components/silke-command-text-field/silke-command-text-field.module.scss +119 -0
  63. package/src/components/silke-command-text-field/silke-command-text-field.tsx +672 -0
  64. package/src/components/silke-command-text-field/utils.spec.ts +366 -0
  65. package/src/components/silke-command-text-field/utils.ts +287 -0
  66. package/src/components/silke-conditions-input/silke-conditions-input.scss +4 -4
  67. package/src/components/silke-content-column/silke-content-column.scss +1 -1
  68. package/src/components/silke-context-menu/silke-context-menu.scss +3 -4
  69. package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
  70. package/src/components/silke-css-number-field/silke-css-number-field.scss +14 -12
  71. package/src/components/silke-divider/silke-divider.mdx +154 -32
  72. package/src/components/silke-divider/silke-divider.scss +3 -2
  73. package/src/components/silke-drawer/silke-drawer.scss +6 -2
  74. package/src/components/silke-form/silke-form.mdx +254 -27
  75. package/src/components/silke-form-schema/fields/array-field-inline.tsx +1 -0
  76. package/src/components/silke-form-schema/fields/array-field-modal.tsx +9 -4
  77. package/src/components/silke-form-schema/fields/array-field.tsx +27 -3
  78. package/src/components/silke-form-schema/fields/color-field.tsx +36 -0
  79. package/src/components/silke-form-schema/fields/styles.scss +34 -35
  80. package/src/components/silke-form-schema/schema-utils.ts +27 -1
  81. package/src/components/silke-form-schema/silke-schema-field.tsx +2 -0
  82. package/src/components/silke-form-schema/silke-schema-fields.tsx +4 -3
  83. package/src/components/silke-gradient-picker/silke-gradient-picker.module.scss +2 -2
  84. package/src/components/silke-icon/silke-icon.mdx +212 -8
  85. package/src/components/silke-icon/silke-icon.scss +10 -2
  86. package/src/components/silke-icon/silke-icon.tsx +1 -0
  87. package/src/components/silke-icon/silke-stacked-icon.scss +42 -45
  88. package/src/components/silke-icon-browser/silke-icon-browser.mdx +143 -0
  89. package/src/components/silke-image/silke-image-color-backdrop.scss +6 -6
  90. package/src/components/silke-image/silke-image.mdx +189 -41
  91. package/src/components/silke-image/silke-image.scss +3 -3
  92. package/src/components/silke-image/silke-image.tsx +14 -1
  93. package/src/components/silke-link/silke-link.scss +3 -5
  94. package/src/components/silke-list/index.ts +1 -0
  95. package/src/components/silke-list/silke-list-item.mdx +83 -0
  96. package/src/components/silke-list/silke-list-item.scss +119 -0
  97. package/src/components/silke-list/silke-list-item.tsx +137 -12
  98. package/src/components/silke-list/silke-list.mdx +108 -13
  99. package/src/components/silke-list/silke-list.scss +8 -15
  100. package/src/components/silke-list/silke-list.tsx +63 -9
  101. package/src/components/silke-list/types.ts +22 -0
  102. package/src/components/silke-list/utils.ts +24 -0
  103. package/src/components/silke-loader/silke-loader.mdx +139 -5
  104. package/src/components/silke-loader/silke-loader.scss +1 -1
  105. package/src/components/silke-modal/silke-modal.scss +9 -9
  106. package/src/components/silke-navigation-link/silke-navigation-link.mdx +27 -2
  107. package/src/components/silke-navigation-link/silke-navigation-link.scss +34 -40
  108. package/src/components/silke-navigation-link/silke-navigation-link.tsx +7 -6
  109. package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +228 -31
  110. package/src/components/silke-overflow-menu/silke-overflow-menu.scss +8 -8
  111. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +14 -8
  112. package/src/components/silke-popover/silke-popover.scss +5 -5
  113. package/src/components/silke-popover-native/silke-popover-native.scss +93 -78
  114. package/src/components/silke-popover-native/silke-popover-native.tsx +4 -0
  115. package/src/components/silke-popover-native/use-popover-positioning.ts +1 -3
  116. package/src/components/silke-progress-indicator/silke-progress-indicator.scss +1 -1
  117. package/src/components/silke-radio-button/silke-radio-button.scss +18 -11
  118. package/src/components/silke-search-field/silke-search-field.mdx +161 -7
  119. package/src/components/silke-shortcut-button/index.ts +1 -0
  120. package/src/components/silke-shortcut-button/silke-shortcut-button.mdx +89 -0
  121. package/src/components/silke-shortcut-button/silke-shortcut-button.scss +145 -0
  122. package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +55 -0
  123. package/src/components/silke-skeleton/silke-skeleton.mdx +109 -0
  124. package/src/components/silke-skeleton/silke-skeleton.scss +1 -1
  125. package/src/components/silke-slider/silke-slider.module.scss +19 -19
  126. package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +3 -3
  127. package/src/components/silke-sortable-list/silke-sortable-list.scss +4 -5
  128. package/src/components/silke-table/silke-table.scss +1 -1
  129. package/src/components/silke-tabs/silke-tabs.scss +3 -3
  130. package/src/components/silke-tag/silke-tag.mdx +179 -43
  131. package/src/components/silke-tag/silke-tag.scss +50 -13
  132. package/src/components/silke-tag/silke-tag.tsx +17 -7
  133. package/src/components/silke-text/silke-text.scss +6 -4
  134. package/src/components/silke-text/silke-title.scss +7 -14
  135. package/src/components/silke-text-field/silke-text-field.scss +9 -9
  136. package/src/components/silke-text-field/silke-text-field.tsx +1 -1
  137. package/src/components/silke-tile/silke-tile.scss +7 -3
  138. package/src/components/silke-toast-notification/silke-toast-notification.scss +4 -5
  139. package/src/components/silke-toggle/silke-toggle.mdx +163 -33
  140. package/src/components/silke-toggle/silke-toggle.scss +4 -4
  141. package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
  142. package/src/components/silke-tooltip/silke-shortcuts.tsx +3 -3
  143. package/src/components/silke-tooltip/silke-tooltip.scss +11 -16
  144. package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +9 -7
  145. package/src/components/silke-virtual/silke-virtual.mdx +161 -0
  146. package/src/components/silke-virtual/silke-virtual.scss +8 -8
  147. package/src/icons.tsx +58 -1
  148. package/src/styles/core.scss +42 -45
  149. package/src/styles/math.scss +66 -66
  150. package/tsconfig.build.json +2 -6
  151. package/tsconfig.build.tsbuildinfo +1 -1
  152. package/tsconfig.json +3 -14
  153. package/dist/types/components/silke-action-list/index.d.ts +0 -1
  154. package/dist/types/components/silke-action-list/silke-action-list.d.ts +0 -11
  155. package/dist/types/components/silke-list-card/index.d.ts +0 -1
  156. package/dist/types/components/silke-list-card/silke-list-card.d.ts +0 -14
  157. package/src/components/silke-action-list/index.ts +0 -1
  158. package/src/components/silke-action-list/silke-action-list.mdx +0 -48
  159. package/src/components/silke-action-list/silke-action-list.scss +0 -21
  160. package/src/components/silke-action-list/silke-action-list.tsx +0 -85
  161. package/src/components/silke-list-card/index.ts +0 -1
  162. package/src/components/silke-list-card/silke-list-card.mdx +0 -46
  163. package/src/components/silke-list-card/silke-list-card.scss +0 -57
  164. package/src/components/silke-list-card/silke-list-card.tsx +0 -63
@@ -81,6 +81,26 @@ const putMatchingItemsOnTop = (filteredItems: Entry<any>[], searchString: string
81
81
  return [...itemsWithMatch, ...itemsWithNoMatch];
82
82
  };
83
83
 
84
+ type GroupedEntries<T> = { groupLabel?: string; items: Entry<T>[] };
85
+
86
+ function groupEntriesByLabel<T>(entries: Entry<T>[]): GroupedEntries<T>[] {
87
+ const grouped: GroupedEntries<T>[] = [];
88
+ let currentGroup: GroupedEntries<T> | null = null;
89
+
90
+ entries.forEach((entry) => {
91
+ const groupLabel = !entry.divider ? (entry as Data<T>).groupLabel : undefined;
92
+
93
+ if (!currentGroup || currentGroup.groupLabel !== groupLabel) {
94
+ currentGroup = { groupLabel, items: [] };
95
+ grouped.push(currentGroup);
96
+ }
97
+
98
+ currentGroup.items.push(entry);
99
+ });
100
+
101
+ return grouped;
102
+ }
103
+
84
104
  export const useMatchingItemsOnTop = (
85
105
  filteredItems: Entry<any>[],
86
106
  searchString?: string,
@@ -122,16 +142,19 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
122
142
  const size = form.size || context.size || 'base';
123
143
 
124
144
  const inputField = useRef<HTMLDivElement>();
125
- const isSelected = (value: T): boolean => {
126
- if (form.multiple) {
127
- const values = Array.isArray(form.value) ? form.value : [];
128
- for (const v of values) {
129
- if (isEqual(v, value) || isEqual(value, selectedVariableKey)) return true;
145
+ const isSelected = useCallback(
146
+ (value: T): boolean => {
147
+ if (form.multiple) {
148
+ const values = Array.isArray(form.value) ? form.value : [];
149
+ for (const v of values) {
150
+ if (isEqual(v, value) || isEqual(value, selectedVariableKey)) return true;
151
+ }
152
+ return false;
130
153
  }
131
- return false;
132
- }
133
- return isEqual(value, form.value) || isEqual(value, selectedVariableKey);
134
- };
154
+ return isEqual(value, form.value) || isEqual(value, selectedVariableKey);
155
+ },
156
+ [form.multiple, form.value, selectedVariableKey],
157
+ );
135
158
 
136
159
  function getIndexInDir(
137
160
  currentIndex: number,
@@ -230,7 +253,15 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
230
253
  ];
231
254
  }, [itemsWithMatchingOnTop, maxDisplayedItems]);
232
255
 
233
- const filteredDataEntries = displayedItems.filter((entry) => !entry.divider) as Data<T>[];
256
+ const sortedItems = useMemo<Entry<T>[]>(
257
+ () => [...displayedItems].sort(sort),
258
+ [displayedItems, sort],
259
+ );
260
+ const groupedItems = useMemo(() => groupEntriesByLabel(sortedItems), [sortedItems]);
261
+ const navigableItems = useMemo(
262
+ () => sortedItems.filter((entry) => !entry.divider) as Data<T>[],
263
+ [sortedItems],
264
+ );
234
265
 
235
266
  const isItemSelected = (item: string): boolean => {
236
267
  return (
@@ -270,22 +301,22 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
270
301
  useParentScroll(containerRef, updatePlacement);
271
302
  useWindowResize(updatePlacement);
272
303
 
273
- const getIndexOfFirstSelectedItem = () => {
274
- for (let i = 0; i < filteredItems.length; i++) {
275
- if (isSelected(filteredItems[i].value)) {
304
+ const getIndexOfFirstSelectedItem = useCallback(() => {
305
+ for (let i = 0; i < navigableItems.length; i++) {
306
+ if (isSelected(navigableItems[i].value)) {
276
307
  return i;
277
308
  }
278
309
  }
279
310
 
280
311
  return 0;
281
- };
312
+ }, [isSelected, navigableItems]);
282
313
 
283
314
  useEffect(() => {
284
315
  if (highlight === undefined) {
285
316
  const indexOfFirstSelectedItem = getIndexOfFirstSelectedItem();
286
317
  setHighlight(indexOfFirstSelectedItem);
287
318
  }
288
- }, []);
319
+ }, [getIndexOfFirstSelectedItem, highlight]);
289
320
 
290
321
  const handleSelect = (item?: Entry<T>) => {
291
322
  inputField?.current?.focus();
@@ -331,7 +362,7 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
331
362
  setSearchText('');
332
363
  setPrevSearchText('');
333
364
  } else {
334
- const item = highlight !== undefined && filteredDataEntries[highlight];
365
+ const item = highlight !== undefined && navigableItems[highlight];
335
366
  if (item) {
336
367
  handleSelect(item);
337
368
  } else {
@@ -350,7 +381,7 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
350
381
  e.preventDefault();
351
382
  e.stopPropagation();
352
383
  const { key } = e;
353
- setHighlight((value) => getIndexInDir(value || 0, filteredDataEntries.length, key));
384
+ setHighlight((value) => getIndexInDir(value || 0, navigableItems.length, key));
354
385
  break;
355
386
  }
356
387
  case 'Escape': {
@@ -388,12 +419,13 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
388
419
  rounded={size === 's' ? 'tiny' : 'small'}
389
420
  shadow="level3"
390
421
  data-cy={dataCy ? dataCy + '-dropdown' : undefined}
391
- bg="neutral-20"
422
+ bg="neutral-10"
392
423
  column
393
424
  style={{
394
425
  maxHeight: 300,
395
426
  minWidth: dropDownMinWidth,
396
427
  maxWidth: dropDownMaxWidth,
428
+ border: '1px solid var(--color-surface-2)',
397
429
  }}
398
430
  gap={disableSearch ? undefined : 'xs'}
399
431
  vPad="xs"
@@ -445,7 +477,7 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
445
477
  {buttonRight && <div onClick={() => onRequestClose?.()}>{buttonRight}</div>}
446
478
  </SilkeTextField>
447
479
  </SilkeBox>
448
- {!disableSearch && <SilkeDivider />}
480
+ {!disableSearch && <SilkeDivider dark />}
449
481
  <SilkeBox column scroll flex hPad="xs">
450
482
  {displayedItems.length === 0 && (
451
483
  <SilkeBox hPad="s" height={size} vAlign="center">
@@ -453,23 +485,7 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
453
485
  </SilkeBox>
454
486
  )}
455
487
  {(() => {
456
- const sortedItems = displayedItems.sort(sort);
457
- const groupedItems: { groupLabel?: string; items: Entry<T>[] }[] = [];
458
- let currentGroup: { groupLabel?: string; items: Entry<T>[] } | null = null;
459
-
460
- // Group items by groupLabel
461
- sortedItems.forEach((item) => {
462
- const itemGroupLabel = !item.divider ? (item as Data<T>).groupLabel : undefined;
463
-
464
- if (!currentGroup || currentGroup.groupLabel !== itemGroupLabel) {
465
- currentGroup = { groupLabel: itemGroupLabel, items: [] };
466
- groupedItems.push(currentGroup);
467
- }
468
-
469
- currentGroup.items.push(item);
470
- });
471
-
472
- let itemIndex = 0;
488
+ let navigableIndex = 0;
473
489
 
474
490
  return groupedItems.map((group, groupIdx) => (
475
491
  <React.Fragment key={`group-${groupIdx}`}>
@@ -480,24 +496,27 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
480
496
  </SilkeTextSmall>
481
497
  </SilkeBox>
482
498
  )}
483
- {group.items.map((item) => {
484
- const currentItemIndex = itemIndex++;
485
- return item.divider ? (
486
- <SilkeDivider dark key={`hr-${currentItemIndex}`} />
487
- ) : (
499
+ {group.items.map((item, itemIdx) => {
500
+ if (item.divider) {
501
+ return <SilkeDivider dark key={`group-${groupIdx}-divider-${itemIdx}`} />;
502
+ }
503
+
504
+ const currentIndex = navigableIndex++;
505
+
506
+ return (
488
507
  <AutocompleteItem
489
508
  ItemRender={ItemRender}
490
- key={currentItemIndex}
509
+ key={`group-${groupIdx}-item-${itemIdx}`}
491
510
  size={size}
492
511
  iconFontSize={iconFontSize}
493
512
  item={item}
494
- highlight={currentItemIndex === highlight}
513
+ highlight={currentIndex === highlight}
495
514
  selected={isSelected(item.value)}
496
515
  multiple={form.multiple}
497
516
  onMouseDown={(e) => {
498
517
  e.preventDefault();
499
518
  e.stopPropagation();
500
- if (!item.divider && !item.disabled) handleSelect(item);
519
+ if (!item.disabled) handleSelect(item);
501
520
  }}
502
521
  />
503
522
  );
@@ -1,33 +1,333 @@
1
- # Layout box
1
+ # SilkeBox
2
2
 
3
- ```jsx
3
+ A flexible layout component that provides a consistent way to create layouts, spacing, and styling. SilkeBox is the foundation for most UI layouts in Silke, offering flexbox-based positioning with semantic spacing values.
4
+
5
+ ## Features
6
+
7
+ - **Flexbox layout**: Row or column direction with gap spacing
8
+ - **Semantic sizing**: Consistent spacing scale (xs, s, m, l, xl)
9
+ - **Padding control**: Unified or separate vertical/horizontal padding
10
+ - **Background & colors**: Theme-aware color props with hover states
11
+ - **Border radius**: Multiple rounded corner presets
12
+ - **Polymorphic rendering**: Render as different HTML elements
13
+ - **Scroll handling**: Enable scrolling with optional visible scrollbars
14
+ - **Alignment**: Flexible content alignment for both axes
15
+
16
+ ## Basic Usage
17
+
18
+ ```js
4
19
  <SilkeBox gap>
5
- <SilkeButton label="Buttons in a row" />
6
- <SilkeButton label="Buttons in a row" />
20
+ <SilkeButton label="Button 1" />
21
+ <SilkeButton label="Button 2" />
22
+ </SilkeBox>
23
+ ```
24
+
25
+ ## Column Layout
26
+
27
+ Stack items vertically:
28
+
29
+ ```js
30
+ <SilkeBox column gap>
31
+ <SilkeButton label="Top" />
32
+ <SilkeButton label="Middle" />
33
+ <SilkeButton label="Bottom" />
34
+ </SilkeBox>
35
+ ```
36
+
37
+ ## Gap Spacing
38
+
39
+ Control spacing between items with the `gap` prop:
40
+
41
+ ```js
42
+ <SilkeBox gap="l">
43
+ {['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl'].map((gapSize) => (
44
+ <SilkeBox key={gapSize} column gap={gapSize} bg="neutral-10" pad="s" rounded>
45
+ <SilkeText size="s" weight="medium">{gapSize}</SilkeText>
46
+ <SilkeBox bg="accent-50" style={{ height: 20 }} rounded />
47
+ <SilkeBox bg="accent-50" style={{ height: 20 }} rounded />
48
+ </SilkeBox>
49
+ ))}
50
+ </SilkeBox>
51
+ ```
52
+
53
+ ## Padding
54
+
55
+ Use `pad` for uniform padding, or `vPad`/`hPad` for axis-specific:
56
+
57
+ ```js
58
+ <SilkeBox gap="m">
59
+ <SilkeBox pad="m" bg="neutral-10" rounded>
60
+ <SilkeText>pad="m"</SilkeText>
61
+ </SilkeBox>
62
+ <SilkeBox vPad="l" hPad="s" bg="neutral-10" rounded>
63
+ <SilkeText>vPad="l" hPad="s"</SilkeText>
64
+ </SilkeBox>
65
+ <SilkeBox pad="xl" bg="neutral-10" rounded>
66
+ <SilkeText>pad="xl"</SilkeText>
67
+ </SilkeBox>
68
+ </SilkeBox>
69
+ ```
70
+
71
+ ## Size Props
72
+
73
+ Set dimensions using the semantic size scale:
74
+
75
+ ```js
76
+ <SilkeBox gap="s" wrap>
77
+ {['xs', 's', 'base', 'm', 'l', 'xl'].map((size) => (
78
+ <SilkeBox key={size} size={size} bg="accent-40" rounded vAlign="center" hAlign="center">
79
+ <SilkeText size="s" color="neutral-0">{size}</SilkeText>
80
+ </SilkeBox>
81
+ ))}
82
+ </SilkeBox>
83
+ ```
84
+
85
+ ## Alignment
86
+
87
+ Align content horizontally and vertically:
88
+
89
+ ```js
90
+ <SilkeBox gap="m">
91
+ <SilkeBox width="l" height="l" bg="neutral-10" rounded hAlign="start" vAlign="start">
92
+ <SilkeBox size="s" bg="accent-50" rounded />
93
+ </SilkeBox>
94
+ <SilkeBox width="l" height="l" bg="neutral-10" rounded hAlign="center" vAlign="center">
95
+ <SilkeBox size="s" bg="accent-50" rounded />
96
+ </SilkeBox>
97
+ <SilkeBox width="l" height="l" bg="neutral-10" rounded hAlign="end" vAlign="end">
98
+ <SilkeBox size="s" bg="accent-50" rounded />
99
+ </SilkeBox>
100
+ <SilkeBox width="l" height="l" bg="neutral-10" rounded hAlign="spread">
101
+ <SilkeBox size="xs" bg="accent-50" rounded />
102
+ <SilkeBox size="xs" bg="accent-50" rounded />
103
+ </SilkeBox>
104
+ </SilkeBox>
105
+ ```
106
+
107
+ ## Background Colors
108
+
109
+ Apply theme colors with optional hover states:
110
+
111
+ ```js
112
+ <SilkeBox gap="s">
113
+ <SilkeBox pad="m" bg="accent-50" rounded>
114
+ <SilkeText color="neutral-0">accent-50</SilkeText>
115
+ </SilkeBox>
116
+ <SilkeBox pad="m" bg="success-50" rounded>
117
+ <SilkeText color="neutral-0">success-50</SilkeText>
118
+ </SilkeBox>
119
+ <SilkeBox pad="m" bg="neutral-10" bgHover="neutral-20" rounded cursor="pointer">
120
+ <SilkeText>Hover me</SilkeText>
121
+ </SilkeBox>
122
+ <SilkeBox pad="m" bg="blur" rounded>
123
+ <SilkeText>blur background</SilkeText>
124
+ </SilkeBox>
125
+ </SilkeBox>
126
+ ```
127
+
128
+ ## Border Radius
129
+
130
+ Multiple rounded corner presets:
131
+
132
+ ```js
133
+ <SilkeBox gap="s">
134
+ <SilkeBox size="l" bg="accent-50" rounded="tiny" />
135
+ <SilkeBox size="l" bg="accent-50" rounded="small" />
136
+ <SilkeBox size="l" bg="accent-50" rounded="medium" />
137
+ <SilkeBox size="l" bg="accent-50" rounded="full" />
138
+ </SilkeBox>
139
+ ```
140
+
141
+ ## Shadow Levels
142
+
143
+ Apply shadow elevation:
144
+
145
+ ```js
146
+ <SilkeBox gap="l" pad="m">
147
+ {['level1', 'level2', 'level3', 'level4'].map((shadow) => (
148
+ <SilkeBox key={shadow} pad="m" bg="neutral-0" rounded shadow={shadow}>
149
+ <SilkeText>{shadow}</SilkeText>
150
+ </SilkeBox>
151
+ ))}
7
152
  </SilkeBox>
8
153
  ```
9
154
 
10
- ```jsx
11
- <SilkeBox gap column>
12
- <SilkeButton label="Buttons in a column" />
13
- <SilkeButton label="Buttons in a column" />
155
+ ## Fill Container
156
+
157
+ Make the box fill its parent:
158
+
159
+ ```js
160
+ <SilkeBox style={{ height: 100 }} bg="neutral-10" rounded pad="s">
161
+ <SilkeBox fill bg="accent-50" rounded vAlign="center" hAlign="center">
162
+ <SilkeText color="neutral-0">Fills parent</SilkeText>
163
+ </SilkeBox>
164
+ </SilkeBox>
165
+ ```
166
+
167
+ ## Flex Item
168
+
169
+ Mark as a flex item that grows:
170
+
171
+ ```js
172
+ <SilkeBox gap="s">
173
+ <SilkeBox pad="s" bg="neutral-20" rounded>
174
+ <SilkeText>Fixed</SilkeText>
175
+ </SilkeBox>
176
+ <SilkeBox flex pad="s" bg="accent-50" rounded>
177
+ <SilkeText color="neutral-0">Flex grows</SilkeText>
178
+ </SilkeBox>
179
+ <SilkeBox pad="s" bg="neutral-20" rounded>
180
+ <SilkeText>Fixed</SilkeText>
181
+ </SilkeBox>
182
+ </SilkeBox>
183
+ ```
184
+
185
+ ## Wrap Items
186
+
187
+ Allow items to wrap to new lines:
188
+
189
+ ```js
190
+ <SilkeBox wrap gap="s" style={{ maxWidth: 300 }}>
191
+ {Array.from({ length: 10 }, (_, i) => (
192
+ <SilkeBox key={i} pad="s" bg="accent-40" rounded>
193
+ <SilkeText color="neutral-0">Item {i + 1}</SilkeText>
194
+ </SilkeBox>
195
+ ))}
196
+ </SilkeBox>
197
+ ```
198
+
199
+ ## Scrollable Content
200
+
201
+ Enable scrolling with optional visible scrollbars:
202
+
203
+ ```js
204
+ <SilkeBox column gap="m">
205
+ <SilkeBox scroll style={{ height: 100 }} bg="neutral-10" rounded pad="s">
206
+ <SilkeBox column gap="xs">
207
+ {Array.from({ length: 10 }, (_, i) => (
208
+ <SilkeText key={i}>Scrollable item {i + 1}</SilkeText>
209
+ ))}
210
+ </SilkeBox>
211
+ </SilkeBox>
212
+ <SilkeBox scroll="show" style={{ height: 100 }} bg="neutral-10" rounded pad="s">
213
+ <SilkeBox column gap="xs">
214
+ {Array.from({ length: 10 }, (_, i) => (
215
+ <SilkeText key={i}>Visible scrollbar {i + 1}</SilkeText>
216
+ ))}
217
+ </SilkeBox>
218
+ </SilkeBox>
14
219
  </SilkeBox>
15
220
  ```
16
221
 
17
- ## Different gaps to mind
222
+ ## Aspect Ratio
18
223
 
19
- ```jsx
20
- let a = 123;
224
+ Maintain aspect ratio:
21
225
 
22
- let component = (
23
- <SilkeBox gap>
24
- {['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl', 'xxxl'].map((gap) => (
25
- <SilkeBox gap={gap} column hAlign>
26
- <SilkeButton label={gap} />
27
- <SilkeButton label={gap} />
28
- <SilkeButton label={gap} />
29
- </SilkeBox>
30
- ))}
226
+ ```js
227
+ <SilkeBox gap="m">
228
+ <SilkeBox width="l" aspectRatio="16:9" bg="accent-50" rounded vAlign="center" hAlign="center">
229
+ <SilkeText color="neutral-0" size="s">16:9</SilkeText>
230
+ </SilkeBox>
231
+ <SilkeBox width="l" aspectRatio="4:3" bg="success-50" rounded vAlign="center" hAlign="center">
232
+ <SilkeText color="neutral-0" size="s">4:3</SilkeText>
233
+ </SilkeBox>
234
+ <SilkeBox width="l" aspectRatio="1:1" bg="warning-50" rounded vAlign="center" hAlign="center">
235
+ <SilkeText color="neutral-0" size="s">1:1</SilkeText>
31
236
  </SilkeBox>
32
- );
237
+ </SilkeBox>
238
+ ```
239
+
240
+ ## Polymorphic Rendering
241
+
242
+ Render as different HTML elements:
243
+
244
+ ```js
245
+ <SilkeBox column gap="s">
246
+ <SilkeBox tag="button" pad="s" bg="accent-50" rounded cursor="pointer" onClick={() => alert('clicked')}>
247
+ <SilkeText color="neutral-0">Renders as button</SilkeText>
248
+ </SilkeBox>
249
+ <SilkeBox tag="a" href="#" pad="s" bg="neutral-10" rounded>
250
+ <SilkeText>Renders as anchor</SilkeText>
251
+ </SilkeBox>
252
+ <SilkeBox tag="form" column gap="s" pad="s" bg="neutral-10" rounded>
253
+ <SilkeText>Renders as form</SilkeText>
254
+ </SilkeBox>
255
+ </SilkeBox>
256
+ ```
257
+
258
+ ## Debug Mode
259
+
260
+ Visualize box boundaries:
261
+
262
+ ```js
263
+ <SilkeBox debug column gap="s" pad="s">
264
+ <SilkeBox gap="s">
265
+ <SilkeBox pad="s">Item 1</SilkeBox>
266
+ <SilkeBox pad="s">Item 2</SilkeBox>
267
+ </SilkeBox>
268
+ <SilkeBox gap="s">
269
+ <SilkeBox pad="s">Item 3</SilkeBox>
270
+ <SilkeBox pad="s">Item 4</SilkeBox>
271
+ </SilkeBox>
272
+ </SilkeBox>
273
+ ```
274
+
275
+ ## Props
276
+
277
+ | Prop | Type | Default | Description |
278
+ | ------------- | ---------------------------------------------- | ------- | ------------------------------------------------- |
279
+ | `column` | `boolean` | `false` | Stack children vertically |
280
+ | `fill` | `boolean` | `false` | Fill parent container |
281
+ | `flex` | `boolean` | `false` | Mark as flex item that grows |
282
+ | `wrap` | `boolean` | `false` | Allow items to wrap |
283
+ | `gap` | `BoxSpace` | - | Space between children |
284
+ | `pad` | `BoxSpace` | - | Padding on all sides |
285
+ | `vPad` | `BoxSpace` | - | Vertical padding only |
286
+ | `hPad` | `BoxSpace` | - | Horizontal padding only |
287
+ | `size` | `BoxSize` | - | Sets both width and height |
288
+ | `width` | `BoxSize` | - | Width of the box |
289
+ | `height` | `BoxSize` | - | Height of the box |
290
+ | `minWidth` | `BoxSize` | - | Minimum width |
291
+ | `minHeight` | `BoxSize` | - | Minimum height |
292
+ | `align` | `BoxAlign \| [BoxAlign, BoxAlign]` | - | Align content (single or [horizontal, vertical]) |
293
+ | `vAlign` | `BoxAlign` | - | Vertical alignment |
294
+ | `hAlign` | `BoxAlign` | - | Horizontal alignment |
295
+ | `bg` | `SilkeColor \| 'blur'` | - | Background color |
296
+ | `bgHover` | `SilkeColor` | - | Background color on hover |
297
+ | `color` | `SilkeColor` | - | Text color |
298
+ | `colorHover` | `SilkeColor` | - | Text color on hover |
299
+ | `rounded` | `boolean \| 'tiny' \| 'small' \| 'medium' \| 'full'` | - | Border radius |
300
+ | `shadow` | `'level1' \| 'level2' \| 'level3' \| 'level4'` | - | Shadow elevation |
301
+ | `overflow` | `'hidden' \| 'scroll-y'` | - | Overflow behavior |
302
+ | `scroll` | `boolean \| 'show'` | - | Enable scrolling |
303
+ | `cursor` | `'pointer' \| 'grab' \| 'text'` | - | Cursor style |
304
+ | `userSelect` | `'none' \| 'text'` | - | User selection behavior |
305
+ | `aspectRatio` | `'16:9' \| '4:3' \| '1:1'` | - | Maintain aspect ratio |
306
+ | `tag` | `string` | `'div'` | HTML element to render |
307
+ | `debug` | `boolean` | `false` | Show debug outlines |
308
+
309
+ ## Types
310
+
311
+ ```typescript
312
+ type BoxSpace = 'xxs' | 'xs' | 's' | 'sm' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl' | 'none' | boolean;
313
+
314
+ type BoxSize = 'xs' | 's' | 'base' | 'm' | 'l' | 'xl' | 'xxl' | '256' | '512';
315
+
316
+ type BoxAlign = 'center' | 'start' | 'end' | 'spread' | 'space' | boolean;
317
+ ```
318
+
319
+ ## Supported Tags
320
+
321
+ The `tag` prop supports: `div`, `a`, `button`, `input`, `label`, `form`, `ol`, `ul`, `li`, `header`, `dl`, `dt`, `dd`, `nav`, `link` (React Router Link).
322
+
323
+ ## Flex Helper
324
+
325
+ Use the `Flex` component to create flexible spacers:
326
+
327
+ ```js
328
+ <SilkeBox gap="s">
329
+ <SilkeButton label="Left" />
330
+ <Flex />
331
+ <SilkeButton label="Right" />
332
+ </SilkeBox>
33
333
  ```
@@ -3,7 +3,7 @@
3
3
  .box {
4
4
  display: flex;
5
5
  position: relative;
6
-
6
+
7
7
  &.debug,
8
8
  &.debug .box {
9
9
  outline: 1px solid red;
@@ -16,7 +16,8 @@
16
16
  }
17
17
  }
18
18
 
19
- button, input{
19
+ button,
20
+ input {
20
21
  border: none;
21
22
  outline: none;
22
23
  border-radius: 0;
@@ -164,14 +165,13 @@ button.box {
164
165
  .minWidth-#{$name} {
165
166
  min-width: #{$size};
166
167
  }
167
-
168
168
  }
169
169
 
170
- .overflow-hidden{
170
+ .overflow-hidden {
171
171
  contain: paint;
172
172
  overflow: clip;
173
173
  }
174
- .overflow-scroll-y{
174
+ .overflow-scroll-y {
175
175
  overflow-y: scroll;
176
176
  }
177
177