@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.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +34 -34
- package/dist/index.js.LEGAL.txt +12 -12
- package/dist/styles.css +4416 -4020
- package/dist/types/components/index.d.ts +3 -2
- 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/fields/color-field.d.ts +3 -0
- package/dist/types/components/silke-form-schema/schema-utils.d.ts +6 -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/silke-popover-native.d.ts +3 -1
- 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 +7 -2
- package/src/_variables.scss +125 -129
- package/src/components/index.ts +3 -2
- 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/silke-autocomplete-field.scss +18 -12
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +3 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +63 -44
- 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 +24 -15
- 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 +672 -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 +9 -4
- package/src/components/silke-form-schema/fields/array-field.tsx +27 -3
- package/src/components/silke-form-schema/fields/color-field.tsx +36 -0
- package/src/components/silke-form-schema/fields/styles.scss +34 -35
- package/src/components/silke-form-schema/schema-utils.ts +27 -1
- package/src/components/silke-form-schema/silke-schema-field.tsx +2 -0
- 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/silke-popover-native.scss +93 -78
- package/src/components/silke-popover-native/silke-popover-native.tsx +4 -0
- package/src/components/silke-popover-native/use-popover-positioning.ts +1 -3
- 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-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 +50 -13
- 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 +1 -1
- 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 +58 -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-action-list/index.d.ts +0 -1
- package/dist/types/components/silke-action-list/silke-action-list.d.ts +0 -11
- 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-action-list/index.ts +0 -1
- package/src/components/silke-action-list/silke-action-list.mdx +0 -48
- package/src/components/silke-action-list/silke-action-list.scss +0 -21
- package/src/components/silke-action-list/silke-action-list.tsx +0 -85
- 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
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import { SilkeBox, SilkeText, SilkeIcon, SilkeIconDefinitions, SilkeSearchField, SilkeDivider } from '@vev/silke';
|
|
3
|
+
|
|
4
|
+
export const sentenceCase = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
5
|
+
|
|
6
|
+
export const IconTile = ({ icon, copied, onCopy }) => (
|
|
7
|
+
<div
|
|
8
|
+
className="icon-tile"
|
|
9
|
+
style={{
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
width: 100,
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
borderRadius: 'var(--border-radius-small)',
|
|
16
|
+
padding: 8,
|
|
17
|
+
background: copied === icon ? 'color-mix(in srgb, var(--color-success-50) 10%, transparent)' : undefined,
|
|
18
|
+
}}
|
|
19
|
+
onClick={() => onCopy(icon)}
|
|
20
|
+
>
|
|
21
|
+
<div style={{ height: 32, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
22
|
+
<SilkeIcon icon={icon} style={{ fontSize: 20 }} />
|
|
23
|
+
</div>
|
|
24
|
+
<SilkeText size="xs" color="neutral-60" style={{ textAlign: 'center', wordBreak: 'break-all' }}>
|
|
25
|
+
{icon}
|
|
26
|
+
</SilkeText>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const IconGroup = ({ title, icons, copied, onCopy, defaultOpen = true }) => {
|
|
31
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<SilkeBox column gap="s">
|
|
35
|
+
<SilkeBox
|
|
36
|
+
gap="s"
|
|
37
|
+
vAlign="center"
|
|
38
|
+
onClick={() => setOpen(!open)}
|
|
39
|
+
style={{ cursor: 'pointer', userSelect: 'none' }}
|
|
40
|
+
>
|
|
41
|
+
<SilkeIcon icon={open ? 'chevron.down' : 'chevron.right'} style={{ fontSize: 12 }} />
|
|
42
|
+
<SilkeText size="l" weight="bold">{title}</SilkeText>
|
|
43
|
+
<SilkeText size="s" color="neutral-40">{icons.length}</SilkeText>
|
|
44
|
+
</SilkeBox>
|
|
45
|
+
{open && (
|
|
46
|
+
<SilkeBox gap="xs" wrap>
|
|
47
|
+
{[...icons].sort().map((icon) => (
|
|
48
|
+
<IconTile key={icon} icon={icon} copied={copied} onCopy={onCopy} />
|
|
49
|
+
))}
|
|
50
|
+
</SilkeBox>
|
|
51
|
+
)}
|
|
52
|
+
<SilkeDivider />
|
|
53
|
+
</SilkeBox>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const IconBrowser = () => {
|
|
58
|
+
const [search, setSearch] = useState('');
|
|
59
|
+
const [copied, setCopied] = useState(null);
|
|
60
|
+
const timeoutRef = useRef(null);
|
|
61
|
+
|
|
62
|
+
const allIcons = Object.keys(SilkeIconDefinitions);
|
|
63
|
+
|
|
64
|
+
const handleCopy = (name) => {
|
|
65
|
+
navigator.clipboard.writeText(name).then(() => {
|
|
66
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
67
|
+
setCopied(name);
|
|
68
|
+
timeoutRef.current = setTimeout(() => setCopied(null), 1500);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const filteredIcons = allIcons.filter((icon) =>
|
|
73
|
+
icon.toLowerCase().includes(search.toLowerCase())
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const groups = {};
|
|
77
|
+
const ungrouped = [];
|
|
78
|
+
|
|
79
|
+
filteredIcons.forEach((name) => {
|
|
80
|
+
if (name.includes('.')) {
|
|
81
|
+
const prefix = name.split('.')[0];
|
|
82
|
+
if (!groups[prefix]) groups[prefix] = [];
|
|
83
|
+
groups[prefix].push(name);
|
|
84
|
+
} else {
|
|
85
|
+
ungrouped.push(name);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<SilkeBox column gap="l">
|
|
91
|
+
<SilkeBox
|
|
92
|
+
gap="s"
|
|
93
|
+
vAlign="center"
|
|
94
|
+
style={{ position: 'sticky', top: 16, zIndex: 1, paddingTop: 8, paddingBottom: 8 }}
|
|
95
|
+
bg="neutral-0"
|
|
96
|
+
>
|
|
97
|
+
<SilkeBox flex>
|
|
98
|
+
<SilkeSearchField
|
|
99
|
+
placeholder="Search icons..."
|
|
100
|
+
value={search}
|
|
101
|
+
onChange={setSearch}
|
|
102
|
+
/>
|
|
103
|
+
</SilkeBox>
|
|
104
|
+
{copied ? (
|
|
105
|
+
<SilkeText size="s" color="success-50" style={{ whiteSpace: 'nowrap' }}>
|
|
106
|
+
Copied "{copied}"
|
|
107
|
+
</SilkeText>
|
|
108
|
+
) : (
|
|
109
|
+
<SilkeText size="s" color="neutral-40" style={{ whiteSpace: 'nowrap' }}>
|
|
110
|
+
{filteredIcons.length} icons
|
|
111
|
+
</SilkeText>
|
|
112
|
+
)}
|
|
113
|
+
</SilkeBox>
|
|
114
|
+
|
|
115
|
+
{ungrouped.length > 0 && (
|
|
116
|
+
<IconGroup
|
|
117
|
+
title="Uncategorized"
|
|
118
|
+
icons={ungrouped}
|
|
119
|
+
copied={copied}
|
|
120
|
+
onCopy={handleCopy}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
{Object.entries(groups)
|
|
125
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
126
|
+
.map(([prefix, icons]) => (
|
|
127
|
+
<IconGroup
|
|
128
|
+
key={prefix}
|
|
129
|
+
title={sentenceCase(prefix)}
|
|
130
|
+
icons={icons}
|
|
131
|
+
copied={copied}
|
|
132
|
+
onCopy={handleCopy}
|
|
133
|
+
/>
|
|
134
|
+
))}
|
|
135
|
+
</SilkeBox>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
<style>{`.icon-tile:hover { outline: 1px solid var(--color-neutral-20); }`}</style>
|
|
140
|
+
|
|
141
|
+
# Icon Browser
|
|
142
|
+
|
|
143
|
+
<IconBrowser />
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
.root{
|
|
2
|
-
--color-1:var(--color-neutral-20);
|
|
3
|
-
--color-2:var(--color-neutral-20);
|
|
1
|
+
.root {
|
|
2
|
+
--color-1: var(--color-neutral-20);
|
|
3
|
+
--color-2: var(--color-neutral-20);
|
|
4
4
|
background-color: var(--color-1) !important;
|
|
5
5
|
transition: 0.5s background-color ease-out;
|
|
6
|
-
|
|
7
|
-
&:hover{
|
|
6
|
+
|
|
7
|
+
&:hover {
|
|
8
8
|
background-position: 100px;
|
|
9
9
|
}
|
|
10
|
-
}
|
|
10
|
+
}
|
|
@@ -1,55 +1,203 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SilkeImage
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
7
|
-
<SilkeBox column gap style={{ width:
|
|
8
|
-
<SilkeImage aspectRatio="16:9" src=
|
|
9
|
-
<
|
|
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
|
-
##
|
|
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
|
|
20
|
-
<SilkeImage
|
|
21
|
-
<SilkeImage
|
|
22
|
-
<SilkeImage
|
|
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
|
-
##
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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) -
|
|
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({
|
|
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
|
}
|
|
@@ -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
|
+
}
|