@transferwise/components 0.0.0-experimental-a12c97e → 0.0.0-experimental-302d967
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/build/listItem/AvatarLayout/ListItemAvatarLayout.js +2 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -1
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +2 -0
- package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -1
- package/build/listItem/AvatarView/ListItemAvatarView.js +2 -0
- package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -1
- package/build/listItem/AvatarView/ListItemAvatarView.mjs +2 -0
- package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -1
- package/build/listItem/Image/ListItemImage.js +6 -2
- package/build/listItem/Image/ListItemImage.js.map +1 -1
- package/build/listItem/Image/ListItemImage.mjs +6 -2
- package/build/listItem/Image/ListItemImage.mjs.map +1 -1
- package/build/listItem/ListItem.js +16 -14
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +16 -14
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/listItem/ListItemContext.js.map +1 -1
- package/build/listItem/ListItemContext.mjs.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.js +1 -1
- package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs +1 -1
- package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
- package/build/listItem/_stories/images/landscape.svg +1 -0
- package/build/listItem/_stories/images/portrait.svg +1 -0
- package/build/listItem/useListItemMedia.js +21 -0
- package/build/listItem/useListItemMedia.js.map +1 -0
- package/build/listItem/useListItemMedia.mjs +19 -0
- package/build/listItem/useListItemMedia.mjs.map +1 -0
- package/build/main.css +64 -101
- package/build/styles/avatarView/AvatarView.css +1 -3
- package/build/styles/listItem/ListItem.css +63 -98
- package/build/styles/listItem/ListItem.grid.css +17 -11
- package/build/styles/main.css +64 -101
- package/build/switch/Switch.js.map +1 -1
- package/build/switch/Switch.mjs.map +1 -1
- package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -1
- package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -1
- package/build/types/listItem/Image/ListItemImage.d.ts +1 -1
- package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
- package/build/types/listItem/ListItem.d.ts +1 -1
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/ListItemContext.d.ts +4 -0
- package/build/types/listItem/ListItemContext.d.ts.map +1 -1
- package/build/types/listItem/test-utils.d.ts +7 -0
- package/build/types/listItem/test-utils.d.ts.map +1 -0
- package/build/types/listItem/useListItemMedia.d.ts +6 -0
- package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
- package/build/types/switch/Switch.d.ts +1 -1
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/avatarView/AvatarView.css +1 -3
- package/src/avatarView/AvatarView.less +1 -2
- package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +8 -58
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +0 -3
- package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +3 -0
- package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +3 -21
- package/src/listItem/AvatarView/ListItemAvatarView.tsx +3 -0
- package/src/listItem/Button/ListItemButton.spec.tsx +10 -35
- package/src/listItem/Button/ListItemButton.story.tsx +37 -95
- package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +0 -18
- package/src/listItem/IconButton/ListItemIconButton.story.tsx +2 -15
- package/src/listItem/Image/ListItemImage.spec.tsx +8 -5
- package/src/listItem/Image/ListItemImage.story.tsx +23 -6
- package/src/listItem/Image/ListItemImage.tsx +12 -4
- package/src/listItem/ListItem.css +63 -98
- package/src/listItem/ListItem.grid.css +17 -11
- package/src/listItem/ListItem.grid.less +24 -16
- package/src/listItem/ListItem.less +60 -113
- package/src/listItem/ListItem.tsx +24 -18
- package/src/listItem/ListItemContext.tsx +5 -0
- package/src/listItem/Navigation/ListItemNavigation.story.tsx +2 -5
- package/src/listItem/Navigation/ListItemNavigation.tsx +1 -1
- package/src/listItem/Radio/ListItemRadio.story.tsx +0 -10
- package/src/listItem/Switch/ListItemSwitch.story.tsx +0 -8
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +142 -2
- package/src/listItem/_stories/ListItem.story.tsx +141 -243
- package/src/listItem/_stories/ListItem.variants.test.story.tsx +7 -2
- package/src/listItem/_stories/images/landscape.svg +1 -0
- package/src/listItem/_stories/images/portrait.svg +1 -0
- package/src/listItem/test-utils.tsx +33 -0
- package/src/listItem/useListItemMedia.tsx +13 -0
- package/src/main.css +64 -101
- package/src/switch/Switch.tsx +1 -1
- package/build/types/listItem/_stories/helpers.d.ts +0 -27
- package/build/types/listItem/_stories/helpers.d.ts.map +0 -1
- package/src/listItem/_stories/ListItem.scenarios.story.tsx +0 -209
- package/src/listItem/_stories/helpers.tsx +0 -53
|
@@ -2,7 +2,6 @@ import { useState } from 'react';
|
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
3
|
import { MultiCurrency, Plus } from '@transferwise/icons';
|
|
4
4
|
import { lorem5, lorem10 } from '../../test-utils';
|
|
5
|
-
import Emphasis from '../../emphasis';
|
|
6
5
|
import { ListItem, Props as ItemProps } from '../ListItem';
|
|
7
6
|
import {
|
|
8
7
|
SB_LIST_ITEM_CONTROLS as CONTROLS,
|
|
@@ -10,20 +9,6 @@ import {
|
|
|
10
9
|
SB_LIST_ITEM_PROMPTS as PROMPTS,
|
|
11
10
|
SB_LIST_ITEM_MEDIA as MEDIA,
|
|
12
11
|
} from './subcomponents';
|
|
13
|
-
import { disableControls, storySourceWithoutNoise, withoutKey } from './helpers';
|
|
14
|
-
import Link from '../../link';
|
|
15
|
-
|
|
16
|
-
const hideControls = disableControls([
|
|
17
|
-
'additionalInfo',
|
|
18
|
-
'control',
|
|
19
|
-
'prompt',
|
|
20
|
-
'media',
|
|
21
|
-
'className',
|
|
22
|
-
'id',
|
|
23
|
-
'role',
|
|
24
|
-
'aria-labelledby',
|
|
25
|
-
'as',
|
|
26
|
-
]);
|
|
27
12
|
|
|
28
13
|
/**
|
|
29
14
|
* List Items let users review or select options from a dynamic list.<br />
|
|
@@ -271,17 +256,16 @@ export const Playground: StoryObj<PreviewStoryArgs> = {
|
|
|
271
256
|
previewAdditionalInfoFull: 'non-interactive',
|
|
272
257
|
previewAdditionalInfoPartial: 'non-interactive',
|
|
273
258
|
},
|
|
274
|
-
decorators: [withoutKey],
|
|
275
259
|
};
|
|
276
260
|
|
|
277
261
|
/**
|
|
278
262
|
* ListItem uses container queries under the hood, which means its layout self-adjusts based on
|
|
279
263
|
* the available space. At the 100% zoom level, these breakpoints correspond to
|
|
280
|
-
* containers under `
|
|
281
|
-
* and above `
|
|
264
|
+
* containers under `320px`, those between `321px and 399px`, and finally everything including
|
|
265
|
+
* and above `400px`. <br />
|
|
282
266
|
* This also supports high levels of zoom for assistive tech users.
|
|
283
267
|
*/
|
|
284
|
-
export const Responsiveness:
|
|
268
|
+
export const Responsiveness: Story = {
|
|
285
269
|
parameters: {
|
|
286
270
|
docs: {
|
|
287
271
|
canvas: {
|
|
@@ -289,32 +273,42 @@ export const Responsiveness: StoryObj<PreviewStoryArgs> = {
|
|
|
289
273
|
},
|
|
290
274
|
},
|
|
291
275
|
},
|
|
292
|
-
argTypes: {
|
|
293
|
-
...hideControls(),
|
|
294
|
-
...previewArgTypes,
|
|
295
|
-
},
|
|
296
|
-
args: {
|
|
297
|
-
subtitle: lorem10,
|
|
298
|
-
previewInteractivity: 'fully-interactive',
|
|
299
|
-
previewPrompt: 'interactive',
|
|
300
|
-
previewMedia: 'image',
|
|
301
|
-
previewControlFull: 'Button',
|
|
302
|
-
previewControlPartial: 'Button',
|
|
303
|
-
previewAdditionalInfoFull: 'non-interactive',
|
|
304
|
-
previewAdditionalInfoPartial: 'non-interactive',
|
|
305
|
-
},
|
|
306
|
-
decorators: [withoutKey],
|
|
307
276
|
render: (args) => {
|
|
308
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
309
|
-
|
|
310
277
|
return (
|
|
311
278
|
<ol
|
|
312
279
|
className="list-unstyled"
|
|
313
|
-
style={{ display: 'grid', gridTemplateColumns: '
|
|
280
|
+
style={{ display: 'grid', gridTemplateColumns: '320px 360px 400px', gap: 16 }}
|
|
314
281
|
>
|
|
315
|
-
<
|
|
316
|
-
|
|
317
|
-
|
|
282
|
+
<div style={{ width: '320px' }}>
|
|
283
|
+
<ListItem
|
|
284
|
+
{...args}
|
|
285
|
+
subtitle={lorem10}
|
|
286
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
287
|
+
control={CONTROLS.button}
|
|
288
|
+
media={MEDIA.image}
|
|
289
|
+
prompt={PROMPTS.interactive}
|
|
290
|
+
/>
|
|
291
|
+
</div>
|
|
292
|
+
<div style={{ width: '360px' }}>
|
|
293
|
+
<ListItem
|
|
294
|
+
{...args}
|
|
295
|
+
subtitle={lorem10}
|
|
296
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
297
|
+
control={CONTROLS.button}
|
|
298
|
+
media={MEDIA.image}
|
|
299
|
+
prompt={PROMPTS.interactive}
|
|
300
|
+
/>
|
|
301
|
+
</div>
|
|
302
|
+
<div style={{ width: '400px' }}>
|
|
303
|
+
<ListItem
|
|
304
|
+
{...args}
|
|
305
|
+
subtitle={lorem10}
|
|
306
|
+
additionalInfo={<div />}
|
|
307
|
+
control={CONTROLS.button}
|
|
308
|
+
media={MEDIA.image}
|
|
309
|
+
prompt={PROMPTS.interactive}
|
|
310
|
+
/>
|
|
311
|
+
</div>
|
|
318
312
|
</ol>
|
|
319
313
|
);
|
|
320
314
|
},
|
|
@@ -333,7 +327,7 @@ export const Responsiveness: StoryObj<PreviewStoryArgs> = {
|
|
|
333
327
|
* **NB:** This behaviour is slightly different on mobile platforms as they have more control over
|
|
334
328
|
* layout calculations.
|
|
335
329
|
*/
|
|
336
|
-
export const ContentRatio:
|
|
330
|
+
export const ContentRatio: Story = {
|
|
337
331
|
parameters: {
|
|
338
332
|
docs: {
|
|
339
333
|
canvas: {
|
|
@@ -342,56 +336,45 @@ export const ContentRatio: StoryObj<PreviewStoryArgs> = {
|
|
|
342
336
|
},
|
|
343
337
|
},
|
|
344
338
|
args: {
|
|
345
|
-
valueColumnWidth: 70,
|
|
346
|
-
subtitle: lorem5,
|
|
347
339
|
valueTitle: `${lorem5} ${lorem5}`,
|
|
348
340
|
valueSubtitle: lorem5,
|
|
349
|
-
|
|
350
|
-
previewPrompt: 'interactive',
|
|
351
|
-
previewMedia: 'image',
|
|
352
|
-
previewControlFull: 'Button',
|
|
353
|
-
previewControlPartial: 'Button',
|
|
354
|
-
previewAdditionalInfoFull: 'non-interactive',
|
|
355
|
-
previewAdditionalInfoPartial: 'non-interactive',
|
|
356
|
-
as: 'div',
|
|
357
|
-
},
|
|
358
|
-
argTypes: {
|
|
359
|
-
...hideControls(['disabled', 'spotlight']),
|
|
360
|
-
...previewArgTypes,
|
|
341
|
+
valueColumnWidth: 70,
|
|
361
342
|
},
|
|
362
343
|
render: (args) => {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
344
|
+
return (
|
|
345
|
+
<ListItem
|
|
346
|
+
{...args}
|
|
347
|
+
subtitle={lorem5}
|
|
348
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
349
|
+
control={CONTROLS.button}
|
|
350
|
+
media={MEDIA.image}
|
|
351
|
+
prompt={PROMPTS.interactive}
|
|
352
|
+
/>
|
|
353
|
+
);
|
|
366
354
|
},
|
|
367
355
|
};
|
|
368
356
|
|
|
369
357
|
/**
|
|
370
358
|
* List item supports default and inverted title and description to allow for further flexibility
|
|
371
|
-
* in the component.
|
|
359
|
+
* in the component.
|
|
372
360
|
*
|
|
373
361
|
* Refer to the [design documentation](https://wise.design/components/list-item#content-hierarchy) for more details.
|
|
374
362
|
*/
|
|
375
|
-
export const ContentHierarchy:
|
|
363
|
+
export const ContentHierarchy: Story = {
|
|
376
364
|
args: {
|
|
377
365
|
inverted: true,
|
|
378
|
-
previewInteractivity: 'fully-interactive',
|
|
379
|
-
previewPrompt: 'interactive',
|
|
380
|
-
previewMedia: 'image',
|
|
381
|
-
previewControlFull: 'Button',
|
|
382
|
-
previewControlPartial: 'Button',
|
|
383
|
-
previewAdditionalInfoFull: 'non-interactive',
|
|
384
|
-
previewAdditionalInfoPartial: 'non-interactive',
|
|
385
|
-
as: 'div',
|
|
386
|
-
},
|
|
387
|
-
argTypes: {
|
|
388
|
-
...hideControls(['valueColumnWidth', 'disabled']),
|
|
389
|
-
...previewArgTypes,
|
|
390
366
|
},
|
|
391
367
|
render: (args) => {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
368
|
+
return (
|
|
369
|
+
<ListItem
|
|
370
|
+
{...args}
|
|
371
|
+
subtitle={lorem10}
|
|
372
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
373
|
+
control={CONTROLS.button}
|
|
374
|
+
media={MEDIA.image}
|
|
375
|
+
prompt={PROMPTS.interactive}
|
|
376
|
+
/>
|
|
377
|
+
);
|
|
395
378
|
},
|
|
396
379
|
};
|
|
397
380
|
|
|
@@ -400,29 +383,28 @@ export const ContentHierarchy: StoryObj<PreviewStoryArgs> = {
|
|
|
400
383
|
*
|
|
401
384
|
* Refer to the [design documentation](https://wise.design/components/list-item#spotlight) for more details.
|
|
402
385
|
*/
|
|
403
|
-
export const Spotlight:
|
|
404
|
-
argTypes: {
|
|
405
|
-
...hideControls(['spotlight', 'valueColumnWidth']),
|
|
406
|
-
...previewArgTypes,
|
|
407
|
-
},
|
|
408
|
-
args: {
|
|
409
|
-
subtitle: lorem10,
|
|
410
|
-
previewInteractivity: 'fully-interactive',
|
|
411
|
-
previewPrompt: 'interactive',
|
|
412
|
-
previewMedia: 'image',
|
|
413
|
-
previewControlFull: 'Button',
|
|
414
|
-
previewControlPartial: 'Button',
|
|
415
|
-
previewAdditionalInfoFull: 'non-interactive',
|
|
416
|
-
previewAdditionalInfoPartial: 'non-interactive',
|
|
417
|
-
},
|
|
418
|
-
decorators: [withoutKey],
|
|
386
|
+
export const Spotlight: Story = {
|
|
419
387
|
render: (args) => {
|
|
420
|
-
const [props, previewProps] = getPropsForPreview(args);
|
|
421
|
-
|
|
422
388
|
return (
|
|
423
389
|
<ol className="list-unstyled">
|
|
424
|
-
<ListItem
|
|
425
|
-
|
|
390
|
+
<ListItem
|
|
391
|
+
{...args}
|
|
392
|
+
subtitle={lorem10}
|
|
393
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
394
|
+
control={CONTROLS.button}
|
|
395
|
+
media={MEDIA.image}
|
|
396
|
+
prompt={PROMPTS.interactive}
|
|
397
|
+
spotlight="inactive"
|
|
398
|
+
/>
|
|
399
|
+
<ListItem
|
|
400
|
+
{...args}
|
|
401
|
+
subtitle={lorem10}
|
|
402
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
403
|
+
control={CONTROLS.button}
|
|
404
|
+
media={MEDIA.image}
|
|
405
|
+
prompt={PROMPTS.interactive}
|
|
406
|
+
spotlight="active"
|
|
407
|
+
/>
|
|
426
408
|
</ol>
|
|
427
409
|
);
|
|
428
410
|
},
|
|
@@ -443,126 +425,82 @@ export const Spotlight: StoryObj<PreviewStoryArgs> = {
|
|
|
443
425
|
* All of these limitations were put in place to ensure that the list item is compliant with
|
|
444
426
|
* accessibility guidance and offers consistent experience across all engineering platforms.
|
|
445
427
|
*
|
|
446
|
-
* Please refer to the [design documentation](https://wise.design/components/list-item
|
|
428
|
+
* Please refer to the [design documentation](https://wise.design/components/list-item#:~:text=specific%20list%20item.-,Interaction,-The%20list%20item) for more details.
|
|
447
429
|
*/
|
|
448
|
-
export const Interactivity:
|
|
449
|
-
|
|
450
|
-
...hideControls([
|
|
451
|
-
'title',
|
|
452
|
-
'subtitle',
|
|
453
|
-
'valueTitle',
|
|
454
|
-
'valueSubtitle',
|
|
455
|
-
'valueColumnWidth',
|
|
456
|
-
'inverted',
|
|
457
|
-
]),
|
|
458
|
-
},
|
|
459
|
-
args: {
|
|
460
|
-
subtitle: lorem10,
|
|
461
|
-
},
|
|
462
|
-
decorators: [withoutKey],
|
|
463
|
-
render: function Render(args) {
|
|
430
|
+
export const Interactivity: Story = {
|
|
431
|
+
render: function Render() {
|
|
464
432
|
const [clicked, setClicked] = useState(0);
|
|
465
433
|
|
|
466
|
-
const renderPrompt = () => (
|
|
467
|
-
<ListItem.Prompt sentiment="positive">
|
|
468
|
-
Finally, there is a prompt{' '}
|
|
469
|
-
<Link href="https://wise.com" target="_blank" rel="noreferrer">
|
|
470
|
-
referencing some details
|
|
471
|
-
</Link>{' '}
|
|
472
|
-
for your convenience.
|
|
473
|
-
</ListItem.Prompt>
|
|
474
|
-
);
|
|
475
|
-
|
|
476
|
-
const renderInteractiveInfo = () => (
|
|
477
|
-
<ListItem.AdditionalInfo
|
|
478
|
-
action={{
|
|
479
|
-
label: 'Details about the subject.',
|
|
480
|
-
href: 'https://wise.com',
|
|
481
|
-
target: '_blank',
|
|
482
|
-
}}
|
|
483
|
-
>
|
|
484
|
-
Which is augmented with additional info.
|
|
485
|
-
</ListItem.AdditionalInfo>
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
const renderStaticInfo = () => (
|
|
489
|
-
<ListItem.AdditionalInfo>Which is augmented with additional info.</ListItem.AdditionalInfo>
|
|
490
|
-
);
|
|
491
|
-
|
|
492
434
|
return (
|
|
493
435
|
<>
|
|
494
436
|
<label>Count: {clicked}</label>
|
|
495
|
-
<
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
/>
|
|
553
|
-
</ol>
|
|
437
|
+
<ListItem
|
|
438
|
+
title="Fully interactive"
|
|
439
|
+
subtitle={lorem10}
|
|
440
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
441
|
+
control={
|
|
442
|
+
<ListItem.Button
|
|
443
|
+
priority="secondary-neutral"
|
|
444
|
+
onClick={() => setClicked((current) => current + 1)}
|
|
445
|
+
>
|
|
446
|
+
as Button
|
|
447
|
+
</ListItem.Button>
|
|
448
|
+
}
|
|
449
|
+
prompt={PROMPTS.interactive}
|
|
450
|
+
/>
|
|
451
|
+
<ListItem
|
|
452
|
+
title="Partially interactive"
|
|
453
|
+
subtitle={lorem10}
|
|
454
|
+
additionalInfo={ADDITIONAL_INFO.interactive}
|
|
455
|
+
control={
|
|
456
|
+
<ListItem.Button
|
|
457
|
+
priority="secondary-neutral"
|
|
458
|
+
partiallyInteractive
|
|
459
|
+
onClick={() => setClicked((current) => current + 1)}
|
|
460
|
+
>
|
|
461
|
+
as Button
|
|
462
|
+
</ListItem.Button>
|
|
463
|
+
}
|
|
464
|
+
prompt={PROMPTS.interactive}
|
|
465
|
+
/>
|
|
466
|
+
<ListItem
|
|
467
|
+
title="Fully interactive"
|
|
468
|
+
subtitle={lorem10}
|
|
469
|
+
additionalInfo={ADDITIONAL_INFO.nonInteractive}
|
|
470
|
+
control={
|
|
471
|
+
<ListItem.IconButton
|
|
472
|
+
aria-label="Add something to me"
|
|
473
|
+
onClick={() => setClicked((current) => current + 1)}
|
|
474
|
+
>
|
|
475
|
+
<Plus />
|
|
476
|
+
</ListItem.IconButton>
|
|
477
|
+
}
|
|
478
|
+
prompt={PROMPTS.interactive}
|
|
479
|
+
/>
|
|
480
|
+
<ListItem
|
|
481
|
+
title="Partially interactive"
|
|
482
|
+
subtitle={lorem10}
|
|
483
|
+
additionalInfo={ADDITIONAL_INFO.interactive}
|
|
484
|
+
control={
|
|
485
|
+
<ListItem.IconButton
|
|
486
|
+
partiallyInteractive
|
|
487
|
+
onClick={() => setClicked((current) => current + 1)}
|
|
488
|
+
>
|
|
489
|
+
<Plus />
|
|
490
|
+
</ListItem.IconButton>
|
|
491
|
+
}
|
|
492
|
+
prompt={PROMPTS.interactive}
|
|
493
|
+
/>
|
|
554
494
|
</>
|
|
555
495
|
);
|
|
556
496
|
},
|
|
557
|
-
}
|
|
497
|
+
};
|
|
558
498
|
|
|
559
499
|
/**
|
|
560
500
|
* While most disabled states will show as grayed out, the navigation control switches from chevron
|
|
561
501
|
* to a new icon for improved user experience and accessibility. <br />
|
|
562
502
|
* For the same reason, only the control part of the List Item is dimmed, while all the content
|
|
563
503
|
* retains high contrast and interactivity.
|
|
564
|
-
*
|
|
565
|
-
* Please refer to the [design documentation](https://wise.design/components/list-item#accessibility:~:text=-,Disabled%20states,-) for more details
|
|
566
504
|
*/
|
|
567
505
|
export const Disabled: Story = {
|
|
568
506
|
parameters: {
|
|
@@ -571,11 +509,9 @@ export const Disabled: Story = {
|
|
|
571
509
|
sourceState: 'hidden',
|
|
572
510
|
},
|
|
573
511
|
},
|
|
574
|
-
controls: { disable: true },
|
|
575
|
-
knobs: { disable: true },
|
|
576
512
|
},
|
|
577
|
-
render: (
|
|
578
|
-
<
|
|
513
|
+
render: () => (
|
|
514
|
+
<div>
|
|
579
515
|
<ListItem
|
|
580
516
|
disabled
|
|
581
517
|
media={
|
|
@@ -729,44 +665,6 @@ export const Disabled: Story = {
|
|
|
729
665
|
</ListItem.Button>
|
|
730
666
|
}
|
|
731
667
|
/>
|
|
732
|
-
</
|
|
668
|
+
</div>
|
|
733
669
|
),
|
|
734
670
|
};
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* For backwards compatibility, all of the ListItem's content elements accept `ReactNode`.
|
|
738
|
-
* That said, most of them should be fed with plain text only. The exception is `valueTitle`
|
|
739
|
-
* and `valueSubtitle` which can be augmented with sentiment colours, strikethrough or bold
|
|
740
|
-
* styles. <br />
|
|
741
|
-
*
|
|
742
|
-
* Please refer to the [design documentation](https://wise.design/components/list-item#content) for more details.
|
|
743
|
-
*/
|
|
744
|
-
export const StylingLabels: Story = {
|
|
745
|
-
argTypes: {
|
|
746
|
-
...hideControls(['spotlight', 'valueColumnWidth']),
|
|
747
|
-
},
|
|
748
|
-
args: {
|
|
749
|
-
title: lorem5,
|
|
750
|
-
subtitle: lorem10,
|
|
751
|
-
media: MEDIA.image,
|
|
752
|
-
control: CONTROLS.iconButton,
|
|
753
|
-
prompt: PROMPTS.interactive,
|
|
754
|
-
},
|
|
755
|
-
decorators: [withoutKey],
|
|
756
|
-
render: function Render(args) {
|
|
757
|
-
return (
|
|
758
|
-
<ol className="list-unstyled">
|
|
759
|
-
<ListItem
|
|
760
|
-
{...args}
|
|
761
|
-
valueTitle={<Emphasis text="<negative>100 GBP</negative>" />}
|
|
762
|
-
valueSubtitle={<s>125 GBP</s>}
|
|
763
|
-
/>
|
|
764
|
-
<ListItem
|
|
765
|
-
{...args}
|
|
766
|
-
valueTitle={<Emphasis text="<positive>100 GBP</positive>" />}
|
|
767
|
-
valueSubtitle={<strong>125 GBP</strong>}
|
|
768
|
-
/>
|
|
769
|
-
</ol>
|
|
770
|
-
);
|
|
771
|
-
},
|
|
772
|
-
};
|
|
@@ -71,18 +71,23 @@ const generateVariantsForControl = (controlType: ControlType): Story => {
|
|
|
71
71
|
const additionalInfo = isInteractive ? infoWithLink : infoWithoutLink;
|
|
72
72
|
const variants = [
|
|
73
73
|
{ title },
|
|
74
|
+
{ title, valueTitle },
|
|
74
75
|
{ title, subtitle },
|
|
76
|
+
{ title, valueTitle, valueSubtitle },
|
|
75
77
|
{ title, subtitle, inverted: true },
|
|
76
78
|
{ title, subtitle, valueTitle },
|
|
77
79
|
{ title, subtitle, valueTitle, inverted: true },
|
|
78
80
|
{ title, subtitle, valueTitle, valueSubtitle },
|
|
79
81
|
{ title, subtitle, valueTitle, valueSubtitle, inverted: true },
|
|
80
82
|
{ media, title },
|
|
83
|
+
{ media, title, valueTitle },
|
|
84
|
+
{ media, title, subtitle },
|
|
85
|
+
{ media, title, valueTitle, valueSubtitle },
|
|
86
|
+
{ media, title, valueTitle },
|
|
87
|
+
{ media, title, valueSubtitle },
|
|
81
88
|
{ media, title, subtitle },
|
|
82
89
|
{ media, title, subtitle, valueTitle },
|
|
83
90
|
{ media, title, subtitle, valueTitle, valueSubtitle },
|
|
84
|
-
{ media, title },
|
|
85
|
-
{ media, title, subtitle },
|
|
86
91
|
{ media, title, subtitle, additionalInfo: infoWithoutLink },
|
|
87
92
|
isInteractive ? { media, title, subtitle, additionalInfo: infoWithLink } : null,
|
|
88
93
|
{ media, title, subtitle, additionalInfo, valueTitle },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 112 80"><path fill="#9FE870" stroke="#163300" stroke-width="2" d="M1 79V1h110v78z"/><path fill="#163300" stroke="#163300" stroke-width="2" d="M74.2 21.4 60.9 58h-5.8l11.1-30.8.5-1.3H48.6l.8 1.5 3 5.2-4.7 5.5-1.4 1.7h9.1l-1.4 4H37.3l9.5-11.2 1.4-1.6h-1.5L41 21.4h33.1Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 80 112"><path fill="#9FE870" stroke="#163300" stroke-width="2" d="M1 1h78v110H1z"/><path fill="#163300" stroke="#163300" stroke-width="2" d="M59 37 45.9 73.8H40l11-30.9.6-1.3H33.4l1 1.5 3 5.2-4.8 5.5-1.4 1.7h9.1l-1.5 4H22.2l9.5-11.2 1.4-1.6h-1.6L26 37h33Z"/></svg>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { render, type RenderResult } from '../test-utils';
|
|
2
|
+
import { ListItemContext } from './ListItemContext';
|
|
3
|
+
|
|
4
|
+
export const mockSetControlType = jest.fn();
|
|
5
|
+
export const mockSetControlProps = jest.fn();
|
|
6
|
+
export const mockSetMediaSize = jest.fn();
|
|
7
|
+
|
|
8
|
+
export const renderWithListItemContext = (ui: React.ReactNode): RenderResult => {
|
|
9
|
+
return render(
|
|
10
|
+
<ListItemContext.Provider
|
|
11
|
+
value={{
|
|
12
|
+
setControlType: mockSetControlType,
|
|
13
|
+
setControlProps: mockSetControlProps,
|
|
14
|
+
setMediaSize: mockSetMediaSize,
|
|
15
|
+
ids: {
|
|
16
|
+
title: 'title',
|
|
17
|
+
additionalInfo: 'additional-info',
|
|
18
|
+
valueTitle: 'value-title',
|
|
19
|
+
control: 'control',
|
|
20
|
+
prompt: 'prompt',
|
|
21
|
+
},
|
|
22
|
+
props: {},
|
|
23
|
+
describedByIds: 'described-by-ids',
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
{ui}
|
|
27
|
+
</ListItemContext.Provider>,
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const clearListItemMocks = () => {
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext, useEffect } from 'react';
|
|
2
|
+
import { ListItemContext, type ListItemContextData } from './ListItemContext';
|
|
3
|
+
import type { ListItemAvatarViewProps } from './AvatarView';
|
|
4
|
+
|
|
5
|
+
export function useListItemMedia(size?: ListItemAvatarViewProps['size']) {
|
|
6
|
+
const { setMediaSize, mediaSize } = useContext<ListItemContextData>(ListItemContext);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
setMediaSize(size);
|
|
10
|
+
}, [size, setMediaSize]);
|
|
11
|
+
|
|
12
|
+
return { mediaSize, setMediaSize };
|
|
13
|
+
}
|