@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.
Files changed (174) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/index.js +40 -38
  3. package/dist/index.js.LEGAL.txt +12 -0
  4. package/dist/styles.css +1596 -1036
  5. package/dist/types/components/index.d.ts +4 -1
  6. package/dist/types/components/silke-autocomplete-field/autocomplete-types.d.ts +4 -0
  7. package/dist/types/components/silke-autocomplete-field/index.d.ts +1 -0
  8. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +60 -0
  9. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +3 -0
  10. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-popup-native.d.ts +15 -0
  11. package/dist/types/components/silke-button/silke-dropdown-button.d.ts +8 -13
  12. package/dist/types/components/silke-card/silke-card-grid.d.ts +33 -1
  13. package/dist/types/components/silke-command-text-field/image-utils.d.ts +20 -0
  14. package/dist/types/components/silke-command-text-field/index.d.ts +4 -0
  15. package/dist/types/components/silke-command-text-field/silke-command-parser.d.ts +3 -0
  16. package/dist/types/components/silke-command-text-field/silke-command-parser.spec.d.ts +1 -0
  17. package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +46 -0
  18. package/dist/types/components/silke-command-text-field/utils.d.ts +61 -0
  19. package/dist/types/components/silke-command-text-field/utils.spec.d.ts +1 -0
  20. package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
  21. package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +1 -0
  22. package/dist/types/components/silke-image/silke-image.d.ts +2 -1
  23. package/dist/types/components/silke-list/index.d.ts +1 -0
  24. package/dist/types/components/silke-list/silke-list-item.d.ts +24 -6
  25. package/dist/types/components/silke-list/silke-list.d.ts +9 -9
  26. package/dist/types/components/silke-list/types.d.ts +19 -0
  27. package/dist/types/components/silke-list/utils.d.ts +3 -0
  28. package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +1 -0
  29. package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +6 -1
  30. package/dist/types/components/silke-popover-native/index.d.ts +1 -0
  31. package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +37 -0
  32. package/dist/types/components/silke-popover-native/types.d.ts +6 -0
  33. package/dist/types/components/silke-popover-native/use-popover-positioning.d.ts +9 -0
  34. package/dist/types/components/silke-select-field/index.d.ts +1 -0
  35. package/dist/types/components/silke-select-field/silke-select-field-native.d.ts +4 -0
  36. package/dist/types/components/silke-shortcut-button/index.d.ts +1 -0
  37. package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +15 -0
  38. package/dist/types/components/silke-tag/silke-tag.d.ts +1 -1
  39. package/dist/types/icons.d.ts +32 -0
  40. package/jest.config.js +2 -3
  41. package/package.json +9 -3
  42. package/src/_variables.scss +125 -129
  43. package/src/components/index.ts +4 -1
  44. package/src/components/silke-action-box/silke-action-box.scss +2 -3
  45. package/src/components/silke-alert-banner/silke-alert-banner.scss +9 -10
  46. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +2 -2
  47. package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
  48. package/src/components/silke-autocomplete-field/index.ts +1 -0
  49. package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +346 -0
  50. package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +39 -0
  51. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -12
  52. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +3 -0
  53. package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +542 -0
  54. package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +92 -41
  55. package/src/components/silke-box/silke-box.mdx +321 -21
  56. package/src/components/silke-box/silke-box.scss +5 -5
  57. package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +147 -9
  58. package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
  59. package/src/components/silke-button/silke-big-button.scss +1 -1
  60. package/src/components/silke-button/silke-button.scss +27 -18
  61. package/src/components/silke-button/silke-dropdown-button.mdx +67 -0
  62. package/src/components/silke-button/silke-dropdown-button.tsx +40 -122
  63. package/src/components/silke-card/silke-card-grid.tsx +5 -3
  64. package/src/components/silke-card/silke-card.scss +8 -7
  65. package/src/components/silke-card/silke-card.tsx +7 -1
  66. package/src/components/silke-checkbox/silke-checkbox.mdx +139 -14
  67. package/src/components/silke-checkbox/silke-checkbox.scss +11 -11
  68. package/src/components/silke-color-picker/color-picker.scss +8 -8
  69. package/src/components/silke-color-swatches/silke-color-swatches.mdx +130 -0
  70. package/src/components/silke-command-text-field/image-utils.ts +71 -0
  71. package/src/components/silke-command-text-field/index.ts +12 -0
  72. package/src/components/silke-command-text-field/silke-command-parser.spec.ts +89 -0
  73. package/src/components/silke-command-text-field/silke-command-parser.ts +47 -0
  74. package/src/components/silke-command-text-field/silke-command-text-field.mdx +301 -0
  75. package/src/components/silke-command-text-field/silke-command-text-field.module.scss +119 -0
  76. package/src/components/silke-command-text-field/silke-command-text-field.tsx +665 -0
  77. package/src/components/silke-command-text-field/utils.spec.ts +366 -0
  78. package/src/components/silke-command-text-field/utils.ts +287 -0
  79. package/src/components/silke-conditions-input/silke-conditions-input.scss +4 -4
  80. package/src/components/silke-content-column/silke-content-column.scss +1 -1
  81. package/src/components/silke-context-menu/silke-context-menu.scss +3 -4
  82. package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
  83. package/src/components/silke-css-number-field/silke-css-number-field.scss +14 -12
  84. package/src/components/silke-divider/silke-divider.mdx +154 -32
  85. package/src/components/silke-divider/silke-divider.scss +3 -2
  86. package/src/components/silke-drawer/silke-drawer.scss +6 -2
  87. package/src/components/silke-form/silke-form.mdx +254 -27
  88. package/src/components/silke-form-schema/fields/array-field-inline.tsx +1 -0
  89. package/src/components/silke-form-schema/fields/array-field-modal.tsx +1 -0
  90. package/src/components/silke-form-schema/fields/styles.scss +34 -35
  91. package/src/components/silke-form-schema/silke-schema-field.tsx +1 -1
  92. package/src/components/silke-form-schema/silke-schema-fields.tsx +4 -3
  93. package/src/components/silke-gradient-picker/silke-gradient-picker.module.scss +2 -2
  94. package/src/components/silke-icon/silke-icon.mdx +212 -8
  95. package/src/components/silke-icon/silke-icon.scss +10 -2
  96. package/src/components/silke-icon/silke-icon.tsx +1 -0
  97. package/src/components/silke-icon/silke-stacked-icon.scss +42 -45
  98. package/src/components/silke-icon-browser/silke-icon-browser.mdx +143 -0
  99. package/src/components/silke-image/silke-image-color-backdrop.scss +6 -6
  100. package/src/components/silke-image/silke-image.mdx +189 -41
  101. package/src/components/silke-image/silke-image.scss +3 -3
  102. package/src/components/silke-image/silke-image.tsx +14 -1
  103. package/src/components/silke-link/silke-link.scss +3 -5
  104. package/src/components/silke-list/index.ts +1 -0
  105. package/src/components/silke-list/silke-list-item.mdx +83 -0
  106. package/src/components/silke-list/silke-list-item.scss +119 -0
  107. package/src/components/silke-list/silke-list-item.tsx +137 -12
  108. package/src/components/silke-list/silke-list.mdx +108 -13
  109. package/src/components/silke-list/silke-list.scss +8 -15
  110. package/src/components/silke-list/silke-list.tsx +63 -9
  111. package/src/components/silke-list/types.ts +22 -0
  112. package/src/components/silke-list/utils.ts +24 -0
  113. package/src/components/silke-loader/silke-loader.mdx +139 -5
  114. package/src/components/silke-loader/silke-loader.scss +1 -1
  115. package/src/components/silke-modal/silke-modal.scss +9 -9
  116. package/src/components/silke-navigation-link/silke-navigation-link.mdx +27 -2
  117. package/src/components/silke-navigation-link/silke-navigation-link.scss +34 -40
  118. package/src/components/silke-navigation-link/silke-navigation-link.tsx +7 -6
  119. package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +228 -31
  120. package/src/components/silke-overflow-menu/silke-overflow-menu.scss +8 -8
  121. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +14 -8
  122. package/src/components/silke-popover/silke-popover.scss +5 -5
  123. package/src/components/silke-popover-native/index.ts +1 -0
  124. package/src/components/silke-popover-native/silke-popover-native.mdx +207 -0
  125. package/src/components/silke-popover-native/silke-popover-native.scss +127 -0
  126. package/src/components/silke-popover-native/silke-popover-native.tsx +176 -0
  127. package/src/components/silke-popover-native/types.ts +21 -0
  128. package/src/components/silke-popover-native/use-popover-positioning.ts +157 -0
  129. package/src/components/silke-progress-indicator/silke-progress-indicator.scss +1 -1
  130. package/src/components/silke-radio-button/silke-radio-button.scss +18 -11
  131. package/src/components/silke-search-field/silke-search-field.mdx +161 -7
  132. package/src/components/silke-select-field/index.ts +1 -0
  133. package/src/components/silke-select-field/silke-select-field-native.tsx +17 -0
  134. package/src/components/silke-select-field/silke-select-field.mdx +65 -0
  135. package/src/components/silke-shortcut-button/index.ts +1 -0
  136. package/src/components/silke-shortcut-button/silke-shortcut-button.mdx +89 -0
  137. package/src/components/silke-shortcut-button/silke-shortcut-button.scss +145 -0
  138. package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +55 -0
  139. package/src/components/silke-skeleton/silke-skeleton.mdx +109 -0
  140. package/src/components/silke-skeleton/silke-skeleton.scss +1 -1
  141. package/src/components/silke-slider/silke-slider.module.scss +19 -19
  142. package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +3 -3
  143. package/src/components/silke-sortable-list/silke-sortable-list.scss +4 -5
  144. package/src/components/silke-table/silke-table.scss +1 -1
  145. package/src/components/silke-tabs/silke-tabs.scss +3 -3
  146. package/src/components/silke-tag/silke-tag.mdx +179 -43
  147. package/src/components/silke-tag/silke-tag.scss +49 -12
  148. package/src/components/silke-tag/silke-tag.tsx +17 -7
  149. package/src/components/silke-text/silke-text.scss +6 -4
  150. package/src/components/silke-text/silke-title.scss +7 -14
  151. package/src/components/silke-text-field/silke-text-field.scss +9 -9
  152. package/src/components/silke-text-field/silke-text-field.tsx +3 -2
  153. package/src/components/silke-tile/silke-tile.scss +7 -3
  154. package/src/components/silke-toast-notification/silke-toast-notification.scss +4 -5
  155. package/src/components/silke-toggle/silke-toggle.mdx +163 -33
  156. package/src/components/silke-toggle/silke-toggle.scss +4 -4
  157. package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
  158. package/src/components/silke-tooltip/silke-shortcuts.tsx +3 -3
  159. package/src/components/silke-tooltip/silke-tooltip.scss +11 -16
  160. package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +9 -7
  161. package/src/components/silke-virtual/silke-virtual.mdx +161 -0
  162. package/src/components/silke-virtual/silke-virtual.scss +8 -8
  163. package/src/icons.tsx +45 -1
  164. package/src/styles/core.scss +42 -45
  165. package/src/styles/math.scss +66 -66
  166. package/tsconfig.build.json +2 -6
  167. package/tsconfig.build.tsbuildinfo +1 -1
  168. package/tsconfig.json +3 -14
  169. package/dist/types/components/silke-list-card/index.d.ts +0 -1
  170. package/dist/types/components/silke-list-card/silke-list-card.d.ts +0 -14
  171. package/src/components/silke-list-card/index.ts +0 -1
  172. package/src/components/silke-list-card/silke-list-card.mdx +0 -46
  173. package/src/components/silke-list-card/silke-list-card.scss +0 -57
  174. package/src/components/silke-list-card/silke-list-card.tsx +0 -63
