@transferwise/components 46.133.0 → 46.134.0

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.
Files changed (78) hide show
  1. package/build/chips/Chips.js.map +1 -1
  2. package/build/chips/Chips.mjs.map +1 -1
  3. package/build/label/Label.js +1 -1
  4. package/build/label/Label.js.map +1 -1
  5. package/build/label/Label.mjs +1 -1
  6. package/build/label/Label.mjs.map +1 -1
  7. package/build/logo/Logo.js +6 -0
  8. package/build/logo/Logo.js.map +1 -1
  9. package/build/logo/Logo.mjs +6 -0
  10. package/build/logo/Logo.mjs.map +1 -1
  11. package/build/main.css +47 -9
  12. package/build/moneyInput/MoneyInput.js +28 -12
  13. package/build/moneyInput/MoneyInput.js.map +1 -1
  14. package/build/moneyInput/MoneyInput.mjs +30 -14
  15. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  16. package/build/moneyInput/currencyFormatting.js +8 -2
  17. package/build/moneyInput/currencyFormatting.js.map +1 -1
  18. package/build/moneyInput/currencyFormatting.mjs +5 -4
  19. package/build/moneyInput/currencyFormatting.mjs.map +1 -1
  20. package/build/statusIcon/StatusIcon.js +1 -12
  21. package/build/statusIcon/StatusIcon.js.map +1 -1
  22. package/build/statusIcon/StatusIcon.mjs +1 -12
  23. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  24. package/build/styles/listItem/ListItem.css +4 -4
  25. package/build/styles/listItem/ListItem.grid.css +3 -3
  26. package/build/styles/main.css +47 -9
  27. package/build/styles/sentimentSurface/SentimentSurface.css +1 -1
  28. package/build/styles/statusIcon/StatusIcon.css +35 -4
  29. package/build/types/chips/Chips.d.ts +1 -1
  30. package/build/types/chips/Chips.d.ts.map +1 -1
  31. package/build/types/common/commonProps.d.ts +0 -6
  32. package/build/types/common/commonProps.d.ts.map +1 -1
  33. package/build/types/label/Label.d.ts.map +1 -1
  34. package/build/types/logo/Logo.d.ts +10 -1
  35. package/build/types/logo/Logo.d.ts.map +1 -1
  36. package/build/types/moneyInput/MoneyInput.d.ts +6 -0
  37. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  38. package/build/types/moneyInput/currencyFormatting.d.ts +4 -3
  39. package/build/types/moneyInput/currencyFormatting.d.ts.map +1 -1
  40. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  41. package/package.json +8 -8
  42. package/src/button/_stories/Button.story.tsx +15 -5
  43. package/src/checkboxButton/CheckboxButton.story.tsx +125 -44
  44. package/src/checkboxButton/CheckboxButton.test.story.tsx +236 -0
  45. package/src/chips/Chips.story.tsx +141 -102
  46. package/src/chips/Chips.test.story.tsx +177 -0
  47. package/src/chips/Chips.tsx +1 -1
  48. package/src/circularButton/CircularButton.story.tsx +261 -49
  49. package/src/circularButton/CircularButton.test.story.tsx +192 -2
  50. package/src/common/commonProps.ts +0 -6
  51. package/src/iconButton/IconButton.story.tsx +315 -110
  52. package/src/iconButton/IconButton.test.story.tsx +217 -44
  53. package/src/label/Label.tsx +1 -2
  54. package/src/listItem/ListItem.css +4 -4
  55. package/src/listItem/ListItem.grid.css +3 -3
  56. package/src/listItem/ListItem.grid.less +5 -3
  57. package/src/listItem/ListItem.less +1 -1
  58. package/src/listItem/ListItem.vars.less +2 -2
  59. package/src/listItem/_stories/ListItem.layout.test.story.tsx +55 -0
  60. package/src/logo/Logo.story.tsx +181 -21
  61. package/src/logo/Logo.test.story.tsx +40 -7
  62. package/src/logo/Logo.tsx +10 -1
  63. package/src/main.css +47 -9
  64. package/src/moneyInput/MoneyInput.story.tsx +10 -1
  65. package/src/moneyInput/MoneyInput.test.story.tsx +141 -1
  66. package/src/moneyInput/MoneyInput.test.tsx +45 -0
  67. package/src/moneyInput/MoneyInput.tsx +27 -3
  68. package/src/moneyInput/currencyFormatting.ts +11 -5
  69. package/src/sentimentSurface/SentimentSurface.css +1 -1
  70. package/src/sentimentSurface/SentimentSurface.less +1 -1
  71. package/src/statusIcon/StatusIcon.css +35 -4
  72. package/src/statusIcon/StatusIcon.less +35 -4
  73. package/src/statusIcon/StatusIcon.story.tsx +119 -79
  74. package/src/statusIcon/StatusIcon.test.story.tsx +125 -0
  75. package/src/statusIcon/StatusIcon.test.tsx +16 -23
  76. package/src/statusIcon/StatusIcon.tsx +2 -16
  77. package/src/switch/Switch.story.tsx +64 -42
  78. package/src/switch/Switch.test.story.tsx +123 -0
