@vev/silke 1.1.3 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/index.js +40 -38
- package/dist/index.js.LEGAL.txt +12 -0
- package/dist/styles.css +1596 -1036
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/silke-autocomplete-field/autocomplete-types.d.ts +4 -0
- package/dist/types/components/silke-autocomplete-field/index.d.ts +1 -0
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +60 -0
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +3 -0
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-popup-native.d.ts +15 -0
- package/dist/types/components/silke-button/silke-dropdown-button.d.ts +8 -13
- package/dist/types/components/silke-card/silke-card-grid.d.ts +33 -1
- package/dist/types/components/silke-command-text-field/image-utils.d.ts +20 -0
- package/dist/types/components/silke-command-text-field/index.d.ts +4 -0
- package/dist/types/components/silke-command-text-field/silke-command-parser.d.ts +3 -0
- package/dist/types/components/silke-command-text-field/silke-command-parser.spec.d.ts +1 -0
- package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +46 -0
- package/dist/types/components/silke-command-text-field/utils.d.ts +61 -0
- package/dist/types/components/silke-command-text-field/utils.spec.d.ts +1 -0
- package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
- package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +1 -0
- package/dist/types/components/silke-image/silke-image.d.ts +2 -1
- package/dist/types/components/silke-list/index.d.ts +1 -0
- package/dist/types/components/silke-list/silke-list-item.d.ts +24 -6
- package/dist/types/components/silke-list/silke-list.d.ts +9 -9
- package/dist/types/components/silke-list/types.d.ts +19 -0
- package/dist/types/components/silke-list/utils.d.ts +3 -0
- package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +1 -0
- package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +6 -1
- package/dist/types/components/silke-popover-native/index.d.ts +1 -0
- package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +37 -0
- package/dist/types/components/silke-popover-native/types.d.ts +6 -0
- package/dist/types/components/silke-popover-native/use-popover-positioning.d.ts +9 -0
- package/dist/types/components/silke-select-field/index.d.ts +1 -0
- package/dist/types/components/silke-select-field/silke-select-field-native.d.ts +4 -0
- package/dist/types/components/silke-shortcut-button/index.d.ts +1 -0
- package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +15 -0
- package/dist/types/components/silke-tag/silke-tag.d.ts +1 -1
- package/dist/types/icons.d.ts +32 -0
- package/jest.config.js +2 -3
- package/package.json +9 -3
- package/src/_variables.scss +125 -129
- package/src/components/index.ts +4 -1
- package/src/components/silke-action-box/silke-action-box.scss +2 -3
- package/src/components/silke-alert-banner/silke-alert-banner.scss +9 -10
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +2 -2
- package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
- package/src/components/silke-autocomplete-field/index.ts +1 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +346 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +39 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -12
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +3 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +542 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +92 -41
- package/src/components/silke-box/silke-box.mdx +321 -21
- package/src/components/silke-box/silke-box.scss +5 -5
- package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +147 -9
- package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
- package/src/components/silke-button/silke-big-button.scss +1 -1
- package/src/components/silke-button/silke-button.scss +27 -18
- package/src/components/silke-button/silke-dropdown-button.mdx +67 -0
- package/src/components/silke-button/silke-dropdown-button.tsx +40 -122
- package/src/components/silke-card/silke-card-grid.tsx +5 -3
- package/src/components/silke-card/silke-card.scss +8 -7
- package/src/components/silke-card/silke-card.tsx +7 -1
- package/src/components/silke-checkbox/silke-checkbox.mdx +139 -14
- package/src/components/silke-checkbox/silke-checkbox.scss +11 -11
- package/src/components/silke-color-picker/color-picker.scss +8 -8
- package/src/components/silke-color-swatches/silke-color-swatches.mdx +130 -0
- package/src/components/silke-command-text-field/image-utils.ts +71 -0
- package/src/components/silke-command-text-field/index.ts +12 -0
- package/src/components/silke-command-text-field/silke-command-parser.spec.ts +89 -0
- package/src/components/silke-command-text-field/silke-command-parser.ts +47 -0
- package/src/components/silke-command-text-field/silke-command-text-field.mdx +301 -0
- package/src/components/silke-command-text-field/silke-command-text-field.module.scss +119 -0
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +665 -0
- package/src/components/silke-command-text-field/utils.spec.ts +366 -0
- package/src/components/silke-command-text-field/utils.ts +287 -0
- package/src/components/silke-conditions-input/silke-conditions-input.scss +4 -4
- package/src/components/silke-content-column/silke-content-column.scss +1 -1
- package/src/components/silke-context-menu/silke-context-menu.scss +3 -4
- package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
- package/src/components/silke-css-number-field/silke-css-number-field.scss +14 -12
- package/src/components/silke-divider/silke-divider.mdx +154 -32
- package/src/components/silke-divider/silke-divider.scss +3 -2
- package/src/components/silke-drawer/silke-drawer.scss +6 -2
- package/src/components/silke-form/silke-form.mdx +254 -27
- package/src/components/silke-form-schema/fields/array-field-inline.tsx +1 -0
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +1 -0
- package/src/components/silke-form-schema/fields/styles.scss +34 -35
- package/src/components/silke-form-schema/silke-schema-field.tsx +1 -1
- package/src/components/silke-form-schema/silke-schema-fields.tsx +4 -3
- package/src/components/silke-gradient-picker/silke-gradient-picker.module.scss +2 -2
- package/src/components/silke-icon/silke-icon.mdx +212 -8
- package/src/components/silke-icon/silke-icon.scss +10 -2
- package/src/components/silke-icon/silke-icon.tsx +1 -0
- package/src/components/silke-icon/silke-stacked-icon.scss +42 -45
- package/src/components/silke-icon-browser/silke-icon-browser.mdx +143 -0
- package/src/components/silke-image/silke-image-color-backdrop.scss +6 -6
- package/src/components/silke-image/silke-image.mdx +189 -41
- package/src/components/silke-image/silke-image.scss +3 -3
- package/src/components/silke-image/silke-image.tsx +14 -1
- package/src/components/silke-link/silke-link.scss +3 -5
- package/src/components/silke-list/index.ts +1 -0
- package/src/components/silke-list/silke-list-item.mdx +83 -0
- package/src/components/silke-list/silke-list-item.scss +119 -0
- package/src/components/silke-list/silke-list-item.tsx +137 -12
- package/src/components/silke-list/silke-list.mdx +108 -13
- package/src/components/silke-list/silke-list.scss +8 -15
- package/src/components/silke-list/silke-list.tsx +63 -9
- package/src/components/silke-list/types.ts +22 -0
- package/src/components/silke-list/utils.ts +24 -0
- package/src/components/silke-loader/silke-loader.mdx +139 -5
- package/src/components/silke-loader/silke-loader.scss +1 -1
- package/src/components/silke-modal/silke-modal.scss +9 -9
- package/src/components/silke-navigation-link/silke-navigation-link.mdx +27 -2
- package/src/components/silke-navigation-link/silke-navigation-link.scss +34 -40
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +7 -6
- package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +228 -31
- package/src/components/silke-overflow-menu/silke-overflow-menu.scss +8 -8
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +14 -8
- package/src/components/silke-popover/silke-popover.scss +5 -5
- package/src/components/silke-popover-native/index.ts +1 -0
- package/src/components/silke-popover-native/silke-popover-native.mdx +207 -0
- package/src/components/silke-popover-native/silke-popover-native.scss +127 -0
- package/src/components/silke-popover-native/silke-popover-native.tsx +176 -0
- package/src/components/silke-popover-native/types.ts +21 -0
- package/src/components/silke-popover-native/use-popover-positioning.ts +157 -0
- package/src/components/silke-progress-indicator/silke-progress-indicator.scss +1 -1
- package/src/components/silke-radio-button/silke-radio-button.scss +18 -11
- package/src/components/silke-search-field/silke-search-field.mdx +161 -7
- package/src/components/silke-select-field/index.ts +1 -0
- package/src/components/silke-select-field/silke-select-field-native.tsx +17 -0
- package/src/components/silke-select-field/silke-select-field.mdx +65 -0
- package/src/components/silke-shortcut-button/index.ts +1 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.mdx +89 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.scss +145 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +55 -0
- package/src/components/silke-skeleton/silke-skeleton.mdx +109 -0
- package/src/components/silke-skeleton/silke-skeleton.scss +1 -1
- package/src/components/silke-slider/silke-slider.module.scss +19 -19
- package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +3 -3
- package/src/components/silke-sortable-list/silke-sortable-list.scss +4 -5
- package/src/components/silke-table/silke-table.scss +1 -1
- package/src/components/silke-tabs/silke-tabs.scss +3 -3
- package/src/components/silke-tag/silke-tag.mdx +179 -43
- package/src/components/silke-tag/silke-tag.scss +49 -12
- package/src/components/silke-tag/silke-tag.tsx +17 -7
- package/src/components/silke-text/silke-text.scss +6 -4
- package/src/components/silke-text/silke-title.scss +7 -14
- package/src/components/silke-text-field/silke-text-field.scss +9 -9
- package/src/components/silke-text-field/silke-text-field.tsx +3 -2
- package/src/components/silke-tile/silke-tile.scss +7 -3
- package/src/components/silke-toast-notification/silke-toast-notification.scss +4 -5
- package/src/components/silke-toggle/silke-toggle.mdx +163 -33
- package/src/components/silke-toggle/silke-toggle.scss +4 -4
- package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
- package/src/components/silke-tooltip/silke-shortcuts.tsx +3 -3
- package/src/components/silke-tooltip/silke-tooltip.scss +11 -16
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +9 -7
- package/src/components/silke-virtual/silke-virtual.mdx +161 -0
- package/src/components/silke-virtual/silke-virtual.scss +8 -8
- package/src/icons.tsx +45 -1
- package/src/styles/core.scss +42 -45
- package/src/styles/math.scss +66 -66
- package/tsconfig.build.json +2 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -14
- package/dist/types/components/silke-list-card/index.d.ts +0 -1
- package/dist/types/components/silke-list-card/silke-list-card.d.ts +0 -14
- package/src/components/silke-list-card/index.ts +0 -1
- package/src/components/silke-list-card/silke-list-card.mdx +0 -46
- package/src/components/silke-list-card/silke-list-card.scss +0 -57
- package/src/components/silke-list-card/silke-list-card.tsx +0 -63
|
@@ -6,7 +6,7 @@ import styles from './silke-tag.scss';
|
|
|
6
6
|
|
|
7
7
|
export type SilkeTagKind = 'primary' | 'secondary';
|
|
8
8
|
|
|
9
|
-
export type SilkeTagColor = 'yellow' | 'green' | 'red' | 'gray' | 'blue' | 'purple' | 'dark';
|
|
9
|
+
export type SilkeTagColor = 'yellow' | 'green' | 'red' | 'gray' | 'blue' | 'purple' | 'dark' | 'ai';
|
|
10
10
|
|
|
11
11
|
export type SilkeTagSize = 'tiny';
|
|
12
12
|
|
|
@@ -53,6 +53,15 @@ function SilkeTagComp(
|
|
|
53
53
|
|
|
54
54
|
const iconOnly = !!icon && !label;
|
|
55
55
|
|
|
56
|
+
const showRemoveAsIcon = !!icon && kind === 'secondary' && onRemove;
|
|
57
|
+
if (showRemoveAsIcon) cl.push(styles.showRemoveAsIcon);
|
|
58
|
+
|
|
59
|
+
const removeButton = !disabled && onRemove && (
|
|
60
|
+
<SilkeBox className={styles.removeButton} tag="button" align="center" onMouseDown={onRemove}>
|
|
61
|
+
<SilkeIcon icon="close" />
|
|
62
|
+
</SilkeBox>
|
|
63
|
+
);
|
|
64
|
+
|
|
56
65
|
return (
|
|
57
66
|
<SilkeBox
|
|
58
67
|
{...(rest as any)}
|
|
@@ -66,15 +75,16 @@ function SilkeTagComp(
|
|
|
66
75
|
>
|
|
67
76
|
<SilkeText overflow flex className={styles.label}>
|
|
68
77
|
<SilkeBox gap={innerGap} align="center">
|
|
69
|
-
{
|
|
78
|
+
{showRemoveAsIcon && removeButton}
|
|
79
|
+
{icon && (
|
|
80
|
+
<SilkeBox className={styles.tagIcon} align="center">
|
|
81
|
+
<SilkeIcon icon={icon} />
|
|
82
|
+
</SilkeBox>
|
|
83
|
+
)}
|
|
70
84
|
{label && <span>{label}</span>}
|
|
71
85
|
</SilkeBox>
|
|
72
86
|
</SilkeText>
|
|
73
|
-
{!
|
|
74
|
-
<SilkeBox tag="button" vAlign="center" hAlign="center" onMouseDown={onRemove}>
|
|
75
|
-
<SilkeIcon icon="close" />
|
|
76
|
-
</SilkeBox>
|
|
77
|
-
)}
|
|
87
|
+
{!showRemoveAsIcon && removeButton}
|
|
78
88
|
</SilkeBox>
|
|
79
89
|
);
|
|
80
90
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
@use
|
|
2
|
-
@use
|
|
3
|
-
@import
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
@use '../../variables' as *;
|
|
3
|
+
@import '../../../src/styles/core';
|
|
4
4
|
|
|
5
|
-
$weights:
|
|
5
|
+
$weights:
|
|
6
|
+
'strong' 600,
|
|
7
|
+
'light' 200;
|
|
6
8
|
|
|
7
9
|
.text {
|
|
8
10
|
--font-size: 14px;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
:root{
|
|
1
|
+
:root {
|
|
2
2
|
--silke-title-xxs: 14px;
|
|
3
3
|
--silke-title-xs: 16px;
|
|
4
4
|
--silke-title-s: 24px;
|
|
@@ -14,43 +14,36 @@
|
|
|
14
14
|
--silke-title-xl-line-height: 64px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.title{
|
|
17
|
+
.title {
|
|
18
18
|
&.xl {
|
|
19
|
-
|
|
20
19
|
font-size: var(--silke-title-xl);
|
|
21
20
|
line-height: var(--silke-title-xl-line-height);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
|
|
25
23
|
&.l {
|
|
26
24
|
font-size: var(--silke-title-l);
|
|
27
25
|
line-height: var(--silke-title-l-line-height);
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
|
|
30
28
|
&.m {
|
|
31
|
-
|
|
32
29
|
font-size: var(--silke-title-m);
|
|
33
30
|
line-height: var(--silke-title-m-line-height);
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
|
|
36
33
|
&.s {
|
|
37
|
-
|
|
38
34
|
font-size: var(--silke-title-s);
|
|
39
35
|
line-height: var(--silke-title-s-line-height);
|
|
40
36
|
}
|
|
41
|
-
|
|
37
|
+
|
|
42
38
|
&.xs {
|
|
43
39
|
font-size: var(--silke-title-xs);
|
|
44
40
|
line-height: var(--silke-title-xs-line-height);
|
|
45
41
|
letter-spacing: var(--silke-title-xs-letter-spacing);
|
|
46
42
|
}
|
|
47
|
-
|
|
43
|
+
|
|
48
44
|
&.xxs {
|
|
49
45
|
font-size: var(--silke-title-xxs);
|
|
50
46
|
line-height: var(--silke-title-xxs-line-height);
|
|
51
47
|
letter-spacing: var(--silke-title-xxs-letter-spacing);
|
|
52
48
|
}
|
|
53
|
-
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use '../../variables' as *;
|
|
2
2
|
|
|
3
3
|
.wrapper {
|
|
4
4
|
position: relative;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
--text-field-border-radius: var(--border-radius-small);
|
|
29
29
|
--text-field-label-weight: 600;
|
|
30
30
|
|
|
31
|
-
----current-border-color:transparent;
|
|
31
|
+
----current-border-color: transparent;
|
|
32
32
|
|
|
33
33
|
width: 100%;
|
|
34
34
|
min-width: 0;
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
// --text-field-border-color: transparent;
|
|
45
45
|
// --text-field-hover-border-color: var(--color-neutral-20);
|
|
46
46
|
// --text-field-focus-border-color: var(--color-accent-30);
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
/** True ghost field code but Betsy wanted to tweak more on design */
|
|
49
49
|
--text-field-bg: transparent;
|
|
50
50
|
--text-field-hover-bg: transparent;
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
.input::placeholder {
|
|
86
86
|
color: var(--text-field-disabled-placeholder-color);
|
|
87
87
|
}
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
|
|
90
90
|
&:not(.disabled):hover {
|
|
91
91
|
.field {
|
|
@@ -115,9 +115,9 @@
|
|
|
115
115
|
background-color: var(--text-field-bg);
|
|
116
116
|
border-radius: var(--text-field-border-radius);
|
|
117
117
|
transition: color 80ms;
|
|
118
|
-
|
|
119
|
-
&::after{
|
|
120
|
-
content:
|
|
118
|
+
|
|
119
|
+
&::after {
|
|
120
|
+
content: '';
|
|
121
121
|
display: block;
|
|
122
122
|
position: absolute;
|
|
123
123
|
inset: 0 0 0 0;
|
|
@@ -202,7 +202,7 @@ textarea {
|
|
|
202
202
|
white-space: pre-line;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
.itemBefore ~ .input,
|
|
205
|
+
.itemBefore ~ .input,
|
|
206
|
+
.itemBefore ~ [data-input] {
|
|
206
207
|
padding: 0;
|
|
207
208
|
}
|
|
208
|
-
|
|
@@ -95,7 +95,7 @@ export const SilkeTextField = React.forwardRef<HTMLDivElement, SilkeTextFieldPro
|
|
|
95
95
|
|
|
96
96
|
const context = useTextFieldContext();
|
|
97
97
|
|
|
98
|
-
const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>();
|
|
98
|
+
const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
|
|
99
99
|
const helpId = useMemo(() => {
|
|
100
100
|
return `help-${generateGuid()}`;
|
|
101
101
|
}, []);
|
|
@@ -127,7 +127,7 @@ export const SilkeTextField = React.forwardRef<HTMLDivElement, SilkeTextFieldPro
|
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
const inputStyle = rest.style
|
|
130
|
+
const inputStyle = { ...rest.style };
|
|
131
131
|
if (width) inputStyle.width = width;
|
|
132
132
|
|
|
133
133
|
const maxLengthHelp =
|
|
@@ -164,6 +164,7 @@ export const SilkeTextField = React.forwardRef<HTMLDivElement, SilkeTextFieldPro
|
|
|
164
164
|
value: value ?? '',
|
|
165
165
|
rows: multiline === true ? 5 : multiline || undefined,
|
|
166
166
|
autoComplete: autocomplete ? 'on' : 'off',
|
|
167
|
+
...(autoFocus && { autofocus: 'true' }),
|
|
167
168
|
'aria-invalid': !!error,
|
|
168
169
|
'aria-describedby': help ? helpId : undefined,
|
|
169
170
|
onChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use '../../variables' as *;
|
|
2
2
|
$focus-border-width: 2px;
|
|
3
|
-
$widths:
|
|
3
|
+
$widths:
|
|
4
|
+
'tiny' 256px,
|
|
5
|
+
'small' 512px,
|
|
6
|
+
'medium' 768px,
|
|
7
|
+
'large' 1024px;
|
|
4
8
|
|
|
5
|
-
body{
|
|
9
|
+
body {
|
|
6
10
|
--tile-background: var(--color-neutral-5);
|
|
7
11
|
--tile-background-hover: rgba(var(--color-neutral-5-rgb), 0.32);
|
|
8
12
|
--tile-background-active: rgba(var(--color-neutral-5-rgb), 0.08);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
@use
|
|
2
|
-
|
|
1
|
+
@use '../../variables' as *;
|
|
3
2
|
|
|
4
3
|
.notificationBox {
|
|
5
4
|
--notification-background: var(--color-neutral-0);
|
|
@@ -11,7 +10,7 @@
|
|
|
11
10
|
color: var(--color-neutral-100);
|
|
12
11
|
border: 1px solid var(--notification-border);
|
|
13
12
|
max-width: 1096px;
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
&:not(.fluid) {
|
|
16
15
|
width: 320px;
|
|
17
16
|
}
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
|
|
91
90
|
.scale {
|
|
92
91
|
opacity: 0;
|
|
93
|
-
animation: scale 250ms 300ms cubic-bezier(.45
|
|
92
|
+
animation: scale 250ms 300ms cubic-bezier(0.45, 0.65, 0.62, 0.99) forwards;
|
|
94
93
|
transform-origin: center center;
|
|
95
94
|
}
|
|
96
95
|
|
|
@@ -106,5 +105,5 @@
|
|
|
106
105
|
100% {
|
|
107
106
|
opacity: 1;
|
|
108
107
|
transform: scale(1);
|
|
109
|
-
|
|
108
|
+
}
|
|
110
109
|
}
|
|
@@ -1,51 +1,181 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SilkeToggle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A switch component for toggling boolean values on and off. Use toggles for settings that take effect immediately without requiring a save action.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **On/Off states**: Clear visual feedback for boolean values
|
|
8
|
+
- **Label support**: Display label and help text
|
|
9
|
+
- **Size variants**: Normal and small sizes
|
|
10
|
+
- **Form integration**: Works with SilkeForm
|
|
11
|
+
- **Invert mode**: Flip the visual state
|
|
12
|
+
- **Validation**: Built-in required validation
|
|
13
|
+
|
|
14
|
+
## Basic Usage
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const [enabled, setEnabled] = React.useState(false);
|
|
18
|
+
|
|
19
|
+
<SilkeToggle value={enabled} onChange={setEnabled} />;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## With Label
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
const [enabled, setEnabled] = React.useState(true);
|
|
26
|
+
|
|
27
|
+
<SilkeToggle label="Enable notifications" value={enabled} onChange={setEnabled} />;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## With Help Text
|
|
31
|
+
|
|
32
|
+
Provide additional context with the `help` prop:
|
|
4
33
|
|
|
5
34
|
```js
|
|
6
|
-
const [
|
|
7
|
-
|
|
35
|
+
const [enabled, setEnabled] = React.useState(false);
|
|
36
|
+
|
|
37
|
+
<SilkeToggle
|
|
38
|
+
label="Dark mode"
|
|
39
|
+
help="Enable dark theme for the application"
|
|
40
|
+
value={enabled}
|
|
41
|
+
onChange={setEnabled}
|
|
42
|
+
/>;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## States
|
|
8
46
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
47
|
+
```js
|
|
48
|
+
const [on, setOn] = React.useState(true);
|
|
49
|
+
const [off, setOff] = React.useState(false);
|
|
50
|
+
|
|
51
|
+
<SilkeBox column gap="s">
|
|
52
|
+
<SilkeToggle label="Toggle ON" value={on} onChange={setOn} />
|
|
53
|
+
<SilkeToggle label="Toggle OFF" value={off} onChange={setOff} />
|
|
54
|
+
</SilkeBox>;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Size Variants
|
|
58
|
+
|
|
59
|
+
Use `small` for a compact toggle:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
const [normal, setNormal] = React.useState(true);
|
|
63
|
+
const [small, setSmall] = React.useState(true);
|
|
64
|
+
|
|
65
|
+
<SilkeBox column gap="m">
|
|
66
|
+
<SilkeToggle label="Normal size toggle" value={normal} onChange={setNormal} />
|
|
67
|
+
<SilkeToggle small label="Small size toggle" value={small} onChange={setSmall} />
|
|
68
|
+
</SilkeBox>;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Disabled State
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
<SilkeBox column gap="s">
|
|
75
|
+
<SilkeToggle disabled label="Disabled (ON)" value={true} onChange={() => {}} />
|
|
76
|
+
<SilkeToggle disabled label="Disabled (OFF)" value={false} onChange={() => {}} />
|
|
77
|
+
<SilkeToggle disabled small label="Disabled small (ON)" value={true} onChange={() => {}} />
|
|
78
|
+
<SilkeToggle disabled small label="Disabled small (OFF)" value={false} onChange={() => {}} />
|
|
79
|
+
</SilkeBox>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Required Validation
|
|
83
|
+
|
|
84
|
+
Show error when required toggle is off:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
const [agreed, setAgreed] = React.useState(false);
|
|
88
|
+
|
|
89
|
+
<SilkeBox column gap="s">
|
|
90
|
+
<SilkeToggle required label="I agree to the terms" value={agreed} onChange={setAgreed} />
|
|
91
|
+
<SilkeText size="s" color={agreed ? 'success-50' : 'error-50'}>
|
|
92
|
+
{agreed ? 'Thank you for agreeing' : 'You must agree to continue'}
|
|
93
|
+
</SilkeText>
|
|
94
|
+
</SilkeBox>;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Inverted Mode
|
|
98
|
+
|
|
99
|
+
Use `invert` to flip the visual state (toggle appears ON when value is false):
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const [disabled, setDisabled] = React.useState(false);
|
|
103
|
+
|
|
104
|
+
<SilkeBox column gap="s">
|
|
105
|
+
<SilkeToggle invert label="Disable feature" help="When on, this feature is disabled" value={disabled} onChange={setDisabled} />
|
|
106
|
+
<SilkeText size="s">Feature is: {disabled ? 'DISABLED' : 'ENABLED'}</SilkeText>
|
|
107
|
+
</SilkeBox>;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Form Integration
|
|
111
|
+
|
|
112
|
+
Use within SilkeForm:
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
const [settings, setSettings] = React.useState({
|
|
116
|
+
notifications: true,
|
|
117
|
+
autoSave: false,
|
|
118
|
+
darkMode: false,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
<SilkeForm value={settings} onChange={setSettings}>
|
|
122
|
+
<SilkeBox column gap="m">
|
|
123
|
+
<SilkeToggle name="notifications" label="Push notifications" />
|
|
124
|
+
<SilkeToggle name="autoSave" label="Auto-save" help="Automatically save changes" />
|
|
125
|
+
<SilkeToggle name="darkMode" label="Dark mode" />
|
|
12
126
|
</SilkeBox>
|
|
13
|
-
|
|
14
|
-
<SilkeToggle small label="Tiny toggle, tiny text" value={checked} onChange={setChecked} />
|
|
15
|
-
</>;
|
|
127
|
+
</SilkeForm>;
|
|
16
128
|
```
|
|
17
129
|
|
|
18
|
-
##
|
|
130
|
+
## Settings Panel Example
|
|
19
131
|
|
|
20
132
|
```js
|
|
21
|
-
const [
|
|
133
|
+
const [settings, setSettings] = React.useState({
|
|
134
|
+
emailNotifications: true,
|
|
135
|
+
smsNotifications: false,
|
|
136
|
+
marketingEmails: false,
|
|
137
|
+
twoFactor: true,
|
|
138
|
+
});
|
|
22
139
|
|
|
23
|
-
|
|
24
|
-
<
|
|
140
|
+
<SilkeBox column gap="m" style={{ maxWidth: 400 }}>
|
|
141
|
+
<SilkeText kind="title" size="s">Notification Settings</SilkeText>
|
|
142
|
+
<SilkeToggle
|
|
143
|
+
label="Email notifications"
|
|
144
|
+
help="Receive updates via email"
|
|
145
|
+
value={settings.emailNotifications}
|
|
146
|
+
onChange={(v) => setSettings({ ...settings, emailNotifications: v })}
|
|
147
|
+
/>
|
|
25
148
|
<SilkeToggle
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onChange={setChecked}
|
|
149
|
+
label="SMS notifications"
|
|
150
|
+
help="Receive updates via text message"
|
|
151
|
+
value={settings.smsNotifications}
|
|
152
|
+
onChange={(v) => setSettings({ ...settings, smsNotifications: v })}
|
|
31
153
|
/>
|
|
32
|
-
<
|
|
154
|
+
<SilkeDivider space="s" />
|
|
155
|
+
<SilkeText kind="title" size="s">Security</SilkeText>
|
|
33
156
|
<SilkeToggle
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
onChange={setChecked}
|
|
157
|
+
label="Two-factor authentication"
|
|
158
|
+
help="Require code when signing in"
|
|
159
|
+
value={settings.twoFactor}
|
|
160
|
+
onChange={(v) => setSettings({ ...settings, twoFactor: v })}
|
|
39
161
|
/>
|
|
40
|
-
|
|
162
|
+
</SilkeBox>;
|
|
41
163
|
```
|
|
42
164
|
|
|
43
|
-
##
|
|
165
|
+
## Props
|
|
44
166
|
|
|
45
|
-
|
|
46
|
-
|
|
167
|
+
| Prop | Type | Default | Description |
|
|
168
|
+
| ---------- | -------------------------- | ------- | ---------------------------------------- |
|
|
169
|
+
| `value` | `boolean` | - | Current toggle state |
|
|
170
|
+
| `onChange` | `(value: boolean) => void` | - | Called when toggle is switched |
|
|
171
|
+
| `label` | `string` | - | Label text |
|
|
172
|
+
| `help` | `React.ReactNode` | - | Help text displayed below label |
|
|
173
|
+
| `name` | `string` | - | Field name for form integration |
|
|
174
|
+
| `small` | `boolean` | `false` | Use smaller toggle size |
|
|
175
|
+
| `disabled` | `boolean` | `false` | Disable the toggle |
|
|
176
|
+
| `readOnly` | `boolean` | `false` | Prevent changes |
|
|
177
|
+
| `required` | `boolean` | `false` | Mark as required (shows error if false) |
|
|
178
|
+
| `invert` | `boolean` | `false` | Invert visual state (ON when false) |
|
|
179
|
+
| `error` | `string` | - | Error message to display |
|
|
47
180
|
|
|
48
|
-
|
|
49
|
-
<SilkeToggle value={checked} onChange={setChecked} />
|
|
50
|
-
</>;
|
|
51
|
-
```
|
|
181
|
+
Also accepts standard HTML input attributes and form field props.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@use
|
|
2
|
-
@use
|
|
1
|
+
@use '../../variables' as *;
|
|
2
|
+
@use 'sass:math';
|
|
3
3
|
|
|
4
4
|
$bg-off: var(--color-neutral-30);
|
|
5
5
|
$bg-on: var(--color-accent-30);
|
|
@@ -43,7 +43,7 @@ $bg-on: var(--color-accent-30);
|
|
|
43
43
|
transition: background-color 100ms ease;
|
|
44
44
|
|
|
45
45
|
&::after {
|
|
46
|
-
content:
|
|
46
|
+
content: '';
|
|
47
47
|
display: block;
|
|
48
48
|
width: calc(50% - #{$space-xxs});
|
|
49
49
|
height: 100%;
|
|
@@ -64,7 +64,7 @@ $bg-on: var(--color-accent-30);
|
|
|
64
64
|
.disabled {
|
|
65
65
|
cursor: not-allowed;
|
|
66
66
|
pointer-events: none;
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
.switch {
|
|
69
69
|
background: var(--color-neutral-30);
|
|
70
70
|
}
|
|
@@ -33,11 +33,11 @@ export const SilkeShortcuts = ({
|
|
|
33
33
|
{Keyboard.getFormatted(s).map((keys, i) =>
|
|
34
34
|
keys
|
|
35
35
|
.split(' ')
|
|
36
|
-
.map((f) =>
|
|
36
|
+
.map((f, index) =>
|
|
37
37
|
isShortcutIcon(f) ? (
|
|
38
|
-
<SilkeIcon icon={f as IconSymbol} key={i} />
|
|
38
|
+
<SilkeIcon icon={f as IconSymbol} key={i + index} />
|
|
39
39
|
) : (
|
|
40
|
-
<span key={i}>{f}</span>
|
|
40
|
+
<span key={i + index}>{f}</span>
|
|
41
41
|
),
|
|
42
42
|
),
|
|
43
43
|
)}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use '../../variables' as *;
|
|
2
2
|
|
|
3
|
-
$border-color: rgba(
|
|
4
|
-
var(--color-neutral-60-rgb),
|
|
5
|
-
var(--opacity-level-light)
|
|
6
|
-
);
|
|
3
|
+
$border-color: rgba(var(--color-neutral-60-rgb), var(--opacity-level-light));
|
|
7
4
|
.root {
|
|
8
5
|
position: relative;
|
|
9
6
|
filter: var(--shadow-level-4);
|
|
@@ -52,7 +49,7 @@ $border-color: rgba(
|
|
|
52
49
|
.definitionTooltip:not(.noBorder) {
|
|
53
50
|
border-bottom: 1px dotted var(--color-accent-40);
|
|
54
51
|
|
|
55
|
-
&:hover{
|
|
52
|
+
&:hover {
|
|
56
53
|
border-bottom-style: solid;
|
|
57
54
|
}
|
|
58
55
|
}
|
|
@@ -69,34 +66,32 @@ $border-color: rgba(
|
|
|
69
66
|
line-height: 14px;
|
|
70
67
|
font-weight: 300;
|
|
71
68
|
}
|
|
72
|
-
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
.tiny{
|
|
71
|
+
.tiny {
|
|
77
72
|
width: 192px;
|
|
78
|
-
.img{
|
|
73
|
+
.img {
|
|
79
74
|
aspect-ratio: 192/120;
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
|
|
83
|
-
.small{
|
|
78
|
+
.small {
|
|
84
79
|
width: 256px;
|
|
85
|
-
.img{
|
|
80
|
+
.img {
|
|
86
81
|
aspect-ratio: 256/160;
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
|
|
90
|
-
.base{
|
|
85
|
+
.base {
|
|
91
86
|
width: 320px;
|
|
92
|
-
.img{
|
|
87
|
+
.img {
|
|
93
88
|
aspect-ratio: 320/200;
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
.large{
|
|
92
|
+
.large {
|
|
98
93
|
width: 384px;
|
|
99
|
-
.img{
|
|
94
|
+
.img {
|
|
100
95
|
aspect-ratio: 384/240;
|
|
101
96
|
}
|
|
102
97
|
}
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
// Style border of wrapped children when open
|
|
10
|
-
&[data-open=
|
|
10
|
+
&[data-open='true'] *::after {
|
|
11
11
|
--current-border-color: var(--color-support-tertiary-40) !important;
|
|
12
12
|
--text-field-border-color: var(--color-support-tertiary-40) !important;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// Style border of children when hovered
|
|
16
|
-
&[data-is-variable=
|
|
16
|
+
&[data-is-variable='true']:hover *::after {
|
|
17
17
|
--current-border-color: var(--color-support-tertiary-40) !important;
|
|
18
18
|
--text-field-border-color: var(--color-support-tertiary-40) !important;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
&[data-full-width=
|
|
21
|
+
&[data-full-width='true'] {
|
|
22
22
|
width: 100%;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
&:after,
|
|
37
37
|
&:before {
|
|
38
|
-
content:
|
|
38
|
+
content: '';
|
|
39
39
|
position: absolute;
|
|
40
40
|
width: 12px;
|
|
41
41
|
height: 12px;
|
|
@@ -51,7 +51,9 @@
|
|
|
51
51
|
&:before {
|
|
52
52
|
transform: scale(0);
|
|
53
53
|
transform-origin: center center;
|
|
54
|
-
transition:
|
|
54
|
+
transition:
|
|
55
|
+
opacity 0.2s ease,
|
|
56
|
+
transform 0.2s ease;
|
|
55
57
|
}
|
|
56
58
|
&:after {
|
|
57
59
|
content: attr(data-icon);
|
|
@@ -63,8 +65,8 @@
|
|
|
63
65
|
background: var(--color-support-tertiary-40);
|
|
64
66
|
transition: opacity 0.2s ease;
|
|
65
67
|
}
|
|
66
|
-
&:hover:after
|
|
68
|
+
&:hover:after {
|
|
67
69
|
transform: scale(1.2);
|
|
68
70
|
opacity: 1;
|
|
69
71
|
}
|
|
70
|
-
}
|
|
72
|
+
}
|