@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
@@ -1,18 +1,156 @@
1
- # Breadcrumbs
1
+ # SilkeBreadcrumbs
2
+
3
+ A navigation component that shows the user's location within a hierarchical structure. Breadcrumbs help users understand where they are and navigate back to parent pages.
4
+
5
+ ## Features
6
+
7
+ - **Accessible navigation**: Semantic `<nav>` and `<ol>` elements with ARIA labels
8
+ - **Interactive items**: Click handlers for navigation
9
+ - **Icons support**: Add icons or emoji to breadcrumb items
10
+ - **Separator**: Automatic chevron separators between items
11
+ - **Overflow handling**: Text truncation for long labels
12
+
13
+ ## Basic Usage
14
+
15
+ ```js
16
+ <SilkeBreadcrumbs>
17
+ <SilkeBreadcrumb label="Home" onClick={() => console.log('Home')} />
18
+ <SilkeBreadcrumb label="Products" onClick={() => console.log('Products')} />
19
+ <SilkeBreadcrumb label="Electronics" onClick={() => console.log('Electronics')} />
20
+ <SilkeBreadcrumb label="Phones" noSlash />
21
+ </SilkeBreadcrumbs>
22
+ ```
23
+
24
+ ## With Icons
25
+
26
+ Add icons to breadcrumb items:
27
+
28
+ ```js
29
+ <SilkeBreadcrumbs>
30
+ <SilkeBreadcrumb label="Home" icon="home" onClick={() => {}} />
31
+ <SilkeBreadcrumb label="Settings" icon="settings" onClick={() => {}} />
32
+ <SilkeBreadcrumb label="Profile" icon="user" noSlash />
33
+ </SilkeBreadcrumbs>
34
+ ```
35
+
36
+ ## With Emoji
37
+
38
+ Use emoji icons:
39
+
40
+ ```js
41
+ <SilkeBreadcrumbs>
42
+ <SilkeBreadcrumb label="Home" icon={{ type: 0, value: '🏠' }} onClick={() => {}} />
43
+ <SilkeBreadcrumb label="Projects" icon={{ type: 0, value: '📁' }} onClick={() => {}} />
44
+ <SilkeBreadcrumb label="My Project" icon={{ type: 0, value: '📄' }} noSlash />
45
+ </SilkeBreadcrumbs>
46
+ ```
47
+
48
+ ## Current Page (Non-Interactive)
49
+
50
+ The last item is typically non-interactive (no `onClick`):
51
+
52
+ ```js
53
+ <SilkeBreadcrumbs>
54
+ <SilkeBreadcrumb label="Dashboard" onClick={() => console.log('Dashboard')} />
55
+ <SilkeBreadcrumb label="Users" onClick={() => console.log('Users')} />
56
+ <SilkeBreadcrumb label="John Doe" noSlash />
57
+ </SilkeBreadcrumbs>
58
+ ```
59
+
60
+ ## Dynamic Breadcrumbs
61
+
62
+ Build breadcrumbs from data:
2
63
 
3
64
  ```js
4
- const [len, setLen] = React.useState(9);
65
+ const path = [
66
+ { label: 'Home', id: 'home' },
67
+ { label: 'Documents', id: 'docs' },
68
+ { label: 'Projects', id: 'projects' },
69
+ { label: 'Report.pdf', id: 'file' },
70
+ ];
5
71
 
6
- <>
72
+ <SilkeBreadcrumbs>
73
+ {path.map((item, index) => (
74
+ <SilkeBreadcrumb
75
+ key={item.id}
76
+ label={item.label}
77
+ onClick={index < path.length - 1 ? () => console.log(`Navigate to ${item.id}`) : undefined}
78
+ noSlash={index === path.length - 1}
79
+ />
80
+ ))}
81
+ </SilkeBreadcrumbs>;
82
+ ```
83
+
84
+ ## Interactive Navigation
85
+
86
+ Navigate through levels:
87
+
88
+ ```js
89
+ const [path, setPath] = React.useState(['Home', 'Products', 'Electronics', 'Phones', 'iPhone']);
90
+
91
+ const navigateTo = (index) => {
92
+ setPath(path.slice(0, index + 1));
93
+ };
94
+
95
+ <SilkeBox column gap="m">
7
96
  <SilkeBreadcrumbs>
8
- {ipsum.list(len, (i) => (
97
+ {path.map((item, index) => (
9
98
  <SilkeBreadcrumb
10
- key={i}
11
- label={ipsum.name()}
12
- onClick={[2, 4].includes(i) ? null : () => setLen(i + 1)}
99
+ key={index}
100
+ label={item}
101
+ onClick={index < path.length - 1 ? () => navigateTo(index) : undefined}
102
+ noSlash={index === path.length - 1}
13
103
  />
14
104
  ))}
15
105
  </SilkeBreadcrumbs>
16
- <SilkeButton label="Reset" onClick={() => setLen(9)} />
17
- </>;
106
+ <SilkeText size="s" color="neutral-60">Click a breadcrumb to navigate back</SilkeText>
107
+ </SilkeBox>;
18
108
  ```
