@moises.ai/design-system 4.21.12 → 4.21.14
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/index.js +3079 -3003
- package/package.json +1 -1
- package/src/components/InstrumentSelect/InstrumentSelect.jsx +93 -15
- package/src/components/InstrumentSelect/InstrumentSelect.module.css +200 -1
- package/src/components/InstrumentSelect/InstrumentSelect.stories.jsx +167 -10
- package/src/components/InstrumentSelect/InstrumentSelectCard.jsx +36 -4
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,73 @@ function isItemSelected(value, itemValue) {
|
|
|
49
54
|
return value === itemValue
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
function gridGap(size) {
|
|
58
|
+
return size === 'medium' || size === 'large' ? 6 : 4
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const TRACK_MIN = {
|
|
62
|
+
small: 140,
|
|
63
|
+
medium: 148,
|
|
64
|
+
large: 148,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const TRACK_MAX = {
|
|
68
|
+
medium: 160,
|
|
69
|
+
large: 148,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function resolveColumns(columns) {
|
|
73
|
+
if (typeof columns === 'number' && Number.isFinite(columns)) return Math.max(1, columns)
|
|
74
|
+
if (columns && typeof columns === 'object') {
|
|
75
|
+
const initial = columns.initial
|
|
76
|
+
const parsed = typeof initial === 'string' ? parseInt(initial, 10) : initial
|
|
77
|
+
if (Number.isFinite(parsed)) return Math.max(1, parsed)
|
|
78
|
+
}
|
|
79
|
+
return 2
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Horizontal uses flex wrap. Each card stays at least its minimum width, so a row
|
|
84
|
+
* that cannot hold `columns` items wraps the rest. Medium and large are also capped
|
|
85
|
+
* so a wide container never places more than `columns` cards on one row.
|
|
86
|
+
*
|
|
87
|
+
* Vertical fills `rows` rows top to bottom, then starts the next column.
|
|
88
|
+
*/
|
|
89
|
+
function getGridStyle(orientation, size, columns, rows, itemCount) {
|
|
90
|
+
const min = TRACK_MIN[size] ?? TRACK_MIN.small
|
|
91
|
+
const max = TRACK_MAX[size]
|
|
92
|
+
const gap = gridGap(size)
|
|
93
|
+
const gaps = Math.max(columns - 1, 0)
|
|
94
|
+
const share = `calc((100% - ${gap}px * ${gaps}) / ${columns})`
|
|
95
|
+
|
|
96
|
+
if (orientation === 'vertical') {
|
|
97
|
+
const rowCount = Math.max(rows ?? itemCount, 1)
|
|
98
|
+
return {
|
|
99
|
+
display: 'grid',
|
|
100
|
+
gap,
|
|
101
|
+
gridAutoFlow: 'column',
|
|
102
|
+
gridTemplateRows: `repeat(${rowCount}, auto)`,
|
|
103
|
+
gridTemplateColumns: 'unset',
|
|
104
|
+
gridAutoColumns: max ? `minmax(${min}px, ${max}px)` : `minmax(${min}px, 1fr)`,
|
|
105
|
+
justifyContent: 'start',
|
|
106
|
+
width: 'max-content',
|
|
107
|
+
maxWidth: '100%',
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
'--track-min': `${min}px`,
|
|
113
|
+
'--track-max': max ? `${max}px` : share,
|
|
114
|
+
display: 'flex',
|
|
115
|
+
flexWrap: 'wrap',
|
|
116
|
+
alignItems: 'stretch',
|
|
117
|
+
justifyContent: 'flex-start',
|
|
118
|
+
gap,
|
|
119
|
+
width: '100%',
|
|
120
|
+
maxWidth: max ? `calc(${max}px * ${columns} + ${gap}px * ${gaps})` : undefined,
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
52
124
|
/**
|
|
53
125
|
* Instrument selector list with optional title and tooltip header.
|
|
54
126
|
*
|
|
@@ -58,8 +130,9 @@ function isItemSelected(value, itemValue) {
|
|
|
58
130
|
* - Pass `value` to mark items as selected (string for single, string[] for multi).
|
|
59
131
|
* - `onSelect(item)` fires for every click; the parent decides what to do.
|
|
60
132
|
*
|
|
61
|
-
* Layout:
|
|
62
|
-
*
|
|
133
|
+
* Layout: horizontal by default, at most `columns` items per row (2). When the row cannot
|
|
134
|
+
* fit that many cards, the rest wrap onto the next line. Vertical fills `rows` rows down
|
|
135
|
+
* each column before starting the next one. Gap is 4px.
|
|
63
136
|
*
|
|
64
137
|
* @example
|
|
65
138
|
* // Single select
|
|
@@ -97,6 +170,10 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
97
170
|
selectedValue,
|
|
98
171
|
onSelect,
|
|
99
172
|
columns = 2,
|
|
173
|
+
rows,
|
|
174
|
+
orientation = 'horizontal',
|
|
175
|
+
variant = 'neutral',
|
|
176
|
+
size = 'small',
|
|
100
177
|
className,
|
|
101
178
|
...props
|
|
102
179
|
},
|
|
@@ -104,19 +181,11 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
104
181
|
) {
|
|
105
182
|
const resolvedValue = value ?? selectedValue
|
|
106
183
|
|
|
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])
|
|
184
|
+
const cols = useMemo(() => resolveColumns(columns), [columns])
|
|
116
185
|
|
|
117
186
|
const gridStyle = useMemo(
|
|
118
|
-
() => (
|
|
119
|
-
[cols],
|
|
187
|
+
() => getGridStyle(orientation, size, cols, rows, items.length),
|
|
188
|
+
[orientation, size, cols, rows, items.length],
|
|
120
189
|
)
|
|
121
190
|
|
|
122
191
|
return (
|
|
@@ -134,7 +203,13 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
134
203
|
</div>
|
|
135
204
|
)}
|
|
136
205
|
|
|
137
|
-
<div
|
|
206
|
+
<div
|
|
207
|
+
className={styles.grid}
|
|
208
|
+
data-orientation={orientation}
|
|
209
|
+
style={gridStyle}
|
|
210
|
+
role="group"
|
|
211
|
+
aria-label={title}
|
|
212
|
+
>
|
|
138
213
|
{items.map((item) => {
|
|
139
214
|
const itemText = item.text ?? item.label ?? item.name
|
|
140
215
|
const ItemIcon = item.Icon ?? item.icon
|
|
@@ -147,9 +222,12 @@ export const InstrumentSelect = forwardRef(function InstrumentSelect(
|
|
|
147
222
|
value={item.value}
|
|
148
223
|
text={itemText}
|
|
149
224
|
Icon={ItemIcon}
|
|
225
|
+
badge={item.badge}
|
|
150
226
|
selected={isItemSelected(resolvedValue, item.value)}
|
|
151
227
|
locked={itemLocked}
|
|
152
228
|
disabled={itemDisabled}
|
|
229
|
+
variant={variant}
|
|
230
|
+
size={size}
|
|
153
231
|
onClick={() => onSelect?.(item)}
|
|
154
232
|
/>
|
|
155
233
|
)
|
|
@@ -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,196 @@
|
|
|
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
|
+
font-weight: 500;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.cardBadge {
|
|
250
|
+
display: flex;
|
|
251
|
+
flex-shrink: 0;
|
|
252
|
+
padding: 2px 6px;
|
|
253
|
+
justify-content: center;
|
|
254
|
+
align-items: center;
|
|
255
|
+
gap: 6px;
|
|
256
|
+
border-radius: var(--Radius-3, 6px);
|
|
257
|
+
background: var(--Colors-Accent-Accent-Alpha-3, rgba(0, 223, 251, 0.16));
|
|
258
|
+
color: var(--Colors-Accent-Accent-Alpha-11, rgba(120, 247, 255, 0.95));
|
|
259
|
+
font-family: var(
|
|
260
|
+
--Typography-Font-family-text,
|
|
261
|
+
"Articulat CF",
|
|
262
|
+
helvetica,
|
|
263
|
+
arial,
|
|
264
|
+
sans-serif
|
|
265
|
+
);
|
|
266
|
+
font-size: var(--Typography-Font-size-1, 12px);
|
|
267
|
+
font-style: normal;
|
|
268
|
+
font-weight: 500;
|
|
269
|
+
line-height: var(--Typography-Line-height-1, 16px);
|
|
270
|
+
letter-spacing: var(--Typography-Letter-spacing-1, 0.04px);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.card[data-size="medium"] .lockIcon,
|
|
274
|
+
.card[data-size="large"] .lockIcon {
|
|
275
|
+
top: var(--Spacing-3, 12px);
|
|
276
|
+
right: var(--Spacing-3, 12px);
|
|
277
|
+
transform: none;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* cyan + vertical: lock sits inline, beside the name */
|
|
281
|
+
.card[data-size="medium"][data-variant="cyan"] .cardBottom .lockIcon,
|
|
282
|
+
.card[data-size="large"][data-variant="cyan"] .cardBottom .lockIcon {
|
|
283
|
+
position: static;
|
|
284
|
+
top: auto;
|
|
285
|
+
right: auto;
|
|
286
|
+
transform: none;
|
|
287
|
+
flex-shrink: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* ----- Variant: cyan ----- */
|
|
291
|
+
|
|
292
|
+
.card[data-variant="cyan"] {
|
|
293
|
+
border: 2px solid transparent;
|
|
294
|
+
background: rgba(0, 223, 251, 0.11);
|
|
295
|
+
color: var(--neutral-alpha-12);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.card[data-variant="cyan"] .cardIcon {
|
|
299
|
+
color: var(--neutral-alpha-10);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.card[data-variant="cyan"] .cardText {
|
|
303
|
+
color: var(--neutral-alpha-12);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* selected, not hovered */
|
|
307
|
+
.card[data-variant="cyan"][data-state="checked"] {
|
|
308
|
+
border-color: var(--Colors-Accent-Accent-9, #00dae8);
|
|
309
|
+
background: rgba(0, 223, 251, 0.11);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.card[data-variant="cyan"][data-state="checked"] .cardIcon {
|
|
313
|
+
color: var(--accent-a9);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.card[data-variant="cyan"][data-state="checked"] .cardText {
|
|
317
|
+
color: var(--neutral-alpha-12);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/* hover, not selected */
|
|
321
|
+
.card[data-variant="cyan"][data-state="default"]:hover,
|
|
322
|
+
.card[data-variant="cyan"][data-state="hover"] {
|
|
323
|
+
border-color: transparent;
|
|
324
|
+
background: rgba(0, 223, 251, 0.13);
|
|
325
|
+
color: var(--white);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.card[data-variant="cyan"][data-state="default"]:hover .cardIcon,
|
|
329
|
+
.card[data-variant="cyan"][data-state="hover"] .cardIcon {
|
|
330
|
+
color: var(--neutral-alpha-11);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.card[data-variant="cyan"][data-state="default"]:hover .cardText,
|
|
334
|
+
.card[data-variant="cyan"][data-state="hover"] .cardText {
|
|
335
|
+
color: var(--white);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* hover + selected */
|
|
339
|
+
.card[data-variant="cyan"][data-state="checked"]:hover {
|
|
340
|
+
border-color: var(--Colors-Accent-Accent-9, #00dae8);
|
|
341
|
+
background: rgba(0, 223, 251, 0.13);
|
|
342
|
+
color: var(--white);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.card[data-variant="cyan"][data-state="checked"]:hover .cardIcon {
|
|
346
|
+
color: var(--accent-a10);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.card[data-variant="cyan"][data-state="checked"]:hover .cardText {
|
|
350
|
+
color: var(--white);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/* disabled, selected or not — hover does not change the treatment */
|
|
354
|
+
.card[data-variant="cyan"][data-state="disabled"],
|
|
355
|
+
.card[data-variant="cyan"][data-state="disabled-checked"],
|
|
356
|
+
.card[data-variant="cyan"][data-state="disabled"]:hover,
|
|
357
|
+
.card[data-variant="cyan"][data-state="disabled-checked"]:hover {
|
|
358
|
+
border-color: transparent;
|
|
359
|
+
background: rgba(0, 223, 251, 0.11);
|
|
360
|
+
color: var(--neutral-alpha-12);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.card[data-variant="cyan"][data-state="disabled"] .cardIcon,
|
|
364
|
+
.card[data-variant="cyan"][data-state="disabled-checked"] .cardIcon,
|
|
365
|
+
.card[data-variant="cyan"][data-state="disabled"]:hover .cardIcon,
|
|
366
|
+
.card[data-variant="cyan"][data-state="disabled-checked"]:hover .cardIcon {
|
|
367
|
+
color: var(--accent-a10);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.card[data-variant="cyan"][data-state="disabled"] .cardText,
|
|
371
|
+
.card[data-variant="cyan"][data-state="disabled-checked"] .cardText,
|
|
372
|
+
.card[data-variant="cyan"][data-state="disabled"]:hover .cardText,
|
|
373
|
+
.card[data-variant="cyan"][data-state="disabled-checked"]:hover .cardText {
|
|
374
|
+
color: var(--neutral-alpha-12);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.card[data-variant="cyan"][data-state="disabled"] .lockIcon,
|
|
378
|
+
.card[data-variant="cyan"][data-state="disabled-checked"] .lockIcon {
|
|
379
|
+
color: var(--neutral-alpha-8);
|
|
380
|
+
}
|
|
@@ -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
|
})
|