@moises.ai/design-system 4.21.11 → 4.21.13
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/dist/{ScrollIcon-CKgm8_XR.js → ScrollIcon-DGJUkGuF.js} +10 -1
- package/dist/icons.js +1 -1
- package/dist/index.js +3081 -3014
- package/package.json +1 -1
- package/src/components/InstrumentSelect/InstrumentSelect.jsx +88 -15
- package/src/components/InstrumentSelect/InstrumentSelect.module.css +199 -1
- package/src/components/InstrumentSelect/InstrumentSelect.stories.jsx +167 -10
- package/src/components/InstrumentSelect/InstrumentSelectCard.jsx +36 -4
- package/src/icons/CopyIcon.jsx +3 -2
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import styles from './InstrumentSelect.module.css'
|
|
|
17
17
|
* @property {boolean} [locked] - Marks the item as paywalled (alias: `isLocked`). The lock icon is rendered. Click still fires `onSelect`.
|
|
18
18
|
* @property {boolean} [isLocked] - Alias for `locked`.
|
|
19
19
|
* @property {boolean} [disabled] - Disables the item without showing the lock icon.
|
|
20
|
+
* @property {React.ReactNode} [badge] - Optional label chip (for example "New"). Rendered on `size="medium"` and `size="large"`, at the top-right of the card.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -31,7 +32,11 @@ import styles from './InstrumentSelect.module.css'
|
|
|
31
32
|
* @property {InstrumentSelectValue} [value] - Currently selected value(s). Use a string for single-select and a string[] for multi-select. The component is fully controlled — the parent owns selection state and decides toggle/replace/paywall behavior in `onSelect`.
|
|
32
33
|
* @property {InstrumentSelectValue} [selectedValue] - Alias for `value` (backwards-compat with `InstrumentSelector`).
|
|
33
34
|
* @property {(item: InstrumentSelectItem) => void} [onSelect] - Fires for every card click, including locked items. The parent decides whether to update `value`, open a paywall, etc.
|
|
34
|
-
* @property {
|
|
35
|
+
* @property {'horizontal' | 'vertical'} [orientation='horizontal'] - `horizontal` fills each row left to right, then wraps. `vertical` fills each column top to bottom, for `rows` rows, then starts the next column.
|
|
36
|
+
* @property {number | { initial?: string | number, sm?: string | number, md?: string | number, lg?: string | number }} [columns=2] - Horizontal only. Maximum items per row. If the container cannot fit that many at the card's minimum width, the extras wrap onto the next row.
|
|
37
|
+
* @property {number} [rows] - Vertical only. How many rows to fill before starting another column. Defaults to one column (every item on its own row).
|
|
38
|
+
* @property {'neutral' | 'cyan'} [variant='neutral'] - Visual variant. `neutral` is the default bordered card. `cyan` uses the accent-tinted background and selection border.
|
|
39
|
+
* @property {'small' | 'medium' | 'large'} [size='small'] - Card size. `small` is the compact horizontal card. `medium` is the 64px vertical card. `large` is the 148×80 vertical card.
|
|
35
40
|
* @property {string} [className]
|
|
36
41
|
*/
|
|
37
42
|
|
|
@@ -49,6 +54,68 @@ function isItemSelected(value, itemValue) {
|
|
|
49
54
|
return value === itemValue
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
const GRID_GAP = 4
|
|
58
|
+
|
|
59
|
+
const TRACK_MIN = {
|
|
60
|
+
small: 140,
|
|
61
|
+
medium: 148,
|
|
62
|
+
large: 148,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const TRACK_MAX = {
|
|
66
|
+
medium: 160,
|
|
67
|
+
large: 148,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function resolveColumns(columns) {
|
|
71
|
+
if (typeof columns === 'number' && Number.isFinite(columns)) return Math.max(1, columns)
|
|
72
|
+
if (columns && typeof columns === 'object') {
|
|
73
|
+
const initial = columns.initial
|
|
74
|
+
const parsed = typeof initial === 'string' ? parseInt(initial, 10) : initial
|
|
75
|
+
if (Number.isFinite(parsed)) return Math.max(1, parsed)
|
|
76
|
+
}
|
|
77
|
+
return 2
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Horizontal uses flex wrap. Each card stays at least its minimum width, so a row
|
|
82
|
+
* that cannot hold `columns` items wraps the rest. Medium and large are also capped
|
|
83
|
+
* so a wide container never places more than `columns` cards on one row.
|
|
84
|
+
*
|
|
85
|
+
* Vertical fills `rows` rows top to bottom, then starts the next column.
|
|
86
|
+
*/
|
|
87
|
+
function getGridStyle(orientation, size, columns, rows, itemCount) {
|
|
88
|
+
const min = TRACK_MIN[size] ?? TRACK_MIN.small
|
|
89
|
+
const max = TRACK_MAX[size]
|
|
90
|
+
const gaps = Math.max(columns - 1, 0)
|
|
91
|
+
const share = `calc((100% - ${GRID_GAP}px * ${gaps}) / ${columns})`
|
|
92
|
+
|
|
93
|
+
if (orientation === 'vertical') {
|
|
94
|
+
const rowCount = Math.max(rows ?? itemCount, 1)
|
|
95
|
+
return {
|
|
96
|
+
display: 'grid',
|
|
97
|
+
gridAutoFlow: 'column',
|
|
98
|
+
gridTemplateRows: `repeat(${rowCount}, auto)`,
|
|
99
|
+
gridTemplateColumns: 'unset',
|
|
100
|
+
gridAutoColumns: max ? `minmax(${min}px, ${max}px)` : `minmax(${min}px, 1fr)`,
|
|
101
|
+
justifyContent: 'start',
|
|
102
|
+
width: 'max-content',
|
|
103
|
+
maxWidth: '100%',
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
'--track-min': `${min}px`,
|
|
109
|
+
'--track-max': max ? `${max}px` : share,
|
|
110
|
+
display: 'flex',
|
|
111
|
+
flexWrap: 'wrap',
|
|
112
|
+
alignItems: 'stretch',
|
|
113
|
+
justifyContent: 'flex-start',
|
|
114
|
+
width: '100%',
|
|
115
|
+
maxWidth: max ? `calc(${max}px * ${columns} + ${GRID_GAP}px * ${gaps})` : undefined,
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
52
119
|
/**
|
|
53
120
|
* Instrument selector list with optional title and tooltip header.
|
|
54
121
|
*
|
|
@@ -58,8 +125,9 @@ function isItemSelected(value, itemValue) {
|
|
|
58
125
|
* - Pass `value` to mark items as selected (string for single, string[] for multi).
|
|
59
126
|
* - `onSelect(item)` fires for every click; the parent decides what to do.
|
|
60
127
|
*
|
|
61
|
-
* Layout:
|
|
62
|
-
*
|
|
128
|
+
* Layout: horizontal by default, at most `columns` items per row (2). When the row cannot
|
|
129
|
+
* fit that many cards, the rest wrap onto the next line. Vertical fills `rows` rows down
|
|
130
|
+
* each column before starting the next one. Gap is 4px.
|
|
63
131
|
*
|
|
64
132
|
* @example
|
|
65
133
|
* // Single select
|
|
@@ -97,6 +165,10 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
97
165
|
selectedValue,
|
|
98
166
|
onSelect,
|
|
99
167
|
columns = 2,
|
|
168
|
+
rows,
|
|
169
|
+
orientation = 'horizontal',
|
|
170
|
+
variant = 'neutral',
|
|
171
|
+
size = 'small',
|
|
100
172
|
className,
|
|
101
173
|
...props
|
|
102
174
|
},
|
|
@@ -104,19 +176,11 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
104
176
|
) {
|
|
105
177
|
const resolvedValue = value ?? selectedValue
|
|
106
178
|
|
|
107
|
-
const cols = useMemo(() =>
|
|
108
|
-
if (typeof columns === 'number') return columns
|
|
109
|
-
if (columns && typeof columns === 'object') {
|
|
110
|
-
const initial = columns.initial
|
|
111
|
-
const parsed = typeof initial === 'string' ? parseInt(initial, 10) : initial
|
|
112
|
-
return Number.isFinite(parsed) ? parsed : 2
|
|
113
|
-
}
|
|
114
|
-
return 2
|
|
115
|
-
}, [columns])
|
|
179
|
+
const cols = useMemo(() => resolveColumns(columns), [columns])
|
|
116
180
|
|
|
117
181
|
const gridStyle = useMemo(
|
|
118
|
-
() => (
|
|
119
|
-
[cols],
|
|
182
|
+
() => getGridStyle(orientation, size, cols, rows, items.length),
|
|
183
|
+
[orientation, size, cols, rows, items.length],
|
|
120
184
|
)
|
|
121
185
|
|
|
122
186
|
return (
|
|
@@ -134,7 +198,13 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
134
198
|
</div>
|
|
135
199
|
)}
|
|
136
200
|
|
|
137
|
-
<div
|
|
201
|
+
<div
|
|
202
|
+
className={styles.grid}
|
|
203
|
+
data-orientation={orientation}
|
|
204
|
+
style={gridStyle}
|
|
205
|
+
role="group"
|
|
206
|
+
aria-label={title}
|
|
207
|
+
>
|
|
138
208
|
{items.map((item) => {
|
|
139
209
|
const itemText = item.text ?? item.label ?? item.name
|
|
140
210
|
const ItemIcon = item.Icon ?? item.icon
|
|
@@ -147,9 +217,12 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
147
217
|
value={item.value}
|
|
148
218
|
text={itemText}
|
|
149
219
|
Icon={ItemIcon}
|
|
220
|
+
badge={item.badge}
|
|
150
221
|
selected={isItemSelected(resolvedValue, item.value)}
|
|
151
222
|
locked={itemLocked}
|
|
152
223
|
disabled={itemDisabled}
|
|
224
|
+
variant={variant}
|
|
225
|
+
size={size}
|
|
153
226
|
onClick={() => onSelect?.(item)}
|
|
154
227
|
/>
|
|
155
228
|
)
|
|
@@ -41,11 +41,17 @@
|
|
|
41
41
|
|
|
42
42
|
.grid {
|
|
43
43
|
display: grid;
|
|
44
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
45
44
|
gap: 4px;
|
|
46
45
|
width: 100%;
|
|
47
46
|
}
|
|
48
47
|
|
|
48
|
+
.grid[data-orientation="horizontal"] > .card {
|
|
49
|
+
flex: 1 1 var(--track-min, 140px);
|
|
50
|
+
width: auto;
|
|
51
|
+
min-width: var(--track-min, 140px);
|
|
52
|
+
max-width: var(--track-max, 100%);
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
/* ----- Card ----- */
|
|
50
56
|
|
|
51
57
|
.card {
|
|
@@ -179,3 +185,195 @@
|
|
|
179
185
|
color: var(--neutral-alpha-5);
|
|
180
186
|
pointer-events: none;
|
|
181
187
|
}
|
|
188
|
+
|
|
189
|
+
/* ----- Size: medium + large ----- */
|
|
190
|
+
|
|
191
|
+
.card[data-size="medium"],
|
|
192
|
+
.card[data-size="large"] {
|
|
193
|
+
display: flex;
|
|
194
|
+
min-width: 148px;
|
|
195
|
+
max-width: 160px;
|
|
196
|
+
|
|
197
|
+
flex-direction: column;
|
|
198
|
+
justify-content: space-between;
|
|
199
|
+
align-items: flex-start;
|
|
200
|
+
gap: 0;
|
|
201
|
+
border-radius: 12px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.card[data-size="large"] {
|
|
205
|
+
padding: var(--Spacing-3, 12px) var(--Spacing-3, 12px) var(--Spacing-2, 8px)
|
|
206
|
+
var(--Spacing-3, 12px);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.card[data-size="medium"] {
|
|
210
|
+
padding: 8px 12px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.card[data-size="medium"] {
|
|
214
|
+
height: 64px;
|
|
215
|
+
flex: 1 0 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.card[data-size="large"] {
|
|
219
|
+
width: 148px;
|
|
220
|
+
height: 80px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.cardTop,
|
|
224
|
+
.cardBottom {
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
width: 100%;
|
|
228
|
+
min-width: 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.cardTop {
|
|
232
|
+
justify-content: space-between;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.cardBottom {
|
|
236
|
+
justify-content: space-between;
|
|
237
|
+
gap: 4px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.card[data-size="medium"] .cardText,
|
|
241
|
+
.card[data-size="large"] .cardText {
|
|
242
|
+
flex: 0 1 auto;
|
|
243
|
+
width: auto;
|
|
244
|
+
max-width: 100%;
|
|
245
|
+
margin-right: 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.cardBadge {
|
|
249
|
+
display: flex;
|
|
250
|
+
flex-shrink: 0;
|
|
251
|
+
padding: 2px 6px;
|
|
252
|
+
justify-content: center;
|
|
253
|
+
align-items: center;
|
|
254
|
+
gap: 6px;
|
|
255
|
+
border-radius: var(--Radius-3, 6px);
|
|
256
|
+
background: var(--Colors-Accent-Accent-Alpha-3, rgba(0, 223, 251, 0.16));
|
|
257
|
+
color: var(--Colors-Accent-Accent-Alpha-11, rgba(120, 247, 255, 0.95));
|
|
258
|
+
font-family: var(
|
|
259
|
+
--Typography-Font-family-text,
|
|
260
|
+
"Articulat CF",
|
|
261
|
+
helvetica,
|
|
262
|
+
arial,
|
|
263
|
+
sans-serif
|
|
264
|
+
);
|
|
265
|
+
font-size: var(--Typography-Font-size-1, 12px);
|
|
266
|
+
font-style: normal;
|
|
267
|
+
font-weight: 500;
|
|
268
|
+
line-height: var(--Typography-Line-height-1, 16px);
|
|
269
|
+
letter-spacing: var(--Typography-Letter-spacing-1, 0.04px);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.card[data-size="medium"] .lockIcon,
|
|
273
|
+
.card[data-size="large"] .lockIcon {
|
|
274
|
+
top: var(--Spacing-3, 12px);
|
|
275
|
+
right: var(--Spacing-3, 12px);
|
|
276
|
+
transform: none;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* cyan + vertical: lock sits inline, beside the name */
|
|
280
|
+
.card[data-size="medium"][data-variant="cyan"] .cardBottom .lockIcon,
|
|
281
|
+
.card[data-size="large"][data-variant="cyan"] .cardBottom .lockIcon {
|
|
282
|
+
position: static;
|
|
283
|
+
top: auto;
|
|
284
|
+
right: auto;
|
|
285
|
+
transform: none;
|
|
286
|
+
flex-shrink: 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* ----- Variant: cyan ----- */
|
|
290
|
+
|
|
291
|
+
.card[data-variant="cyan"] {
|
|
292
|
+
border: 2px solid transparent;
|
|
293
|
+
background: rgba(0, 223, 251, 0.11);
|
|
294
|
+
color: var(--neutral-alpha-12);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.card[data-variant="cyan"] .cardIcon {
|
|
298
|
+
color: var(--neutral-alpha-10);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.card[data-variant="cyan"] .cardText {
|
|
302
|
+
color: var(--neutral-alpha-12);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* selected, not hovered */
|
|
306
|
+
.card[data-variant="cyan"][data-state="checked"] {
|
|
307
|
+
border-color: var(--Colors-Accent-Accent-9, #00dae8);
|
|
308
|
+
background: rgba(0, 223, 251, 0.11);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.card[data-variant="cyan"][data-state="checked"] .cardIcon {
|
|
312
|
+
color: var(--accent-a9);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.card[data-variant="cyan"][data-state="checked"] .cardText {
|
|
316
|
+
color: var(--neutral-alpha-12);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* hover, not selected */
|
|
320
|
+
.card[data-variant="cyan"][data-state="default"]:hover,
|
|
321
|
+
.card[data-variant="cyan"][data-state="hover"] {
|
|
322
|
+
border-color: transparent;
|
|
323
|
+
background: rgba(0, 223, 251, 0.13);
|
|
324
|
+
color: var(--white);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.card[data-variant="cyan"][data-state="default"]:hover .cardIcon,
|
|
328
|
+
.card[data-variant="cyan"][data-state="hover"] .cardIcon {
|
|
329
|
+
color: var(--neutral-alpha-11);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.card[data-variant="cyan"][data-state="default"]:hover .cardText,
|
|
333
|
+
.card[data-variant="cyan"][data-state="hover"] .cardText {
|
|
334
|
+
color: var(--white);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* hover + selected */
|
|
338
|
+
.card[data-variant="cyan"][data-state="checked"]:hover {
|
|
339
|
+
border-color: var(--Colors-Accent-Accent-9, #00dae8);
|
|
340
|
+
background: rgba(0, 223, 251, 0.13);
|
|
341
|
+
color: var(--white);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.card[data-variant="cyan"][data-state="checked"]:hover .cardIcon {
|
|
345
|
+
color: var(--accent-a10);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.card[data-variant="cyan"][data-state="checked"]:hover .cardText {
|
|
349
|
+
color: var(--white);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* disabled, selected or not — hover does not change the treatment */
|
|
353
|
+
.card[data-variant="cyan"][data-state="disabled"],
|
|
354
|
+
.card[data-variant="cyan"][data-state="disabled-checked"],
|
|
355
|
+
.card[data-variant="cyan"][data-state="disabled"]:hover,
|
|
356
|
+
.card[data-variant="cyan"][data-state="disabled-checked"]:hover {
|
|
357
|
+
border-color: transparent;
|
|
358
|
+
background: rgba(0, 223, 251, 0.11);
|
|
359
|
+
color: var(--neutral-alpha-12);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.card[data-variant="cyan"][data-state="disabled"] .cardIcon,
|
|
363
|
+
.card[data-variant="cyan"][data-state="disabled-checked"] .cardIcon,
|
|
364
|
+
.card[data-variant="cyan"][data-state="disabled"]:hover .cardIcon,
|
|
365
|
+
.card[data-variant="cyan"][data-state="disabled-checked"]:hover .cardIcon {
|
|
366
|
+
color: var(--accent-a10);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.card[data-variant="cyan"][data-state="disabled"] .cardText,
|
|
370
|
+
.card[data-variant="cyan"][data-state="disabled-checked"] .cardText,
|
|
371
|
+
.card[data-variant="cyan"][data-state="disabled"]:hover .cardText,
|
|
372
|
+
.card[data-variant="cyan"][data-state="disabled-checked"]:hover .cardText {
|
|
373
|
+
color: var(--neutral-alpha-12);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.card[data-variant="cyan"][data-state="disabled"] .lockIcon,
|
|
377
|
+
.card[data-variant="cyan"][data-state="disabled-checked"] .lockIcon {
|
|
378
|
+
color: var(--neutral-alpha-8);
|
|
379
|
+
}
|
|
@@ -48,13 +48,23 @@ export default {
|
|
|
48
48
|
},
|
|
49
49
|
tags: ['autodocs'],
|
|
50
50
|
argTypes: {
|
|
51
|
-
columns: { control: { type: 'number', min: 1, max:
|
|
51
|
+
columns: { control: { type: 'number', min: 1, max: 12 } },
|
|
52
|
+
rows: { control: { type: 'number', min: 1, max: 12 } },
|
|
53
|
+
orientation: { control: 'select', options: ['horizontal', 'vertical'] },
|
|
52
54
|
title: { control: 'text' },
|
|
53
55
|
tooltip: { control: 'text' },
|
|
56
|
+
variant: { control: 'select', options: ['neutral', 'cyan'] },
|
|
57
|
+
size: { control: 'select', options: ['small', 'medium', 'large'] },
|
|
58
|
+
},
|
|
59
|
+
args: {
|
|
60
|
+
variant: 'neutral',
|
|
61
|
+
size: 'small',
|
|
62
|
+
orientation: 'horizontal',
|
|
63
|
+
columns: 2,
|
|
54
64
|
},
|
|
55
65
|
decorators: [
|
|
56
|
-
(Story) => (
|
|
57
|
-
<div style={{ width: 340 }}>
|
|
66
|
+
(Story, context) => (
|
|
67
|
+
<div style={{ width: context.parameters.containerWidth ?? 340 }}>
|
|
58
68
|
<Story />
|
|
59
69
|
</div>
|
|
60
70
|
),
|
|
@@ -205,6 +215,96 @@ CardStates.parameters = {
|
|
|
205
215
|
},
|
|
206
216
|
}
|
|
207
217
|
|
|
218
|
+
/* ---------- Cyan variant ---------- */
|
|
219
|
+
|
|
220
|
+
export const Cyan = {
|
|
221
|
+
render: (args) => {
|
|
222
|
+
const [value, setValue] = useState('drums')
|
|
223
|
+
return (
|
|
224
|
+
<InstrumentSelect
|
|
225
|
+
{...args}
|
|
226
|
+
value={value}
|
|
227
|
+
onSelect={(item) => setValue(item.value)}
|
|
228
|
+
/>
|
|
229
|
+
)
|
|
230
|
+
},
|
|
231
|
+
args: {
|
|
232
|
+
variant: 'cyan',
|
|
233
|
+
title: 'Music Stems',
|
|
234
|
+
items: INSTRUMENTS.slice(0, 6),
|
|
235
|
+
},
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export const CyanWithLockedItems = {
|
|
239
|
+
render: (args) => {
|
|
240
|
+
const [values, setValues] = useState(['vocals'])
|
|
241
|
+
return (
|
|
242
|
+
<InstrumentSelect
|
|
243
|
+
{...args}
|
|
244
|
+
value={values}
|
|
245
|
+
onSelect={(item) => {
|
|
246
|
+
if (item.locked) return
|
|
247
|
+
setValues((curr) =>
|
|
248
|
+
curr.includes(item.value)
|
|
249
|
+
? curr.filter((v) => v !== item.value)
|
|
250
|
+
: [...curr, item.value],
|
|
251
|
+
)
|
|
252
|
+
}}
|
|
253
|
+
/>
|
|
254
|
+
)
|
|
255
|
+
},
|
|
256
|
+
args: {
|
|
257
|
+
variant: 'cyan',
|
|
258
|
+
title: 'Music Stems',
|
|
259
|
+
items: STEMS_WITH_LOCKED.slice(0, 6),
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* ---------- Medium + large ---------- */
|
|
264
|
+
|
|
265
|
+
const verticalStory = (initialValue) => (args) => {
|
|
266
|
+
const [values, setValues] = useState(initialValue)
|
|
267
|
+
return (
|
|
268
|
+
<InstrumentSelect
|
|
269
|
+
{...args}
|
|
270
|
+
value={values}
|
|
271
|
+
onSelect={(item) => {
|
|
272
|
+
if (item.locked) return
|
|
273
|
+
setValues((curr) =>
|
|
274
|
+
curr.includes(item.value)
|
|
275
|
+
? curr.filter((v) => v !== item.value)
|
|
276
|
+
: [...curr, item.value],
|
|
277
|
+
)
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const verticalItems = STEMS_WITH_LOCKED.slice(0, 6).map((item) => ({
|
|
284
|
+
...item,
|
|
285
|
+
badge: 'New',
|
|
286
|
+
}))
|
|
287
|
+
|
|
288
|
+
export const Medium = {
|
|
289
|
+
render: verticalStory(['vocals', 'guitars']),
|
|
290
|
+
args: {
|
|
291
|
+
variant: 'cyan',
|
|
292
|
+
size: 'medium',
|
|
293
|
+
title: 'Music Stems',
|
|
294
|
+
items: verticalItems,
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export const Large = {
|
|
299
|
+
render: verticalStory(['vocals', 'guitars']),
|
|
300
|
+
args: {
|
|
301
|
+
variant: 'cyan',
|
|
302
|
+
size: 'large',
|
|
303
|
+
title: 'Music Stems',
|
|
304
|
+
items: verticalItems,
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
|
|
208
308
|
/* ---------- Columns ---------- */
|
|
209
309
|
|
|
210
310
|
export const OneColumn = {
|
|
@@ -239,11 +339,68 @@ export const ThreeColumns = {
|
|
|
239
339
|
columns: 3,
|
|
240
340
|
items: INSTRUMENTS,
|
|
241
341
|
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
342
|
+
parameters: {
|
|
343
|
+
containerWidth: 540,
|
|
344
|
+
},
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/* ---------- Wrapping rows ---------- */
|
|
348
|
+
|
|
349
|
+
const wrapRender = (initial) => (args) => {
|
|
350
|
+
const [values, setValues] = useState(initial)
|
|
351
|
+
return (
|
|
352
|
+
<InstrumentSelect
|
|
353
|
+
{...args}
|
|
354
|
+
value={values}
|
|
355
|
+
onSelect={(item) => {
|
|
356
|
+
setValues((curr) =>
|
|
357
|
+
curr.includes(item.value)
|
|
358
|
+
? curr.filter((v) => v !== item.value)
|
|
359
|
+
: [...curr, item.value],
|
|
360
|
+
)
|
|
361
|
+
}}
|
|
362
|
+
/>
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export const HorizontalSevenWide = {
|
|
367
|
+
render: wrapRender(['vocals']),
|
|
368
|
+
args: {
|
|
369
|
+
variant: 'cyan',
|
|
370
|
+
size: 'medium',
|
|
371
|
+
orientation: 'horizontal',
|
|
372
|
+
columns: 7,
|
|
373
|
+
items: INSTRUMENTS,
|
|
374
|
+
},
|
|
375
|
+
parameters: {
|
|
376
|
+
containerWidth: 1144,
|
|
377
|
+
},
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export const HorizontalSevenNarrow = {
|
|
381
|
+
render: wrapRender(['vocals']),
|
|
382
|
+
args: {
|
|
383
|
+
variant: 'cyan',
|
|
384
|
+
size: 'medium',
|
|
385
|
+
orientation: 'horizontal',
|
|
386
|
+
columns: 7,
|
|
387
|
+
items: INSTRUMENTS,
|
|
388
|
+
},
|
|
389
|
+
parameters: {
|
|
390
|
+
containerWidth: 640,
|
|
391
|
+
},
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export const VerticalRows = {
|
|
395
|
+
render: wrapRender(['vocals', 'bass']),
|
|
396
|
+
args: {
|
|
397
|
+
variant: 'cyan',
|
|
398
|
+
size: 'medium',
|
|
399
|
+
orientation: 'vertical',
|
|
400
|
+
rows: 4,
|
|
401
|
+
items: INSTRUMENTS,
|
|
402
|
+
},
|
|
403
|
+
parameters: {
|
|
404
|
+
containerWidth: 520,
|
|
405
|
+
},
|
|
249
406
|
}
|
|
@@ -12,10 +12,13 @@ import styles from './InstrumentSelect.module.css'
|
|
|
12
12
|
* @typedef {Object} InstrumentSelectCardProps
|
|
13
13
|
* @property {string} value - Card value identifier (used by parent list for selection).
|
|
14
14
|
* @property {React.ReactNode} [text] - Card label text.
|
|
15
|
+
* @property {React.ReactNode} [badge] - Optional label chip (for example "New"). Rendered on `size="medium"` and `size="large"`, at the top-right of the card.
|
|
15
16
|
* @property {React.ComponentType<{ width?: number, height?: number }> | React.ReactNode} [Icon] - Icon as a component or pre-rendered JSX element.
|
|
16
17
|
* @property {boolean} [selected=false] - Whether the card is currently selected. Drives the `checked` visual state.
|
|
17
18
|
* @property {boolean} [locked=false] - Marks the card as locked (paywalled). Renders the lock icon and applies the disabled visual state. `onClick` still fires so consumers can trigger a paywall flow.
|
|
18
19
|
* @property {boolean} [disabled=false] - Marks the card as disabled without showing the lock icon.
|
|
20
|
+
* @property {'neutral' | 'cyan'} [variant='neutral'] - Visual variant. `neutral` is the default bordered card. `cyan` uses the accent-tinted background and selection border.
|
|
21
|
+
* @property {'small' | 'medium' | 'large'} [size='small'] - Card size. `small` is the compact horizontal card. `medium` is the 64px vertical card. `large` is the 148×80 vertical card.
|
|
19
22
|
* @property {InstrumentSelectCardState} [state] - Force a specific visual state (overrides `selected`/`locked`/`disabled`). Primarily for documentation/Storybook.
|
|
20
23
|
* @property {(event: React.MouseEvent<HTMLButtonElement>) => void} [onClick]
|
|
21
24
|
* @property {string} [className]
|
|
@@ -43,10 +46,13 @@ export const InstrumentSelectCard = forwardRef(function InstrumentSelectCard(
|
|
|
43
46
|
{
|
|
44
47
|
value,
|
|
45
48
|
text,
|
|
49
|
+
badge,
|
|
46
50
|
Icon,
|
|
47
51
|
selected = false,
|
|
48
52
|
locked = false,
|
|
49
53
|
disabled = false,
|
|
54
|
+
variant = 'neutral',
|
|
55
|
+
size = 'small',
|
|
50
56
|
state,
|
|
51
57
|
onClick,
|
|
52
58
|
className,
|
|
@@ -66,6 +72,9 @@ export const InstrumentSelectCard = forwardRef(function InstrumentSelectCard(
|
|
|
66
72
|
: 'default')
|
|
67
73
|
|
|
68
74
|
const showSpinner = computedState === 'disabled-checked'
|
|
75
|
+
const isVertical = size === 'medium' || size === 'large'
|
|
76
|
+
const showBadge = isVertical && badge != null && badge !== false
|
|
77
|
+
const lockBesideName = locked && variant === 'cyan' && isVertical
|
|
69
78
|
|
|
70
79
|
const renderIcon = () => {
|
|
71
80
|
if (!Icon) return null
|
|
@@ -80,6 +89,8 @@ export const InstrumentSelectCard = forwardRef(function InstrumentSelectCard(
|
|
|
80
89
|
ref={ref}
|
|
81
90
|
type="button"
|
|
82
91
|
data-state={computedState}
|
|
92
|
+
data-variant={variant}
|
|
93
|
+
data-size={size}
|
|
83
94
|
data-value={value}
|
|
84
95
|
data-locked={locked || undefined}
|
|
85
96
|
aria-pressed={selected}
|
|
@@ -88,11 +99,32 @@ export const InstrumentSelectCard = forwardRef(function InstrumentSelectCard(
|
|
|
88
99
|
className={classNames(styles.card, className)}
|
|
89
100
|
{...props}
|
|
90
101
|
>
|
|
91
|
-
{
|
|
92
|
-
|
|
102
|
+
{isVertical ? (
|
|
103
|
+
<>
|
|
104
|
+
<span className={styles.cardTop}>
|
|
105
|
+
{(Icon || showSpinner) && (
|
|
106
|
+
<span className={styles.cardIcon}>{renderIcon()}</span>
|
|
107
|
+
)}
|
|
108
|
+
{showBadge && <span className={styles.cardBadge}>{badge}</span>}
|
|
109
|
+
</span>
|
|
110
|
+
<span className={styles.cardBottom}>
|
|
111
|
+
{text != null && <span className={styles.cardText}>{text}</span>}
|
|
112
|
+
{lockBesideName && (
|
|
113
|
+
<LockIcon width={12} height={12} className={styles.lockIcon} aria-hidden="true" />
|
|
114
|
+
)}
|
|
115
|
+
</span>
|
|
116
|
+
</>
|
|
117
|
+
) : (
|
|
118
|
+
<>
|
|
119
|
+
{(Icon || showSpinner) && (
|
|
120
|
+
<span className={styles.cardIcon}> {renderIcon()} </span>
|
|
121
|
+
)}
|
|
122
|
+
{text != null && <span className={styles.cardText}>{text}</span>}
|
|
123
|
+
</>
|
|
124
|
+
)}
|
|
125
|
+
{locked && !lockBesideName && (
|
|
126
|
+
<LockIcon width={12} height={12} className={styles.lockIcon} aria-hidden="true" />
|
|
93
127
|
)}
|
|
94
|
-
{text != null && <span className={styles.cardText}>{text}</span>}
|
|
95
|
-
{locked && <LockIcon width={12} height={12} className={styles.lockIcon} aria-hidden="true" />}
|
|
96
128
|
</button>
|
|
97
129
|
)
|
|
98
130
|
})
|
package/src/icons/CopyIcon.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const CopyIcon = ({ width = 16, height = 16, className, ...props }) => (
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 24 24" fill="none" className={className} {...props}>
|
|
3
|
-
<path d="M5
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 24 24" fill="none" className={className} {...props} aria-label="Copy Icon">
|
|
3
|
+
<path d="M5.5 15C4.11929 15 3 13.8807 3 12.5V5.5C3 4.11929 4.11929 3 5.5 3H12.5C13.8807 3 15 4.11929 15 5.5M11.5 21H18.5C19.8807 21 21 19.8807 21 18.5V11.5C21 10.1193 19.8807 9 18.5 9H11.5C10.1193 9 9 10.1193 9 11.5V18.5C9 19.8807 10.1193 21 11.5 21Z"
|
|
4
|
+
strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" stroke="currentColor" />
|
|
4
5
|
</svg>
|
|
5
6
|
)
|
|
6
7
|
|