@transferwise/components 46.116.1 → 46.117.1
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/main.css +145 -156
- package/build/prompt/InlinePrompt/InlinePrompt.js +14 -8
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +15 -9
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/sentimentSurface/SentimentSurface.js +6 -5
- package/build/sentimentSurface/SentimentSurface.js.map +1 -1
- package/build/sentimentSurface/SentimentSurface.mjs +6 -5
- package/build/sentimentSurface/SentimentSurface.mjs.map +1 -1
- package/build/styles/button/Button.css +22 -22
- package/build/styles/button/Button.vars.css +21 -21
- package/build/styles/iconButton/IconButton.css +8 -8
- package/build/styles/link/Link.css +1 -0
- package/build/styles/main.css +145 -156
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +26 -105
- package/build/styles/sentimentSurface/SentimentSurface.css +88 -21
- package/build/types/button/_stories/helpers.d.ts +11 -0
- package/build/types/button/_stories/helpers.d.ts.map +1 -0
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +19 -3
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/sentimentSurface/SentimentSurface.d.ts +5 -4
- package/build/types/sentimentSurface/SentimentSurface.d.ts.map +1 -1
- package/build/types/sentimentSurface/SentimentSurface.types.d.ts +4 -16
- package/build/types/sentimentSurface/SentimentSurface.types.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +25 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/package.json +13 -12
- package/src/button/Button.css +22 -22
- package/src/button/Button.less +1 -1
- package/src/button/Button.vars.css +21 -21
- package/src/button/Button.vars.less +63 -23
- package/src/button/{Button.accessibility.docs.mdx → _stories/Button.accessibility.docs.mdx} +1 -1
- package/src/button/_stories/Button.brightGreen.tests.story.tsx +31 -0
- package/src/button/_stories/Button.dark.tests.story.tsx +25 -0
- package/src/button/_stories/Button.default.tests.story.tsx +25 -0
- package/src/button/_stories/Button.forestGreen.tests.story.tsx +28 -0
- package/src/button/{Button.story.tsx → _stories/Button.story.tsx} +78 -113
- package/src/button/_stories/Button.tests.story.tsx +139 -0
- package/src/button/_stories/helpers.tsx +118 -0
- package/src/iconButton/IconButton.css +8 -8
- package/src/iconButton/IconButton.less +35 -4
- package/src/iconButton/IconButton.story.tsx +72 -3
- package/src/link/Link.css +1 -0
- package/src/link/Link.less +1 -0
- package/src/link/Link.story.tsx +28 -0
- package/src/main.css +145 -156
- package/src/prompt/InlinePrompt/InlinePrompt.css +26 -105
- package/src/prompt/InlinePrompt/InlinePrompt.less +31 -119
- package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +87 -29
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +223 -31
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +42 -11
- package/src/sentimentSurface/SentimentSurface.css +88 -21
- package/src/sentimentSurface/SentimentSurface.docs.mdx +32 -495
- package/src/sentimentSurface/SentimentSurface.less +151 -114
- package/src/sentimentSurface/SentimentSurface.spec.tsx +31 -11
- package/src/sentimentSurface/SentimentSurface.story.tsx +323 -108
- package/src/sentimentSurface/SentimentSurface.tests.story.tsx +90 -40
- package/src/sentimentSurface/SentimentSurface.tsx +16 -9
- package/src/sentimentSurface/SentimentSurface.types.ts +5 -20
- package/src/test-utils/story-config.ts +5 -1
- package/build/sentimentSurface/classMap.js +0 -17
- package/build/sentimentSurface/classMap.js.map +0 -1
- package/build/sentimentSurface/classMap.mjs +0 -14
- package/build/sentimentSurface/classMap.mjs.map +0 -1
- package/build/types/sentimentSurface/classMap.d.ts +0 -4
- package/build/types/sentimentSurface/classMap.d.ts.map +0 -1
- package/src/button/Button.tests.story.tsx +0 -27
- package/src/sentimentSurface/classMap.ts +0 -15
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
.wds-Button {
|
|
2
|
-
--Button-background: var(--color-interactive-accent);
|
|
3
|
-
--Button-background-hover: var(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
--Button-
|
|
2
|
+
--Button-background: var(--color-sentiment-interactive-primary, var(--color-interactive-accent));
|
|
3
|
+
--Button-background-hover: var(
|
|
4
|
+
--color-sentiment-interactive-primary-hover,
|
|
5
|
+
var(--color-interactive-accent-hover)
|
|
6
|
+
);
|
|
7
|
+
--Button-background-active: var(
|
|
8
|
+
--color-sentiment-interactive-primary-active,
|
|
9
|
+
var(--color-interactive-accent-active)
|
|
10
|
+
);
|
|
11
|
+
--Button-color: var(--color-sentiment-interactive-control, var(--color-interactive-control));
|
|
12
|
+
--Button-color-hover: var(
|
|
13
|
+
--color-sentiment-interactive-control-hover,
|
|
14
|
+
var(--color-interactive-control-hover)
|
|
15
|
+
);
|
|
16
|
+
--Button-color-active: var(
|
|
17
|
+
--color-sentiment-interactive-control-active,
|
|
18
|
+
var(--color-interactive-control-active)
|
|
19
|
+
);
|
|
8
20
|
--Button-border-radius: var(--radius-full);
|
|
9
21
|
--Button-label-gap: var(--size-4);
|
|
10
22
|
|
|
@@ -16,24 +28,54 @@
|
|
|
16
28
|
--Button-transition-duration: 150ms;
|
|
17
29
|
--Button-transition-easing: ease-in-out;
|
|
18
30
|
|
|
19
|
-
--Button-secondary-background: var(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
--Button-secondary-
|
|
24
|
-
|
|
31
|
+
--Button-secondary-background: var(
|
|
32
|
+
--color-sentiment-interactive-secondary-neutral,
|
|
33
|
+
var(--color-interactive-neutral)
|
|
34
|
+
);
|
|
35
|
+
--Button-secondary-background-hover: var(
|
|
36
|
+
--color-sentiment-interactive-secondary-neutral-hover,
|
|
37
|
+
var(--color-interactive-neutral-hover)
|
|
38
|
+
);
|
|
39
|
+
--Button-secondary-background-active: var(
|
|
40
|
+
--color-sentiment-interactive-secondary-neutral-active,
|
|
41
|
+
var(--color-interactive-neutral-active)
|
|
42
|
+
);
|
|
43
|
+
--Button-secondary-color: var(
|
|
44
|
+
--color-sentiment-content-primary,
|
|
45
|
+
var(--color-interactive-primary)
|
|
46
|
+
);
|
|
47
|
+
--Button-secondary-color-hover: var(
|
|
48
|
+
--color-sentiment-content-primary-hover,
|
|
49
|
+
var(--color-interactive-primary-hover)
|
|
50
|
+
);
|
|
51
|
+
--Button-secondary-color-active: var(
|
|
52
|
+
--color-sentiment-content-primary-active,
|
|
53
|
+
var(--color-interactive-primary-active)
|
|
54
|
+
);
|
|
25
55
|
|
|
26
|
-
--Button-secondary-neutral-background: var(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
56
|
+
--Button-secondary-neutral-background: var(
|
|
57
|
+
--color-sentiment-interactive-secondary-neutral,
|
|
58
|
+
var(--color-background-neutral)
|
|
59
|
+
);
|
|
60
|
+
--Button-secondary-neutral-background-hover: var(
|
|
61
|
+
--color-sentiment-interactive-secondary-neutral-hover,
|
|
62
|
+
var(--color-background-neutral-hover)
|
|
63
|
+
);
|
|
64
|
+
--Button-secondary-neutral-background-active: var(
|
|
65
|
+
--color-sentiment-interactive-secondary-neutral-active,
|
|
66
|
+
var(--color-background-neutral-active)
|
|
67
|
+
);
|
|
68
|
+
--Button-secondary-neutral-color: var(
|
|
69
|
+
--color-sentiment-content-primary,
|
|
70
|
+
var(--color-content-primary)
|
|
71
|
+
);
|
|
30
72
|
|
|
31
73
|
--Button-tertiary-background: transparent;
|
|
32
|
-
--Button-tertiary-background-hover: var(--color-background-screen-hover);
|
|
33
|
-
--Button-tertiary-background-active: var(--color-background-screen-active);
|
|
34
|
-
--Button-tertiary-color: var(--color-interactive-primary);
|
|
35
|
-
--Button-tertiary-color-hover: var(--color-interactive-primary-hover);
|
|
36
|
-
--Button-tertiary-color-active: var(--color-interactive-primary-active);
|
|
74
|
+
--Button-tertiary-background-hover: var(--color-sentiment-interactive-secondary-neutral, var(--color-background-screen-hover));
|
|
75
|
+
--Button-tertiary-background-active: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-screen-active));
|
|
76
|
+
--Button-tertiary-color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
77
|
+
--Button-tertiary-color-hover: var(--color-sentiment-content-primary-hover, var(--color-interactive-primary-hover));
|
|
78
|
+
--Button-tertiary-color-active: var(--color-sentiment-content-primary-active, var(--color-interactive-primary-active));
|
|
37
79
|
|
|
38
80
|
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
39
81
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
@@ -52,5 +94,3 @@
|
|
|
52
94
|
--Button-secondary-negative-color: var(--color-white);
|
|
53
95
|
}
|
|
54
96
|
}
|
|
55
|
-
|
|
56
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, Canvas, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
-
import { NavigationOption } from '..';
|
|
3
2
|
import { Bulb } from '@transferwise/icons';
|
|
3
|
+
import { NavigationOption } from '../../navigationOption/NavigationOption';
|
|
4
4
|
import * as stories from './Button.story';
|
|
5
5
|
|
|
6
6
|
<Meta title="Actions/Button/Accessibility" />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
+
import Button from '../Button.resolver';
|
|
3
|
+
import { generateSurfaceVariant } from './helpers';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
component: Button,
|
|
7
|
+
title: 'Actions/Button/Tests/theme: bright green',
|
|
8
|
+
tags: ['!autodocs'],
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export const Success = generateSurfaceVariant({
|
|
13
|
+
sentiment: 'success',
|
|
14
|
+
theme: 'bright-green',
|
|
15
|
+
});
|
|
16
|
+
Success.storyName = 'Sentiment awareness: success';
|
|
17
|
+
|
|
18
|
+
export const Warning = generateSurfaceVariant({ sentiment: 'warning', theme: 'bright-green' });
|
|
19
|
+
Warning.storyName = 'Sentiment awareness: warning';
|
|
20
|
+
|
|
21
|
+
export const Negative = generateSurfaceVariant({ sentiment: 'negative', theme: 'bright-green' });
|
|
22
|
+
Negative.storyName = 'Sentiment awareness: negative';
|
|
23
|
+
|
|
24
|
+
export const Neutral = generateSurfaceVariant({ sentiment: 'neutral', theme: 'bright-green' });
|
|
25
|
+
Neutral.storyName = 'Sentiment awareness: neutral';
|
|
26
|
+
|
|
27
|
+
export const Proposition = generateSurfaceVariant({
|
|
28
|
+
sentiment: 'proposition',
|
|
29
|
+
theme: 'bright-green',
|
|
30
|
+
});
|
|
31
|
+
Proposition.storyName = 'Sentiment awareness: proposition';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
+
import Button from '../Button.resolver';
|
|
3
|
+
import { generateSurfaceVariant } from './helpers';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
component: Button,
|
|
7
|
+
title: 'Actions/Button/Tests/theme: dark mode',
|
|
8
|
+
tags: ['!autodocs'],
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export const Success = generateSurfaceVariant({ theme: 'dark', sentiment: 'success' });
|
|
13
|
+
Success.storyName = 'Sentiment awareness: success';
|
|
14
|
+
|
|
15
|
+
export const Warning = generateSurfaceVariant({ theme: 'dark', sentiment: 'warning' });
|
|
16
|
+
Warning.storyName = 'Sentiment awareness: warning';
|
|
17
|
+
|
|
18
|
+
export const Negative = generateSurfaceVariant({ theme: 'dark', sentiment: 'negative' });
|
|
19
|
+
Negative.storyName = 'Sentiment awareness: negative';
|
|
20
|
+
|
|
21
|
+
export const Neutral = generateSurfaceVariant({ theme: 'dark', sentiment: 'neutral' });
|
|
22
|
+
Neutral.storyName = 'Sentiment awareness: neutral';
|
|
23
|
+
|
|
24
|
+
export const Proposition = generateSurfaceVariant({ theme: 'dark', sentiment: 'proposition' });
|
|
25
|
+
Proposition.storyName = 'Sentiment awareness: proposition';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
+
import Button from '../Button.resolver';
|
|
3
|
+
import { generateSurfaceVariant } from './helpers';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
component: Button,
|
|
7
|
+
title: 'Actions/Button/Tests/theme: default',
|
|
8
|
+
tags: ['!autodocs'],
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export const Success = generateSurfaceVariant({ sentiment: 'success' });
|
|
13
|
+
Success.storyName = 'Sentiment awareness: success';
|
|
14
|
+
|
|
15
|
+
export const Warning = generateSurfaceVariant({ sentiment: 'warning' });
|
|
16
|
+
Warning.storyName = 'Sentiment awareness: warning';
|
|
17
|
+
|
|
18
|
+
export const Negative = generateSurfaceVariant({ sentiment: 'negative' });
|
|
19
|
+
Negative.storyName = 'Sentiment awareness: negative';
|
|
20
|
+
|
|
21
|
+
export const Neutral = generateSurfaceVariant({ sentiment: 'neutral' });
|
|
22
|
+
Neutral.storyName = 'Sentiment awareness: neutral';
|
|
23
|
+
|
|
24
|
+
export const Proposition = generateSurfaceVariant({ sentiment: 'proposition' });
|
|
25
|
+
Proposition.storyName = 'Sentiment awareness: proposition';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
+
import Button from '../Button.resolver';
|
|
3
|
+
import { generateSurfaceVariant } from './helpers';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
component: Button,
|
|
7
|
+
title: 'Actions/Button/Tests/theme: forest green',
|
|
8
|
+
tags: ['!autodocs'],
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export const Success = generateSurfaceVariant({ sentiment: 'success', theme: 'forest-green' });
|
|
13
|
+
Success.storyName = 'Sentiment awareness: success';
|
|
14
|
+
|
|
15
|
+
export const Warning = generateSurfaceVariant({ sentiment: 'warning', theme: 'forest-green' });
|
|
16
|
+
Warning.storyName = 'Sentiment awareness: warning';
|
|
17
|
+
|
|
18
|
+
export const Negative = generateSurfaceVariant({ sentiment: 'negative', theme: 'forest-green' });
|
|
19
|
+
Negative.storyName = 'Sentiment awareness: negative';
|
|
20
|
+
|
|
21
|
+
export const Neutral = generateSurfaceVariant({ sentiment: 'neutral', theme: 'forest-green' });
|
|
22
|
+
Neutral.storyName = 'Sentiment awareness: neutral';
|
|
23
|
+
|
|
24
|
+
export const Proposition = generateSurfaceVariant({
|
|
25
|
+
sentiment: 'proposition',
|
|
26
|
+
theme: 'forest-green',
|
|
27
|
+
});
|
|
28
|
+
Proposition.storyName = 'Sentiment awareness: proposition';
|
|
@@ -2,9 +2,10 @@ import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
|
2
2
|
import { fn } from 'storybook/test';
|
|
3
3
|
import { Freeze, ArrowRight, ChevronRight } from '@transferwise/icons';
|
|
4
4
|
import { Flag } from '@wise/art';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import { lorem10, lorem20 } from '../../test-utils';
|
|
6
|
+
import SentimentSurface from '../../sentimentSurface';
|
|
7
|
+
import type { ButtonProps } from '../Button.types';
|
|
8
|
+
import Button from '../Button.resolver';
|
|
8
9
|
|
|
9
10
|
const withContainer = (Story: any) => (
|
|
10
11
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
@@ -695,116 +696,6 @@ export const WithAvatars: StoryObj<PreviewStoryArgs> = {
|
|
|
695
696
|
decorators: [withComponentGrid()],
|
|
696
697
|
};
|
|
697
698
|
|
|
698
|
-
const buttonPriorities = ['primary', 'secondary', 'secondary-neutral', 'tertiary'] as const;
|
|
699
|
-
const buttonSizes = ['sm', 'md', 'lg'] as const;
|
|
700
|
-
|
|
701
|
-
export const AllVariants = storyConfig(
|
|
702
|
-
{
|
|
703
|
-
tags: ['!autodocs'],
|
|
704
|
-
parameters: {
|
|
705
|
-
padding: '0',
|
|
706
|
-
},
|
|
707
|
-
render: () => (
|
|
708
|
-
<div
|
|
709
|
-
className="button-variants"
|
|
710
|
-
style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
|
|
711
|
-
>
|
|
712
|
-
{buttonPriorities.map((priority) =>
|
|
713
|
-
buttonSizes.map((size) => (
|
|
714
|
-
<div
|
|
715
|
-
key={`${priority}-default-${size}`}
|
|
716
|
-
style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
|
|
717
|
-
>
|
|
718
|
-
<Button
|
|
719
|
-
v2
|
|
720
|
-
priority={priority as ButtonPriority}
|
|
721
|
-
size={size}
|
|
722
|
-
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
723
|
-
addonEnd={{ type: 'icon', value: <ArrowRight /> }}
|
|
724
|
-
block
|
|
725
|
-
>
|
|
726
|
-
{`${priority} default ${size}`}
|
|
727
|
-
</Button>
|
|
728
|
-
<Button
|
|
729
|
-
className="m-t-1 m-b-1"
|
|
730
|
-
v2
|
|
731
|
-
priority={priority as ButtonPriority}
|
|
732
|
-
size={size}
|
|
733
|
-
addonStart={{
|
|
734
|
-
type: 'avatar',
|
|
735
|
-
value: [{ asset: <Freeze /> }, { asset: <Freeze /> }],
|
|
736
|
-
}}
|
|
737
|
-
addonEnd={{ type: 'icon', value: <ArrowRight /> }}
|
|
738
|
-
block
|
|
739
|
-
disabled
|
|
740
|
-
>
|
|
741
|
-
{`${priority} default ${size} Disabled`}
|
|
742
|
-
</Button>
|
|
743
|
-
<Button
|
|
744
|
-
v2
|
|
745
|
-
priority={priority as ButtonPriority}
|
|
746
|
-
size={size}
|
|
747
|
-
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
748
|
-
addonEnd={{ type: 'icon', value: <ArrowRight /> }}
|
|
749
|
-
block
|
|
750
|
-
loading
|
|
751
|
-
>
|
|
752
|
-
{`${priority} default ${size} Loading`}
|
|
753
|
-
</Button>
|
|
754
|
-
</div>
|
|
755
|
-
)),
|
|
756
|
-
)}
|
|
757
|
-
{['primary', 'secondary'].map((priority) =>
|
|
758
|
-
buttonSizes.map((size) => (
|
|
759
|
-
<div
|
|
760
|
-
key={`${priority}-negative-${size}`}
|
|
761
|
-
style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
|
|
762
|
-
>
|
|
763
|
-
<Button
|
|
764
|
-
v2
|
|
765
|
-
sentiment="negative"
|
|
766
|
-
priority={priority as ButtonPriority}
|
|
767
|
-
size={size}
|
|
768
|
-
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
769
|
-
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
770
|
-
block
|
|
771
|
-
>
|
|
772
|
-
{`${priority} negative ${size}`}
|
|
773
|
-
</Button>
|
|
774
|
-
<Button
|
|
775
|
-
className="m-t-1 m-b-1"
|
|
776
|
-
v2
|
|
777
|
-
sentiment="negative"
|
|
778
|
-
priority={priority as ButtonPriority}
|
|
779
|
-
size={size}
|
|
780
|
-
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
781
|
-
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
782
|
-
block
|
|
783
|
-
disabled
|
|
784
|
-
>
|
|
785
|
-
{`${priority} negative ${size} Disabled`}
|
|
786
|
-
</Button>
|
|
787
|
-
<Button
|
|
788
|
-
v2
|
|
789
|
-
sentiment="negative"
|
|
790
|
-
priority={priority as ButtonPriority}
|
|
791
|
-
size={size}
|
|
792
|
-
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
793
|
-
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
794
|
-
block
|
|
795
|
-
loading
|
|
796
|
-
>
|
|
797
|
-
{`${priority} negative ${size} Loading`}
|
|
798
|
-
</Button>
|
|
799
|
-
</div>
|
|
800
|
-
)),
|
|
801
|
-
)}
|
|
802
|
-
</div>
|
|
803
|
-
),
|
|
804
|
-
},
|
|
805
|
-
{ variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
|
|
806
|
-
);
|
|
807
|
-
|
|
808
699
|
/**
|
|
809
700
|
* **NB:** The button doesn't know how long its label is, how many words it consists of and
|
|
810
701
|
* how zoomed in it is. That is likely to lead to scenarios in which the text will overflow
|
|
@@ -908,3 +799,77 @@ export const AccessibilityAddons: Story = {
|
|
|
908
799
|
},
|
|
909
800
|
tags: ['!autodocs', '!dev'],
|
|
910
801
|
};
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* `Button` is sentiment-aware and will automatically adjust its colours if wrapped inside
|
|
805
|
+
* the [SentimentSurface](?path=/docs/foundations-sentimentsurface--docs) component
|
|
806
|
+
*/
|
|
807
|
+
export const SentimentAwareness: Story = {
|
|
808
|
+
render: (args) => {
|
|
809
|
+
return (
|
|
810
|
+
<>
|
|
811
|
+
{(['success', 'warning', 'negative', 'neutral', 'proposition'] as const).map(
|
|
812
|
+
(sentiment) => (
|
|
813
|
+
<SentimentSurface
|
|
814
|
+
key={sentiment}
|
|
815
|
+
sentiment={sentiment}
|
|
816
|
+
className="p-a-1 d-flex align-items-center"
|
|
817
|
+
style={{ gap: 'var(--size-8)' }}
|
|
818
|
+
>
|
|
819
|
+
<Button
|
|
820
|
+
v2
|
|
821
|
+
size="md"
|
|
822
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
823
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
824
|
+
>
|
|
825
|
+
Primary
|
|
826
|
+
</Button>
|
|
827
|
+
<Button
|
|
828
|
+
v2
|
|
829
|
+
size="md"
|
|
830
|
+
priority="secondary"
|
|
831
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
832
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
833
|
+
>
|
|
834
|
+
Secondary
|
|
835
|
+
</Button>
|
|
836
|
+
<Button
|
|
837
|
+
v2
|
|
838
|
+
size="md"
|
|
839
|
+
priority="secondary-neutral"
|
|
840
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
841
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
842
|
+
>
|
|
843
|
+
Secondary Neutral
|
|
844
|
+
</Button>
|
|
845
|
+
<Button
|
|
846
|
+
v2
|
|
847
|
+
size="md"
|
|
848
|
+
disabled
|
|
849
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
850
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
851
|
+
>
|
|
852
|
+
Disabled
|
|
853
|
+
</Button>
|
|
854
|
+
</SentimentSurface>
|
|
855
|
+
),
|
|
856
|
+
)}
|
|
857
|
+
</>
|
|
858
|
+
);
|
|
859
|
+
},
|
|
860
|
+
parameters: {
|
|
861
|
+
docs: {
|
|
862
|
+
source: { type: 'dynamic' },
|
|
863
|
+
canvas: {
|
|
864
|
+
sourceState: 'hidden',
|
|
865
|
+
},
|
|
866
|
+
},
|
|
867
|
+
},
|
|
868
|
+
decorators: [
|
|
869
|
+
(Story) => (
|
|
870
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
871
|
+
<Story />
|
|
872
|
+
</div>
|
|
873
|
+
),
|
|
874
|
+
],
|
|
875
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
+
import { ArrowRight, ChevronRight, Freeze } from '@transferwise/icons';
|
|
3
|
+
import { expect, userEvent, within } from 'storybook/test';
|
|
4
|
+
import { storyConfig } from '../../test-utils';
|
|
5
|
+
import Button from '../Button.resolver';
|
|
6
|
+
import { ButtonPriority } from '../Button.types';
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Button> = {
|
|
9
|
+
component: Button,
|
|
10
|
+
title: 'Actions/Button/Tests',
|
|
11
|
+
tags: ['!autodocs'],
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
export const FocusTertiary = storyConfig(
|
|
16
|
+
{
|
|
17
|
+
render: () => (
|
|
18
|
+
<Button v2 priority="tertiary">
|
|
19
|
+
Focus has underline
|
|
20
|
+
</Button>
|
|
21
|
+
),
|
|
22
|
+
},
|
|
23
|
+
{},
|
|
24
|
+
);
|
|
25
|
+
FocusTertiary.play = async ({ canvasElement }) => {
|
|
26
|
+
await userEvent.tab();
|
|
27
|
+
const canvas = within(canvasElement);
|
|
28
|
+
const buttonElement: HTMLButtonElement = canvas.getByRole('button');
|
|
29
|
+
await expect(buttonElement).toHaveFocus();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const buttonPriorities = ['primary', 'secondary', 'secondary-neutral', 'tertiary'] as const;
|
|
33
|
+
const buttonSizes = ['sm', 'md', 'lg'] as const;
|
|
34
|
+
export const AllVariants = storyConfig(
|
|
35
|
+
{
|
|
36
|
+
tags: ['!autodocs'],
|
|
37
|
+
parameters: {
|
|
38
|
+
padding: '0',
|
|
39
|
+
},
|
|
40
|
+
render: () => (
|
|
41
|
+
<div
|
|
42
|
+
className="button-variants"
|
|
43
|
+
style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
|
|
44
|
+
>
|
|
45
|
+
{buttonPriorities.map((priority) =>
|
|
46
|
+
buttonSizes.map((size) => (
|
|
47
|
+
<div
|
|
48
|
+
key={`${priority}-default-${size}`}
|
|
49
|
+
style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
|
|
50
|
+
>
|
|
51
|
+
<Button
|
|
52
|
+
v2
|
|
53
|
+
priority={priority as ButtonPriority}
|
|
54
|
+
size={size}
|
|
55
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
56
|
+
addonEnd={{ type: 'icon', value: <ArrowRight /> }}
|
|
57
|
+
block
|
|
58
|
+
>
|
|
59
|
+
{`${priority} default ${size}`}
|
|
60
|
+
</Button>
|
|
61
|
+
<Button
|
|
62
|
+
className="m-t-1 m-b-1"
|
|
63
|
+
v2
|
|
64
|
+
priority={priority as ButtonPriority}
|
|
65
|
+
size={size}
|
|
66
|
+
addonStart={{
|
|
67
|
+
type: 'avatar',
|
|
68
|
+
value: [{ asset: <Freeze /> }, { asset: <Freeze /> }],
|
|
69
|
+
}}
|
|
70
|
+
addonEnd={{ type: 'icon', value: <ArrowRight /> }}
|
|
71
|
+
block
|
|
72
|
+
disabled
|
|
73
|
+
>
|
|
74
|
+
{`${priority} default ${size} Disabled`}
|
|
75
|
+
</Button>
|
|
76
|
+
<Button
|
|
77
|
+
v2
|
|
78
|
+
priority={priority as ButtonPriority}
|
|
79
|
+
size={size}
|
|
80
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
81
|
+
addonEnd={{ type: 'icon', value: <ArrowRight /> }}
|
|
82
|
+
block
|
|
83
|
+
loading
|
|
84
|
+
>
|
|
85
|
+
{`${priority} default ${size} Loading`}
|
|
86
|
+
</Button>
|
|
87
|
+
</div>
|
|
88
|
+
)),
|
|
89
|
+
)}
|
|
90
|
+
{['primary', 'secondary'].map((priority) =>
|
|
91
|
+
buttonSizes.map((size) => (
|
|
92
|
+
<div
|
|
93
|
+
key={`${priority}-negative-${size}`}
|
|
94
|
+
style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
|
|
95
|
+
>
|
|
96
|
+
<Button
|
|
97
|
+
v2
|
|
98
|
+
sentiment="negative"
|
|
99
|
+
priority={priority as ButtonPriority}
|
|
100
|
+
size={size}
|
|
101
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
102
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
103
|
+
block
|
|
104
|
+
>
|
|
105
|
+
{`${priority} negative ${size}`}
|
|
106
|
+
</Button>
|
|
107
|
+
<Button
|
|
108
|
+
className="m-t-1 m-b-1"
|
|
109
|
+
v2
|
|
110
|
+
sentiment="negative"
|
|
111
|
+
priority={priority as ButtonPriority}
|
|
112
|
+
size={size}
|
|
113
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
114
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
115
|
+
block
|
|
116
|
+
disabled
|
|
117
|
+
>
|
|
118
|
+
{`${priority} negative ${size} Disabled`}
|
|
119
|
+
</Button>
|
|
120
|
+
<Button
|
|
121
|
+
v2
|
|
122
|
+
sentiment="negative"
|
|
123
|
+
priority={priority as ButtonPriority}
|
|
124
|
+
size={size}
|
|
125
|
+
addonEnd={{ type: 'icon', value: <ChevronRight /> }}
|
|
126
|
+
addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
|
|
127
|
+
block
|
|
128
|
+
loading
|
|
129
|
+
>
|
|
130
|
+
{`${priority} negative ${size} Loading`}
|
|
131
|
+
</Button>
|
|
132
|
+
</div>
|
|
133
|
+
)),
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
),
|
|
137
|
+
},
|
|
138
|
+
{ variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
|
|
139
|
+
);
|