@@ -1,55 +1,203 @@
1
- # Image
1
+ # SilkeImage
2
2
 
3
- NB: You can not define width of image or place in layout row
3
+ A versatile image component that handles standard images, avatars, icons, emoji, and shapes. Supports aspect ratio constraints and integrates with the SilkeBox layout system.
4
+
5
+ ## Features
6
+
7
+ - **Standard images**: Display images with URL source
8
+ - **Avatar mode**: Circular profile pictures in various sizes
9
+ - **Icon support**: Display Silke icons in place of images
10
+ - **Emoji support**: Render emoji characters
11
+ - **Aspect ratios**: Constrain images to 16:9, 4:3, or 1:1
12
+ - **Background color**: Set fallback background color
13
+
14
+ ## Basic Usage
15
+
16
+ ```js
17
+ <SilkeImage src="https://picsum.photos/400/300" alt="Sample image" />
18
+ ```
19
+
20
+ ## Aspect Ratios
21
+
22
+ Constrain images to standard aspect ratios:
4
23
 
5
24
  ```js
6
- <SilkeBox fill align="center">
7
- <SilkeBox column gap style={{ width: 300 }}>
8
- <SilkeImage aspectRatio="16:9" src={ipsum.image()} />
9
- <SilkeImage aspectRatio="4:3" src={ipsum.image()} />
10
- <SilkeImage aspectRatio="1:1" src={ipsum.image()} />
25
+ <SilkeBox gap="m">
26
+ <SilkeBox column gap="xs" style={{ width: 200 }}>
27
+ <SilkeImage aspectRatio="16:9" src="https://picsum.photos/400/225" />
28
+ <SilkeText size="s" color="neutral-60">16:9</SilkeText>
11
29
  </SilkeBox>
30
+ <SilkeBox column gap="xs" style={{ width: 200 }}>
31
+ <SilkeImage aspectRatio="4:3" src="https://picsum.photos/400/300" />
32
+ <SilkeText size="s" color="neutral-60">4:3</SilkeText>
33
+ </SilkeBox>
34
+ <SilkeBox column gap="xs" style={{ width: 150 }}>
35
+ <SilkeImage aspectRatio="1:1" src="https://picsum.photos/400/400" />
36
+ <SilkeText size="s" color="neutral-60">1:1</SilkeText>
37
+ </SilkeBox>
38
+ </SilkeBox>
39
+ ```
40
+
41
+ ## Avatar Mode
42
+
43
+ Use `avatar` for circular profile pictures:
44
+
45
+ ```js
46
+ <SilkeBox gap="m" vAlign="end">
47
+ <SilkeBox column gap="xs" vAlign="center">
48
+ <SilkeImage avatar="xs" src="https://i.pravatar.cc/100?img=1" alt="User" />
49
+ <SilkeText size="s">xs</SilkeText>
50
+ </SilkeBox>
51
+ <SilkeBox column gap="xs" vAlign="center">
52
+ <SilkeImage avatar="s" src="https://i.pravatar.cc/100?img=2" alt="User" />
53
+ <SilkeText size="s">s</SilkeText>
54
+ </SilkeBox>
55
+ <SilkeBox column gap="xs" vAlign="center">
56
+ <SilkeImage avatar src="https://i.pravatar.cc/100?img=3" alt="User" />
57
+ <SilkeText size="s">base</SilkeText>
58
+ </SilkeBox>
59
+ <SilkeBox column gap="xs" vAlign="center">
60
+ <SilkeImage avatar="m" src="https://i.pravatar.cc/100?img=4" alt="User" />
61
+ <SilkeText size="s">m</SilkeText>
62
+ </SilkeBox>
63
+ <SilkeBox column gap="xs" vAlign="center">
64
+ <SilkeImage avatar="l" src="https://i.pravatar.cc/100?img=5" alt="User" />
65
+ <SilkeText size="s">l</SilkeText>
66
+ </SilkeBox>
67
+ <SilkeBox column gap="xs" vAlign="center">
68
+ <SilkeImage avatar="xl" src="https://i.pravatar.cc/100?img=6" alt="User" />
69
+ <SilkeText size="s">xl</SilkeText>
70
+ </SilkeBox>
71
+ </SilkeBox>
72
+ ```
73
+
74
+ ## With Icon
75
+
76
+ Display a Silke icon instead of an image:
77
+
78
+ ```js
79
+ <SilkeBox gap="m">
80
+ <SilkeImage avatar="m" icon="user" bgColor="var(--color-accent-20)" />
81
+ <SilkeImage avatar="m" icon="star" bgColor="var(--color-warning-20)" />
82
+ <SilkeImage avatar="m" icon="check" bgColor="var(--color-success-20)" />
83
+ <SilkeImage avatar="m" icon="settings" bgColor="var(--color-neutral-20)" />
84
+ </SilkeBox>
85
+ ```
86
+
87
+ ## With Emoji
88
+
89
+ Display emoji characters:
90
+
91
+ ```js
92
+ <SilkeBox gap="m">
93
+ <SilkeImage avatar="m" icon={{ type: 0, value: '👋' }} bgColor="var(--color-accent-10)" />
94
+ <SilkeImage avatar="m" icon={{ type: 0, value: '🎉' }} bgColor="var(--color-warning-10)" />
95
+ <SilkeImage avatar="m" icon={{ type: 0, value: '🚀' }} bgColor="var(--color-success-10)" />
96
+ <SilkeImage avatar="m" icon={{ type: 0, value: '💡' }} bgColor="var(--color-neutral-10)" />
12
97
  </SilkeBox>
13
98
  ```
