@transferwise/components 0.0.0-experimental-4aed95c → 0.0.0-experimental-6e97184

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-4aed95c",
3
+ "version": "0.0.0-experimental-6e97184",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -93,8 +93,8 @@
93
93
  "rollup": "^4.17.2",
94
94
  "storybook": "^8.1.10",
95
95
  "@transferwise/less-config": "3.1.0",
96
- "@transferwise/neptune-css": "14.12.0",
97
- "@wise/components-theming": "1.3.0"
96
+ "@wise/components-theming": "1.3.0",
97
+ "@transferwise/neptune-css": "14.12.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@transferwise/icons": "^3.7.0",
@@ -1,97 +1,66 @@
1
- import { action } from '@storybook/addon-actions';
2
- import { boolean, select, text } from '@storybook/addon-knobs';
3
- import { Freeze, Plus, Whatsapp } from '@transferwise/icons';
1
+ import * as Icons from '@transferwise/icons';
4
2
 
5
- import { Priority, ControlType } from '../common';
3
+ import { ControlType, Priority } from '../common';
6
4
 
5
+ import { Meta, StoryObj } from '@storybook/react';
7
6
  import CircularButton from './CircularButton';
8
7
 
9
8
  export default {
10
9
  component: CircularButton,
11
10
  title: 'Actions/CircularButton',
12
- };
11
+ args: {
12
+ children: 'Button text',
13
+ // Needs to be cast because we're mapping icon names to components
14
+ icon: 'Freeze' as unknown as React.ReactElement,
15
+ },
16
+ argTypes: {
17
+ icon: {
18
+ options: Object.keys(Icons),
19
+ mapping: Object.fromEntries(
20
+ Object.entries(Icons).map(([name, Icon]) => [name, <Icon key={name} />]),
21
+ ),
22
+ },
23
+ },
24
+ } satisfies Meta<typeof CircularButton>;
13
25
 
14
- const icons = {
15
- plus: <Plus />,
16
- freeze: <Freeze />,
17
- whatsapp: <Whatsapp />,
18
- };
26
+ type Story = StoryObj<typeof CircularButton>;
19
27
 
20
- export const Basic = () => {
21
- const icon = select('icon', ['freeze', 'plus', 'whatsapp'], 'freeze');
22
- const priority = select('priority', [Priority.PRIMARY, Priority.SECONDARY], Priority.PRIMARY);
23
- const type = select('type', Object.values(ControlType), ControlType.ACCENT);
24
- const disabled = boolean('disabled', false);
25
- const label = text('label', 'Button text');
26
- const background = select('theme', ['light', 'blue'], 'light');
27
- return (
28
- <div className={background === 'blue' ? 'bg--dark p-a-3' : ''}>
29
- <CircularButton
30
- icon={icons[icon]}
31
- priority={priority}
32
- type={type}
33
- disabled={disabled}
34
- onClick={action('Button Clicked')}
35
- >
36
- {label}
37
- </CircularButton>
38
- </div>
39
- );
28
+ export const Basic: Story = {
29
+ args: {
30
+ priority: Priority.PRIMARY,
31
+ type: ControlType.ACCENT,
32
+ disabled: false,
33
+ },
40
34
  };
41
35
 
42
- export const deprecated = () => {
43
- const icon = select('icon', ['freeze', 'plus', 'whatsapp'], 'freeze');
44
- const disabled = boolean('disabled', false);
45
- const label = text('label', 'Button text');
46
- const background = select('theme', ['light', 'blue'], 'light');
47
-
48
- const commonProps = {
49
- label,
36
+ export const All: Story = {
37
+ args: {
50
38
  className: 'm-r-2',
51
- disabled,
52
- icon: icons[icon],
53
- onClick: action('Button Clicked'),
54
- };
55
-
56
- return (
57
- <div className={background === 'blue' ? 'bg--dark p-a-3' : ''}>
58
- <div className="m-b-2">
59
- <div className="title-4 m-b-1">Accent</div>
60
- <CircularButton priority={Priority.PRIMARY} type={ControlType.ACCENT} {...commonProps}>
61
- {label}
62
- </CircularButton>
63
- <CircularButton priority={Priority.SECONDARY} type={ControlType.ACCENT} {...commonProps}>
64
- {label}
65
- </CircularButton>
66
- </div>
67
- <div className="m-b-2">
68
- <div className="title-4 m-b-1">Positive</div>
69
- <CircularButton priority={Priority.PRIMARY} type={ControlType.POSITIVE} {...commonProps}>
70
- {label}
71
- </CircularButton>
72
-
73
- <CircularButton priority={Priority.SECONDARY} type={ControlType.POSITIVE} {...commonProps}>
74
- {label}
75
- </CircularButton>
76
- </div>
77
- <div className="m-b-2">
78
- <div className="title-4 m-b-1">Negative</div>
79
- <CircularButton priority={Priority.PRIMARY} type={ControlType.NEGATIVE} {...commonProps}>
80
- {label}
81
- </CircularButton>
82
- <CircularButton priority={Priority.SECONDARY} type={ControlType.NEGATIVE} {...commonProps}>
83
- {label}
84
- </CircularButton>
85
- </div>
86
- <div className="m-b-2">
87
- <div className="title-4 m-b-1">Disabled</div>
88
- <CircularButton {...commonProps} disabled>
89
- {label}
90
- </CircularButton>
91
- <CircularButton {...commonProps} priority={Priority.SECONDARY} disabled>
92
- {label}
93
- </CircularButton>
94
- </div>
95
- </div>
96
- );
39
+ },
40
+ render: (props) => {
41
+ return (
42
+ <>
43
+ <div className="m-b-2">
44
+ <div className="title-4 m-b-1">Accent</div>
45
+ <CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.ACCENT} />
46
+ <CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.ACCENT} />
47
+ </div>
48
+ <div className="m-b-2">
49
+ <div className="title-4 m-b-1">Positive</div>
50
+ <CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.POSITIVE} />
51
+ <CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.POSITIVE} />
52
+ </div>
53
+ <div className="m-b-2">
54
+ <div className="title-4 m-b-1">Negative</div>
55
+ <CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.NEGATIVE} />
56
+ <CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.NEGATIVE} />
57
+ </div>
58
+ <div className="m-b-2">
59
+ <div className="title-4 m-b-1">Disabled</div>
60
+ <CircularButton {...props} disabled />
61
+ <CircularButton {...props} priority={Priority.SECONDARY} disabled />
62
+ </div>
63
+ </>
64
+ );
65
+ },
97
66
  };