109
+
110
+ ## In a Page Header
111
+
112
+ ```js
113
+ <SilkeBox column gap="m" pad="m" bg="neutral-10" rounded>
114
+ <SilkeBreadcrumbs>
115
+ <SilkeBreadcrumb label="Dashboard" icon="home" onClick={() => {}} />
116
+ <SilkeBreadcrumb label="Projects" onClick={() => {}} />
117
+ <SilkeBreadcrumb label="My Project" noSlash />
118
+ </SilkeBreadcrumbs>
119
+ <SilkeText kind="title">My Project</SilkeText>
120
+ <SilkeText color="neutral-60">Project description and details</SilkeText>
121
+ </SilkeBox>
122
+ ```
123
+
124
+ ## Props
125
+
126
+ ### SilkeBreadcrumbs
127
+
128
+ | Prop | Type | Default | Description |
129
+ | ---------- | ----------------- | ------- | ------------------------------ |
130
+ | `children` | `React.ReactNode` | - | SilkeBreadcrumb items |
131
+ | `maxItems` | `number` | - | Maximum items to display |
132
+
133
+ Also accepts `SilkeBox` navigation props.
134
+
135
+ ### SilkeBreadcrumb
136
+
137
+ | Prop | Type | Default | Description |
138
+ | --------- | ------------------------------------------ | ------- | ---------------------------------------- |
139
+ | `label` | `React.ReactNode` | - | Breadcrumb text |
140
+ | `icon` | `IEmojiIcon \| SilkeIcons` | - | Icon or emoji to display |
141
+ | `noSlash` | `boolean` | `false` | Hide the chevron separator |
142
+ | `onClick` | `(e: React.MouseEvent) => void` | - | Click handler (makes item interactive) |
143
+
144
+ ## Accessibility
145
+
146
+ - Uses semantic `<nav>` element with `aria-label="Breadcrumbs"`
147
+ - Uses ordered list `<ol>` for proper document structure
148
+ - Interactive items render as `<a>` elements
149
+ - Current page (last item) should not have an `onClick` handler
150
+
151
+ ## Styling Notes
152
+
153
+ - Interactive items show hover/focus states
154
+ - Long labels are truncated with ellipsis
155
+ - Chevron separators are automatically added between items
156
+ - Use `noSlash` on the last item to hide its separator
@@ -20,10 +20,10 @@
20
20
  color: var(--color-neutral-60) !important;
21
21
  }
22
22
 
23
- .icon{
24
- [class*="silke-image"],[class*="silke-icon"]{
23
+ .icon {
24
+ [class*='silke-image'],
25
+ [class*='silke-icon'] {
25
26
  font-size: 12px !important;
26
-
27
27
  }
28
28
  }
29
29
  }
@@ -15,7 +15,7 @@
15
15
  background: var(--button-background-pressed);
16
16
  }
17
17
 
18
- small{
18
+ small {
19
19
  color: var(--button-sub-label-color);
20
20
  }
21
21
  }
@@ -1,12 +1,13 @@
1
- @use "../../variables" as *;
1
+ @use '../../variables' as *;
2
2
  $default: $size-base;
3
- $sizes: "s" $size-s, "base" $size-base;
3
+ $sizes:
4
+ 's' $size-s,
5
+ 'base' $size-base;
4
6
 