14
99
 
15
- ## Avatar
100
+ ## Background Color
101
+
102
+ Set a background color for avatars or as a fallback:
16
103
 
17
104
  ```js
18
- <SilkeBox gap>
19
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar="tiny" />
20
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar="small" />
21
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar />
22
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar="medium" />
23
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar="large" />
24
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar="x-large" />
25
- <SilkeImage src={ipsum.image()} alt="Profile pic" avatar="huge" />
105
+ <SilkeBox gap="m">
106
+ <SilkeImage avatar="m" bgColor="#6366f1" />
107
+ <SilkeImage avatar="m" bgColor="#22c55e" />
108
+ <SilkeImage avatar="m" bgColor="#f59e0b" />
109
+ <SilkeImage avatar="m" bgColor="#ef4444" />
26
110
  </SilkeBox>
27
111
  ```
28
112
 
29
- ## Emoji
30
-
31
- ```js
32
- <SilkeBox gap>
33
- <SilkeImage
34
- avatar="m"
35
- icon={{
36
- type: 0,
37
- value: '👋',
38
- }}
39
- />
40
- <SilkeImage
41
- avatar="m"
42
- icon={{
43
- type: 0,
44
- value: '🧙‍♂️',
45
- }}
46
- />
47
- <SilkeImage
48
- avatar="m"
49
- icon={{
50
- type: 0,
51
- value: '👩‍💻',
52
- }}
53
- />
113
+ ## User List Example
114
+
115
+ ```js
116
+ const users = [
117
+ { name: 'Alice', avatar: 'https://i.pravatar.cc/100?img=1' },
118
+ { name: 'Bob', avatar: 'https://i.pravatar.cc/100?img=2' },
119
+ { name: 'Charlie', avatar: 'https://i.pravatar.cc/100?img=3' },
120
+ ];
121
+
122
+ <SilkeBox column gap="s">
123
+ {users.map((user) => (
124
+ <SilkeBox key={user.name} gap="s" vAlign="center">
125
+ <SilkeImage avatar="s" src={user.avatar} alt={user.name} />
126
+ <SilkeText>{user.name}</SilkeText>
127
+ </SilkeBox>
128
+ ))}
129
+ </SilkeBox>;
130
+ ```
131
+
132
+ ## Card with Image
133
+
134
+ ```js
135
+ <SilkeCard style={{ width: 300 }}>
136
+ <SilkeImage aspectRatio="16:9" src="https://picsum.photos/600/338" />
137
+ <SilkeBox column pad="m" gap="xs">
138
+ <SilkeText weight="medium">Card Title</SilkeText>
139
+ <SilkeText size="s" color="neutral-60">Card description goes here</SilkeText>
140
+ </SilkeBox>
141
+ </SilkeCard>
142
+ ```
143
+
144
+ ## Fallback Avatar
145
+
146
+ Show initials or icon when no image is available:
147
+
148
+ ```js
149
+ <SilkeBox gap="m">
150
+ <SilkeImage avatar="m" icon="user" bgColor="var(--color-neutral-30)" />
151
+ <SilkeImage avatar="m" icon={{ type: 0, value: 'JD' }} bgColor="var(--color-accent-40)" />
54
152
  </SilkeBox>
