@vev/silke 1.1.3 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/index.js +40 -38
- package/dist/index.js.LEGAL.txt +12 -0
- package/dist/styles.css +1596 -1036
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/silke-autocomplete-field/autocomplete-types.d.ts +4 -0
- package/dist/types/components/silke-autocomplete-field/index.d.ts +1 -0
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +60 -0
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +3 -0
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-popup-native.d.ts +15 -0
- package/dist/types/components/silke-button/silke-dropdown-button.d.ts +8 -13
- package/dist/types/components/silke-card/silke-card-grid.d.ts +33 -1
- package/dist/types/components/silke-command-text-field/image-utils.d.ts +20 -0
- package/dist/types/components/silke-command-text-field/index.d.ts +4 -0
- package/dist/types/components/silke-command-text-field/silke-command-parser.d.ts +3 -0
- package/dist/types/components/silke-command-text-field/silke-command-parser.spec.d.ts +1 -0
- package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +46 -0
- package/dist/types/components/silke-command-text-field/utils.d.ts +61 -0
- package/dist/types/components/silke-command-text-field/utils.spec.d.ts +1 -0
- package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
- package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +1 -0
- package/dist/types/components/silke-image/silke-image.d.ts +2 -1
- package/dist/types/components/silke-list/index.d.ts +1 -0
- package/dist/types/components/silke-list/silke-list-item.d.ts +24 -6
- package/dist/types/components/silke-list/silke-list.d.ts +9 -9
- package/dist/types/components/silke-list/types.d.ts +19 -0
- package/dist/types/components/silke-list/utils.d.ts +3 -0
- package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +1 -0
- package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +6 -1
- package/dist/types/components/silke-popover-native/index.d.ts +1 -0
- package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +37 -0
- package/dist/types/components/silke-popover-native/types.d.ts +6 -0
- package/dist/types/components/silke-popover-native/use-popover-positioning.d.ts +9 -0
- package/dist/types/components/silke-select-field/index.d.ts +1 -0
- package/dist/types/components/silke-select-field/silke-select-field-native.d.ts +4 -0
- package/dist/types/components/silke-shortcut-button/index.d.ts +1 -0
- package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +15 -0
- package/dist/types/components/silke-tag/silke-tag.d.ts +1 -1
- package/dist/types/icons.d.ts +32 -0
- package/jest.config.js +2 -3
- package/package.json +9 -3
- package/src/_variables.scss +125 -129
- package/src/components/index.ts +4 -1
- package/src/components/silke-action-box/silke-action-box.scss +2 -3
- package/src/components/silke-alert-banner/silke-alert-banner.scss +9 -10
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +2 -2
- package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
- package/src/components/silke-autocomplete-field/index.ts +1 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +346 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +39 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -12
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +3 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +542 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +92 -41
- package/src/components/silke-box/silke-box.mdx +321 -21
- package/src/components/silke-box/silke-box.scss +5 -5
- package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +147 -9
- package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
- package/src/components/silke-button/silke-big-button.scss +1 -1
- package/src/components/silke-button/silke-button.scss +27 -18
- package/src/components/silke-button/silke-dropdown-button.mdx +67 -0
- package/src/components/silke-button/silke-dropdown-button.tsx +40 -122
- package/src/components/silke-card/silke-card-grid.tsx +5 -3
- package/src/components/silke-card/silke-card.scss +8 -7
- package/src/components/silke-card/silke-card.tsx +7 -1
- package/src/components/silke-checkbox/silke-checkbox.mdx +139 -14
- package/src/components/silke-checkbox/silke-checkbox.scss +11 -11
- package/src/components/silke-color-picker/color-picker.scss +8 -8
- package/src/components/silke-color-swatches/silke-color-swatches.mdx +130 -0
- package/src/components/silke-command-text-field/image-utils.ts +71 -0
- package/src/components/silke-command-text-field/index.ts +12 -0
- package/src/components/silke-command-text-field/silke-command-parser.spec.ts +89 -0
- package/src/components/silke-command-text-field/silke-command-parser.ts +47 -0
- package/src/components/silke-command-text-field/silke-command-text-field.mdx +301 -0
- package/src/components/silke-command-text-field/silke-command-text-field.module.scss +119 -0
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +665 -0
- package/src/components/silke-command-text-field/utils.spec.ts +366 -0
- package/src/components/silke-command-text-field/utils.ts +287 -0
- package/src/components/silke-conditions-input/silke-conditions-input.scss +4 -4
- package/src/components/silke-content-column/silke-content-column.scss +1 -1
- package/src/components/silke-context-menu/silke-context-menu.scss +3 -4
- package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
- package/src/components/silke-css-number-field/silke-css-number-field.scss +14 -12
- package/src/components/silke-divider/silke-divider.mdx +154 -32
- package/src/components/silke-divider/silke-divider.scss +3 -2
- package/src/components/silke-drawer/silke-drawer.scss +6 -2
- package/src/components/silke-form/silke-form.mdx +254 -27
- package/src/components/silke-form-schema/fields/array-field-inline.tsx +1 -0
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +1 -0
- package/src/components/silke-form-schema/fields/styles.scss +34 -35
- package/src/components/silke-form-schema/silke-schema-field.tsx +1 -1
- package/src/components/silke-form-schema/silke-schema-fields.tsx +4 -3
- package/src/components/silke-gradient-picker/silke-gradient-picker.module.scss +2 -2
- package/src/components/silke-icon/silke-icon.mdx +212 -8
- package/src/components/silke-icon/silke-icon.scss +10 -2
- package/src/components/silke-icon/silke-icon.tsx +1 -0
- package/src/components/silke-icon/silke-stacked-icon.scss +42 -45
- package/src/components/silke-icon-browser/silke-icon-browser.mdx +143 -0
- package/src/components/silke-image/silke-image-color-backdrop.scss +6 -6
- package/src/components/silke-image/silke-image.mdx +189 -41
- package/src/components/silke-image/silke-image.scss +3 -3
- package/src/components/silke-image/silke-image.tsx +14 -1
- package/src/components/silke-link/silke-link.scss +3 -5
- package/src/components/silke-list/index.ts +1 -0
- package/src/components/silke-list/silke-list-item.mdx +83 -0
- package/src/components/silke-list/silke-list-item.scss +119 -0
- package/src/components/silke-list/silke-list-item.tsx +137 -12
- package/src/components/silke-list/silke-list.mdx +108 -13
- package/src/components/silke-list/silke-list.scss +8 -15
- package/src/components/silke-list/silke-list.tsx +63 -9
- package/src/components/silke-list/types.ts +22 -0
- package/src/components/silke-list/utils.ts +24 -0
- package/src/components/silke-loader/silke-loader.mdx +139 -5
- package/src/components/silke-loader/silke-loader.scss +1 -1
- package/src/components/silke-modal/silke-modal.scss +9 -9
- package/src/components/silke-navigation-link/silke-navigation-link.mdx +27 -2
- package/src/components/silke-navigation-link/silke-navigation-link.scss +34 -40
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +7 -6
- package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +228 -31
- package/src/components/silke-overflow-menu/silke-overflow-menu.scss +8 -8
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +14 -8
- package/src/components/silke-popover/silke-popover.scss +5 -5
- package/src/components/silke-popover-native/index.ts +1 -0
- package/src/components/silke-popover-native/silke-popover-native.mdx +207 -0
- package/src/components/silke-popover-native/silke-popover-native.scss +127 -0
- package/src/components/silke-popover-native/silke-popover-native.tsx +176 -0
- package/src/components/silke-popover-native/types.ts +21 -0
- package/src/components/silke-popover-native/use-popover-positioning.ts +157 -0
- package/src/components/silke-progress-indicator/silke-progress-indicator.scss +1 -1
- package/src/components/silke-radio-button/silke-radio-button.scss +18 -11
- package/src/components/silke-search-field/silke-search-field.mdx +161 -7
- package/src/components/silke-select-field/index.ts +1 -0
- package/src/components/silke-select-field/silke-select-field-native.tsx +17 -0
- package/src/components/silke-select-field/silke-select-field.mdx +65 -0
- package/src/components/silke-shortcut-button/index.ts +1 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.mdx +89 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.scss +145 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +55 -0
- package/src/components/silke-skeleton/silke-skeleton.mdx +109 -0
- package/src/components/silke-skeleton/silke-skeleton.scss +1 -1
- package/src/components/silke-slider/silke-slider.module.scss +19 -19
- package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +3 -3
- package/src/components/silke-sortable-list/silke-sortable-list.scss +4 -5
- package/src/components/silke-table/silke-table.scss +1 -1
- package/src/components/silke-tabs/silke-tabs.scss +3 -3
- package/src/components/silke-tag/silke-tag.mdx +179 -43
- package/src/components/silke-tag/silke-tag.scss +49 -12
- package/src/components/silke-tag/silke-tag.tsx +17 -7
- package/src/components/silke-text/silke-text.scss +6 -4
- package/src/components/silke-text/silke-title.scss +7 -14
- package/src/components/silke-text-field/silke-text-field.scss +9 -9
- package/src/components/silke-text-field/silke-text-field.tsx +3 -2
- package/src/components/silke-tile/silke-tile.scss +7 -3
- package/src/components/silke-toast-notification/silke-toast-notification.scss +4 -5
- package/src/components/silke-toggle/silke-toggle.mdx +163 -33
- package/src/components/silke-toggle/silke-toggle.scss +4 -4
- package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
- package/src/components/silke-tooltip/silke-shortcuts.tsx +3 -3
- package/src/components/silke-tooltip/silke-tooltip.scss +11 -16
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +9 -7
- package/src/components/silke-virtual/silke-virtual.mdx +161 -0
- package/src/components/silke-virtual/silke-virtual.scss +8 -8
- package/src/icons.tsx +45 -1
- package/src/styles/core.scss +42 -45
- package/src/styles/math.scss +66 -66
- package/tsconfig.build.json +2 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -14
- package/dist/types/components/silke-list-card/index.d.ts +0 -1
- package/dist/types/components/silke-list-card/silke-list-card.d.ts +0 -14
- package/src/components/silke-list-card/index.ts +0 -1
- package/src/components/silke-list-card/silke-list-card.mdx +0 -46
- package/src/components/silke-list-card/silke-list-card.scss +0 -57
- 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 = (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
132
|
-
}
|
|
133
|
-
|
|
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,
|
|
@@ -189,7 +212,7 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
|
|
|
189
212
|
if (!form.multiple && !isUndefined(form.value)) {
|
|
190
213
|
resetSearchText();
|
|
191
214
|
}
|
|
192
|
-
}, [
|
|
215
|
+
}, [form.multiple, resetSearchText, form.value]);
|
|
193
216
|
|
|
194
217
|
useEffect(() => {
|
|
195
218
|
if (highlight !== undefined) {
|
|
@@ -230,7 +253,15 @@ export function SilkeAutocompletePopup<T>(props: SilkeAutocompletePopupProps<T>)
|
|
|
230
253
|
];
|
|
231
254
|
}, [itemsWithMatchingOnTop, maxDisplayedItems]);
|
|
232
255
|
|
|
233
|
-
const
|
|
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 <
|
|
275
|
-
if (isSelected(
|
|
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 &&
|
|
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,
|
|
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-
|
|
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,34 +477,53 @@ 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">
|
|
452
484
|
<SilkeTextSmall color="neutral-60">No results</SilkeTextSmall>
|
|
453
485
|
</SilkeBox>
|
|
454
486
|
)}
|
|
455
|
-
{
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
)
|
|
459
|
-
<
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
487
|
+
{(() => {
|
|
488
|
+
let navigableIndex = 0;
|
|
489
|
+
|
|
490
|
+
return groupedItems.map((group, groupIdx) => (
|
|
491
|
+
<React.Fragment key={`group-${groupIdx}`}>
|
|
492
|
+
{group.groupLabel && (
|
|
493
|
+
<SilkeBox hPad="s" vPad="s">
|
|
494
|
+
<SilkeTextSmall color="neutral-60" weight="strong">
|
|
495
|
+
{group.groupLabel}
|
|
496
|
+
</SilkeTextSmall>
|
|
497
|
+
</SilkeBox>
|
|
498
|
+
)}
|
|
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 (
|
|
507
|
+
<AutocompleteItem
|
|
508
|
+
ItemRender={ItemRender}
|
|
509
|
+
key={`group-${groupIdx}-item-${itemIdx}`}
|
|
510
|
+
size={size}
|
|
511
|
+
iconFontSize={iconFontSize}
|
|
512
|
+
item={item}
|
|
513
|
+
highlight={currentIndex === highlight}
|
|
514
|
+
selected={isSelected(item.value)}
|
|
515
|
+
multiple={form.multiple}
|
|
516
|
+
onMouseDown={(e) => {
|
|
517
|
+
e.preventDefault();
|
|
518
|
+
e.stopPropagation();
|
|
519
|
+
if (!item.disabled) handleSelect(item);
|
|
520
|
+
}}
|
|
521
|
+
/>
|
|
522
|
+
);
|
|
523
|
+
})}
|
|
524
|
+
</React.Fragment>
|
|
525
|
+
));
|
|
526
|
+
})()}
|
|
476
527
|
{onAdd && !disableAddFromList && searchText && (
|
|
477
528
|
<AutocompleteItem
|
|
478
529
|
size={size}
|
|
@@ -1,33 +1,333 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SilkeBox
|
|
2
2
|
|
|
3
|
-
|
|
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="
|
|
6
|
-
<SilkeButton label="
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
##
|
|
222
|
+
## Aspect Ratio
|
|
18
223
|
|
|
19
|
-
|
|
20
|
-
let a = 123;
|
|
224
|
+
Maintain aspect ratio:
|
|
21
225
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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,
|
|
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
|
|