5
7
  body {
6
-
7
8
  --silke-button-background: transparent;
8
9
  --silke-button-background-hover: var(--color-accent-20);
9
- --silke-button-background-pressed: (--color-accent-10);
10
+ --silke-button-background-pressed: (--color-accent-10);
10
11
 
11
12
  --silke-button-color: var(--color-neutral-100);
12
13
  --silke-button-color-hover: var(--color-neutral-100);
@@ -37,7 +38,8 @@ body {
37
38
  border: var(--silke-button-border-hover);
38
39
  }
39
40
 
40
- &:active,&.selected {
41
+ &:active,
42
+ &.selected {
41
43
  background: var(--silke-button-background-pressed);
42
44
  color: var(--silke-button-color-pressed);
43
45
  border: var(--silke-button-border-pressed);
@@ -61,7 +63,7 @@ body {
61
63
  }
62
64
 
63
65
  &:not(.iconOnly) {
64
- padding: 0 $space-sm 0 $space-sm;
66
+ padding: 0 $space-sm 0 $space-sm;
65
67
  }
66
68
 
67
69
  &.iconOnly {
@@ -86,7 +88,7 @@ body {
86
88
  left: -4px;
87
89
  right: -4px;
88
90
  bottom: -4px;
89
- content: "";
91
+ content: '';
90
92
  z-index: 1;
91
93
  }
92
94
 
@@ -117,18 +119,26 @@ body {
117
119
  --silke-button-color: var(--color-neutral-90);
118
120
  --silke-button-color-hover: var(--color-neutral-100);
119
121
  --silke-button-background-hover: var(--color-surface-2);
120
- --silke-button-background-pressed: var(--color-surface-3);
122
+ --silke-button-background-pressed: var(--color-surface-2);
123
+ --silke-button-color-pressed: var(--color-neutral-100);
121
124
  }
122
125
 
123
126
  &.upgrade {
124
- --silke-button-background: linear-gradient(24deg, var(--color-support-quaternary-30, 0.88) 0%, rgba(150,90,191,0.88) 100%);
127
+ --silke-button-background: linear-gradient(
128
+ 24deg,
129
+ var(--color-support-quaternary-30, 0.88) 0%,
130
+ rgba(150, 90, 191, 0.88) 100%
131
+ );
125
132
  --silke-button-color: var(--var-color-neutral-100);
126
- --silke-button-background-hover: linear-gradient(24deg, var(--color-support-quaternary-30, 0.88) 0%, var(--color-support-quaternary-30, 01) 100%);
127
- --silke-button-color: var(--var-color-neutral-90);
133
+ --silke-button-background-hover: linear-gradient(
134
+ 24deg,
135
+ var(--color-support-quaternary-30, 0.88) 0%,
136
+ var(--color-support-quaternary-30, 01) 100%
137
+ );
138
+ --silke-button-color: var(--var-color-neutral-90);
128
139
  --silke-button-background-pressed: var(--color-support-quaternary-20);
129
140
  --silke-button-color-pressed: var(--var-color-neutral-100);
130
141
  }
131
-
132
142
  }
133
143
 
134
144
  .icon {
@@ -144,9 +154,8 @@ body {
144
154
  .button.#{$name} {
145
155
  height: $size;
146
156
  min-height: $size;
147
-
148
157
 
149
- @if $name == "s" {
158
+ @if $name == 's' {
150
159
  font-size: $font-small;
151
160
  }
152
161
 
@@ -154,7 +163,7 @@ body {
154
163
  &:not(.iconOnly) {
155
164
  padding: 0 $space-s 0 $space-s;
156
165
  }
157
- }
166
+ }
158
167
  &.iconOnly {
159
168
  width: $size;
160
169
  min-width: $size;
@@ -0,0 +1,67 @@
1
+ # Dropdown button
2
+
3
+ ```js
4
+ <SilkeBox wrap gap align="center" fill>
5
+ <SilkeDropdownButton
6
+ label="Create project"
7
+ kind="primary"
8
+ items={[
9
+ {
10
+ label: 'Desktop first',
11
+ icon: 'desktop',
12
+ groupLabel: 'Blank',
13
+ onClick: () => {},
14
+ },
15
+ {
16
+ label: 'Mobile first',
17
+ icon: 'mobile',
18
+ groupLabel: 'Blank',
19
+ onClick: () => {},
20
+ },
21
+ {
22
+ label: 'Devices',
23
+ icon: 'devices',
24
+ groupLabel: 'Blank',
25
+ items: [
26
+ {
27
+ label: 'Large desktop',
28
+ icon: 'desktop',
29
+ onClick: () => {},
30
+ },
31
+ {
32
+ label: 'Small desktop',
33
+ icon: 'tablet',
34
+ onClick: () => {},
35
+ },
36
+ {
37
+ label: 'Really long breakpoint name here',
38
+ icon: 'laptop',
39
+ onClick: () => {},
40
+ },
41
+ ],
42
+ },
43
+ 'divider',
44
+ {
45
+ label: 'Library page',
46
+ icon: 'library',
47
+ groupLabel: 'Start with',
48
+ onClick: () => {},
49
+ },
50
+ {
51
+ label: 'Figma design',
52
+ icon: 'figma',
53
+ groupLabel: 'Start with',
54
+ onClick: () => {},
55
+ },
56
+ {
57
+ label: 'Page draft',
58
+ icon: 'ai.page',
59
+ tag: { label: 'AI', size: 'tiny', kind: 'secondary', icon: 'ai.sparkle' },
60
+ groupLabel: 'Start with',
61
+ onClick: () => {},
62
+ },
63
+ ]}
64
+ closeOnSelect
65
+ />
66
+ </SilkeBox>
67
+ ```
@@ -1,78 +1,36 @@
1
- import React, { useCallback, useMemo, useRef, useState } from 'react';
1
+ import React, { useRef, useState } from 'react';
2
2
  import { SilkeButton, SilkeButtonProps } from './silke-button';
3
- import { SilkePopover, SilkePopoverProps } from '../silke-popover';
4
- import { isBoolean, isFunction } from 'lodash';
5
- import { generateGuid } from '@vev/utils';
6
- import styles from '../silke-overflow-menu/silke-overflow-menu.scss';
7
- import { ButtonContext } from './index';
8
- import { SilkeBox } from '../silke-box';
9
- import { SilkeOverflowMenuItem } from '../silke-overflow-menu';
10
- import { SilkeDivider } from '../silke-divider';
3
+ import { SilkePopoverProps } from '../silke-popover';
4
+ import { SilkeList } from '../silke-list';
5
+ import { SilkePopoverNative } from '../silke-popover-native';
6
+ import type { SilkeListItemType } from '../silke-list/types';
7
+ import { PopoverPlacement } from '../silke-popover-native/types';
11
8
 
12
9
  export type SilkeDropdownButtonProps = {
13
- children?: React.ReactNode;
14
- open?: boolean;
15
- /**
16
- * What triggers the opening of the overflow menu
17
- * @default "click"
18
- */
19
- trigger?: 'click' | 'right-click';
20
- onToggleOpen?: (open: boolean) => void;
21
- /** Pass items or children */
22
- items?:
23
- | (SilkeOverflowMenuItem | React.ReactElement | 'divider')[]
24
- | (() => (SilkeOverflowMenuItem | React.ReactElement | 'divider')[]);
10
+ items?: SilkeListItemType[];
11
+ placement?: PopoverPlacement;
25
12
  matchWidth?: boolean;
13
+ animate?: boolean;
14
+ size?: 's' | 'base';
15
+ closeOnSelect?: boolean;
26
16
  } & SilkeButtonProps &
27
17
  Omit<SilkePopoverProps, 'anchor' | 'hide' | 'children' | 'kind'>;
28
18
 
29
19
  export function SilkeDropdownButton({
30
- children,
31
20
  label,
32
- open: externalOpen,
33
21
  icon,
34
22
  items = [],
35
23
  offsetX,
36
- offsetY,
37
- trigger = 'click',
38
- targetOrigin = 'top-right',
39
- anchorOrigin = 'bottom-right',
40
- onClick,
41
- onMouseDown,
42
- onToggleOpen,
24
+ offsetY = 2,
25
+ placement = 'bottom-end',
43
26
  matchWidth = false,
27
+ size = 'base',
28
+ animate = false,
29
+ closeOnSelect = false,
44
30
  ...rest
45
31
  }: SilkeDropdownButtonProps) {
46
- const [open, setOpen] = useState(false);
47
- const ref = useRef<HTMLElement>(null);
48
- const isOpen = isBoolean(externalOpen) ? externalOpen : open;
49
- const buttonId = useMemo(() => {
50
- return 'button-' + generateGuid();
51
- }, []);
52
-
53
- const handleToggleOpen = useCallback(
54
- (e: any) => {
55
- e?.stopPropagation();
56
- if (onMouseDown) onMouseDown(e);
57
- if (isBoolean(externalOpen) && onToggleOpen) {
58
- // Handle open/close externally
59
- onToggleOpen(!isOpen);
60
- } else if (
61
- isOpen ||
62
- (trigger === 'click' && !e?.button) ||
63
- (trigger === 'right-click' && e?.button === 2)
64
- ) {
65
- // Handle open/close internally
66
- setOpen(!isOpen);
67
- }
68
- },
69
- [externalOpen, trigger, isOpen, onToggleOpen],
70
- );
71
-
72
- const boxRef = useRef<HTMLDivElement>(null);
73
-
74
- if (anchorOrigin?.includes('top')) offsetY = (offsetY || 0) - 1;
75
- else offsetY = (offsetY || 0) + 1;
32
+ const [isOpen, setIsOpen] = useState(false);
33
+ const ref = useRef<HTMLButtonElement>(null);
76
34
 
77
35
  return (
78
36
  <>
@@ -80,73 +38,33 @@ export function SilkeDropdownButton({
80
38
  ref={ref}
81
39
  label={label}
82
40
  icon={icon || (isOpen ? 'chevron.up' : 'chevron.down')}
83
- id={buttonId}
84
41
  aria-expanded={isOpen}
85
42
  aria-label="Menu"
86
43
  aria-haspopup="true"
87
- onMouseDown={handleToggleOpen}
88
- onContextMenu={trigger === 'right-click' ? (e) => e.preventDefault() : undefined}
89
- onClick={(e) => {
90
- e.stopPropagation();
91
- e.preventDefault();
92
- if (onClick) onClick(e);
93
- // Ugly hack to separate mouse and keyboard events
94
- if (!e.screenX && !e.screenY) handleToggleOpen(e);
95
- }}
44
+ selected={isOpen}
45
+ onClick={() => setIsOpen(!isOpen)}
96
46
  {...rest}
97
47
  />
98
- {isOpen && (
99
- <SilkePopover
100
- anchor={ref}
101
- matchAnchorWidth={matchWidth}
102
- contextId="silke.overflow.menu"
103
- offsetX={offsetX}
104
- offsetY={offsetY}
105
- targetOrigin={targetOrigin}
106
- anchorOrigin={anchorOrigin}
107
- onRequestClose={handleToggleOpen}
108
- >
109
- <ButtonContext size="base">
110
- {items && (
111
- <SilkeBox
112
- tabIndex={-1}
113
- column
114
- pad="xs"
115
- bg="neutral-20"
116
- shadow="level2"
117
- className={styles.menu}
118
- onClick={() => setOpen(false)}
119
- ref={boxRef}
120
- aria-labelledby={buttonId}
121
- >
122
- {(isFunction(items) ? items() : items)?.map((item, index) => {
123
- return React.isValidElement(item) ? (
124
- item
125
- ) : item === 'divider' ? (
126
- <SilkeDivider key={index} dark />
127
- ) : (
128
- <SilkeOverflowMenuItem
129
- key={index}
130
- size={rest.size}
131
- {...(item as SilkeOverflowMenuItem)}
132
- onClick={(e) => {
133
- e.stopPropagation();
134
- (item as SilkeOverflowMenuItem).onClick?.(e);
135
- handleToggleOpen(e);
136
- }}
137
- />
138
- );
139
- })}
140
- </SilkeBox>
141
- )}
142
- {children && (
143
- <div ref={boxRef} tabIndex={-1} aria-labelledby={buttonId}>
144
- {children}
145
- </div>
146
- )}
147
- </ButtonContext>
148
- </SilkePopover>
149
- )}
48
+
49
+ <SilkePopoverNative
50
+ anchor={ref}
51
+ hide={!isOpen}
52
+ offsetX={offsetX}
53
+ offsetY={offsetY}
54
+ placement={placement}
55
+ matchWidth={matchWidth}
56
+ hideBackdrop
57
+ animate={animate}
58
+ onRequestClose={() => setIsOpen(false)}
59
+ shadow="level4"
60
+ >
61
+ <SilkeList
62
+ items={items || []}
63
+ size={size}
64
+ maxHeight={400}
65
+ onSelect={() => closeOnSelect && setIsOpen(false)}
66
+ />
67
+ </SilkePopoverNative>
150
68
  </>
151
69
  );
152
70
  }
@@ -28,13 +28,15 @@ export function SilkeCardGrid({
28
28
  );
29
29
  }
30
30
 
31
- export function SilkeSkeletonCard() {
31
+ export const SilkeSkeletonCard = React.forwardRef<HTMLDivElement, BoxDivProps>((props, ref) => {
32
32
  return (
33
- <SilkeBox column gap="s" className={styles.card}>
33
+ <SilkeBox column gap="s" className={styles.card} ref={ref} {...props}>
34
34
  <SilkeBox className={styles.imageWrapper} column bg="surface-2">
35
35
  <div className={styles.img} />
36
36
  </SilkeBox>
37
37
  <SilkeBox rounded="tiny" gap="m" column flex bg="surface-2" height="s" />
38
38
  </SilkeBox>
39
39
  );
40
- }
40
+ });
41
+
42
+ SilkeSkeletonCard.displayName = 'SilkeSkeletonCard';
@@ -92,7 +92,9 @@ body {
92
92
  object-fit: cover;
93
93
  scale: 1;
94
94
  transform-origin: center center;
95
- transition: $transition-duration scale ease-out, 3s filter ease-out,
95
+ transition:
96
+ $transition-duration scale ease-out,
97
+ 3s filter ease-out,
96
98
  $transition-duration translate ease-out;
97
99
  &.shadow {
98
100
  filter: drop-shadow(0 0 50px rgba(0, 0, 0, 0.3));
@@ -139,7 +141,7 @@ body {
139
141
  }
140
142
 
141
143
  .cardText .title {
142
- font-family: "Roboto Flex", sans-serif;
144
+ font-family: 'Roboto Flex', sans-serif;
143
145
  font-variation-settings: var(--font-variation-settings-brand);
144
146
  line-height: 1;
145
147
  }
@@ -158,8 +160,7 @@ body {
158
160
  grid-template-columns: repeat(auto-fill, minmax(var(--min-card-width), 1fr));
159
161
  grid-template-rows: max-content;
160
162
  max-width: calc(
161
- var(--card-size) * var(--max-columns) + var(--grid-gap) *
162
- (var(--max-columns) - 1)
163
+ var(--card-size) * var(--max-columns) + var(--grid-gap) * (var(--max-columns) - 1)
163
164
  );
164
165
 
165
166
  &.small {
@@ -174,8 +175,8 @@ body {
174
175
  gap: 2px;
175
176
  }
176
177
 
177
- .title{
178
- font-family: "Roboto Flex", sans-serif;
178
+ .title {
179
+ font-family: 'Roboto Flex', sans-serif;
179
180
  font-variation-settings: var(--font-variation-settings);
180
181
  font-size: 12px;
181
182
  }
@@ -208,7 +209,7 @@ body {
208
209
  fill: var(--color-surface-3);
209
210
  }
210
211
  &::before {
211
- content: "";
212
+ content: '';
212
213
  position: absolute;
213
214
  top: 0;
214
215
  right: 0;
@@ -163,7 +163,13 @@ export const SilkeCard = React.forwardRef(
163
163
  gap="xs"
164
164
  className={`${styles.cardText} ${styles.overflowHidden}`}
165
165
  >
166
- <SilkeText size="base" flex overflow className={styles.title}>
166
+ <SilkeText
167
+ size="base"
168
+ flex
169
+ overflow
170
+ className={styles.title}
171
+ title={typeof title === 'string' ? title : undefined}
172
+ >
167
173
  {title}
168
174
  </SilkeText>
169
175
  {subTitle && (