55
153
  ```
154
+
155
+ ## Props
156
+
157
+ | Prop | Type | Default | Description |
158
+ | ------------- | ------------------------------ | ------- | ---------------------------------------- |
159
+ | `src` | `string` | - | Image URL |
160
+ | `alt` | `string` | - | Alt text for accessibility |
161
+ | `avatar` | `BoxSize \| true` | - | Enable circular avatar mode with size |
162
+ | `icon` | `IEmojiIcon \| SilkeIcons` | - | Display icon or emoji instead of image |
163
+ | `bgColor` | `string` | - | Background color |
164
+ | `aspectRatio` | `'16:9' \| '4:3' \| '1:1'` | - | Constrain to aspect ratio |
165
+ | `draggable` | `boolean` | - | Allow image to be dragged |
166
+
167
+ Also accepts all `SilkeBox` props for layout control.
168
+
169
+ ## Types
170
+
171
+ ```typescript
172
+ type SilkeImageProps = {
173
+ src?: string;
174
+ icon?: IEmojiIcon | SilkeIcons;
175
+ alt?: string;
176
+ avatar?: BoxSize | true;
177
+ bgColor?: string;
178
+ } & BoxProps;
179
+
180
+ // EmojiType values
181
+ enum EmojiType {
182
+ emoji = 0,
183
+ icon = 1,
184
+ upload = 2,
185
+ }
186
+
187
+ interface IEmojiIcon {
188
+ type: EmojiType;
189
+ value: string | { url: string };
190
+ }
191
+ ```
192
+
193
+ ## Avatar Sizes
194
+
195
+ | Size | Pixels |
196
+ | ------ | ------ |
197
+ | `xs` | 16px |
198
+ | `s` | 24px |
199
+ | `base` | 32px |
200
+ | `m` | 48px |
201
+ | `l` | 64px |
202
+ | `xl` | 96px |
203
+ | `xxl` | 128px |
@@ -9,8 +9,8 @@
9
9
  .avatar {
10
10
  border-radius: 50%;
11
11
  overflow: hidden;
12
- font-size:calc(var(--box-width) - 8px);
13
- svg{
12
+ font-size: calc(var(--box-width) - 8px);
13
+ svg {
14
14
  width: calc(var(--box-width) - 8px);
15
15
  height: calc(var(--box-width) - 8px);
16
16
  }
@@ -19,7 +19,7 @@
19
19
  .emoji {
20
20
  width: var(--box-width);
21
21
  height: var(--box-width);
22
- font-size: calc(var(--box-width) - 8px);
22
+ font-size: calc(var(--box-width) - 10px);
23
23
  vertical-align: middle;
24
24
  text-align: center;
25
25
  line-height: var(--box-height);
@@ -11,9 +11,18 @@ export type SilkeImageProps = {
11
11
  icon?: IEmojiIcon | SilkeIcons;
12
12
  alt?: string;
13
13
  avatar?: BoxSize | true;
14
+ bgColor?: string;
14
15
  } & BoxProps;
15
16
 
16
- export function SilkeImage({ src, alt, avatar, icon, draggable, ...rest }: SilkeImageProps) {
17
+ export function SilkeImage({
18
+ src,
19
+ alt,
20
+ avatar,
21
+ icon,
22
+ draggable,
23
+ bgColor,
24
+ ...rest
25
+ }: SilkeImageProps) {
17
26
  if (avatar) {
18
27
  rest.className = styles.avatar + ' ' + (rest.className || '');
19
28
  if (avatar === true) avatar = 'base';
@@ -22,6 +31,10 @@ export function SilkeImage({ src, alt, avatar, icon, draggable, ...rest }: Silke
22
31
  delete rest.aspectRatio;
23
32
  }
24
33
 
34
+ if (bgColor) {
35
+ rest.style = { ...rest.style, backgroundColor: bgColor };
36
+ }
37
+
25
38
  if (icon) {
26
39
  if (isString(icon)) {
27
40
  return (
@@ -1,13 +1,12 @@
1
1
  @use '../../variables' as *;
2
2
  :global {
3
-
4
3
  .silke-link {
5
- text-decoration: underline;
4
+ text-decoration: underline;
6
5
  cursor: pointer;
7
6
  color: var(--color-accent-40);
8
7
  user-select: text;
9
8
 
10
- &.secondary{
9
+ &.secondary {
11
10
  color: var(--color-neutral-40);
12
11
  }
13
12
 
@@ -30,7 +29,7 @@
30
29
  }
31
30
 
32
31
  .silke-link-icon {
33
- margin-left: .25em;
32
+ margin-left: 0.25em;
34
33
  }
35
34
 
36
35
  button.silke-link {
@@ -40,5 +39,4 @@
40
39
  text-align: inherit;
41
40
  padding: 0;
42
41
  }
43
-
44
42
  }
@@ -1,2 +1,3 @@
1
1
  export * from './silke-list';
2
2
  export * from './silke-list-item';
3
+ export * from './types';
@@ -0,0 +1,83 @@
1
+ # Silke list item
2
+
3
+ ## Basic usage
4
+
5
+ ```js
6
+ <SilkeListItem label="Item 1" />
7
+ ```
8
+
9
+ ## With icon
10
+
11
+ ```js
12
+ <SilkeListItem label="Item 1" icon="widget" />
13
+ ```
14
+
15
+ ## With tag
16
+
17
+ ```js
18
+ <SilkeListItem
19
+ label="Item 1"
20
+ icon="widget"
21
+ tag={{ label: 'Tag', size: 'tiny', kind: 'secondary' }}
22
+ />
23
+ ```
24
+
25
+ ## With subLabel
26
+
27
+ ```js
28
+ <SilkeBox column gap="xxs">
29
+ <SilkeListItem label="Item 1" subLabel="Sub label" />
30
+ <SilkeListItem label="Item 1" subLabel={<SilkeText>Sub label</SilkeText>} />
31
+ <SilkeListItem
32
+ label="Item 1"
33
+ subLabel="Sub label"
34
+ icon="widget"
35
+ tag={{ label: 'Tag', size: 'tiny', kind: 'secondary' }}
36
+ />
37
+ </SilkeBox>
38
+ ```
39
+
40
+ ## With items
41
+
42
+ ```js
43
+ <SilkeListItem label="Item 1" items={[{ label: 'Item 1.1' }, { label: 'Item 1.2' }]} />
44
+ ```
45
+
46
+ ## With link
47
+
48
+ ```js
49
+ <SilkeListItem label="Item 1" link="https://www.google.com" />
50
+ ```
51
+
52
+ ## With active indicator
53
+
54
+ ```js
55
+ const [activeIndex, setActiveIndex] = React.useState(0);
56
+
57
+ <SilkeBox column gap="xxs">
58
+ <SilkeListItem label="Item 1" active={activeIndex === 0} onClick={() => setActiveIndex(0)} />
59
+ <SilkeListItem label="Item 2" active={activeIndex === 1} onClick={() => setActiveIndex(1)} />
60
+ <SilkeListItem label="Item 3" active={activeIndex === 2} onClick={() => setActiveIndex(2)} />
61
+ </SilkeBox>;
62
+ ```
63
+
64
+ ## With children
65
+
66
+ ```js
67
+ <SilkeListItem label="Item 1" children={<SilkeText>Children</SilkeText>} />
68
+ ```
69
+
70
+ ## With super long label
71
+
72
+ ```js
73
+ <div style={{ width: 200 }}>
74
+ <SilkeListItem
75
+ label="Item 1"
76
+ icon="widget"
77
+ items={[{ label: 'Item 1.1' }, { label: 'Item 1.2' }]}
78
+ label="lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut
79
+ labore et dolore magna aliqua. lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
80
+ do eiusmod tempor incididunt ut labore et dolore magna aliqua."
81
+ />
82
+ </div>
83
+ ```
@@ -0,0 +1,119 @@
1
+ @use '../../variables' as *;
2
+
3
+ .item {
4
+ flex: 1;
5
+ color: var(--color-neutral-90);
6
+ background-color: transparent;
7
+ width: 100%;
8
+ cursor: pointer;
9
+ }
10
+ .item:focus {
11
+ outline: none;
12
+ background-color: var(--color-surface-2);
13
+ }
14
+ .item:hover {
15
+ background-color: var(--color-surface-2);
16
+ color: var(--color-neutral-100);
17
+ }
18
+ .item[data-active='true'] {
19
+ background: var(--color-surface-1);
20
+ color: var(--color-neutral-100);
21
+ }
22
+ .item[data-no-icon='true'] .body {
23
+ padding-left: $space-xs;
24
+ }
25
+
26
+ .item:focus-visible::after {
27
+ border: 1px solid var(--color-neutral-70);
28
+ position: absolute;
29
+ border-radius: var(--border-radius-small);
30
+ top: -4px;
31
+ left: -4px;
32
+ right: -4px;
33
+ bottom: -4px;
34
+ content: '';
35
+ z-index: 20;
36
+ }
37
+
38
+ // Active indicator
39
+ .item::before {
40
+ content: '';
41
+ position: absolute;
42
+ display: block;
43
+ height: 16px;
44
+ width: 4px;
45
+ border-radius: var(--border-radius-tiny);
46
+ margin: 8px 0 8px 0;
47
+ pointer-events: none;
48
+ transform: translateX(-20px);
49
+ opacity: 1;
50
+ transition: all 0.2s ease-out;
51
+ }
52
+ .item[data-active='true']::before {
53
+ background: var(--color-accent-30);
54
+ transform: translateX(-12px);
55
+ opacity: 1;
56
+ }
57
+
58
+ .icon {
59
+ font-size: $font-small;
60
+ }
61
+
62
+ .body {
63
+ display: flex;
64
+ flex-direction: column;
65
+ align-items: flex-start;
66
+ overflow: hidden;
67
+ }
68
+
69
+ .label,
70
+ .subLabel {
71
+ width: 100%;
72
+ white-space: nowrap;
73
+ overflow: hidden;
74
+ text-overflow: ellipsis;
75
+ }
76
+
77
+ .subLabel {
78
+ color: var(--color-neutral-70);
79
+ }
80
+
81
+ .arrow {
82
+ margin-left: auto;
83
+ font-size: $font-small;
84
+ color: var(--color-neutral-70);
85
+ }
86
+
87
+ .children {
88
+ margin-left: auto;
89
+ opacity: 0;
90
+ transition: opacity 0.2s ease-out;
91
+ }
92
+ .children:focus {
93
+ opacity: 1;
94
+ }
95
+
96
+ .item:hover .children,
97
+ .item:focus-visible .children,
98
+ .item[data-always-show-children='true'] .children {
99
+ opacity: 1;
100
+ }
101
+
102
+ @supports selector(.item:has(:focus-visible)) {
103
+ .item:has(:focus-visible) .children {
104
+ opacity: 1;
105
+ }
106
+ }
107
+
108
+ // Modifiers
109
+ .item[data-size='s'] .icon {
110
+ font-size: $font-small;
111
+ }
112
+
113
+ .item[data-pad-body-right='true'] .body {
114
+ padding-right: $space-xs;
115
+ }
116
+
117
+ .item[data-has-children='true'] {
118
+ padding-right: $space-xs;
119
+ }
@@ -1,16 +1,141 @@
1
- import React from 'react';
2
- import { SilkeButton, SilkeButtonProps } from '../silke-button';
3
- import styles from './silke-list.scss';
1
+ import React, { useRef } from 'react';
2
+ import type { SilkeListItemData } from './types';
3
+ import { IEmojiIcon } from '@vev/utils';
4
+ import { isString } from 'lodash';
5
+ import { BoxButtonProps, BoxLinkProps, SilkeBox } from '../silke-box';
6
+ import { SilkeIcon, SilkeIcons } from '../silke-icon';
7
+ import { SilkeTag, SilkeTagProps } from '../silke-tag';
8
+ import { SilkePopoverNative } from '../silke-popover-native';
9
+ import { SilkeList } from './silke-list';
10
+ import { SilkeText } from '../silke-text';
4
11
 
5
- export type SilkeListItemProps = {
6
- focus?: boolean;
7
- selected?: boolean;
8
- } & Omit<SilkeButtonProps, 'kind' | 'size'>;
12
+ import styles from './silke-list-item.scss';
13
+ import { SilkeImage } from '../silke-image';
14
+
15
+ type SilkeListItemProps = {
16
+ label: string | React.ReactNode;
17
+ subLabel?: string | React.ReactNode;
18
+ icon?: IEmojiIcon | SilkeIcons | React.ReactElement;
19
+ items?: SilkeListItemData[];
20
+ link?: string;
21
+ size?: 's' | 'base';
22
+ tag?: SilkeTagProps;
23
+ active?: boolean;
24
+ gap?: boolean;
25
+ maxHeight?: number;
26
+ children?: React.ReactNode;
27
+ alwaysShowChildren?: boolean;
28
+ onClick?: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
29
+ onSelect?: () => void;
30
+ } & Omit<React.ComponentProps<typeof SilkeBox>, 'children' | 'tag'>;
31
+
32
+ export const SilkeListItem = ({
33
+ label,
34
+ subLabel,
35
+ icon,
36
+ items,
37
+ link,
38
+ tag,
39
+ active,
40
+ size,
41
+ gap,
42
+ maxHeight,
43
+ children,
44
+ alwaysShowChildren,
45
+ onClick,
46
+ onSelect,
47
+ ...rest
48
+ }: SilkeListItemProps) => {
49
+ const boxRef = useRef<HTMLButtonElement>(null);
50
+ const hasSubItems = items && items.length > 0;
51
+ const hasChildren = children && React.Children.count(children) > 0;
52
+ const noContentRight = !icon && !children && !tag;
53
+
54
+ const boxContent = (
55
+ <>
56
+ {icon && (
57
+ <SilkeBox size="s" align="center" pad="xs" className={styles.icon}>
58
+ {React.isValidElement(icon) || isString(icon) ? (
59
+ <SilkeIcon icon={icon || 'error'} />
60
+ ) : (
61
+ <SilkeImage icon={icon as any} avatar="s" />
62
+ )}
63
+ </SilkeBox>
64
+ )}
65
+ <div className={styles.body}>
66
+ <SilkeText size={size === 's' ? 'small' : 'base'} className={styles.label}>
67
+ {label}
68
+ </SilkeText>
69
+
70
+ {subLabel && (
71
+ <SilkeText size={size === 's' ? 'micro' : 'small'} className={styles.subLabel}>
72
+ {subLabel}
73
+ </SilkeText>
74
+ )}
75
+ </div>
76
+
77
+ {tag && <SilkeTag {...tag} />}
78
+ {hasSubItems && (
79
+ <span className={styles.arrow}>
80
+ <SilkeIcon icon="right" />
81
+ </span>
82
+ )}
83
+ {children && <span className={styles.children}>{children}</span>}
84
+ </>
85
+ );
86
+
87
+ const commonProps = {
88
+ rounded: 'small' as const,
89
+ gap: size === 's' ? 'xs' : 's',
90
+ bgHover: 'surface-2',
91
+ vPad: 'xs',
92
+ vAlign: 'center',
93
+ hPad: 'xs',
94
+ height: size === 's' ? 's' : 'base',
95
+ className: styles.item,
96
+ 'data-size': size,
97
+ 'data-active': active,
98
+ 'data-has-children': hasChildren,
99
+ 'data-no-icon': !icon,
100
+ 'data-pad-body-right': size !== 's' && noContentRight,
101
+ 'data-always-show-children': alwaysShowChildren,
102
+ onClick: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {
103
+ if (!hasSubItems) {
104
+ onClick?.(e);
105
+ onSelect?.();
106
+ }
107
+ },
108
+ ...rest,
109
+ };
110
+
111
+ const linkProps = {
112
+ tag: 'link',
113
+ to: link,
114
+ ...commonProps,
115
+ } as BoxLinkProps;
116
+
117
+ const buttonProps = {
118
+ tag: 'button',
119
+ ...commonProps,
120
+ } as BoxButtonProps;
9
121
 
10
- export function SilkeListItem({ label, ...rest }: SilkeListItemProps) {
11
122
  return (
12
- <li className={styles.item}>
13
- <SilkeButton kind="ghost" size="base" focus label={label} {...rest} />
14
- </li>
123
+ <>
124
+ {link ? (
125
+ <SilkeBox ref={boxRef} {...linkProps}>
126
+ {boxContent}
127
+ </SilkeBox>
128
+ ) : (
129
+ <SilkeBox ref={boxRef} {...buttonProps}>
130
+ {boxContent}
131
+ </SilkeBox>
132
+ )}
133
+
134
+ {hasSubItems && (
135
+ <SilkePopoverNative hint anchor={boxRef} placement="right-start" hideBackdrop offsetX={8}>
136
+ <SilkeList items={items} gap={gap} maxHeight={maxHeight} onSelect={onSelect} />
137
+ </SilkePopoverNative>
138
+ )}
139
+ </>
15
140
  );
16
- }
141
+ };