@transferwise/components 0.0.0-experimental-28a3dd5 → 0.0.0-experimental-c5e7eab
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.
|
@@ -4,6 +4,13 @@ export type ButtonSentiment = 'default' | 'negative';
|
|
|
4
4
|
export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
5
5
|
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
6
6
|
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
7
|
+
type ButtonAddonStart = {
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
avatars?: AvatarLayoutProps['avatars'];
|
|
10
|
+
};
|
|
11
|
+
type ButtonAddonEnd = {
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
};
|
|
7
14
|
/**
|
|
8
15
|
* Common properties for the Button component.
|
|
9
16
|
*/
|
|
@@ -42,24 +49,13 @@ export interface CommonProps {
|
|
|
42
49
|
* @default default
|
|
43
50
|
*/
|
|
44
51
|
sentiment?: ButtonSentiment;
|
|
45
|
-
/**
|
|
46
|
-
iconStart?: React.ElementType;
|
|
47
|
-
/** Icon to be displayed on the right side of the button */
|
|
48
|
-
iconEnd?: React.ElementType;
|
|
49
|
-
/** Media to be displayed on the left side of the button */
|
|
50
|
-
avatars?: AvatarLayoutProps['avatars'];
|
|
51
|
-
/** Content to be displayed inside the button */
|
|
52
|
-
children?: ReactNode;
|
|
52
|
+
/** Accessory to be displayed before the label */
|
|
53
53
|
addonStart?: ButtonAddonStart;
|
|
54
|
+
/** Accessory to be displayed after the label */
|
|
54
55
|
addonEnd?: ButtonAddonEnd;
|
|
56
|
+
/** Content to be displayed inside the button */
|
|
57
|
+
children?: ReactNode;
|
|
55
58
|
}
|
|
56
|
-
type ButtonAddonStart = {
|
|
57
|
-
icon?: React.ReactNode;
|
|
58
|
-
avatars?: AvatarLayoutProps['avatars'];
|
|
59
|
-
};
|
|
60
|
-
type ButtonAddonEnd = {
|
|
61
|
-
icon?: React.ReactNode;
|
|
62
|
-
};
|
|
63
59
|
export type ButtonElementProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled' | 'className'> & CommonProps;
|
|
64
60
|
export type AnchorElementProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'type' | 'disabled' | 'href' | 'className'> & CommonProps;
|
|
65
61
|
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAExE,KAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;CACxC,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,IAAI,CAAC;IAET;;;QAGI;IACJ,EAAE,CAAC,EAAE,QAAQ,GAAG,GAAG,CAAC;IAEpB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;QAEI;IACJ,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;SAEK;IACL,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;SAGK;IACL,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,iDAAiD;IACjD,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,WAAW,CACzB,GACC,WAAW,CAAC;AACd,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAC3C,GACC,WAAW,CAAC;AAEd,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-c5e7eab",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
"rollup": "^4.18.1",
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
|
-
"@transferwise/
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
94
|
+
"@transferwise/neptune-css": "0.0.0-experimental-c5e7eab",
|
|
95
|
+
"@wise/components-theming": "1.6.1",
|
|
96
|
+
"@transferwise/less-config": "3.1.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
100
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
100
|
+
"@transferwise/neptune-css": "0.0.0-experimental-c5e7eab",
|
|
101
101
|
"@wise/art": "^2.16",
|
|
102
102
|
"@wise/components-theming": "^1.0.0",
|
|
103
103
|
"react": ">=18",
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { fn } from '@storybook/test';
|
|
3
|
-
import {
|
|
4
|
-
Freeze,
|
|
5
|
-
ArrowRight,
|
|
6
|
-
ArrowLeft,
|
|
7
|
-
ArrowDiagonalDown,
|
|
8
|
-
ArrowDiagonalUp,
|
|
9
|
-
ChevronRight,
|
|
10
|
-
ChevronLeft,
|
|
11
|
-
} from '@transferwise/icons';
|
|
3
|
+
import { Freeze, ArrowRight, ChevronRight } from '@transferwise/icons';
|
|
12
4
|
import { Flag } from '@wise/art';
|
|
13
5
|
import Button from './Button.resolver';
|
|
14
6
|
import type { ButtonProps, ButtonPriority } from './Button.types';
|
|
@@ -17,13 +9,6 @@ import { storyConfig } from '../test-utils';
|
|
|
17
9
|
const withContainer = (Story: any) => (
|
|
18
10
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
19
11
|
<Story />
|
|
20
|
-
<Button v2 addonStart={{ icon: <Freeze />, avatars: [{ profileName: 'Test Test' }] }}>
|
|
21
|
-
Button
|
|
22
|
-
</Button>
|
|
23
|
-
|
|
24
|
-
<Button v2 addonEnd={{ icon: <Freeze /> }}>
|
|
25
|
-
Button
|
|
26
|
-
</Button>
|
|
27
12
|
</div>
|
|
28
13
|
);
|
|
29
14
|
|
|
@@ -54,9 +39,8 @@ const withComponentGrid =
|
|
|
54
39
|
*/
|
|
55
40
|
const hideControls = (args: string[]) => {
|
|
56
41
|
const hidden = [
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'iconEnd',
|
|
42
|
+
'addonStart',
|
|
43
|
+
'addonEnd',
|
|
60
44
|
'onClick',
|
|
61
45
|
'onBlur',
|
|
62
46
|
'onFocus',
|
|
@@ -69,84 +53,72 @@ const hideControls = (args: string[]) => {
|
|
|
69
53
|
return Object.fromEntries(hidden.map((item) => [item, { table: { disable: true } }]));
|
|
70
54
|
};
|
|
71
55
|
|
|
72
|
-
/**
|
|
73
|
-
* SB code generation is often not ideal, rendering confusing source.
|
|
74
|
-
* This helper makes icon values more understandable for the stories below.
|
|
75
|
-
*/
|
|
76
|
-
const augmentIconProps = ({ start = 'Freeze', end = 'ArrowRight' } = {}) => ({
|
|
77
|
-
docs: {
|
|
78
|
-
source: {
|
|
79
|
-
transform(value: string): string {
|
|
80
|
-
return value
|
|
81
|
-
.replace(/iconStart=.*?\}+/g, `iconStart={${start}}`)
|
|
82
|
-
.replace(/iconEnd=.*?\}+/g, `iconEnd={${end}}`);
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
56
|
/**
|
|
89
57
|
* Convenience controls for previewing rich markup,
|
|
90
58
|
* not otherwise possible via Storybook
|
|
91
59
|
*/
|
|
92
60
|
type PreviewStoryArgs = Parameters<typeof Button>[0] & {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
previewIconEnd: boolean | ButtonProps['iconEnd'];
|
|
61
|
+
previewAddonStart: boolean | ButtonProps['addonStart'];
|
|
62
|
+
previewAddonEnd: boolean | ButtonProps['addonEnd'];
|
|
96
63
|
};
|
|
97
64
|
const previewArgTypes = {
|
|
98
|
-
|
|
99
|
-
control: '
|
|
100
|
-
|
|
65
|
+
previewAddonStart: {
|
|
66
|
+
control: 'select',
|
|
67
|
+
options: [
|
|
68
|
+
'undefined',
|
|
69
|
+
'icon',
|
|
70
|
+
'avatar: flag',
|
|
71
|
+
'avatar: initials',
|
|
72
|
+
'avatar: icon',
|
|
73
|
+
'avatar: image',
|
|
74
|
+
'avatar: double',
|
|
75
|
+
],
|
|
76
|
+
name: 'Preview with `addonStart`',
|
|
101
77
|
mapping: {
|
|
102
|
-
|
|
78
|
+
undefined,
|
|
79
|
+
icon: { icon: <Freeze /> },
|
|
80
|
+
'avatar: flag': { avatars: [{ asset: <Flag code="pl" /> }] },
|
|
81
|
+
'avatar: initials': { avatars: [{ profileName: 'Jay Jay' }] },
|
|
82
|
+
'avatar: icon': { avatars: [{ asset: <Freeze /> }] },
|
|
83
|
+
'avatar: image': { avatars: [{ imgSrc: '../avatar-square-dude.webp' }] },
|
|
84
|
+
'avatar: double': {
|
|
85
|
+
avatars: [{ asset: <Flag code="gb" /> }, { imgSrc: '../avatar-square-dude.webp' }],
|
|
86
|
+
},
|
|
103
87
|
},
|
|
104
88
|
table: {
|
|
105
89
|
category: 'Preview options',
|
|
90
|
+
type: {
|
|
91
|
+
summary: undefined,
|
|
92
|
+
},
|
|
106
93
|
},
|
|
107
94
|
},
|
|
108
|
-
|
|
95
|
+
previewAddonEnd: {
|
|
109
96
|
control: 'boolean',
|
|
110
|
-
name: '
|
|
111
|
-
mapping: {
|
|
112
|
-
true: ArrowRight,
|
|
113
|
-
},
|
|
114
|
-
table: {
|
|
115
|
-
category: 'Preview options',
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
previewAvatars: {
|
|
119
|
-
control: 'select',
|
|
120
|
-
options: ['undefined', 'flag', 'initials', 'icon', 'image', 'double'],
|
|
121
|
-
name: 'Show with Avatar',
|
|
97
|
+
name: 'Preview with `addonEnd`',
|
|
122
98
|
mapping: {
|
|
123
|
-
|
|
124
|
-
flag: [{ asset: <Flag code="pl" /> }],
|
|
125
|
-
initials: [{ profileName: 'Jay Jay' }],
|
|
126
|
-
icon: [{ asset: <Freeze /> }],
|
|
127
|
-
image: [{ imgSrc: '../avatar-square-dude.webp' }],
|
|
128
|
-
double: [{ asset: <Flag code="gb" /> }, { imgSrc: '../avatar-square-dude.webp' }],
|
|
99
|
+
true: { icon: <ArrowRight /> },
|
|
129
100
|
},
|
|
130
101
|
table: {
|
|
131
102
|
category: 'Preview options',
|
|
103
|
+
type: {
|
|
104
|
+
summary: undefined,
|
|
105
|
+
},
|
|
132
106
|
},
|
|
133
107
|
},
|
|
134
108
|
} as const;
|
|
135
109
|
|
|
136
110
|
const getPropsForPreview = (args: PreviewStoryArgs) => {
|
|
137
|
-
const {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
previewIconEnd: ButtonProps['iconEnd'];
|
|
111
|
+
const { previewAddonStart, previewAddonEnd, ...props } = args as {
|
|
112
|
+
previewAddonStart: ButtonProps['addonStart'];
|
|
113
|
+
previewAddonEnd: ButtonProps['addonEnd'];
|
|
141
114
|
props: typeof Button;
|
|
142
115
|
};
|
|
143
116
|
|
|
144
117
|
return [
|
|
145
118
|
props,
|
|
146
119
|
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
iconEnd: previewIconEnd,
|
|
120
|
+
addonStart: previewAddonStart,
|
|
121
|
+
addonEnd: previewAddonEnd,
|
|
150
122
|
},
|
|
151
123
|
];
|
|
152
124
|
};
|
|
@@ -221,13 +193,10 @@ const meta: Meta<typeof Button> = {
|
|
|
221
193
|
},
|
|
222
194
|
description: 'If set, the component will render as an HTML anchor.',
|
|
223
195
|
},
|
|
224
|
-
|
|
196
|
+
addonStart: {
|
|
225
197
|
control: 'object',
|
|
226
198
|
},
|
|
227
|
-
|
|
228
|
-
control: 'object',
|
|
229
|
-
},
|
|
230
|
-
avatars: {
|
|
199
|
+
addonEnd: {
|
|
231
200
|
control: 'object',
|
|
232
201
|
},
|
|
233
202
|
type: {
|
|
@@ -252,9 +221,8 @@ const meta: Meta<typeof Button> = {
|
|
|
252
221
|
href: undefined,
|
|
253
222
|
as: undefined,
|
|
254
223
|
type: undefined,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
avatars: undefined,
|
|
224
|
+
addonStart: undefined,
|
|
225
|
+
addonEnd: undefined,
|
|
258
226
|
className: undefined,
|
|
259
227
|
onClick: fn(),
|
|
260
228
|
children: 'Button text',
|
|
@@ -279,9 +247,8 @@ export const Playground: StoryObj<PreviewStoryArgs> = {
|
|
|
279
247
|
onKeyDown: fn(),
|
|
280
248
|
onMouseEnter: fn(),
|
|
281
249
|
onMouseLeave: fn(),
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
previewAvatars: false,
|
|
250
|
+
previewAddonStart: false,
|
|
251
|
+
previewAddonEnd: false,
|
|
285
252
|
},
|
|
286
253
|
argTypes: {
|
|
287
254
|
onClick: { table: { disable: true } },
|
|
@@ -326,12 +293,10 @@ export const Sentiment: StoryObj<PreviewStoryArgs> = {
|
|
|
326
293
|
...previewArgTypes,
|
|
327
294
|
},
|
|
328
295
|
args: {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
previewAvatars: false,
|
|
296
|
+
previewAddonStart: false,
|
|
297
|
+
previewAddonEnd: false,
|
|
332
298
|
},
|
|
333
299
|
decorators: [withComponentGrid('30rem')],
|
|
334
|
-
parameters: augmentIconProps(),
|
|
335
300
|
};
|
|
336
301
|
|
|
337
302
|
/**
|
|
@@ -365,9 +330,8 @@ export const Priority: StoryObj<PreviewStoryArgs> = {
|
|
|
365
330
|
...previewArgTypes,
|
|
366
331
|
},
|
|
367
332
|
args: {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
previewAvatars: false,
|
|
333
|
+
previewAddonStart: false,
|
|
334
|
+
previewAddonEnd: false,
|
|
371
335
|
},
|
|
372
336
|
decorators: [withComponentGrid()],
|
|
373
337
|
};
|
|
@@ -399,9 +363,8 @@ export const Size: StoryObj<PreviewStoryArgs> = {
|
|
|
399
363
|
...previewArgTypes,
|
|
400
364
|
},
|
|
401
365
|
args: {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
previewAvatars: false,
|
|
366
|
+
previewAddonStart: false,
|
|
367
|
+
previewAddonEnd: false,
|
|
405
368
|
},
|
|
406
369
|
decorators: [withComponentGrid()],
|
|
407
370
|
};
|
|
@@ -426,9 +389,8 @@ export const AsAnchor: StoryObj<PreviewStoryArgs> = {
|
|
|
426
389
|
args: {
|
|
427
390
|
as: 'a',
|
|
428
391
|
href: 'https://wise.com',
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
previewAvatars: false,
|
|
392
|
+
previewAddonStart: false,
|
|
393
|
+
previewAddonEnd: false,
|
|
432
394
|
onClick: undefined,
|
|
433
395
|
},
|
|
434
396
|
};
|
|
@@ -449,9 +411,8 @@ export const Disabled: StoryObj<PreviewStoryArgs> = {
|
|
|
449
411
|
},
|
|
450
412
|
args: {
|
|
451
413
|
disabled: true,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
previewAvatars: false,
|
|
414
|
+
previewAddonStart: false,
|
|
415
|
+
previewAddonEnd: false,
|
|
455
416
|
},
|
|
456
417
|
};
|
|
457
418
|
|
|
@@ -471,9 +432,8 @@ export const Loading: StoryObj<PreviewStoryArgs> = {
|
|
|
471
432
|
},
|
|
472
433
|
args: {
|
|
473
434
|
loading: true,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
previewAvatars: false,
|
|
435
|
+
previewAddonStart: false,
|
|
436
|
+
previewAddonEnd: false,
|
|
477
437
|
},
|
|
478
438
|
};
|
|
479
439
|
|
|
@@ -496,9 +456,8 @@ export const DisplayBlock: StoryObj<PreviewStoryArgs> = {
|
|
|
496
456
|
},
|
|
497
457
|
args: {
|
|
498
458
|
block: true,
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
previewAvatars: false,
|
|
459
|
+
previewAddonStart: false,
|
|
460
|
+
previewAddonEnd: false,
|
|
502
461
|
},
|
|
503
462
|
};
|
|
504
463
|
|
|
@@ -512,15 +471,15 @@ export const WithIcons: StoryObj<PreviewStoryArgs> = {
|
|
|
512
471
|
|
|
513
472
|
return (
|
|
514
473
|
<>
|
|
515
|
-
<Button {...props}
|
|
474
|
+
<Button {...props} addonStart={{ icon: <Freeze /> }}>
|
|
516
475
|
With start icon
|
|
517
476
|
</Button>
|
|
518
477
|
|
|
519
|
-
<Button {...props}
|
|
478
|
+
<Button {...props} addonEnd={{ icon: <ArrowRight /> }}>
|
|
520
479
|
With end icon
|
|
521
480
|
</Button>
|
|
522
481
|
|
|
523
|
-
<Button {...props}
|
|
482
|
+
<Button {...props} addonStart={{ icon: <Freeze /> }} addonEnd={{ icon: <ArrowRight /> }}>
|
|
524
483
|
With both icons
|
|
525
484
|
</Button>
|
|
526
485
|
</>
|
|
@@ -532,7 +491,27 @@ export const WithIcons: StoryObj<PreviewStoryArgs> = {
|
|
|
532
491
|
args: {
|
|
533
492
|
size: 'md',
|
|
534
493
|
},
|
|
535
|
-
parameters:
|
|
494
|
+
parameters: {
|
|
495
|
+
docs: {
|
|
496
|
+
source: {
|
|
497
|
+
code: `
|
|
498
|
+
<>
|
|
499
|
+
<Button size="md" addonStart={{ icon: <Freeze /> }}>
|
|
500
|
+
With start icon
|
|
501
|
+
</Button>
|
|
502
|
+
|
|
503
|
+
<Button size="md" addonEnd={{ icon: <ArrowRight /> }}>
|
|
504
|
+
With end icon
|
|
505
|
+
</Button>
|
|
506
|
+
|
|
507
|
+
<Button size="md" addonStart={{ icon: <Freeze /> }} addonEnd={{ icon: <ArrowRight /> }}>
|
|
508
|
+
With both icons
|
|
509
|
+
</Button>
|
|
510
|
+
</>
|
|
511
|
+
`,
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
},
|
|
536
515
|
decorators: [withComponentGrid()],
|
|
537
516
|
};
|
|
538
517
|
|
|
@@ -546,19 +525,22 @@ export const WithAvatars: StoryObj<PreviewStoryArgs> = {
|
|
|
546
525
|
|
|
547
526
|
return (
|
|
548
527
|
<>
|
|
549
|
-
<Button {...props}
|
|
528
|
+
<Button {...props} addonStart={{ avatars: [{ asset: <Freeze /> }] }}>
|
|
550
529
|
With single avatar
|
|
551
530
|
</Button>
|
|
552
531
|
|
|
553
|
-
<Button
|
|
532
|
+
<Button
|
|
533
|
+
{...props}
|
|
534
|
+
addonStart={{ avatars: [{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }] }}
|
|
535
|
+
>
|
|
554
536
|
With double avatar
|
|
555
537
|
</Button>
|
|
556
538
|
|
|
557
|
-
<Button {...props}
|
|
539
|
+
<Button {...props} addonStart={{ avatars: [{ profileName: 'John Doe' }] }}>
|
|
558
540
|
With initials
|
|
559
541
|
</Button>
|
|
560
542
|
|
|
561
|
-
<Button {...props}
|
|
543
|
+
<Button {...props} addonStart={{ avatars: [{ imgSrc: '../avatar-square-dude.webp' }] }}>
|
|
562
544
|
With an image
|
|
563
545
|
</Button>
|
|
564
546
|
</>
|
|
@@ -567,25 +549,25 @@ export const WithAvatars: StoryObj<PreviewStoryArgs> = {
|
|
|
567
549
|
argTypes: hideControls(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
|
|
568
550
|
args: {
|
|
569
551
|
size: 'md',
|
|
570
|
-
|
|
552
|
+
addonStart: {},
|
|
571
553
|
},
|
|
572
554
|
parameters: {
|
|
573
555
|
docs: {
|
|
574
556
|
source: {
|
|
575
557
|
code: `
|
|
576
558
|
<>
|
|
577
|
-
<Button v2 size="md"
|
|
559
|
+
<Button v2 size="md" addonStart={{ avatars: [{ asset: <Freeze /> }]}}>
|
|
578
560
|
With single avatar
|
|
579
561
|
</Button>
|
|
580
|
-
|
|
562
|
+
|
|
581
563
|
<Button v2 size="md" avatars={[{ asset: <Flag code="br" /> }, { asset: <Flag code="jp" /> }]}>
|
|
582
564
|
With double avatar
|
|
583
565
|
</Button>
|
|
584
|
-
|
|
566
|
+
|
|
585
567
|
<Button v2 size="md" avatars={[{ profileName: 'John Doe' }]}>
|
|
586
568
|
With initials
|
|
587
569
|
</Button>
|
|
588
|
-
|
|
570
|
+
|
|
589
571
|
<Button v2 size="md" avatars={[{ imgSrc: '../avatar-square-dude.webp' }]}>
|
|
590
572
|
With image Avatar
|
|
591
573
|
</Button>
|
|
@@ -598,17 +580,17 @@ export const WithAvatars: StoryObj<PreviewStoryArgs> = {
|
|
|
598
580
|
};
|
|
599
581
|
|
|
600
582
|
/**
|
|
601
|
-
* Avatar will always take precedence over `
|
|
583
|
+
* Avatar will always take precedence over an icon for `addonStart`
|
|
602
584
|
*/
|
|
603
585
|
export const WithAvatarAndIcon: Story = {
|
|
604
586
|
args: {
|
|
605
587
|
size: 'md',
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
588
|
+
addonStart: {
|
|
589
|
+
avatars: [{ profileName: 'John Doe' }],
|
|
590
|
+
icon: <ArrowRight />,
|
|
591
|
+
},
|
|
609
592
|
},
|
|
610
593
|
argTypes: hideControls(['href', 'target', 'as', 'children']),
|
|
611
|
-
parameters: augmentIconProps(),
|
|
612
594
|
};
|
|
613
595
|
|
|
614
596
|
const buttonPriorities = ['primary', 'secondary', 'tertiary', 'minimal'] as const;
|
|
@@ -635,9 +617,8 @@ export const AllVariants = storyConfig(
|
|
|
635
617
|
v2
|
|
636
618
|
priority={priority as ButtonPriority}
|
|
637
619
|
size={size}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
avatars={[{ asset: <Freeze /> }]}
|
|
620
|
+
addonStart={{ avatars: [{ asset: <Freeze /> }] }}
|
|
621
|
+
addonEnd={{ icon: <ArrowRight /> }}
|
|
641
622
|
block
|
|
642
623
|
href="https://wise.com"
|
|
643
624
|
target="_blank"
|
|
@@ -649,9 +630,8 @@ export const AllVariants = storyConfig(
|
|
|
649
630
|
v2
|
|
650
631
|
priority={priority as ButtonPriority}
|
|
651
632
|
size={size}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
avatars={[{ asset: <Freeze /> }, { asset: <Freeze /> }]}
|
|
633
|
+
addonStart={{ avatars: [{ asset: <Freeze /> }, { asset: <Freeze /> }] }}
|
|
634
|
+
addonEnd={{ icon: <ArrowRight /> }}
|
|
655
635
|
block
|
|
656
636
|
disabled
|
|
657
637
|
>
|
|
@@ -661,9 +641,8 @@ export const AllVariants = storyConfig(
|
|
|
661
641
|
v2
|
|
662
642
|
priority={priority as ButtonPriority}
|
|
663
643
|
size={size}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
avatars={[{ asset: <Freeze /> }]}
|
|
644
|
+
addonStart={{ avatars: [{ asset: <Freeze /> }] }}
|
|
645
|
+
addonEnd={{ icon: <ArrowRight /> }}
|
|
667
646
|
block
|
|
668
647
|
loading
|
|
669
648
|
>
|
|
@@ -683,9 +662,8 @@ export const AllVariants = storyConfig(
|
|
|
683
662
|
sentiment="negative"
|
|
684
663
|
priority={priority as ButtonPriority}
|
|
685
664
|
size={size}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
avatars={[{ asset: <Freeze /> }]}
|
|
665
|
+
addonEnd={{ icon: <ChevronRight /> }}
|
|
666
|
+
addonStart={{ avatars: [{ asset: <Freeze /> }] }}
|
|
689
667
|
block
|
|
690
668
|
href="https://wise.com"
|
|
691
669
|
target="_blank"
|
|
@@ -698,9 +676,8 @@ export const AllVariants = storyConfig(
|
|
|
698
676
|
sentiment="negative"
|
|
699
677
|
priority={priority as ButtonPriority}
|
|
700
678
|
size={size}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
avatars={[{ asset: <Freeze /> }]}
|
|
679
|
+
addonEnd={{ icon: <ChevronRight /> }}
|
|
680
|
+
addonStart={{ avatars: [{ asset: <Freeze /> }] }}
|
|
704
681
|
block
|
|
705
682
|
disabled
|
|
706
683
|
>
|
|
@@ -711,9 +688,8 @@ export const AllVariants = storyConfig(
|
|
|
711
688
|
sentiment="negative"
|
|
712
689
|
priority={priority as ButtonPriority}
|
|
713
690
|
size={size}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
avatars={[{ asset: <Freeze /> }]}
|
|
691
|
+
addonEnd={{ icon: <ChevronRight /> }}
|
|
692
|
+
addonStart={{ avatars: [{ asset: <Freeze /> }] }}
|
|
717
693
|
block
|
|
718
694
|
loading
|
|
719
695
|
>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import type { PrimitiveButtonProps, PrimitiveAnchorProps } from '../primitives';
|
|
3
2
|
import type { AvatarLayoutProps } from '../avatarLayout';
|
|
4
3
|
|
|
5
4
|
export type ButtonSentiment = 'default' | 'negative';
|
|
@@ -7,6 +6,15 @@ export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
|
7
6
|
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
8
7
|
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
9
8
|
|
|
9
|
+
type ButtonAddonStart = {
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
avatars?: AvatarLayoutProps['avatars'];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type ButtonAddonEnd = {
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
10
18
|
/**
|
|
11
19
|
* Common properties for the Button component.
|
|
12
20
|
*/
|
|
@@ -55,31 +63,16 @@ export interface CommonProps {
|
|
|
55
63
|
*/
|
|
56
64
|
sentiment?: ButtonSentiment;
|
|
57
65
|
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/** Icon to be displayed on the right side of the button */
|
|
62
|
-
iconEnd?: React.ElementType;
|
|
66
|
+
/** Accessory to be displayed before the label */
|
|
67
|
+
addonStart?: ButtonAddonStart;
|
|
63
68
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
69
|
+
/** Accessory to be displayed after the label */
|
|
70
|
+
addonEnd?: ButtonAddonEnd;
|
|
66
71
|
|
|
67
72
|
/** Content to be displayed inside the button */
|
|
68
73
|
children?: ReactNode;
|
|
69
|
-
|
|
70
|
-
addonStart?: ButtonAddonStart;
|
|
71
|
-
addonEnd?: ButtonAddonEnd;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
type ButtonAddonStart = {
|
|
75
|
-
icon?: React.ReactNode;
|
|
76
|
-
avatars?: AvatarLayoutProps['avatars'];
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
type ButtonAddonEnd = {
|
|
80
|
-
icon?: React.ReactNode;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
76
|
export type ButtonElementProps = Omit<
|
|
84
77
|
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
85
78
|
'disabled' | 'className'
|
|
@@ -61,17 +61,12 @@ const meta: Meta<typeof Button> = {
|
|
|
61
61
|
disable: true,
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
addonStart: {
|
|
65
65
|
table: {
|
|
66
66
|
disable: true,
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
|
-
|
|
70
|
-
table: {
|
|
71
|
-
disable: true,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
avatars: {
|
|
69
|
+
addonEnd: {
|
|
75
70
|
table: {
|
|
76
71
|
disable: true,
|
|
77
72
|
},
|