@vev/silke 1.1.8 → 1.1.9
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/.turbo/turbo-build.log +800 -0
- package/CHANGELOG.md +8 -0
- package/CLAUDE.md +102 -0
- package/dist/index.js +35 -35
- package/dist/index.js.LEGAL.txt +1 -1
- package/dist/styles.css +474 -258
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/silke-command-text-field/attachment-chip.d.ts +8 -0
- package/dist/types/components/silke-command-text-field/attachment-list.d.ts +15 -0
- package/dist/types/components/silke-command-text-field/file-utils.d.ts +33 -0
- package/dist/types/components/silke-command-text-field/file-utils.spec.d.ts +1 -0
- package/dist/types/components/silke-command-text-field/index.d.ts +6 -1
- package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +23 -6
- package/dist/types/components/silke-command-text-field/utils.d.ts +14 -1
- package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
- package/dist/types/components/silke-css-number-field/silke-css-context.d.ts +2 -0
- package/dist/types/components/silke-css-number-field/silke-css-number-field.d.ts +2 -0
- package/dist/types/components/silke-css-number-field/utils.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/group-field.d.ts +3 -0
- package/dist/types/components/silke-form-schema/fields/object-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/popover-field.d.ts +3 -0
- package/dist/types/components/silke-form-schema/fields/utils/generate-image.d.ts +5 -0
- package/dist/types/components/silke-form-schema/fields/utils/index.d.ts +1 -1
- package/dist/types/components/silke-form-schema/silke-schema-field.d.ts +2 -1
- package/dist/types/components/silke-gradient-picker/index.d.ts +3 -0
- package/dist/types/components/silke-icon/silke-icon.d.ts +1 -1
- package/dist/types/components/silke-list/silke-list.d.ts +6 -1
- package/dist/types/components/silke-list/types.d.ts +2 -0
- package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +4 -1
- package/dist/types/components/silke-theme-card/index.d.ts +1 -0
- package/dist/types/components/silke-theme-card/silke-theme-card.d.ts +18 -0
- package/dist/types/components/silke-theme-swatch/index.d.ts +1 -0
- package/dist/types/components/silke-theme-swatch/silke-theme-swatch.d.ts +11 -0
- package/dist/types/icons.d.ts +5 -2
- package/package.json +32 -20
- package/src/components/index.ts +2 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +25 -18
- package/src/components/silke-button/silke-dropdown-button.mdx +1 -1
- package/src/components/silke-color-picker/color.ts +5 -3
- package/src/components/silke-color-swatches/silke-swatches.tsx +3 -3
- package/src/components/silke-command-text-field/attachment-chip.tsx +71 -0
- package/src/components/silke-command-text-field/attachment-list.tsx +72 -0
- package/src/components/silke-command-text-field/file-utils.spec.ts +148 -0
- package/src/components/silke-command-text-field/file-utils.ts +159 -0
- package/src/components/silke-command-text-field/index.ts +14 -0
- package/src/components/silke-command-text-field/silke-command-text-field.mdx +109 -13
- package/src/components/silke-command-text-field/silke-command-text-field.module.scss +65 -40
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +113 -135
- package/src/components/silke-command-text-field/utils.spec.ts +109 -1
- package/src/components/silke-command-text-field/utils.ts +44 -7
- package/src/components/silke-css-number-field/silke-css-context.tsx +2 -0
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +7 -4
- package/src/components/silke-css-number-field/utils.ts +8 -2
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +69 -48
- package/src/components/silke-form-schema/fields/array-field.tsx +144 -130
- package/src/components/silke-form-schema/fields/color-field.tsx +118 -18
- package/src/components/silke-form-schema/fields/group-field.tsx +49 -0
- package/src/components/silke-form-schema/fields/icon-field.tsx +59 -39
- package/src/components/silke-form-schema/fields/image-field.tsx +50 -39
- package/src/components/silke-form-schema/fields/number-field.tsx +148 -184
- package/src/components/silke-form-schema/fields/object-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/popover-field.tsx +65 -0
- package/src/components/silke-form-schema/fields/select-field.tsx +43 -30
- package/src/components/silke-form-schema/fields/string-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/styles.scss +2 -39
- package/src/components/silke-form-schema/fields/toggle-field.tsx +48 -15
- package/src/components/silke-form-schema/fields/utils/generate-image.ts +20 -0
- package/src/components/silke-form-schema/fields/utils/generate-title.ts +1 -1
- package/src/components/silke-form-schema/fields/utils/index.ts +1 -1
- package/src/components/silke-form-schema/silke-form-schema.mdx +498 -311
- package/src/components/silke-form-schema/silke-schema-field.tsx +10 -3
- package/src/components/silke-form-schema/silke-schema-fields.tsx +9 -5
- package/src/components/silke-gradient-picker/index.ts +3 -0
- package/src/components/silke-icon/silke-icon.mdx +13 -1
- package/src/components/silke-icon/silke-icon.tsx +6 -2
- package/src/components/silke-list/silke-list.tsx +59 -26
- package/src/components/silke-list/types.ts +2 -0
- package/src/components/silke-navigation-link/silke-navigation-link.scss +1 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.scss +16 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +9 -0
- package/src/components/silke-slider/silke-slider.module.scss +1 -1
- package/src/components/silke-text-field/silke-text-field-outline.tsx +9 -6
- package/src/components/silke-text-field/silke-text-field.scss +3 -0
- package/src/components/silke-text-field/silke-text-field.tsx +1 -1
- package/src/components/silke-theme-card/index.ts +1 -0
- package/src/components/silke-theme-card/silke-theme-card.mdx +50 -0
- package/src/components/silke-theme-card/silke-theme-card.module.scss +82 -0
- package/src/components/silke-theme-card/silke-theme-card.tsx +82 -0
- package/src/components/silke-theme-swatch/index.ts +1 -0
- package/src/components/silke-theme-swatch/silke-theme-swatch.mdx +59 -0
- package/src/components/silke-theme-swatch/silke-theme-swatch.module.scss +108 -0
- package/src/components/silke-theme-swatch/silke-theme-swatch.tsx +49 -0
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.tsx +9 -8
- package/src/icons.tsx +26 -7
- package/tsconfig.build.tsbuildinfo +1 -1
- package/project.json +0 -12
|
@@ -28,6 +28,8 @@ import EventField from './fields/event-field';
|
|
|
28
28
|
import UploadField from './fields/upload-field';
|
|
29
29
|
import AudioField from './fields/audio-field';
|
|
30
30
|
import ColorField from './fields/color-field';
|
|
31
|
+
import GroupField from './fields/group-field';
|
|
32
|
+
import PopoverField from './fields/popover-field';
|
|
31
33
|
|
|
32
34
|
type SilkeSchemaFieldProps = {
|
|
33
35
|
field: VevProps;
|
|
@@ -36,6 +38,7 @@ type SilkeSchemaFieldProps = {
|
|
|
36
38
|
isFirst?: boolean;
|
|
37
39
|
disabled?: boolean;
|
|
38
40
|
readonly?: boolean;
|
|
41
|
+
itemIndex?: number;
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
const SCHEMA_FIELD_COMPONENTS: Partial<SchemaFieldComponents> = {
|
|
@@ -54,6 +57,8 @@ const SCHEMA_FIELD_COMPONENTS: Partial<SchemaFieldComponents> = {
|
|
|
54
57
|
icon: IconField,
|
|
55
58
|
event: EventField,
|
|
56
59
|
upload: UploadField,
|
|
60
|
+
group: GroupField,
|
|
61
|
+
popover: PopoverField,
|
|
57
62
|
};
|
|
58
63
|
|
|
59
64
|
export function SilkeSchemaField({
|
|
@@ -63,6 +68,7 @@ export function SilkeSchemaField({
|
|
|
63
68
|
isFirst,
|
|
64
69
|
disabled,
|
|
65
70
|
readonly,
|
|
71
|
+
itemIndex,
|
|
66
72
|
}: SilkeSchemaFieldProps) {
|
|
67
73
|
const extendedFields = useExtendedFields();
|
|
68
74
|
|
|
@@ -79,7 +85,7 @@ export function SilkeSchemaField({
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
if (!field?.name && !['layout', 'divider'].includes(field?.type))
|
|
88
|
+
if (!field?.name && !['layout', 'divider', 'group', 'popover'].includes(field?.type))
|
|
83
89
|
return (
|
|
84
90
|
<SilkeAlertBanner
|
|
85
91
|
kind="error"
|
|
@@ -93,14 +99,14 @@ export function SilkeSchemaField({
|
|
|
93
99
|
|
|
94
100
|
const getVariableType = (field: VevProps) => {
|
|
95
101
|
if (field.component) return 'none';
|
|
96
|
-
if (field.type === 'number' && field.options?.display === 'slider') return 'none';
|
|
102
|
+
if (field.type === 'number' && (field.options?.display === 'slider' || field.options?.display === 'range-slider')) return 'none';
|
|
97
103
|
if (field.type === 'string') return 'text';
|
|
98
104
|
return field.type;
|
|
99
105
|
};
|
|
100
106
|
|
|
101
107
|
return (
|
|
102
108
|
<>
|
|
103
|
-
{['object', '
|
|
109
|
+
{['object', 'divider'].includes(field?.type) && !isFirst && (
|
|
104
110
|
<SilkeBox column flex vPad={field?.type === 'divider' ? 'xs' : 's'}>
|
|
105
111
|
<SilkeDivider dark />
|
|
106
112
|
</SilkeBox>
|
|
@@ -118,6 +124,7 @@ export function SilkeSchemaField({
|
|
|
118
124
|
schema={field as any}
|
|
119
125
|
context={context}
|
|
120
126
|
help={field.description}
|
|
127
|
+
itemIndex={itemIndex}
|
|
121
128
|
onChange={async (value: any) => {
|
|
122
129
|
if (isEvalCallback(field.onChange)) {
|
|
123
130
|
value = await safeEvalFunction(field.onChange.value, value, context);
|
|
@@ -18,15 +18,16 @@ type SilkeSchemaFieldsProps<T extends { [key: string]: any }> = {
|
|
|
18
18
|
export function SilkeSchemaFields<T extends { [key: string]: any }>(
|
|
19
19
|
props: SilkeSchemaFieldsProps<T>,
|
|
20
20
|
) {
|
|
21
|
-
const { schema = [], row,
|
|
21
|
+
const { schema = [], row, ...rest } = props;
|
|
22
22
|
const context = useSchemaContext();
|
|
23
23
|
const [filteredSchema, setFilteredSchema] = useState(schema);
|
|
24
24
|
|
|
25
25
|
// Filter hidden fields here, so they don't use any space in the sidebar
|
|
26
26
|
useEffect(() => {
|
|
27
|
+
const ctxWithValue = { ...context, value: rest?.value ?? context.value };
|
|
27
28
|
const isHidden = async (field: VevProps) => {
|
|
28
29
|
if (isFunction(field?.hidden)) {
|
|
29
|
-
return await field?.hidden(
|
|
30
|
+
return await field?.hidden(ctxWithValue, rest?.itemIndex);
|
|
30
31
|
} else if (field?.hidden) {
|
|
31
32
|
return true;
|
|
32
33
|
}
|
|
@@ -45,13 +46,16 @@ export function SilkeSchemaFields<T extends { [key: string]: any }>(
|
|
|
45
46
|
}) as VevProps[];
|
|
46
47
|
setFilteredSchema(filtered);
|
|
47
48
|
});
|
|
48
|
-
}, [context, schema, itemIndex]);
|
|
49
|
+
}, [context, schema, rest?.itemIndex, rest?.value]);
|
|
49
50
|
|
|
50
51
|
return (
|
|
51
|
-
<SilkeBox flex column={!row} gap="s" vPad=
|
|
52
|
+
<SilkeBox flex column={!row} gap="s" vPad={row ? undefined : 's'} vAlign={row ? 'end' : undefined} style={{ width: '100%' }}>
|
|
52
53
|
{filteredSchema.map((field, index) => {
|
|
53
54
|
return (
|
|
54
|
-
<span
|
|
55
|
+
<span
|
|
56
|
+
key={(field?.name || 'field') + index}
|
|
57
|
+
style={field?.flex ? { flex: 1, minWidth: 0 } : undefined}
|
|
58
|
+
>
|
|
55
59
|
<SilkeSchemaField field={field} {...rest} isFirst={index === 0} />
|
|
56
60
|
</span>
|
|
57
61
|
);
|
|
@@ -8,6 +8,7 @@ A versatile icon component that supports multiple icon sources including the bui
|
|
|
8
8
|
- **Theme colors**: Apply any Silke color to icons
|
|
9
9
|
- **Custom icons**: Pass React elements as icons
|
|
10
10
|
- **Emoji support**: Render emoji characters and shapes
|
|
11
|
+
- **Font Awesome classes**: Use any `fa-*` class name directly
|
|
11
12
|
- **URL images**: Load icons from external URLs
|
|
12
13
|
- **Sizing**: Control size via font-size
|
|
13
14
|
|
|
@@ -90,6 +91,17 @@ const CustomIcon = () => (
|
|
|
90
91
|
</SilkeBox>;
|
|
91
92
|
```
|
|
92
93
|
|
|
94
|
+
## Font Awesome icons
|
|
95
|
+
|
|
96
|
+
You can pass any Font Awesome class name (e.g. `fa-solid fa-star`) as a string that starts with `fa-`:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
<SilkeBox gap="m">
|
|
100
|
+
<SilkeIcon icon="fa-solid fa-star" style={{ fontSize: 24 }} />
|
|
101
|
+
<SilkeIcon icon="fa-regular fa-heart" style={{ fontSize: 24 }} />
|
|
102
|
+
</SilkeBox>
|
|
103
|
+
```
|
|
104
|
+
|
|
93
105
|
## Image URL
|
|
94
106
|
|
|
95
107
|
Load icons from external URLs:
|
|
@@ -194,7 +206,7 @@ Also accepts all standard HTML element attributes.
|
|
|
194
206
|
## Types
|
|
195
207
|
|
|
196
208
|
```typescript
|
|
197
|
-
type SilkeIcons = keyof typeof SilkeIconDefinitions | null | IEmojiIcon
|
|
209
|
+
type SilkeIcons = keyof typeof SilkeIconDefinitions | null | IEmojiIcon | `fa-${string}`;
|
|
198
210
|
|
|
199
211
|
interface IEmojiIcon {
|
|
200
212
|
type: EmojiType;
|
|
@@ -6,7 +6,7 @@ import styles from './silke-icon.scss';
|
|
|
6
6
|
import { SilkeShape } from './silke-shape';
|
|
7
7
|
import { SilkeColor } from '../../silke-theme-provider';
|
|
8
8
|
|
|
9
|
-
export type SilkeIcons = keyof typeof SilkeIconDefinitions | null | IEmojiIcon
|
|
9
|
+
export type SilkeIcons = keyof typeof SilkeIconDefinitions | null | IEmojiIcon | `fa-${string}`;
|
|
10
10
|
|
|
11
11
|
interface SilkeIconProps extends HTMLAttributes<HTMLElement> {
|
|
12
12
|
icon: SilkeIcons | React.ReactElement;
|
|
@@ -49,6 +49,10 @@ export function SilkeIcon({ icon, className, color, ...rest }: SilkeIconProps):
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
if (typeof icon === 'string' && icon.startsWith('fa-')) {
|
|
53
|
+
return <i {...rest} className={cl + ' ' + icon} />;
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
if (!icon || !((icon as any) in SilkeIconDefinitions))
|
|
53
57
|
return (
|
|
54
58
|
<span {...rest} className={cl}>
|
|
@@ -57,8 +61,8 @@ export function SilkeIcon({ icon, className, color, ...rest }: SilkeIconProps):
|
|
|
57
61
|
);
|
|
58
62
|
|
|
59
63
|
const Icon = SilkeIconDefinitions[icon as keyof typeof SilkeIconDefinitions];
|
|
60
|
-
|
|
61
64
|
if (typeof Icon === 'string') return <i {...rest} className={cl + ' ' + Icon} />;
|
|
65
|
+
|
|
62
66
|
return (
|
|
63
67
|
<i {...rest} className={cl}>
|
|
64
68
|
<Icon />
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { generateGuid } from '@vev/utils';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
2
3
|
import { SilkeBox } from '../silke-box';
|
|
3
4
|
import { SilkeDivider } from '../silke-divider';
|
|
4
5
|
import { SilkeTextSmall } from '../silke-text';
|
|
5
6
|
import type { SilkeListItemType } from './types';
|
|
6
7
|
import { groupSilkeListItems, isSilkeListItem } from './utils';
|
|
7
8
|
import { SilkeListItem } from './silke-list-item';
|
|
9
|
+
import { SilkeSortableItemWrapper } from '../silke-sortable-list/silke-sortable-item-wrapper';
|
|
8
10
|
|
|
9
11
|
import styles from './silke-list.scss';
|
|
10
12
|
|
|
@@ -13,11 +15,60 @@ type SilkeListProps = {
|
|
|
13
15
|
size?: 's' | 'base';
|
|
14
16
|
gap?: boolean;
|
|
15
17
|
maxHeight?: number;
|
|
18
|
+
/** Enable drag-and-drop reordering of items */
|
|
19
|
+
sortable?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
16
21
|
onSelect?: (item: SilkeListItemType) => void;
|
|
22
|
+
/** Called with the reordered items array after a drag-and-drop sort */
|
|
23
|
+
onSort?: (items: SilkeListItemType[]) => void;
|
|
17
24
|
};
|
|
18
25
|
|
|
19
|
-
export function SilkeList({ items, size, gap, maxHeight, onSelect }: SilkeListProps) {
|
|
20
|
-
const
|
|
26
|
+
export function SilkeList({ items, size, gap, maxHeight, sortable, disabled, onSelect, onSort }: SilkeListProps) {
|
|
27
|
+
const resolvedItems = typeof items === 'function' ? items() : items;
|
|
28
|
+
const groupedItems = groupSilkeListItems(resolvedItems);
|
|
29
|
+
const hasGroups = groupedItems.some((g) => g.groupLabel);
|
|
30
|
+
const listId = useMemo(() => generateGuid(), []);
|
|
31
|
+
|
|
32
|
+
const renderItem = (item: SilkeListItemType, index: number, keyPrefix: string) => {
|
|
33
|
+
const content = (
|
|
34
|
+
<SilkeBox
|
|
35
|
+
tag="li"
|
|
36
|
+
key={`${keyPrefix}-${index}`}
|
|
37
|
+
hPad={item === 'divider' ? 'none' : 'xs'}
|
|
38
|
+
>
|
|
39
|
+
{isSilkeListItem(item) ? (
|
|
40
|
+
<SilkeListItem
|
|
41
|
+
{...item}
|
|
42
|
+
gap={gap}
|
|
43
|
+
size={size}
|
|
44
|
+
maxHeight={maxHeight}
|
|
45
|
+
onSelect={() => onSelect?.(item)}
|
|
46
|
+
/>
|
|
47
|
+
) : item === 'divider' ? (
|
|
48
|
+
<SilkeDivider dark vSpace="xs" />
|
|
49
|
+
) : (
|
|
50
|
+
React.isValidElement(item) && item
|
|
51
|
+
)}
|
|
52
|
+
</SilkeBox>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (sortable && !disabled && onSort && item !== 'divider') {
|
|
56
|
+
return (
|
|
57
|
+
<SilkeSortableItemWrapper
|
|
58
|
+
key={`${keyPrefix}-${index}`}
|
|
59
|
+
listId={listId}
|
|
60
|
+
triggerState="drop"
|
|
61
|
+
items={resolvedItems}
|
|
62
|
+
index={resolvedItems.indexOf(item)}
|
|
63
|
+
onSort={onSort}
|
|
64
|
+
>
|
|
65
|
+
{content}
|
|
66
|
+
</SilkeSortableItemWrapper>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return content;
|
|
71
|
+
};
|
|
21
72
|
|
|
22
73
|
return (
|
|
23
74
|
<SilkeBox
|
|
@@ -31,8 +82,8 @@ export function SilkeList({ items, size, gap, maxHeight, onSelect }: SilkeListPr
|
|
|
31
82
|
rounded="small"
|
|
32
83
|
style={{ maxHeight: maxHeight ? `${maxHeight}px` : 'none', overflow: 'auto' }}
|
|
33
84
|
>
|
|
34
|
-
{groupedItems.map((group) => (
|
|
35
|
-
<React.Fragment key={group.groupLabel}>
|
|
85
|
+
{groupedItems.map((group, groupIndex) => (
|
|
86
|
+
<React.Fragment key={group.groupLabel ?? `group-${groupIndex}`}>
|
|
36
87
|
{group.groupLabel && (
|
|
37
88
|
<SilkeBox tag="li" hPad="sm" vPad="s">
|
|
38
89
|
<SilkeTextSmall color="neutral-60" weight="strong">
|
|
@@ -40,27 +91,9 @@ export function SilkeList({ items, size, gap, maxHeight, onSelect }: SilkeListPr
|
|
|
40
91
|
</SilkeTextSmall>
|
|
41
92
|
</SilkeBox>
|
|
42
93
|
)}
|
|
43
|
-
{group.items.map((item, index) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
key={`${group.groupLabel}-${index}`}
|
|
47
|
-
hPad={item === 'divider' ? 'none' : 'xs'}
|
|
48
|
-
>
|
|
49
|
-
{isSilkeListItem(item) ? (
|
|
50
|
-
<SilkeListItem
|
|
51
|
-
{...item}
|
|
52
|
-
gap={gap}
|
|
53
|
-
size={size}
|
|
54
|
-
maxHeight={maxHeight}
|
|
55
|
-
onSelect={() => onSelect?.(item)}
|
|
56
|
-
/>
|
|
57
|
-
) : item === 'divider' ? (
|
|
58
|
-
<SilkeDivider dark vSpace="xs" />
|
|
59
|
-
) : (
|
|
60
|
-
React.isValidElement(item) && item
|
|
61
|
-
)}
|
|
62
|
-
</SilkeBox>
|
|
63
|
-
))}
|
|
94
|
+
{group.items.map((item, index) =>
|
|
95
|
+
renderItem(item, index, group.groupLabel ?? `group-${groupIndex}`),
|
|
96
|
+
)}
|
|
64
97
|
</React.Fragment>
|
|
65
98
|
))}
|
|
66
99
|
</SilkeBox>
|
|
@@ -15,6 +15,7 @@ $transition: all 0.2s ease-out;
|
|
|
15
15
|
background: transparent;
|
|
16
16
|
border: none;
|
|
17
17
|
outline: none;
|
|
18
|
+
opacity: 1;
|
|
18
19
|
transition: $transition;
|
|
19
20
|
|
|
20
21
|
view-transition-name: match-element;
|
|
@@ -46,6 +47,14 @@ $transition: all 0.2s ease-out;
|
|
|
46
47
|
height: 32px;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
.wrapper[data-inverted='true'] {
|
|
51
|
+
filter: invert(1) hue-rotate(180deg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.wrapper[data-inverted='true'] .icon i {
|
|
55
|
+
color: var(--color-neutral-20);
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
.wrapper[data-centered='true'] {
|
|
50
59
|
justify-content: center;
|
|
51
60
|
align-items: center;
|
|
@@ -143,3 +152,10 @@ $transition: all 0.2s ease-out;
|
|
|
143
152
|
font-family: var(--font-family-mono);
|
|
144
153
|
transition: $transition;
|
|
145
154
|
}
|
|
155
|
+
|
|
156
|
+
// Modifiers
|
|
157
|
+
|
|
158
|
+
.wrapper[data-hidden='true'] {
|
|
159
|
+
opacity: 0;
|
|
160
|
+
visibility: hidden;
|
|
161
|
+
}
|
|
@@ -9,7 +9,10 @@ export type SilkeShortcutButtonProps = {
|
|
|
9
9
|
icon: SilkeIcons;
|
|
10
10
|
shortcut?: KeyboardEventCode[];
|
|
11
11
|
compressed?: boolean;
|
|
12
|
+
inverted?: boolean;
|
|
12
13
|
centered?: boolean;
|
|
14
|
+
hidden?: boolean;
|
|
15
|
+
suffix?: React.ReactNode;
|
|
13
16
|
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
14
17
|
};
|
|
15
18
|
|
|
@@ -18,7 +21,10 @@ export function SilkeShortcutButton({
|
|
|
18
21
|
icon,
|
|
19
22
|
shortcut,
|
|
20
23
|
compressed,
|
|
24
|
+
inverted,
|
|
21
25
|
centered,
|
|
26
|
+
hidden,
|
|
27
|
+
suffix,
|
|
22
28
|
onClick,
|
|
23
29
|
}: SilkeShortcutButtonProps) {
|
|
24
30
|
const hasShortcut = shortcut && shortcut.length > 0;
|
|
@@ -28,7 +34,9 @@ export function SilkeShortcutButton({
|
|
|
28
34
|
type="button"
|
|
29
35
|
className={styles.wrapper}
|
|
30
36
|
data-compressed={compressed}
|
|
37
|
+
data-inverted={inverted}
|
|
31
38
|
data-centered={centered}
|
|
39
|
+
data-hidden={hidden}
|
|
32
40
|
onClick={onClick}
|
|
33
41
|
>
|
|
34
42
|
<div className={styles.background} />
|
|
@@ -48,6 +56,7 @@ export function SilkeShortcutButton({
|
|
|
48
56
|
))}
|
|
49
57
|
</div>
|
|
50
58
|
)}
|
|
59
|
+
{!compressed && suffix && <div className={styles.shortcut}>{suffix}</div>}
|
|
51
60
|
</button>
|
|
52
61
|
);
|
|
53
62
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
top: calc(50% - var(--point-size) / 2);
|
|
42
42
|
border-radius: 50%;
|
|
43
43
|
background: var(--slider-color);
|
|
44
|
-
border:
|
|
44
|
+
border: 1px solid var(--color-neutral-100);
|
|
45
45
|
&.selected,
|
|
46
46
|
&:focus-visible {
|
|
47
47
|
outline: 2px solid var(--color-accent-30);
|
|
@@ -72,6 +72,7 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
|
|
|
72
72
|
disabled,
|
|
73
73
|
tooltip,
|
|
74
74
|
labelAlign,
|
|
75
|
+
style,
|
|
75
76
|
}: SilkeTextFieldOutlineProps,
|
|
76
77
|
ref,
|
|
77
78
|
) => {
|
|
@@ -116,13 +117,15 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
|
|
|
116
117
|
)}
|
|
117
118
|
</SilkeBox>
|
|
118
119
|
);
|
|
120
|
+
|
|
121
|
+
if (width) {
|
|
122
|
+
style = { ...style, minWidth: width, maxWidth: width, width };
|
|
123
|
+
} else if (flex) {
|
|
124
|
+
style = { ...style, flex: 1 };
|
|
125
|
+
}
|
|
126
|
+
|
|
119
127
|
return (
|
|
120
|
-
<SilkeBox
|
|
121
|
-
column
|
|
122
|
-
className={styles.wrapper}
|
|
123
|
-
style={width ? { minWidth: width, maxWidth: width, width } : flex ? { flex: 1 } : undefined}
|
|
124
|
-
onContextMenu={onContextMenu}
|
|
125
|
-
>
|
|
128
|
+
<SilkeBox column className={styles.wrapper} style={style} onContextMenu={onContextMenu}>
|
|
126
129
|
<SilkeBox
|
|
127
130
|
data-size={`data-input-${size}`}
|
|
128
131
|
tag="div"
|
|
@@ -195,11 +195,14 @@
|
|
|
195
195
|
textarea {
|
|
196
196
|
margin-top: 8px;
|
|
197
197
|
margin-bottom: 8px;
|
|
198
|
+
resize: none;
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
.inputMultiline {
|
|
201
202
|
line-height: 1.2em !important;
|
|
202
203
|
white-space: pre-line;
|
|
204
|
+
field-sizing: content;
|
|
205
|
+
min-height: calc(2 * 1.2em);
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
.itemBefore ~ .input,
|
|
@@ -162,7 +162,7 @@ export const SilkeTextField = React.forwardRef<HTMLDivElement, SilkeTextFieldPro
|
|
|
162
162
|
name,
|
|
163
163
|
style: inputStyle,
|
|
164
164
|
value: value ?? '',
|
|
165
|
-
rows: multiline === true ?
|
|
165
|
+
rows: multiline === true ? 2 : multiline || 2,
|
|
166
166
|
autoComplete: autocomplete ? 'on' : 'off',
|
|
167
167
|
...(autoFocus && { autofocus: 'true' }),
|
|
168
168
|
'aria-invalid': !!error,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './silke-theme-card';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Theme Card
|
|
2
|
+
|
|
3
|
+
A card component for displaying theme previews. Shows a font preview, color strip, theme name, and an optional default badge.
|
|
4
|
+
|
|
5
|
+
## Basic usage
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
<SilkeThemeCard
|
|
9
|
+
name="Brand theme"
|
|
10
|
+
description="All teams"
|
|
11
|
+
primaryColor="rgba(0, 150, 136, 1)"
|
|
12
|
+
secondaryColor="rgba(63, 81, 181, 1)"
|
|
13
|
+
accentColor="rgba(233, 30, 99, 1)"
|
|
14
|
+
bgColor="rgba(255, 255, 255, 1)"
|
|
15
|
+
textColor="rgba(33, 33, 33, 1)"
|
|
16
|
+
baseFont="Lato"
|
|
17
|
+
isDefault
|
|
18
|
+
onClick={() => console.log('clicked')}
|
|
19
|
+
/>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Default badge
|
|
23
|
+
|
|
24
|
+
Use `isDefault` to show a "Default" badge on the selected theme.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
<SilkeBox gap="m" wrap>
|
|
28
|
+
<SilkeThemeCard
|
|
29
|
+
name="Brand theme"
|
|
30
|
+
description="Marketing, Design, Sales, +2"
|
|
31
|
+
primaryColor="rgba(0, 150, 136, 1)"
|
|
32
|
+
secondaryColor="rgba(63, 81, 181, 1)"
|
|
33
|
+
accentColor="rgba(233, 30, 99, 1)"
|
|
34
|
+
bgColor="rgba(255, 255, 255, 1)"
|
|
35
|
+
textColor="rgba(33, 33, 33, 1)"
|
|
36
|
+
baseFont="Lato"
|
|
37
|
+
isDefault
|
|
38
|
+
/>
|
|
39
|
+
<SilkeThemeCard
|
|
40
|
+
name="Dark theme"
|
|
41
|
+
description="Marketing, Design, Sales, +2"
|
|
42
|
+
primaryColor="rgba(187, 134, 252, 1)"
|
|
43
|
+
secondaryColor="rgba(3, 218, 198, 1)"
|
|
44
|
+
accentColor="rgba(207, 102, 121, 1)"
|
|
45
|
+
bgColor="rgba(18, 18, 18, 1)"
|
|
46
|
+
textColor="rgba(230, 230, 230, 1)"
|
|
47
|
+
baseFont="Inter"
|
|
48
|
+
/>
|
|
49
|
+
</SilkeBox>
|
|
50
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@import '../../variables';
|
|
2
|
+
|
|
3
|
+
.themeCard {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
min-width: 200px;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.inner {
|
|
11
|
+
position: relative;
|
|
12
|
+
display: flex;
|
|
13
|
+
height: 144px;
|
|
14
|
+
gap: $space-xxs;
|
|
15
|
+
|
|
16
|
+
border-radius: var(--border-radius-small);
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
background: var(--color-neutral-10);
|
|
19
|
+
transition:
|
|
20
|
+
outline 0.15s ease,
|
|
21
|
+
background 0.15s ease;
|
|
22
|
+
outline: 1px solid transparent;
|
|
23
|
+
|
|
24
|
+
&:hover,
|
|
25
|
+
&:focus-visible {
|
|
26
|
+
outline: 1px solid var(--color-neutral-70);
|
|
27
|
+
background: var(--color-neutral-5);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.preview {
|
|
32
|
+
position: relative;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex: 1;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
padding: $space-m;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.previewText {
|
|
42
|
+
font-size: 48px;
|
|
43
|
+
font-weight: 700;
|
|
44
|
+
color: var(--color-neutral-100);
|
|
45
|
+
z-index: 1;
|
|
46
|
+
user-select: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.colorStrip {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
gap: $space-xxs;
|
|
53
|
+
width: 100%;
|
|
54
|
+
max-width: 80px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.colorStripItem {
|
|
58
|
+
flex: 1;
|
|
59
|
+
height: 100%;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.body {
|
|
63
|
+
display: flex;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
gap: $space-xs;
|
|
66
|
+
padding: $space-s 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.info {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: $space-xs;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.tags {
|
|
76
|
+
position: absolute;
|
|
77
|
+
top: 0;
|
|
78
|
+
left: 0;
|
|
79
|
+
display: flex;
|
|
80
|
+
gap: $space-xs;
|
|
81
|
+
padding: $space-xs;
|
|
82
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './silke-theme-card.module.scss';
|
|
3
|
+
import { SilkeText } from '../silke-text';
|
|
4
|
+
import { SilkeTag } from '../silke-tag';
|
|
5
|
+
import { SilkeOverflowMenu, SilkeOverflowMenuItem } from '../silke-overflow-menu';
|
|
6
|
+
|
|
7
|
+
interface SilkeThemeCardProps {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
primaryColor?: string;
|
|
11
|
+
secondaryColor?: string;
|
|
12
|
+
accentColor?: string;
|
|
13
|
+
bgColor?: string;
|
|
14
|
+
textColor?: string;
|
|
15
|
+
baseFont?: string;
|
|
16
|
+
isDefault?: boolean;
|
|
17
|
+
isSelected?: boolean;
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
menu?: (SilkeOverflowMenuItem | React.ReactElement | 'divider')[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function SilkeThemeCard({
|
|
23
|
+
name,
|
|
24
|
+
description,
|
|
25
|
+
primaryColor,
|
|
26
|
+
secondaryColor,
|
|
27
|
+
accentColor,
|
|
28
|
+
bgColor,
|
|
29
|
+
textColor,
|
|
30
|
+
baseFont,
|
|
31
|
+
isDefault,
|
|
32
|
+
isSelected,
|
|
33
|
+
onClick,
|
|
34
|
+
menu,
|
|
35
|
+
}: SilkeThemeCardProps) {
|
|
36
|
+
return (
|
|
37
|
+
<div className={styles.themeCard} onClick={onClick}>
|
|
38
|
+
<div className={styles.inner} style={{ background: bgColor }}>
|
|
39
|
+
<div className={styles.preview}>
|
|
40
|
+
<span
|
|
41
|
+
className={styles.previewText}
|
|
42
|
+
style={{
|
|
43
|
+
fontFamily: baseFont || 'inherit',
|
|
44
|
+
color: textColor,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
Aa
|
|
48
|
+
</span>
|
|
49
|
+
</div>
|
|
50
|
+
<div className={styles.colorStrip}>
|
|
51
|
+
<div className={styles.colorStripItem} style={{ background: primaryColor }} />
|
|
52
|
+
<div className={styles.colorStripItem} style={{ background: secondaryColor }} />
|
|
53
|
+
<div className={styles.colorStripItem} style={{ background: accentColor }} />
|
|
54
|
+
</div>
|
|
55
|
+
<div className={styles.tags}>
|
|
56
|
+
{isDefault && <SilkeTag kind="secondary" label="Default" />}
|
|
57
|
+
{isSelected && <SilkeTag kind="secondary" label="Selected" />}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<div className={styles.body}>
|
|
61
|
+
<div className={styles.info}>
|
|
62
|
+
<SilkeText>{name}</SilkeText>
|
|
63
|
+
{description && (
|
|
64
|
+
<SilkeText size="small" color="neutral-70">
|
|
65
|
+
{description}
|
|
66
|
+
</SilkeText>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
{menu && (
|
|
70
|
+
<div onClick={(e) => e.stopPropagation()}>
|
|
71
|
+
<SilkeOverflowMenu
|
|
72
|
+
size="s"
|
|
73
|
+
items={menu}
|
|
74
|
+
targetOrigin="top-right"
|
|
75
|
+
anchorOrigin="bottom-right"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './silke-theme-swatch';
|