@@ -13,112 +13,265 @@ import {
13
13
  Bank,
14
14
  Freeze,
15
15
  } from '@transferwise/icons';
16
+ import { fn } from 'storybook/test';
16
17
  import IconButton, { Props } from './IconButton';
17
- import { action } from 'storybook/actions';
18
- import Body from '../body';
19
18
  import SentimentSurface from '../sentimentSurface';
20
19
 
20
+ /**
21
+ * **Design guidance**: <a href="https://wise.design/components/icon-button" target="_blank">wise.design/components/icon-button</a>
22
+ */
21
23
  export default {
22
24
  title: 'Actions/IconButton',
23
25
  component: IconButton,
26
+ args: {
27
+ onClick: fn(),
28
+ 'aria-label': 'Action',
29
+ },
30
+ argTypes: {
31
+ id: { table: { category: 'Common' } },
32
+ className: { table: { category: 'Common' } },
33
+ role: { table: { category: 'Common' } },
34
+ tabIndex: { table: { category: 'Common' } },
35
+ 'data-testid': { table: { category: 'Common' } },
36
+ onClick: { table: { category: 'Common' } },
37
+ },
38
+ parameters: {
39
+ docs: { toc: true },
40
+ },
24
41
  } satisfies Meta<typeof IconButton>;
25
42
 
26
43
  type Story = StoryObj<typeof IconButton>;
27
44
 
28
45
  const sizes: Props['size'][] = [16, 24, 32, 40, 48, 56, 72];
29
46
 
