@vev/silke 1.0.16 → 1.0.18
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 +16 -0
- package/dist/chunk-SOFGXMET.js +22 -0
- package/dist/{chunk-LAB2YEXC.js.map → chunk-SOFGXMET.js.map} +3 -3
- package/dist/index.js +43 -8
- package/dist/index.js.LEGAL.txt +6 -10
- package/dist/index.js.map +4 -4
- package/dist/silke-code-editor-LBP2WDX3.js +25 -0
- package/dist/silke-code-editor-LBP2WDX3.js.map +7 -0
- package/dist/styles.css +593 -618
- package/package.json +6 -6
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +33 -7
- package/src/components/silke-autocomplete-field/autocomplete-tags.tsx +8 -4
- package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +67 -24
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +32 -13
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.spec.tsx +24 -109
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +304 -220
- package/src/components/silke-box/silke-box.mdx +2 -1
- package/src/components/silke-box/silke-box.scss +9 -10
- package/src/components/silke-box/silke-box.tsx +9 -0
- package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +5 -1
- package/src/components/silke-button/silke-button.scss +3 -3
- package/src/components/silke-checkbox/silke-checkbox.mdx +11 -2
- package/src/components/silke-color-palettes/silke-color-palette.mdx +2 -2
- package/src/components/silke-color-picker/color.ts +12 -0
- package/src/components/silke-color-picker/index.ts +1 -0
- package/src/components/silke-color-picker/silke-color-info.tsx +2 -18
- package/src/components/silke-color-picker/silke-color-picker.mdx +19 -9
- package/src/components/silke-color-picker/silke-color-picker.tsx +4 -13
- package/src/components/silke-context-menu/silke-context-menu-item.tsx +5 -1
- package/src/components/silke-context-menu/silke-context-menu.scss +5 -1
- package/src/components/silke-context-menu/silke-context-menu.tsx +4 -2
- package/src/components/silke-css-number-field/silke-css-number-field.mdx +43 -4
- package/src/components/silke-css-number-field/silke-css-number-field.scss +47 -14
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +114 -186
- package/src/components/silke-css-number-field/utils.ts +25 -0
- package/src/components/silke-drawer/silke-drawer.mdx +13 -13
- package/src/components/silke-drawer/silke-drawer.tsx +0 -14
- package/src/components/silke-form/silke-form.mdx +15 -3
- package/src/components/silke-form/silke-form.tsx +1 -1
- package/src/components/silke-form-schema/fields/event-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/utils/generate-title.ts +14 -6
- package/src/components/silke-form-schema/silke-schema-field.tsx +12 -11
- package/src/components/silke-form-schema/silke-schema-fields.tsx +2 -2
- package/src/components/silke-icon/silke-icon.tsx +3 -1
- package/src/components/silke-image/silke-image.scss +2 -2
- package/src/components/silke-loader/silke-loader.mdx +3 -4
- package/src/components/silke-modal/silke-modal.tsx +11 -2
- package/src/components/silke-navigation-link/silke-navigation-link.mdx +6 -1
- package/src/components/silke-navigation-link/silke-navigation-link.scss +12 -2
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +21 -17
- package/src/components/silke-notification/silke-notification.scss +1 -1
- package/src/components/silke-object-field/silke-object-field.mdx +10 -3
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +1 -2
- package/src/components/silke-popover/silke-popover.tsx +1 -20
- package/src/components/silke-progress-indicator/silke-progress-indicator.mdx +9 -3
- package/src/components/silke-radio-button/silke-radio-button.mdx +7 -1
- package/src/components/silke-search-field/silke-search-field.mdx +12 -4
- package/src/components/silke-select-field/silke-select-field.mdx +137 -7
- package/src/components/silke-select-field/silke-select-field.spec.tsx +44 -126
- package/src/components/silke-sortable-list/silke-nested-sortable-item.tsx +17 -2
- package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +6 -2
- package/src/components/silke-sortable-list/silke-nested-sortable-utils.ts +6 -0
- package/src/components/silke-table/silke-table.tsx +1 -1
- package/src/components/silke-tabs/silke-tabs.mdx +2 -2
- package/src/components/silke-tag/silke-tag.mdx +51 -13
- package/src/components/silke-tag/silke-tag.scss +52 -10
- package/src/components/silke-tag/silke-tag.tsx +48 -24
- package/src/components/silke-text-field/silke-text-field-item.tsx +12 -7
- package/src/components/silke-text-field/silke-text-field-outline.tsx +39 -42
- package/src/components/silke-text-field/silke-text-field.mdx +73 -6
- package/src/components/silke-text-field/silke-text-field.scss +153 -247
- package/src/components/silke-text-field/silke-text-field.tsx +4 -3
- package/src/components/silke-tile/silke-tile.mdx +39 -8
- package/src/components/silke-toggle/silke-toggle.mdx +29 -5
- package/src/components/silke-toolbar/silke-toolbar.mdx +35 -15
- package/src/components/silke-tooltip/silke-icon-tooltip.tsx +2 -1
- package/src/docs/app.tsx +9 -16
- package/src/docs/parser.ts +1 -1
- package/src/hooks/form/use-form-field.ts +1 -1
- package/src/hooks/hooks.mdx +3 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-uniq-id.ts +6 -0
- package/src/icons.tsx +10 -2
- package/dist/chunk-LAB2YEXC.js +0 -22
- package/dist/silke-code-editor-WEBZ7JXL.js +0 -25
- package/dist/silke-code-editor-WEBZ7JXL.js.map +0 -7
- /package/dist/{chunk-LAB2YEXC.js.LEGAL.txt → chunk-SOFGXMET.js.LEGAL.txt} +0 -0
- /package/dist/{silke-code-editor-WEBZ7JXL.js.LEGAL.txt → silke-code-editor-LBP2WDX3.js.LEGAL.txt} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, screen, within, act } from '@testing-library/react';
|
|
3
3
|
import { SilkeSelectField } from './silke-select-field';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import userEvent, { UserEvent } from '@testing-library/user-event';
|
|
5
5
|
import { SilkeForm } from '../silke-form';
|
|
6
6
|
import { ARROW_DOWN, ARROW_UP, ENTER } from '../../../jest/keys';
|
|
7
7
|
|
|
@@ -11,6 +11,7 @@ describe('silke-select-field', () => {
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
const makeItem = (value: string) => ({ label: value, value });
|
|
14
|
+
const pressKey = (key: string, user: UserEvent) => act(async () => await user.keyboard(key));
|
|
14
15
|
|
|
15
16
|
const items = [
|
|
16
17
|
makeItem('rat'),
|
|
@@ -22,7 +23,7 @@ describe('silke-select-field', () => {
|
|
|
22
23
|
|
|
23
24
|
it('Has no value when no value passed', () => {
|
|
24
25
|
render(<SilkeSelectField items={items} label="Animal" />);
|
|
25
|
-
expect(screen.getByLabelText('Animal').getAttribute('value')).
|
|
26
|
+
expect(screen.getByLabelText('Animal').getAttribute('value')).toBeNull();
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
it('Has value when value passed', () => {
|
|
@@ -43,17 +44,17 @@ describe('silke-select-field', () => {
|
|
|
43
44
|
const onChange = jest.fn();
|
|
44
45
|
render(<SilkeSelectField items={items} label="Animal" value="rat" onChange={onChange} />);
|
|
45
46
|
const input = screen.getByLabelText('Animal');
|
|
46
|
-
await user.click(input);
|
|
47
|
+
await act(async () => await user.click(input));
|
|
47
48
|
|
|
48
49
|
const optionsList = screen.queryAllByRole('listbox');
|
|
49
50
|
|
|
50
51
|
expect(optionsList).toHaveLength(1);
|
|
52
|
+
const { getByText } = within(optionsList[0]);
|
|
53
|
+
const lionOption = getByText('lion');
|
|
54
|
+
const ratOption = getByText('rat');
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
expect(lionOption).toBeInTheDocument();
|
|
56
|
-
expect(ratOption).toBeInTheDocument();
|
|
56
|
+
expect(lionOption).toBeDefined();
|
|
57
|
+
expect(ratOption).toBeDefined();
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
it('Calls onChange with value when option is clicked', async () => {
|
|
@@ -63,10 +64,9 @@ describe('silke-select-field', () => {
|
|
|
63
64
|
render(<SilkeSelectField items={items} label="Animal" value="rat" onChange={onChange} />);
|
|
64
65
|
|
|
65
66
|
const input = screen.getByLabelText('Animal');
|
|
66
|
-
await user.click(input);
|
|
67
|
+
await act(async () => await user.click(input));
|
|
67
68
|
const option = screen.getByText('lion');
|
|
68
|
-
await user.click(option);
|
|
69
|
-
fireEvent.blur(input);
|
|
69
|
+
await act(async () => await user.click(option));
|
|
70
70
|
|
|
71
71
|
expect(onChange).toHaveBeenCalledWith('lion');
|
|
72
72
|
});
|
|
@@ -78,13 +78,12 @@ describe('silke-select-field', () => {
|
|
|
78
78
|
render(<SilkeSelectField items={items} label="Animal" onChange={onChange} />);
|
|
79
79
|
|
|
80
80
|
const input = screen.getByLabelText('Animal');
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await user.keyboard(ARROW_DOWN); // opens dropdown
|
|
81
|
+
act(() => input.focus());
|
|
84
82
|
|
|
85
|
-
await user
|
|
83
|
+
await pressKey(ARROW_DOWN, user);
|
|
84
|
+
await pressKey(ENTER, user);
|
|
86
85
|
|
|
87
|
-
expect(onChange).toHaveBeenCalledWith('
|
|
86
|
+
expect(onChange).toHaveBeenCalledWith('lion');
|
|
88
87
|
});
|
|
89
88
|
|
|
90
89
|
it('Can be selected with keyboard only', async () => {
|
|
@@ -94,15 +93,13 @@ describe('silke-select-field', () => {
|
|
|
94
93
|
render(<SilkeSelectField items={items} label="Animal" onChange={onChange} />);
|
|
95
94
|
|
|
96
95
|
const input = screen.getByLabelText('Animal');
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
await
|
|
96
|
+
act(() => input.focus());
|
|
97
|
+
await pressKey(ARROW_DOWN, user);
|
|
98
|
+
await pressKey(ARROW_DOWN, user);
|
|
99
|
+
await pressKey(ARROW_DOWN, user);
|
|
100
|
+
await pressKey(ENTER, user);
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
await user.keyboard(ARROW_DOWN);
|
|
103
|
-
await user.keyboard(ENTER);
|
|
104
|
-
|
|
105
|
-
expect(onChange).toHaveBeenCalledWith('bear');
|
|
102
|
+
expect(onChange).toHaveBeenCalledWith('deer');
|
|
106
103
|
});
|
|
107
104
|
|
|
108
105
|
it('When it has value already, pressing arrow key selects item next to value', async () => {
|
|
@@ -112,35 +109,16 @@ describe('silke-select-field', () => {
|
|
|
112
109
|
render(<SilkeSelectField items={items} label="Animal" value="bear" onChange={onChange} />);
|
|
113
110
|
|
|
114
111
|
const input = screen.getByLabelText('Animal');
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
await user.keyboard(ARROW_DOWN); // opens dropdown
|
|
118
|
-
|
|
119
|
-
await user.keyboard(ARROW_UP);
|
|
120
|
-
await user.keyboard(ARROW_UP);
|
|
121
|
-
await user.keyboard(ARROW_UP);
|
|
112
|
+
act(() => input.focus());
|
|
122
113
|
|
|
123
|
-
await user
|
|
114
|
+
await pressKey(ARROW_UP, user);
|
|
115
|
+
await pressKey(ARROW_UP, user);
|
|
116
|
+
await pressKey(ARROW_UP, user);
|
|
117
|
+
await pressKey(ENTER, user);
|
|
124
118
|
|
|
125
119
|
expect(onChange).toHaveBeenCalledWith('cat');
|
|
126
120
|
});
|
|
127
121
|
|
|
128
|
-
it('Selects previous value when pressing enter twice', async () => {
|
|
129
|
-
const onChange = jest.fn();
|
|
130
|
-
const user = userEvent.setup();
|
|
131
|
-
|
|
132
|
-
render(<SilkeSelectField items={items} label="Animal" value="deer" onChange={onChange} />);
|
|
133
|
-
|
|
134
|
-
const input = screen.getByLabelText('Animal');
|
|
135
|
-
await input.focus();
|
|
136
|
-
|
|
137
|
-
await user.keyboard(ARROW_UP); // opens dropdown
|
|
138
|
-
|
|
139
|
-
await user.keyboard(ENTER);
|
|
140
|
-
|
|
141
|
-
expect(onChange).toHaveBeenCalledWith('deer');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
122
|
it('Does not hide dropdown when item is selected on a multiselect select', async () => {
|
|
145
123
|
const onChange = jest.fn();
|
|
146
124
|
const user = userEvent.setup();
|
|
@@ -148,107 +126,47 @@ describe('silke-select-field', () => {
|
|
|
148
126
|
render(<SilkeSelectField items={items} label="Animal" multiple onChange={onChange} />);
|
|
149
127
|
|
|
150
128
|
const input = screen.getByLabelText('Animal');
|
|
151
|
-
|
|
129
|
+
act(() => input.focus());
|
|
152
130
|
|
|
153
|
-
await user.keyboard(ARROW_UP);
|
|
131
|
+
await act(async () => await user.keyboard(ARROW_UP));
|
|
154
132
|
|
|
155
133
|
const lionOption = screen.getByText('lion');
|
|
156
134
|
|
|
157
135
|
const dropdown = screen.getByRole('listbox');
|
|
158
|
-
expect(dropdown).
|
|
136
|
+
expect(dropdown).toBeDefined();
|
|
159
137
|
|
|
160
|
-
await user.click(lionOption);
|
|
138
|
+
await act(async () => await user.click(lionOption));
|
|
161
139
|
|
|
162
140
|
expect(onChange).toHaveBeenCalledWith(['lion']);
|
|
163
|
-
expect(dropdown).
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('Should not be possible to select anything when the dropdown is not open', async () => {
|
|
167
|
-
const onChange = jest.fn();
|
|
168
|
-
const user = userEvent.setup();
|
|
169
|
-
|
|
170
|
-
render(<SilkeSelectField items={items} label="Animal" onChange={onChange} />);
|
|
171
|
-
|
|
172
|
-
const input = screen.getByLabelText('Animal');
|
|
173
|
-
input.focus();
|
|
174
|
-
|
|
175
|
-
await user.keyboard(ARROW_DOWN); // opens dropdown
|
|
176
|
-
|
|
177
|
-
await user.keyboard(ARROW_DOWN);
|
|
178
|
-
await user.keyboard(ENTER);
|
|
179
|
-
|
|
180
|
-
await user.keyboard(ENTER);
|
|
181
|
-
|
|
182
|
-
expect(onChange).toHaveBeenCalledWith('lion');
|
|
183
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('Sets focus on input field and closes dropdown when item selected', async () => {
|
|
187
|
-
const onChange = jest.fn();
|
|
188
|
-
const user = userEvent.setup();
|
|
189
|
-
|
|
190
|
-
render(<SilkeSelectField items={items} label="Animal" onChange={onChange} />);
|
|
191
|
-
|
|
192
|
-
const input = screen.getByLabelText('Animal');
|
|
193
|
-
input.focus();
|
|
194
|
-
|
|
195
|
-
await user.click(input); // opens dropdown
|
|
196
|
-
|
|
197
|
-
const dropdown = screen.getByRole('listbox');
|
|
198
|
-
|
|
199
|
-
expect(dropdown).toBeInTheDocument();
|
|
200
|
-
|
|
201
|
-
const option = screen.getByText('lion');
|
|
202
|
-
await user.click(option);
|
|
203
|
-
|
|
204
|
-
expect(dropdown).not.toBeInTheDocument();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('Closes dropdown when input looses focus', async () => {
|
|
208
|
-
const onChange = jest.fn();
|
|
209
|
-
const user = userEvent.setup();
|
|
210
|
-
|
|
211
|
-
render(<SilkeSelectField items={items} label="Animal" onChange={onChange} />);
|
|
212
|
-
|
|
213
|
-
render(<input type="text" data-testid="other" />);
|
|
214
|
-
|
|
215
|
-
const input = screen.getByLabelText('Animal');
|
|
216
|
-
const otherInput = screen.getByTestId('other');
|
|
217
|
-
input.focus();
|
|
218
|
-
|
|
219
|
-
await user.click(input); // opens dropdown
|
|
220
|
-
|
|
221
|
-
const dropdown = screen.getByRole('listbox');
|
|
222
|
-
|
|
223
|
-
expect(dropdown).toBeInTheDocument();
|
|
224
|
-
|
|
225
|
-
await otherInput.focus();
|
|
226
|
-
|
|
227
|
-
expect(dropdown).not.toBeInTheDocument();
|
|
141
|
+
expect(dropdown).toBeDefined();
|
|
228
142
|
});
|
|
229
143
|
|
|
230
144
|
describe('When Silke Select field is within a Silke form', () => {
|
|
231
145
|
it('Gets value from form', async () => {
|
|
232
146
|
const onChange = jest.fn();
|
|
233
|
-
const
|
|
234
|
-
|
|
147
|
+
const currentIndex = 2;
|
|
235
148
|
render(
|
|
236
|
-
<SilkeForm value={{ animal:
|
|
149
|
+
<SilkeForm value={{ animal: items[currentIndex].value }} onChange={onChange}>
|
|
237
150
|
<SilkeSelectField items={items} name="animal" label="Animal" />
|
|
238
151
|
</SilkeForm>,
|
|
239
152
|
);
|
|
240
153
|
|
|
241
154
|
const input = screen.getByLabelText('Animal');
|
|
242
|
-
|
|
155
|
+
act(() => input.focus());
|
|
243
156
|
|
|
244
157
|
expect(input.getAttribute('value')).toEqual('bear');
|
|
245
158
|
|
|
246
|
-
|
|
159
|
+
const dropdown = screen.getByRole('listbox');
|
|
160
|
+
expect(dropdown).toBeDefined();
|
|
161
|
+
|
|
162
|
+
const searchField = dropdown.querySelector('input') as HTMLInputElement;
|
|
163
|
+
expect(searchField).toBeDefined();
|
|
247
164
|
|
|
248
|
-
|
|
249
|
-
|
|
165
|
+
act(() => fireEvent.keyUp(searchField, { key: 'ArrowDown', code: 'ArrowDown' }));
|
|
166
|
+
act(() => fireEvent.keyUp(searchField, { key: 'ArrowDown', code: 'ArrowDown' }));
|
|
167
|
+
act(() => fireEvent.keyUp(searchField, { key: 'Enter', code: 'Enter' }));
|
|
250
168
|
|
|
251
|
-
expect(onChange).toHaveBeenCalledWith({ animal:
|
|
169
|
+
expect(onChange).toHaveBeenCalledWith({ animal: items[currentIndex + 2].value }, true);
|
|
252
170
|
});
|
|
253
171
|
});
|
|
254
172
|
});
|
|
@@ -94,8 +94,23 @@ export function SilkeNestedSortableItem<T>({
|
|
|
94
94
|
onCollapseToggle(item);
|
|
95
95
|
}}
|
|
96
96
|
>
|
|
97
|
-
{shouldShowIcon && (
|
|
98
|
-
<SilkeIcon
|
|
97
|
+
{(shouldShowIcon || item.replaceIcon) && (
|
|
98
|
+
<SilkeIcon
|
|
99
|
+
icon={
|
|
100
|
+
item.replaceIcon
|
|
101
|
+
? item.replaceIcon.icon
|
|
102
|
+
: hasState(state, ItemState.collapsed)
|
|
103
|
+
? 'caret.right'
|
|
104
|
+
: 'caret.down'
|
|
105
|
+
}
|
|
106
|
+
style={
|
|
107
|
+
item.replaceIcon
|
|
108
|
+
? {
|
|
109
|
+
color: item.replaceIcon.color,
|
|
110
|
+
}
|
|
111
|
+
: undefined
|
|
112
|
+
}
|
|
113
|
+
/>
|
|
99
114
|
)}
|
|
100
115
|
</SilkeBox>
|
|
101
116
|
)}
|
|
@@ -65,8 +65,12 @@ export function SilkeNestedSortableList<T>({
|
|
|
65
65
|
const ref = useRef<HTMLDivElement>(null);
|
|
66
66
|
const [pendingClickItem, setPendingClickItem] = useState<Item<T>>();
|
|
67
67
|
const [startDrag, setStartDrag] = useState(false);
|
|
68
|
-
const [dropState, setDropState] =
|
|
69
|
-
|
|
68
|
+
const [dropState, setDropState] = useState<{
|
|
69
|
+
index: number;
|
|
70
|
+
state: number;
|
|
71
|
+
childIndex: number;
|
|
72
|
+
top: number;
|
|
73
|
+
}>();
|
|
70
74
|
|
|
71
75
|
let cl = styles.list;
|
|
72
76
|
if (className) cl += ' ' + className;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dictionary, last } from 'lodash';
|
|
2
|
+
import { SilkeIcons } from '../silke-icon';
|
|
2
3
|
|
|
3
4
|
export type RenderFunction<T> = (item: Item<T>, index: number) => React.ReactElement;
|
|
4
5
|
export type Item<T> = T & {
|
|
@@ -11,6 +12,11 @@ export type Item<T> = T & {
|
|
|
11
12
|
/** Override the default behavior with checking for children length */
|
|
12
13
|
showExpandIcon?: boolean;
|
|
13
14
|
style?: React.CSSProperties;
|
|
15
|
+
/** Overwrite icon */
|
|
16
|
+
replaceIcon?: {
|
|
17
|
+
icon: SilkeIcons;
|
|
18
|
+
color: string;
|
|
19
|
+
};
|
|
14
20
|
};
|
|
15
21
|
|
|
16
22
|
const INDENT_BITS = 6;
|
|
@@ -110,7 +110,7 @@ export function SilkeTable<T>({
|
|
|
110
110
|
<ButtonContext size="m">
|
|
111
111
|
<SilkeBox column gap="s" className={styles.root}>
|
|
112
112
|
{children && (
|
|
113
|
-
<TextFieldContext size="m" kind="
|
|
113
|
+
<TextFieldContext size="m" kind="ghost" inline>
|
|
114
114
|
<SilkeBox
|
|
115
115
|
className={styles.toolbar}
|
|
116
116
|
gap="m"
|
|
@@ -7,7 +7,7 @@ const [active, setActive] = React.useState(1);
|
|
|
7
7
|
{[1, 2, 3, 4].map((tab) => (
|
|
8
8
|
<SilkeTab
|
|
9
9
|
key={tab}
|
|
10
|
-
label={
|
|
10
|
+
label={"Tab " + tab}
|
|
11
11
|
disabled={tab === 3}
|
|
12
12
|
active={tab === active}
|
|
13
13
|
onClick={() => setActive(tab)}
|
|
@@ -29,7 +29,7 @@ const [active, setActive] = React.useState(1);
|
|
|
29
29
|
{[1, 2, 3, 4].map((tab) => (
|
|
30
30
|
<SilkeTab
|
|
31
31
|
key={tab}
|
|
32
|
-
label={
|
|
32
|
+
label={"Tab " + tab}
|
|
33
33
|
disabled={tab === 3}
|
|
34
34
|
active={tab === active}
|
|
35
35
|
onClick={() => setActive(tab)}
|
|
@@ -1,34 +1,57 @@
|
|
|
1
1
|
```js
|
|
2
2
|
<SilkeBox column gap>
|
|
3
|
-
{["sand", "yellow", "green", "red", "gray", "blue"].map((color) => (
|
|
3
|
+
{["sand", "yellow", "green", "red", "gray", "blue", "brandYellow","dark"].map((color) => (
|
|
4
4
|
<SilkeBox gap key={color}>
|
|
5
|
-
<SilkeTag
|
|
6
|
-
<SilkeTag
|
|
7
|
-
<SilkeTag
|
|
8
|
-
<SilkeTag
|
|
5
|
+
<SilkeTag color={color} label={color} />
|
|
6
|
+
<SilkeTag color={color} label={ipsum.name()} onRemove={() => {}} />
|
|
7
|
+
<SilkeTag color={color} label={ipsum.name(10)} onRemove={() => {}} />
|
|
8
|
+
<SilkeTag color={color} label="Disabled" disabled/>
|
|
9
9
|
</SilkeBox>
|
|
10
10
|
))}
|
|
11
11
|
</SilkeBox>
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Outlined Tags
|
|
15
15
|
|
|
16
16
|
```js
|
|
17
17
|
<SilkeBox gap>
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
{["sand", "yellow", "green", "red", "gray", "blue", "brandYellow" ,"dark"].map((color) => (
|
|
19
|
+
<SilkeBox gap key={color} col>
|
|
20
|
+
<SilkeTag kind="outlined" color={color} label={color} outline />
|
|
21
|
+
</SilkeBox>
|
|
22
|
+
))}
|
|
20
23
|
</SilkeBox>
|
|
21
24
|
```
|
|
22
25
|
|
|
23
|
-
##
|
|
26
|
+
## secondary with Icon
|
|
24
27
|
|
|
25
28
|
```js
|
|
26
29
|
<SilkeBox gap>
|
|
27
|
-
{["sand", "yellow", "green", "red", "gray", "blue"].map((color) => (
|
|
30
|
+
{["sand", "yellow", "green", "red", "gray", "blue", "brandYellow" ,"dark"].map((color) => (
|
|
28
31
|
<SilkeBox gap key={color} col>
|
|
29
|
-
<SilkeTag kind={color} label={color} outline />
|
|
32
|
+
<SilkeTag kind="secondary" color={color} label={color} outline icon="react" />
|
|
30
33
|
</SilkeBox>
|
|
31
34
|
))}
|
|
35
|
+
<SilkeTag kind="secondary" label="Emoji" outline icon="😎" />
|
|
36
|
+
</SilkeBox>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Sizes
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
<SilkeBox gap column>
|
|
43
|
+
<SilkeBox gap >
|
|
44
|
+
<SilkeTag label="Primary base" />
|
|
45
|
+
<SilkeTag size="tiny" label=" Primary tiny" />
|
|
46
|
+
</SilkeBox>
|
|
47
|
+
<SilkeBox gap >
|
|
48
|
+
<SilkeTag kind="outlined" label="Outlined base" />
|
|
49
|
+
<SilkeTag kind="outlined" size="tiny" label="Outlined tiny" />
|
|
50
|
+
</SilkeBox>
|
|
51
|
+
<SilkeBox gap >
|
|
52
|
+
<SilkeTag kind="secondary" label="Secondary base" />
|
|
53
|
+
<SilkeTag kind="secondary" size="tiny" label="Secondary tiny" />
|
|
54
|
+
</SilkeBox>
|
|
32
55
|
</SilkeBox>
|
|
33
56
|
```
|
|
34
57
|
|
|
@@ -36,11 +59,26 @@
|
|
|
36
59
|
|
|
37
60
|
```js
|
|
38
61
|
<SilkeBox gap>
|
|
39
|
-
{["sand", "yellow", "green", "red", "gray", "blue"].map((color) => (
|
|
62
|
+
{["sand", "yellow", "green", "red", "gray", "blue", "brandYellow" ,"dark"].map((color) => (
|
|
63
|
+
<SilkeBox gap key={color} col>
|
|
64
|
+
<SilkeTag color={color} label={color} icon="react" />
|
|
65
|
+
</SilkeBox>
|
|
66
|
+
))}
|
|
67
|
+
</SilkeBox>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Icon Only
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
<SilkeBox gap>
|
|
74
|
+
{["sand", "yellow", "green", "red", "gray", "blue", "brandYellow","dark"].map((color) => (
|
|
40
75
|
<SilkeBox gap key={color} col>
|
|
41
|
-
<SilkeTag
|
|
76
|
+
<SilkeTag color={color} icon="react" />
|
|
42
77
|
</SilkeBox>
|
|
43
78
|
))}
|
|
79
|
+
<SilkeBox gap col>
|
|
80
|
+
<SilkeTag kind="secondary" color="green" icon="react" />
|
|
81
|
+
</SilkeBox>
|
|
44
82
|
</SilkeBox>
|
|
45
83
|
```
|
|
46
84
|
|
|
@@ -7,67 +7,104 @@ $tag-width-max: 150px;
|
|
|
7
7
|
$btn-size: $size-xs;
|
|
8
8
|
$btn-font-size: $font-small;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
$colors: (
|
|
11
12
|
name: "gray",
|
|
12
13
|
bg: var(--color-neutral-40-rgb),
|
|
14
|
+
outline: var(--color-neutral-40-rgb),
|
|
13
15
|
color: var(--color-neutral-100),
|
|
14
16
|
btn-bg-hover: var(--color-neutral-30),
|
|
15
17
|
),
|
|
16
18
|
(
|
|
17
19
|
name: "sand",
|
|
18
20
|
bg: var(--color-brand-quaternary-30-rgb),
|
|
21
|
+
outline: var(--color-brand-quaternary-30-rgb),
|
|
19
22
|
color: var(--color-neutral-0),
|
|
20
23
|
btn-bg-hover: var(--color-support-primary-20),
|
|
21
24
|
),
|
|
22
25
|
(
|
|
23
26
|
name: "yellow",
|
|
24
27
|
bg: var(--color-warning-30-rgb),
|
|
28
|
+
outline: var(--color-warning-30-rgb),
|
|
25
29
|
color: var(--color-neutral-0),
|
|
26
30
|
btn-bg-hover: var(--color-warning-20),
|
|
27
31
|
),
|
|
28
32
|
(
|
|
29
33
|
name: "green",
|
|
30
34
|
bg: var(--color-success-30-rgb),
|
|
35
|
+
outline: var(--color-success-30-rgb),
|
|
31
36
|
color: var(--color-neutral-0),
|
|
32
37
|
btn-bg-hover: var(--color-success-20),
|
|
33
38
|
),
|
|
34
39
|
(
|
|
35
40
|
name: "red",
|
|
36
41
|
bg: var(--color-error-30-rgb),
|
|
42
|
+
outline: var(--color-error-30-rgb),
|
|
37
43
|
color: var(--color-neutral-0),
|
|
38
44
|
btn-bg-hover: var(--color-error-20),
|
|
39
45
|
),
|
|
40
46
|
(
|
|
41
47
|
name: "blue",
|
|
42
48
|
bg: var(--color-support-secondary-30-rgb),
|
|
49
|
+
outline: var(--color-support-secondary-30-rgb),
|
|
43
50
|
color: var(--color-neutral-0),
|
|
44
51
|
btn-bg-hover: var(--color-accent-20),
|
|
52
|
+
),
|
|
53
|
+
(
|
|
54
|
+
name: "brandYellow",
|
|
55
|
+
bg: var(--color-brand-primary-40-rgb),
|
|
56
|
+
outline: var(--color-brand-primary-40-rgb),
|
|
57
|
+
color: var(--color-neutral-0),
|
|
58
|
+
btn-bg-hover: var(--color-brand-primary-50),
|
|
59
|
+
),
|
|
60
|
+
(
|
|
61
|
+
name: "dark",
|
|
62
|
+
bg: (var(--color-neutral-0-rgb), .64),
|
|
63
|
+
outline: var(--color-neutral-20-rgb),
|
|
64
|
+
color: var(--color-neutral-100),
|
|
65
|
+
btn-bg-hover: var(--color-neutral-20),
|
|
45
66
|
);
|
|
46
67
|
|
|
47
68
|
.tag {
|
|
48
69
|
--tag-background: transparent;
|
|
49
70
|
--tag-color: var(--color-neutral-0);
|
|
71
|
+
--tag-icon-color: var(--color-neutral-0);
|
|
50
72
|
--tag-button-background: transparent;
|
|
51
73
|
background-color: rgb(var(--tag-background));
|
|
52
|
-
border-radius: math.div($tag-height , 2);
|
|
53
74
|
height: $tag-height;
|
|
54
75
|
max-height: $tag-height;
|
|
55
76
|
min-width: $tag-width-min;
|
|
56
77
|
max-width: $tag-width-max;
|
|
57
78
|
font-size: $font-small;
|
|
79
|
+
border-radius: math.div($tag-height , 2);
|
|
58
80
|
color: var(--tag-color);
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
--tag-
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@each $color in $colors {
|
|
85
|
+
&.#{map-get($color, "name")} {
|
|
86
|
+
--tag-button-background: #{map-get($color, "btn-bg-hover")};
|
|
87
|
+
--tag-background: #{map-get($color, "bg")};
|
|
88
|
+
--tag-outline: #{map-get($color, "outline")};
|
|
89
|
+
--tag-color: #{map-get($color, "color")};
|
|
90
|
+
--tag-icon-color: #{map-get($color, "bg")};
|
|
65
91
|
}
|
|
66
92
|
}
|
|
67
93
|
|
|
68
|
-
&.
|
|
94
|
+
&.primary{
|
|
95
|
+
--tag-icon-color: var(--color-neutral-0);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.secondary{
|
|
69
99
|
--tag-color: var(--color-neutral-100);
|
|
70
|
-
|
|
100
|
+
background-color: rgb(var(--color-neutral-20-rgb), .48);
|
|
101
|
+
border-radius: var(--border-radius-tiny);
|
|
102
|
+
backdrop-filter: blur(8px);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&.outlined{
|
|
106
|
+
--tag-color: var(--color-neutral-100);
|
|
107
|
+
border: 1px solid rgb(var(--tag-outline));
|
|
71
108
|
background-color: rgb(var(--tag-background), .24);
|
|
72
109
|
|
|
73
110
|
}
|
|
@@ -108,5 +145,10 @@ $kinds: (
|
|
|
108
145
|
}
|
|
109
146
|
|
|
110
147
|
.label {
|
|
111
|
-
padding: 0 $space-
|
|
148
|
+
padding: 0 $space-xs;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.tagIcon{
|
|
152
|
+
font-size: 14px;
|
|
153
|
+
color: rgb(var(--tag-icon-color)) ;
|
|
112
154
|
}
|