@transferwise/components 46.117.0 → 46.118.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.
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +2 -0
- package/build/index.mjs.map +1 -1
- package/build/main.css +85 -25
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/styles/button/Button.css +5 -5
- package/build/styles/button/Button.vars.css +5 -5
- package/build/styles/main.css +85 -25
- package/build/styles/sentimentSurface/SentimentSurface.css +80 -20
- package/build/types/button/_stories/helpers.d.ts +11 -0
- package/build/types/button/_stories/helpers.d.ts.map +1 -0
- package/build/types/index.d.ts +4 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +3 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +1 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/alert/Alert.story.tsx +1 -1
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/button/Button.css +5 -5
- package/src/button/Button.vars.css +5 -5
- package/src/button/Button.vars.less +28 -7
- 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} +6 -6
- package/src/button/{Button.tests.story.tsx → _stories/Button.tests.story.tsx} +5 -82
- package/src/button/_stories/helpers.tsx +118 -0
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
- package/src/iconButton/IconButton.story.tsx +2 -2
- package/src/index.ts +4 -0
- package/src/inlineAlert/InlineAlert.story.tsx +1 -1
- package/src/link/Link.story.tsx +2 -2
- package/src/main.css +85 -25
- package/src/nudge/Nudge.story.tsx +1 -1
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +41 -2
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +3 -1
- package/src/provider/theme/ThemeProvider.story.tsx +1 -1
- package/src/sentimentSurface/SentimentSurface.css +80 -20
- package/src/sentimentSurface/SentimentSurface.less +40 -10
- package/src/sentimentSurface/SentimentSurface.story.tsx +163 -102
- package/src/sentimentSurface/SentimentSurface.tests.story.tsx +6 -2
- package/src/test-utils/story-config.ts +5 -0
- package/src/{neptune-css/NeptuneCSS.story.tsx → tokens/tokens.story.tsx} +2 -2
- package/src/withId/withId.story.tsx +1 -0
package/src/button/Button.css
CHANGED
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
--Button-secondary-neutral-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-neutral-active));
|
|
25
25
|
--Button-secondary-neutral-color: var(--color-sentiment-content-primary, var(--color-content-primary));
|
|
26
26
|
--Button-tertiary-background: transparent;
|
|
27
|
-
--Button-tertiary-background-hover: var(--color-background-screen-hover);
|
|
28
|
-
--Button-tertiary-background-active: var(--color-background-screen-active);
|
|
29
|
-
--Button-tertiary-color: var(--color-interactive-primary);
|
|
30
|
-
--Button-tertiary-color-hover: var(--color-interactive-primary-hover);
|
|
31
|
-
--Button-tertiary-color-active: var(--color-interactive-primary-active);
|
|
27
|
+
--Button-tertiary-background-hover: var(--color-sentiment-interactive-secondary-neutral, var(--color-background-screen-hover));
|
|
28
|
+
--Button-tertiary-background-active: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-screen-active));
|
|
29
|
+
--Button-tertiary-color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
30
|
+
--Button-tertiary-color-hover: var(--color-sentiment-content-primary-hover, var(--color-interactive-primary-hover));
|
|
31
|
+
--Button-tertiary-color-active: var(--color-sentiment-content-primary-active, var(--color-interactive-primary-active));
|
|
32
32
|
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
33
33
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
34
34
|
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
--Button-secondary-neutral-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-neutral-active));
|
|
25
25
|
--Button-secondary-neutral-color: var(--color-sentiment-content-primary, var(--color-content-primary));
|
|
26
26
|
--Button-tertiary-background: transparent;
|
|
27
|
-
--Button-tertiary-background-hover: var(--color-background-screen-hover);
|
|
28
|
-
--Button-tertiary-background-active: var(--color-background-screen-active);
|
|
29
|
-
--Button-tertiary-color: var(--color-interactive-primary);
|
|
30
|
-
--Button-tertiary-color-hover: var(--color-interactive-primary-hover);
|
|
31
|
-
--Button-tertiary-color-active: var(--color-interactive-primary-active);
|
|
27
|
+
--Button-tertiary-background-hover: var(--color-sentiment-interactive-secondary-neutral, var(--color-background-screen-hover));
|
|
28
|
+
--Button-tertiary-background-active: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-screen-active));
|
|
29
|
+
--Button-tertiary-color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
30
|
+
--Button-tertiary-color-hover: var(--color-sentiment-content-primary-hover, var(--color-interactive-primary-hover));
|
|
31
|
+
--Button-tertiary-color-active: var(--color-sentiment-content-primary-active, var(--color-interactive-primary-active));
|
|
32
32
|
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
33
33
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
34
34
|
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
.wds-Button {
|
|
2
|
-
--Button-background: var(
|
|
2
|
+
--Button-background: var(
|
|
3
|
+
--color-sentiment-interactive-primary,
|
|
4
|
+
var(--color-interactive-accent)
|
|
5
|
+
);
|
|
3
6
|
--Button-background-hover: var(
|
|
4
7
|
--color-sentiment-interactive-primary-hover,
|
|
5
8
|
var(--color-interactive-accent-hover)
|
|
@@ -8,7 +11,10 @@
|
|
|
8
11
|
--color-sentiment-interactive-primary-active,
|
|
9
12
|
var(--color-interactive-accent-active)
|
|
10
13
|
);
|
|
11
|
-
--Button-color: var(
|
|
14
|
+
--Button-color: var(
|
|
15
|
+
--color-sentiment-interactive-control,
|
|
16
|
+
var(--color-interactive-control)
|
|
17
|
+
);
|
|
12
18
|
--Button-color-hover: var(
|
|
13
19
|
--color-sentiment-interactive-control-hover,
|
|
14
20
|
var(--color-interactive-control-hover)
|
|
@@ -71,11 +77,26 @@
|
|
|
71
77
|
);
|
|
72
78
|
|
|
73
79
|
--Button-tertiary-background: transparent;
|
|
74
|
-
--Button-tertiary-background-hover: var(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
--Button-tertiary-
|
|
80
|
+
--Button-tertiary-background-hover: var(
|
|
81
|
+
--color-sentiment-interactive-secondary-neutral,
|
|
82
|
+
var(--color-background-screen-hover)
|
|
83
|
+
);
|
|
84
|
+
--Button-tertiary-background-active: var(
|
|
85
|
+
--color-sentiment-interactive-secondary-neutral-hover,
|
|
86
|
+
var(--color-background-screen-active)
|
|
87
|
+
);
|
|
88
|
+
--Button-tertiary-color: var(
|
|
89
|
+
--color-sentiment-content-primary,
|
|
90
|
+
var(--color-interactive-primary)
|
|
91
|
+
);
|
|
92
|
+
--Button-tertiary-color-hover: var(
|
|
93
|
+
--color-sentiment-content-primary-hover,
|
|
94
|
+
var(--color-interactive-primary-hover)
|
|
95
|
+
);
|
|
96
|
+
--Button-tertiary-color-active: var(
|
|
97
|
+
--color-sentiment-content-primary-active,
|
|
98
|
+
var(--color-interactive-primary-active)
|
|
99
|
+
);
|
|
79
100
|
|
|
80
101
|
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
81
102
|
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
@@ -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,10 +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 {
|
|
8
|
-
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';
|
|
9
9
|
|
|
10
10
|
const withContainer = (Story: any) => (
|
|
11
11
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
|
@@ -801,8 +801,8 @@ export const AccessibilityAddons: Story = {
|
|
|
801
801
|
};
|
|
802
802
|
|
|
803
803
|
/**
|
|
804
|
-
* `Button` is sentiment-aware and will automatically adjust its
|
|
805
|
-
*
|
|
804
|
+
* `Button` is sentiment-aware and will automatically adjust its colours if wrapped inside
|
|
805
|
+
* the [SentimentSurface](?path=/docs/foundations-sentimentsurface--docs) component
|
|
806
806
|
*/
|
|
807
807
|
export const SentimentAwareness: Story = {
|
|
808
808
|
render: (args) => {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react-webpack5';
|
|
2
|
-
import Button from './Button.resolver';
|
|
3
|
-
import { expect, userEvent, within } from 'storybook/test';
|
|
4
|
-
import { storyConfig } from '../test-utils';
|
|
5
|
-
import { ButtonPriority } from './Button.types';
|
|
6
2
|
import { ArrowRight, ChevronRight, Freeze } from '@transferwise/icons';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
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';
|
|
9
7
|
|
|
10
8
|
const meta: Meta<typeof Button> = {
|
|
11
9
|
component: Button,
|
|
12
10
|
title: 'Actions/Button/Tests',
|
|
11
|
+
tags: ['!autodocs'],
|
|
13
12
|
};
|
|
14
13
|
export default meta;
|
|
15
14
|
|
|
@@ -138,79 +137,3 @@ export const AllVariants = storyConfig(
|
|
|
138
137
|
},
|
|
139
138
|
{ variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
|
|
140
139
|
);
|
|
141
|
-
|
|
142
|
-
export const SentimentAwareness = storyConfig(
|
|
143
|
-
{
|
|
144
|
-
render: () => {
|
|
145
|
-
const PERMUTATIONS = {
|
|
146
|
-
emphasis: ['base', 'elevated'] as const,
|
|
147
|
-
sentiment: ['success', 'warning', 'negative', 'neutral', 'proposition'] as const,
|
|
148
|
-
disabled: [false, true] as const,
|
|
149
|
-
others: [
|
|
150
|
-
{
|
|
151
|
-
addonStart: { type: 'avatar' as const, value: [{ asset: <Freeze /> }] },
|
|
152
|
-
addonEnd: { type: 'icon' as const, value: <ChevronRight /> },
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
addonStart: { type: 'avatar' as const, value: [{ profileName: 'John Doe' }] },
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
addonStart: {
|
|
159
|
-
type: 'avatar' as const,
|
|
160
|
-
value: [
|
|
161
|
-
{
|
|
162
|
-
asset: <Flag code="gb" />,
|
|
163
|
-
},
|
|
164
|
-
{ asset: <Freeze /> },
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
loading: true,
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
priority: ['primary', 'secondary', 'secondary-neutral'] as const,
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<>
|
|
177
|
-
{PERMUTATIONS.emphasis.map((emphasis) =>
|
|
178
|
-
PERMUTATIONS.sentiment.map((sentiment) => (
|
|
179
|
-
<SentimentSurface
|
|
180
|
-
key={`${emphasis}-${sentiment}`}
|
|
181
|
-
sentiment={sentiment}
|
|
182
|
-
emphasis={emphasis}
|
|
183
|
-
style={{
|
|
184
|
-
padding: 'var(--size-8)',
|
|
185
|
-
display: 'grid',
|
|
186
|
-
gridTemplateColumns: 'repeat(3, min-content)',
|
|
187
|
-
gap: 'var(--size-8)',
|
|
188
|
-
}}
|
|
189
|
-
>
|
|
190
|
-
{PERMUTATIONS.disabled.map((disabled) =>
|
|
191
|
-
PERMUTATIONS.others.map((media, mediaVariant) =>
|
|
192
|
-
PERMUTATIONS.priority.map((priority) => (
|
|
193
|
-
<div key={`${emphasis}-${sentiment}-${disabled}-${priority}-${mediaVariant}`}>
|
|
194
|
-
<Button v2 size="md" disabled={disabled} priority={priority} {...media}>
|
|
195
|
-
{priority}
|
|
196
|
-
</Button>
|
|
197
|
-
</div>
|
|
198
|
-
)),
|
|
199
|
-
),
|
|
200
|
-
)}
|
|
201
|
-
</SentimentSurface>
|
|
202
|
-
)),
|
|
203
|
-
)}
|
|
204
|
-
</>
|
|
205
|
-
);
|
|
206
|
-
},
|
|
207
|
-
decorators: [
|
|
208
|
-
(Story: React.ComponentType) => (
|
|
209
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
210
|
-
<Story />
|
|
211
|
-
</div>
|
|
212
|
-
),
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
{},
|
|
216
|
-
);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ThemeProvider, type ThemeProviderProps } from '@wise/components-theming';
|
|
2
|
+
import { ChevronRight, Freeze } from '@transferwise/icons';
|
|
3
|
+
import { Flag } from '@wise/art';
|
|
4
|
+
import SentimentSurface from '../../sentimentSurface';
|
|
5
|
+
import Header from '../../header';
|
|
6
|
+
import Button from '../Button';
|
|
7
|
+
|
|
8
|
+
interface GenerateSurfaceVariantProps {
|
|
9
|
+
theme?: 'forest-green' | 'bright-green' | 'dark';
|
|
10
|
+
sentiment: 'success' | 'warning' | 'negative' | 'neutral' | 'proposition';
|
|
11
|
+
}
|
|
12
|
+
export const generateSurfaceVariant = ({ theme, sentiment }: GenerateSurfaceVariantProps) => ({
|
|
13
|
+
storyName: '',
|
|
14
|
+
render: () => {
|
|
15
|
+
const PERMUTATIONS = {
|
|
16
|
+
emphasis: ['base', 'elevated'] as const,
|
|
17
|
+
disabled: [false, true] as const,
|
|
18
|
+
others: [
|
|
19
|
+
{
|
|
20
|
+
addonStart: { type: 'avatar' as const, value: [{ asset: <Freeze /> }] },
|
|
21
|
+
addonEnd: { type: 'icon' as const, value: <ChevronRight /> },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
addonStart: { type: 'avatar' as const, value: [{ profileName: 'John Doe' }] },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
addonStart: {
|
|
28
|
+
type: 'avatar' as const,
|
|
29
|
+
value: [
|
|
30
|
+
{
|
|
31
|
+
asset: <Flag code="gb" />,
|
|
32
|
+
},
|
|
33
|
+
{ asset: <Freeze /> },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
loading: true,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
priority: ['primary', 'secondary', 'secondary-neutral', 'tertiary'] as const,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const story = PERMUTATIONS.emphasis.map((emphasis) => (
|
|
45
|
+
<SentimentSurface
|
|
46
|
+
key={`${emphasis}-${sentiment}`}
|
|
47
|
+
sentiment={sentiment}
|
|
48
|
+
emphasis={emphasis}
|
|
49
|
+
style={{
|
|
50
|
+
padding: 'var(--size-8)',
|
|
51
|
+
display: 'grid',
|
|
52
|
+
gridTemplateColumns: 'repeat(1, min-content)',
|
|
53
|
+
gap: 'var(--size-8)',
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
{PERMUTATIONS.disabled.map((disabled) =>
|
|
57
|
+
PERMUTATIONS.others.map((media, mediaVariant) =>
|
|
58
|
+
PERMUTATIONS.priority.map((priority) => (
|
|
59
|
+
<div key={`${emphasis}-${sentiment}-${disabled}-${priority}-${mediaVariant}`}>
|
|
60
|
+
<Button v2 size="md" disabled={disabled} priority={priority} {...media}>
|
|
61
|
+
{priority}
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
64
|
+
)),
|
|
65
|
+
),
|
|
66
|
+
)}
|
|
67
|
+
</SentimentSurface>
|
|
68
|
+
));
|
|
69
|
+
|
|
70
|
+
if (theme === 'dark') {
|
|
71
|
+
return (
|
|
72
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, min-content)' }}>
|
|
73
|
+
<ThemeProvider theme="personal" screenMode="dark" className="p-a-2 p-l-4">
|
|
74
|
+
<Header title="Personal brand" />
|
|
75
|
+
{story}
|
|
76
|
+
</ThemeProvider>
|
|
77
|
+
<ThemeProvider theme="business" screenMode="dark" className="p-a-2 p-r-4">
|
|
78
|
+
<Header title="Business brand" />
|
|
79
|
+
{story}
|
|
80
|
+
</ThemeProvider>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const personalVariant = (theme || 'personal') as ThemeProviderProps['theme'];
|
|
86
|
+
const businessVariant = (
|
|
87
|
+
theme ? (`business--${theme}` as const) : 'business'
|
|
88
|
+
) as ThemeProviderProps['theme'];
|
|
89
|
+
const platformVariant = (
|
|
90
|
+
theme ? (`platform--${theme}` as const) : 'platform'
|
|
91
|
+
) as ThemeProviderProps['theme'];
|
|
92
|
+
return (
|
|
93
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, min-content)' }}>
|
|
94
|
+
<ThemeProvider theme={personalVariant} screenMode="light" className="p-a-2 p-l-4">
|
|
95
|
+
<Header title="Personal brand" />
|
|
96
|
+
{story}
|
|
97
|
+
</ThemeProvider>
|
|
98
|
+
<ThemeProvider theme={businessVariant} screenMode="light" className="p-a-2">
|
|
99
|
+
<Header title="Business brand" />
|
|
100
|
+
{story}
|
|
101
|
+
</ThemeProvider>
|
|
102
|
+
{theme === 'bright-green' ? null : (
|
|
103
|
+
<ThemeProvider theme={platformVariant} screenMode="light" className="p-a-2 p-r-4">
|
|
104
|
+
<Header title="Platform brand" />
|
|
105
|
+
{story}
|
|
106
|
+
</ThemeProvider>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
decorators: [
|
|
112
|
+
(Story: React.ComponentType) => (
|
|
113
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
114
|
+
<Story />
|
|
115
|
+
</div>
|
|
116
|
+
),
|
|
117
|
+
],
|
|
118
|
+
});
|
|
@@ -109,8 +109,8 @@ export const Basic: Story = {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* `IconButton` is sentiment-aware and will automatically adjust its
|
|
113
|
-
*
|
|
112
|
+
* `IconButton` is sentiment-aware and will automatically adjust its colours if wrapped inside
|
|
113
|
+
* the [SentimentSurface](?path=/docs/foundations-sentimentsurface--docs) component
|
|
114
114
|
*/
|
|
115
115
|
export const SentimentAwareness: Story = {
|
|
116
116
|
render: () => {
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export type { HeaderProps } from './header';
|
|
|
35
35
|
export type { EmphasisProps } from './emphasis';
|
|
36
36
|
export type { FieldProps } from './field/Field';
|
|
37
37
|
export type { InfoProps } from './info';
|
|
38
|
+
export type { InlinePromptProps } from './prompt';
|
|
38
39
|
export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
|
|
39
40
|
export type { InputProps } from './inputs/Input';
|
|
40
41
|
export type { InputGroupProps } from './inputs/InputGroup';
|
|
@@ -89,6 +90,7 @@ export type { SnackbarContextType } from './snackbar/SnackbarContext';
|
|
|
89
90
|
export type { StatusIconProps } from './statusIcon';
|
|
90
91
|
export type { StickyProps } from './sticky';
|
|
91
92
|
export type { SummaryProps } from './summary';
|
|
93
|
+
export type { SentimentSurfaceProps } from './sentimentSurface';
|
|
92
94
|
export type { SwitchProps } from './switch';
|
|
93
95
|
export type { SwitchOptionProps } from './switchOption';
|
|
94
96
|
export type { TabItem, TabsProps } from './tabs';
|
|
@@ -169,6 +171,7 @@ export { default as Header } from './header';
|
|
|
169
171
|
export { default as Image } from './image';
|
|
170
172
|
export { default as Info } from './info';
|
|
171
173
|
export { default as InlineAlert } from './inlineAlert';
|
|
174
|
+
export { InlinePrompt } from './prompt';
|
|
172
175
|
export { default as InputWithDisplayFormat } from './inputWithDisplayFormat';
|
|
173
176
|
export { Input } from './inputs/Input';
|
|
174
177
|
export { InputGroup } from './inputs/InputGroup';
|
|
@@ -209,6 +212,7 @@ export { default as ResponsivePanel } from './common/responsivePanel';
|
|
|
209
212
|
export { default as Section } from './section';
|
|
210
213
|
export { default as SegmentedControl } from './segmentedControl';
|
|
211
214
|
export { default as Select } from './select';
|
|
215
|
+
export { default as SentimentSurface } from './sentimentSurface';
|
|
212
216
|
export { default as SlidingPanel } from './slidingPanel';
|
|
213
217
|
export { default as SnackbarPortal } from './snackbar/Snackbar';
|
|
214
218
|
export { SnackbarConsumer, SnackbarContext } from './snackbar/SnackbarContext';
|
package/src/link/Link.story.tsx
CHANGED
|
@@ -161,8 +161,8 @@ export const Basic = () => {
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* `Link` is sentiment-aware and will automatically adjust its
|
|
165
|
-
*
|
|
164
|
+
* `Link` is sentiment-aware and will automatically adjust its colours if wrapped inside
|
|
165
|
+
* the [SentimentSurface](?path=/docs/foundations-sentimentsurface--docs) component
|
|
166
166
|
*/
|
|
167
167
|
export const SentimentAwareness = function Render() {
|
|
168
168
|
return (['success', 'warning', 'negative'] as const).map((sentiment) => (
|