30
- const Template = ({ size, disabled }: Props) => {
31
- return (
47
+ /**
48
+ * Explore size, priority, type, and disabled state via the controls panel.
49
+ * Use `aria-label` to provide an accessible name.
50
+ */
51
+ export const Playground: Story = {
52
+ args: {
53
+ size: 48,
54
+ priority: 'primary',
55
+ type: 'default',
56
+ disabled: false,
57
+ },
58
+ render: (args) => (
59
+ <IconButton {...args}>
60
+ <Plus />
61
+ </IconButton>
62
+ ),
63
+ };
64
+
65
+ /**
66
+ * Priorities set a visual hierarchy amongst the buttons displayed on the
67
+ * screen to help more important buttons to take precedence over others. <br />
68
+ * <a href="https://wise.design/components/icon-button#priorities" target="_blank">Design documentation</a>
69
+ */
70
+ export const Priority: Story = {
71
+ args: {
72
+ type: 'default',
73
+ },
74
+ argTypes: {
75
+ type: {
76
+ control: 'radio',
77
+ options: ['default', 'negative'],
78
+ },
79
+ priority: { table: { disable: true } },
80
+ size: { table: { disable: true } },
81
+ disabled: { table: { disable: true } },
82
+ href: { table: { disable: true } },
83
+ target: { table: { disable: true } },
84
+ onClick: { table: { disable: true } },
85
+ },
86
+ decorators: [
87
+ (Story) => (
88
+ <div style={{ display: 'flex', gap: '24px', alignItems: 'center', justifyContent: 'center' }}>
89
+ <Story />
90
+ </div>
91
+ ),
92
+ ],
93
+ render: (args: Props) => (
32
94
  <>
33
- <IconButton
34
- size={size}
35
- disabled={disabled}
36
- aria-label="One step back"
37
- priority="primary"
38
- type="default"
39
- onClick={action('button click')}
40
- >
95
+ <IconButton priority="primary" type={args.type} aria-label="Primary" onClick={fn()}>
41
96
  <Plus />
42
97
  </IconButton>
43
- <IconButton
44
- size={size}
45
- disabled={disabled}
46
- aria-label="One step back"
47
- priority="secondary"
48
- type="default"
49
- onClick={action('button click')}
50
- >
51
- <Defrost />
98
+ <IconButton priority="secondary" type={args.type} aria-label="Secondary" onClick={fn()}>
99
+ <Settings />
52
100
  </IconButton>
53
- <IconButton
54
- size={size}
55
- disabled={disabled}
56
- aria-label="One step back"
57
- priority="tertiary"
58
- type="default"
59
- onClick={action('button click')}
60
- >
61
- <ArrowLeft />
101
+ <IconButton priority="tertiary" type={args.type} aria-label="Tertiary" onClick={fn()}>
102
+ <Star />
62
103
  </IconButton>
63
- <IconButton
64
- size={size}
65
- disabled={disabled}
66
- aria-label="One step back"
67
- priority="minimal"
68
- type="default"
69
- onClick={action('button click')}
70
- >
104
+ <IconButton priority="minimal" type={args.type} aria-label="Minimal" onClick={fn()}>
71
105
  <Menu />
72
106
  </IconButton>
73
- <IconButton
74
- size={size}
75
- disabled={disabled}
76
- aria-label="One step back"
77
- priority="primary"
78
- type="negative"
79
- onClick={action('button click')}
80
- >
81
- <Cross />
107
+ </>
108
+ ),
109
+ };
110
+
111
+ /**
112
+ * There are two different types of button – default and negative – designed to emphasise the nature of the action. <br />
113
+ * <a href="https://wise.design/components/icon-button#types" target="_blank">Design documentation</a>
114
+ */
115
+ export const Type: Story = {
116
+ args: {
117
+ priority: 'primary',
118
+ },
119
+ argTypes: {
120
+ priority: {
121
+ control: 'radio',
122
+ options: ['primary', 'secondary', 'tertiary', 'minimal'],
123
+ },
124
+ type: { table: { disable: true } },
125
+ size: { table: { disable: true } },
126
+ disabled: { table: { disable: true } },
127
+ href: { table: { disable: true } },
128
+ target: { table: { disable: true } },
129
+ onClick: { table: { disable: true } },
130
+ },
131
+ decorators: [
132
+ (Story) => (
133
+ <div style={{ display: 'flex', gap: '24px', alignItems: 'center', justifyContent: 'center' }}>
134
+ <Story />
135
+ </div>
136
+ ),
137
+ ],
138
+ render: (args: Props) => (
139
+ <>
140
+ <IconButton priority={args.priority} type="default" aria-label="Default" onClick={fn()}>
141
+ <Plus />
82
142
  </IconButton>
83
- <IconButton
84
- size={size}
85
- disabled={disabled}
86
- aria-label="One step back"
87
- priority="secondary"
88
- type="negative"
89
- onClick={action('button click')}
90
- >
91
- <Edit />
143
+ <IconButton priority={args.priority} type="negative" aria-label="Negative" onClick={fn()}>
144
+ <Cross />
92
145
  </IconButton>
93
146
  </>
94
- );
147
+ ),
95
148
  };
96
149
 
97
- export const Basic: Story = {
98
- render: () => {
99
- return (
100
- <div
101
- style={{
102
- gap: '1em',
103
- display: 'grid',
104
- justifyContent: 'space-between',
105
- gridTemplate: `auto auto / repeat(6, min-content)`,
106
- }}
107
- >
108
- {['Primary', 'Secondary', 'Tertiary', 'Minimal', 'Neg primary', 'Neg secondary'].map(
109
- (variant) => (
110
- <Body key={variant} type="body-default-bold">
111
- {variant}
112
- </Body>
113
- ),
114
- )}
115
- {sizes.map((size) => (
116
- <Template key={size} size={size} />
117
- ))}
118
- <Template size={72} disabled />
150
+ /**
151
+ * IconButton is available in 7 sizes: 16, 24, 32, 40, 48, 56, 72. <br />
152
+ * <a href="https://wise.design/components/icon-button#sizes" target="_blank">Design documentation</a>
153
+ */
154
+ export const Size: Story = {
155
+ args: {
156
+ priority: 'primary',
157
+ type: 'default',
158
+ },
159
+ argTypes: {
160
+ priority: {
161
+ control: 'radio',
162
+ options: ['primary', 'secondary', 'tertiary', 'minimal'],
163
+ },
164
+ type: {
165
+ control: 'radio',
166
+ options: ['default', 'negative'],
167
+ },
168
+ size: { table: { disable: true } },
169
+ disabled: { table: { disable: true } },
170
+ href: { table: { disable: true } },
171
+ target: { table: { disable: true } },
172
+ onClick: { table: { disable: true } },
173
+ },
174
+ decorators: [
175
+ (Story) => (
176
+ <div style={{ display: 'flex', gap: '24px', alignItems: 'center' }}>
177
+ <Story />
119
178
  </div>
120
- );
179
+ ),
180
+ ],
181
+ render: (args: Props) => (
182
+ <>
183
+ {sizes.map((size) => (
184
+ <div
185
+ key={size}
186
+ style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px' }}
187
+ >
188
+ <IconButton
189
+ size={size}
190
+ priority={args.priority}
191
+ type={args.type}
192
+ aria-label={`${size}px`}
193
+ >
194
+ <ArrowLeft />
195
+ </IconButton>
196
+ <span style={{ fontSize: '12px' }}>{size}px</span>
197
+ </div>
198
+ ))}
199
+ </>
200
+ ),
201
+ parameters: {
202
+ docs: {
203
+ source: {
204
+ code: `{[16, 24, 32, 40, 48, 56, 72].map((size) => (
205
+ <div key={size}>
206
+ <IconButton size={size} priority="primary" type="default" aria-label={\`\${size}px\`}>
207
+ <ArrowLeft />
208
+ </IconButton>
209
+ <span>{size}px</span>
210
+ </div>
211
+ ))}`,
212
+ },
213
+ },
214
+ },
215
+ };
216
+
217
+ /**
218
+ * Disabled buttons cannot be interacted with and are visually distinct.
219
+ */
220
+ export const Disabled: Story = {
221
+ args: {
222
+ priority: 'primary',
223
+ type: 'default',
224
+ },
225
+ argTypes: {
226
+ priority: {
227
+ control: 'radio',
228
+ options: ['primary', 'secondary', 'tertiary', 'minimal'],
229
+ },
230
+ type: {
231
+ control: 'radio',
232
+ options: ['default', 'negative'],
233
+ },
234
+ size: { table: { disable: true } },
235
+ disabled: { table: { disable: true } },
236
+ href: { table: { disable: true } },
237
+ target: { table: { disable: true } },
238
+ onClick: { table: { disable: true } },
121
239
  },
240
+ render: (args: Props) => (
241
+ <IconButton disabled priority={args.priority} type={args.type} aria-label="Disabled">
242
+ <Plus />
243
+ </IconButton>
244
+ ),
245
+ };
246
+
247
+ /**
248
+ * IconButton can render as an anchor element when `href` is provided.
249
+ */
250
+ export const AsAnchor: Story = {
251
+ args: {
252
+ priority: 'primary',
253
+ type: 'default',
254
+ href: 'https://wise.com',
255
+ target: '_blank',
256
+ },
257
+ argTypes: {
258
+ priority: {
259
+ control: 'radio',
260
+ options: ['primary', 'secondary', 'tertiary', 'minimal'],
261
+ },
262
+ type: {
263
+ control: 'radio',
264
+ options: ['default', 'negative'],
265
+ },
266
+ size: { table: { disable: true } },
267
+ disabled: { table: { disable: true } },
268
+ onClick: { table: { disable: true } },
269
+ },
270
+ render: (args: Props) => (
271
+ <IconButton {...args} aria-label="External link">
272
+ <ArrowLeft />
273
+ </IconButton>
274
+ ),
122
275
  };
123
276
 
124
277
  /**
@@ -126,8 +279,25 @@ export const Basic: Story = {
126
279
  * the [SentimentSurface](?path=/docs/foundations-sentimentsurface--docs) component
127
280
  */
128
281
  export const SentimentAwareness: Story = {
129
- render: () => {
130
- const priorities = ['primary', 'secondary', 'tertiary', 'minimal', 'disabled'] as const;
282
+ args: {
283
+ size: 48,
284
+ },
285
+ argTypes: {
286
+ size: {
287
+ control: 'radio',
288
+ options: [16, 24, 32, 40, 48, 56, 72],
289
+ },
290
+ },
291
+ render: (args: Props) => {
292
+ const priorities = [
293
+ { key: 'primary', label: 'primary' },
294
+ { key: 'secondary', label: 'secondary' },
295
+ { key: 'tertiary', label: 'tertiary' },
296
+ { key: 'minimal', label: 'minimal' },
297
+ { key: 'neg-primary', label: 'negative\nprimary' },
298
+ { key: 'neg-secondary', label: 'negative\nsecondary' },
299
+ { key: 'disabled', label: 'disabled' },
300
+ ] as const;
131
301
  const sentiments = ['success', 'warning', 'negative', 'neutral', 'proposition'] as const;
132
302
 
133
303
  return (
@@ -137,21 +307,23 @@ export const SentimentAwareness: Story = {
137
307
  <div style={{ width: '82px', paddingLeft: '8px' }} />
138
308
  {priorities.map((priority) => (
139
309
  <div
140
- key={priority}
310
+ key={priority.key}
141
311
  style={{
142
- width: '32px',
312
+ width: `${args.size}px`,
143
313
  textAlign: 'center',
144
314
  fontSize: '11px',
145
315
  fontWeight: 'bold',
146
316
  writingMode: 'vertical-rl',
147
317
  transform: 'rotate(180deg)',
148
- height: '60px',
318
+ height: '80px',
149
319
  display: 'flex',
150
320
  alignItems: 'center',
151
321
  justifyContent: 'center',
322
+ whiteSpace: 'pre',
323
+ lineHeight: '1',
152
324
  }}
153
325
  >
154
- {priority}
326
+ {priority.label}
155
327
  </div>
156
328
  ))}
157
329
  </div>
@@ -176,48 +348,66 @@ export const SentimentAwareness: Story = {
176
348
  {sentiment} (base)
177
349
  </div>
178
350
  <IconButton
179
- size={32}
351
+ size={args.size}
180
352
  aria-label="Primary action"
181
353
  priority="primary"
182
354
  type="default"
183
- onClick={action('button click')}
355
+ onClick={fn()}
184
356
  >
185
357
  <Plus />
186
358
  </IconButton>
187
359
  <IconButton
188
- size={32}
360
+ size={args.size}
189
361
  aria-label="Secondary action"
190
362
  priority="secondary"
191
363
  type="default"
192
- onClick={action('button click')}
364
+ onClick={fn()}
193
365
  >
194
366
  <Settings />
195
367
  </IconButton>
196
368
  <IconButton
197
- size={32}
369
+ size={args.size}
198
370
  aria-label="Tertiary action"
199
371
  priority="tertiary"
200
372
  type="default"
201
- onClick={action('button click')}
373
+ onClick={fn()}
202
374
  >
203
375
  <Star />
204
376
  </IconButton>
205
377
  <IconButton
206
- size={32}
378
+ size={args.size}
207
379
  aria-label="Minimal action"
208
380
  priority="minimal"
209
381
  type="default"
210
- onClick={action('button click')}
382
+ onClick={fn()}
211
383
  >
212
384
  <Travel />
213
385
  </IconButton>
214
386
  <IconButton
215
- size={32}
387
+ size={args.size}
388
+ aria-label="Negative primary action"
389
+ priority="primary"
390
+ type="negative"
391
+ onClick={fn()}
392
+ >
393
+ <Cross />
394
+ </IconButton>
395
+ <IconButton
396
+ size={args.size}
397
+ aria-label="Negative secondary action"
398
+ priority="secondary"
399
+ type="negative"
400
+ onClick={fn()}
401
+ >
402
+ <Edit />
403
+ </IconButton>
404
+ <IconButton
405
+ size={args.size}
216
406
  aria-label="Disabled action"
217
407
  priority="primary"
218
408
  type="default"
219
409
  disabled
220
- onClick={action('button click')}
410
+ onClick={fn()}
221
411
  >
222
412
  <Menu />
223
413
  </IconButton>
@@ -240,48 +430,66 @@ export const SentimentAwareness: Story = {
240
430
  {sentiment} (elevated)
241
431
  </div>
242
432
  <IconButton
243
- size={32}
433
+ size={args.size}
244
434
  aria-label="Primary action"
245
435
  priority="primary"
246
436
  type="default"
247
- onClick={action('button click')}
437
+ onClick={fn()}
248
438
  >
249
439
  <Briefcase />
250
440
  </IconButton>
251
441
  <IconButton
252
- size={32}
442
+ size={args.size}
253
443
  aria-label="Secondary action"
254
444
  priority="secondary"
255
445
  type="default"
256
- onClick={action('button click')}
446
+ onClick={fn()}
257
447
  >
258
448
  <Bank />
259
449
  </IconButton>
260
450
  <IconButton
261
- size={32}
451
+ size={args.size}
262
452
  aria-label="Tertiary action"
263
453
  priority="tertiary"
264
454
  type="default"
265
- onClick={action('button click')}
455
+ onClick={fn()}
266
456
  >
267
457
  <Freeze />
268
458
  </IconButton>
269
459
  <IconButton
270
- size={32}
460
+ size={args.size}
271
461
  aria-label="Minimal action"
272
462
  priority="minimal"
273
463
  type="default"
274
- onClick={action('button click')}
464
+ onClick={fn()}
275
465
  >
276
466
  <Edit />
277
467
  </IconButton>
278
468
  <IconButton
279
- size={32}
469
+ size={args.size}
470
+ aria-label="Negative primary action"
471
+ priority="primary"
472
+ type="negative"
473
+ onClick={fn()}
474
+ >
475
+ <Cross />
476
+ </IconButton>
477
+ <IconButton
478
+ size={args.size}
479
+ aria-label="Negative secondary action"
480
+ priority="secondary"
481
+ type="negative"
482
+ onClick={fn()}
483
+ >
484
+ <Edit />
485
+ </IconButton>
486
+ <IconButton
487
+ size={args.size}
280
488
  aria-label="Disabled action"
281
489
  priority="primary"
282
490
  type="default"
283
491
  disabled
284
- onClick={action('button click')}
492
+ onClick={fn()}
285
493
  >
286
494
  <Cross />
287
495
  </IconButton>
@@ -292,10 +500,7 @@ export const SentimentAwareness: Story = {
292
500
  },
293
501
  parameters: {
294
502
  docs: {
295
- source: { type: 'dynamic' },
296
- canvas: {
297
- sourceState: 'hidden',
298
- },
503
+ canvas: { sourceState: 'hidden' },
299
504
  },
300
505
  },
301
506
  };