@transferwise/components 46.116.0 → 46.117.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 (71) hide show
  1. package/build/alert/Alert.js +2 -1
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +2 -1
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/main.css +60 -139
  6. package/build/prompt/InlinePrompt/InlinePrompt.js +14 -8
  7. package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
  8. package/build/prompt/InlinePrompt/InlinePrompt.mjs +15 -9
  9. package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
  10. package/build/sentimentSurface/SentimentSurface.js +6 -5
  11. package/build/sentimentSurface/SentimentSurface.js.map +1 -1
  12. package/build/sentimentSurface/SentimentSurface.mjs +6 -5
  13. package/build/sentimentSurface/SentimentSurface.mjs.map +1 -1
  14. package/build/styles/button/Button.css +17 -17
  15. package/build/styles/button/Button.vars.css +16 -16
  16. package/build/styles/iconButton/IconButton.css +8 -8
  17. package/build/styles/inputs/Input.css +2 -4
  18. package/build/styles/inputs/TextArea.css +2 -4
  19. package/build/styles/link/Link.css +1 -0
  20. package/build/styles/main.css +60 -139
  21. package/build/styles/popover/Popover.css +2 -4
  22. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +26 -105
  23. package/build/styles/sentimentSurface/SentimentSurface.css +4 -1
  24. package/build/types/alert/Alert.d.ts.map +1 -1
  25. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +19 -3
  26. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
  27. package/build/types/sentimentSurface/SentimentSurface.d.ts +5 -4
  28. package/build/types/sentimentSurface/SentimentSurface.d.ts.map +1 -1
  29. package/build/types/sentimentSurface/SentimentSurface.types.d.ts +4 -16
  30. package/build/types/sentimentSurface/SentimentSurface.types.d.ts.map +1 -1
  31. package/build/types/test-utils/story-config.d.ts +24 -0
  32. package/build/types/test-utils/story-config.d.ts.map +1 -1
  33. package/package.json +13 -12
  34. package/src/alert/Alert.tsx +3 -1
  35. package/src/button/Button.css +17 -17
  36. package/src/button/Button.less +1 -1
  37. package/src/button/Button.story.tsx +75 -110
  38. package/src/button/Button.tests.story.tsx +189 -0
  39. package/src/button/Button.vars.css +16 -16
  40. package/src/button/Button.vars.less +58 -18
  41. package/src/iconButton/IconButton.css +8 -8
  42. package/src/iconButton/IconButton.less +35 -4
  43. package/src/iconButton/IconButton.story.tsx +72 -3
  44. package/src/inputs/Input.css +2 -4
  45. package/src/inputs/TextArea.css +2 -4
  46. package/src/link/Link.css +1 -0
  47. package/src/link/Link.less +1 -0
  48. package/src/link/Link.story.tsx +28 -0
  49. package/src/main.css +60 -139
  50. package/src/popover/Popover.css +2 -4
  51. package/src/prompt/InlinePrompt/InlinePrompt.css +26 -105
  52. package/src/prompt/InlinePrompt/InlinePrompt.less +31 -119
  53. package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +87 -29
  54. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +223 -31
  55. package/src/prompt/InlinePrompt/InlinePrompt.tsx +42 -11
  56. package/src/sentimentSurface/SentimentSurface.css +4 -1
  57. package/src/sentimentSurface/SentimentSurface.docs.mdx +37 -478
  58. package/src/sentimentSurface/SentimentSurface.less +118 -114
  59. package/src/sentimentSurface/SentimentSurface.spec.tsx +31 -11
  60. package/src/sentimentSurface/SentimentSurface.story.tsx +325 -147
  61. package/src/sentimentSurface/SentimentSurface.tests.story.tsx +85 -86
  62. package/src/sentimentSurface/SentimentSurface.tsx +16 -9
  63. package/src/sentimentSurface/SentimentSurface.types.ts +5 -20
  64. package/src/test-utils/story-config.ts +0 -1
  65. package/build/sentimentSurface/classMap.js +0 -17
  66. package/build/sentimentSurface/classMap.js.map +0 -1
  67. package/build/sentimentSurface/classMap.mjs +0 -14
  68. package/build/sentimentSurface/classMap.mjs.map +0 -1
  69. package/build/types/sentimentSurface/classMap.d.ts +0 -4
  70. package/build/types/sentimentSurface/classMap.d.ts.map +0 -1
  71. package/src/sentimentSurface/classMap.ts +0 -15
@@ -1 +1 @@
1
- {"version":3,"file":"story-config.d.ts","sourceRoot":"","sources":["../../../src/test-utils/story-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAarB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,CACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,cAAc,GACd,cAAc,GACd,KAAK,GACL,QAAQ,GACR,MAAM,CACT,EAAE,CAAC;CACL;AAmBD;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,EAC9B,aAAa,QAAQ,CAAC,IAAI,CAAC,EAC3B,cAAc,WAAW,KACxB,QAAQ,CAAC,IAAI,CAuBf,CAAC"}
1
+ {"version":3,"file":"story-config.d.ts","sourceRoot":"","sources":["../../../src/test-utils/story-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAarB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,CACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,cAAc,GACd,cAAc,GACd,KAAK,GACL,QAAQ,GACR,MAAM,CACT,EAAE,CAAC;CACL;AAkBD;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,EAC9B,aAAa,QAAQ,CAAC,IAAI,CAAC,EAC3B,cAAc,WAAW,KACxB,QAAQ,CAAC,IAAI,CAuBf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.116.0",
3
+ "version": "46.117.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -49,10 +49,10 @@
49
49
  "@rollup/plugin-node-resolve": "^16.0.1",
50
50
  "@rollup/plugin-typescript": "^12.1.4",
51
51
  "@rollup/plugin-url": "^8.0.2",
52
- "@storybook/addon-a11y": "^9.1.3",
53
- "@storybook/addon-docs": "^9.1.3",
54
- "@storybook/addon-webpack5-compiler-babel": "^3.0.6",
55
- "@storybook/react-webpack5": "^9.1.3",
52
+ "@storybook/addon-a11y": "^10.1.4",
53
+ "@storybook/addon-docs": "^10.1.4",
54
+ "@storybook/addon-webpack5-compiler-babel": "^4.0.0",
55
+ "@storybook/react-webpack5": "^10.1.4",
56
56
  "@testing-library/dom": "^10.4.1",
57
57
  "@testing-library/jest-dom": "^6.8.0",
58
58
  "@testing-library/react": "^16.3.0",
@@ -72,6 +72,7 @@
72
72
  "@wise/eslint-config": "^13.1.0",
73
73
  "babel-plugin-formatjs": "^10.5.39",
74
74
  "eslint": "^9.33.0",
75
+ "eslint-plugin-storybook": "10.1.4",
75
76
  "gulp": "^5.0.1",
76
77
  "jest": "^30.0.5",
77
78
  "jest-environment-jsdom": "^29.7.0",
@@ -80,12 +81,12 @@
80
81
  "react-intl": "^7.1.11",
81
82
  "rollup": "^4.47.1",
82
83
  "rollup-preserve-directives": "^1.1.3",
83
- "storybook": "^9.1.3",
84
- "storybook-addon-tag-badges": "^2.0.2",
85
- "storybook-addon-test-codegen": "^2.0.1",
84
+ "storybook": "^10.1.10",
85
+ "storybook-addon-tag-badges": "^3.0.4",
86
+ "storybook-addon-test-codegen": "^3.0.1",
86
87
  "@transferwise/less-config": "3.1.2",
87
- "@transferwise/neptune-css": "14.25.2",
88
- "@wise/components-theming": "1.9.0",
88
+ "@transferwise/neptune-css": "14.26.0",
89
+ "@wise/components-theming": "1.9.1",
89
90
  "@wise/wds-configs": "0.0.0"
90
91
  },
91
92
  "peerDependencies": {
@@ -93,10 +94,10 @@
93
94
  "@transferwise/neptune-css": "^14.24",
94
95
  "@wise/art": "^2.24.4",
95
96
  "@wise/components-theming": "^1.6.2",
97
+ "framer-motion": "^12.23.22",
96
98
  "react": ">=18",
97
99
  "react-dom": ">=18",
98
- "react-intl": "^5.10.0 || ^6 || ^7",
99
- "framer-motion": "^12.23.22"
100
+ "react-intl": "^5.10.0 || ^6 || ^7"
100
101
  },
101
102
  "dependencies": {
102
103
  "@babel/runtime": "^7.28.3",
@@ -147,9 +147,11 @@ export default function Alert({
147
147
 
148
148
  const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);
149
149
  useEffect(() => {
150
- setTimeout(() => {
150
+ const timeoutId = setTimeout(() => {
151
151
  setShouldAnnounce(true);
152
152
  }, WDS_LIVE_REGION_DELAY_MS);
153
+
154
+ return () => clearTimeout(timeoutId);
153
155
  }, []);
154
156
 
155
157
  const closeButtonReference = useRef<HTMLButtonElement>(null);
@@ -1,10 +1,10 @@
1
1
  .wds-Button {
2
- --Button-background: var(--color-interactive-accent);
3
- --Button-background-hover: var(--color-interactive-accent-hover);
4
- --Button-background-active: var(--color-interactive-accent-active);
5
- --Button-color: var(--color-interactive-control);
6
- --Button-color-hover: var(--color-interactive-control-hover);
7
- --Button-color-active: var(--color-interactive-control-active);
2
+ --Button-background: var(--color-sentiment-interactive-primary, var(--color-interactive-accent));
3
+ --Button-background-hover: var(--color-sentiment-interactive-primary-hover, var(--color-interactive-accent-hover));
4
+ --Button-background-active: var(--color-sentiment-interactive-primary-active, var(--color-interactive-accent-active));
5
+ --Button-color: var(--color-sentiment-interactive-control, var(--color-interactive-control));
6
+ --Button-color-hover: var(--color-sentiment-interactive-control-hover, var(--color-interactive-control-hover));
7
+ --Button-color-active: var(--color-sentiment-interactive-control-active, var(--color-interactive-control-active));
8
8
  --Button-border-radius: var(--radius-full);
9
9
  --Button-label-gap: var(--size-4);
10
10
  --Button-large-padding: var(--size-12) var(--size-16);
@@ -13,16 +13,16 @@
13
13
  --Button-avatar-border-color: var(--color-border-neutral);
14
14
  --Button-transition-duration: 150ms;
15
15
  --Button-transition-easing: ease-in-out;
16
- --Button-secondary-background: var(--color-interactive-neutral);
17
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
18
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
19
- --Button-secondary-color: var(--color-interactive-primary);
20
- --Button-secondary-color-hover: var(--color-interactive-primary-hover);
21
- --Button-secondary-color-active: var(--color-interactive-primary-active);
22
- --Button-secondary-neutral-background: var(--color-background-neutral);
23
- --Button-secondary-neutral-background-hover: var(--color-background-neutral-hover);
24
- --Button-secondary-neutral-background-active: var(--color-background-neutral-active);
25
- --Button-secondary-neutral-color: var(--color-content-primary);
16
+ --Button-secondary-background: var(--color-sentiment-interactive-secondary-neutral, var(--color-interactive-neutral));
17
+ --Button-secondary-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-interactive-neutral-hover));
18
+ --Button-secondary-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-interactive-neutral-active));
19
+ --Button-secondary-color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
20
+ --Button-secondary-color-hover: var(--color-sentiment-content-primary-hover, var(--color-interactive-primary-hover));
21
+ --Button-secondary-color-active: var(--color-sentiment-content-primary-active, var(--color-interactive-primary-active));
22
+ --Button-secondary-neutral-background: var(--color-sentiment-interactive-secondary-neutral, var(--color-background-neutral));
23
+ --Button-secondary-neutral-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-neutral-hover));
24
+ --Button-secondary-neutral-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-neutral-active));
25
+ --Button-secondary-neutral-color: var(--color-sentiment-content-primary, var(--color-content-primary));
26
26
  --Button-tertiary-background: transparent;
27
27
  --Button-tertiary-background-hover: var(--color-background-screen-hover);
28
28
  --Button-tertiary-background-active: var(--color-background-screen-active);
@@ -113,7 +113,7 @@
113
113
  --Button-color-active: var(--Button-secondary-neutral-color);
114
114
  }
115
115
  .wds-Button--secondary-neutral .wds-Button-icon--end {
116
- color: var(--color-interactive-primary);
116
+ color: var(--Button-secondary-color);
117
117
  }
118
118
  .wds-Button--tertiary {
119
119
  --Button-background: var(--Button-tertiary-background);
@@ -74,7 +74,7 @@
74
74
  --Button-color-active: var(--Button-secondary-neutral-color);
75
75
 
76
76
  .wds-Button-icon--end {
77
- color: var(--color-interactive-primary);
77
+ color: var(--Button-secondary-color);
78
78
  }
79
79
  }
80
80
 
@@ -5,6 +5,7 @@ import { Flag } from '@wise/art';
5
5
  import Button from './Button.resolver';
6
6
  import type { ButtonProps, ButtonPriority } from './Button.types';
7
7
  import { lorem10, lorem20, storyConfig } from '../test-utils';
8
+ import SentimentSurface from '../sentimentSurface';
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
805
+ * colours if wrapped inside the [SentimentSurface](/?path=/docs/content-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
+ };
@@ -2,6 +2,10 @@ import { Meta } from '@storybook/react-webpack5';
2
2
  import Button from './Button.resolver';
3
3
  import { expect, userEvent, within } from 'storybook/test';
4
4
  import { storyConfig } from '../test-utils';
5
+ import { ButtonPriority } from './Button.types';
6
+ import { ArrowRight, ChevronRight, Freeze } from '@transferwise/icons';
7
+ import SentimentSurface from '../sentimentSurface';
8
+ import { Flag } from '@wise/art';
5
9
 
6
10
  const meta: Meta<typeof Button> = {
7
11
  component: Button,
@@ -25,3 +29,188 @@ FocusTertiary.play = async ({ canvasElement }) => {
25
29
  const buttonElement: HTMLButtonElement = canvas.getByRole('button');
26
30
  await expect(buttonElement).toHaveFocus();
27
31
  };
32
+
33
+ const buttonPriorities = ['primary', 'secondary', 'secondary-neutral', 'tertiary'] as const;
34
+ const buttonSizes = ['sm', 'md', 'lg'] as const;
35
+ export const AllVariants = storyConfig(
36
+ {
37
+ tags: ['!autodocs'],
38
+ parameters: {
39
+ padding: '0',
40
+ },
41
+ render: () => (
42
+ <div
43
+ className="button-variants"
44
+ style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
45
+ >
46
+ {buttonPriorities.map((priority) =>
47
+ buttonSizes.map((size) => (
48
+ <div
49
+ key={`${priority}-default-${size}`}
50
+ style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
51
+ >
52
+ <Button
53
+ v2
54
+ priority={priority as ButtonPriority}
55
+ size={size}
56
+ addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
57
+ addonEnd={{ type: 'icon', value: <ArrowRight /> }}
58
+ block
59
+ >
60
+ {`${priority} default ${size}`}
61
+ </Button>
62
+ <Button
63
+ className="m-t-1 m-b-1"
64
+ v2
65
+ priority={priority as ButtonPriority}
66
+ size={size}
67
+ addonStart={{
68
+ type: 'avatar',
69
+ value: [{ asset: <Freeze /> }, { asset: <Freeze /> }],
70
+ }}
71
+ addonEnd={{ type: 'icon', value: <ArrowRight /> }}
72
+ block
73
+ disabled
74
+ >
75
+ {`${priority} default ${size} Disabled`}
76
+ </Button>
77
+ <Button
78
+ v2
79
+ priority={priority as ButtonPriority}
80
+ size={size}
81
+ addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
82
+ addonEnd={{ type: 'icon', value: <ArrowRight /> }}
83
+ block
84
+ loading
85
+ >
86
+ {`${priority} default ${size} Loading`}
87
+ </Button>
88
+ </div>
89
+ )),
90
+ )}
91
+ {['primary', 'secondary'].map((priority) =>
92
+ buttonSizes.map((size) => (
93
+ <div
94
+ key={`${priority}-negative-${size}`}
95
+ style={{ flex: '1 0 30%', marginBottom: '16px', justifyContent: 'space-between' }}
96
+ >
97
+ <Button
98
+ v2
99
+ sentiment="negative"
100
+ priority={priority as ButtonPriority}
101
+ size={size}
102
+ addonEnd={{ type: 'icon', value: <ChevronRight /> }}
103
+ addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
104
+ block
105
+ >
106
+ {`${priority} negative ${size}`}
107
+ </Button>
108
+ <Button
109
+ className="m-t-1 m-b-1"
110
+ v2
111
+ sentiment="negative"
112
+ priority={priority as ButtonPriority}
113
+ size={size}
114
+ addonEnd={{ type: 'icon', value: <ChevronRight /> }}
115
+ addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
116
+ block
117
+ disabled
118
+ >
119
+ {`${priority} negative ${size} Disabled`}
120
+ </Button>
121
+ <Button
122
+ v2
123
+ sentiment="negative"
124
+ priority={priority as ButtonPriority}
125
+ size={size}
126
+ addonEnd={{ type: 'icon', value: <ChevronRight /> }}
127
+ addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}
128
+ block
129
+ loading
130
+ >
131
+ {`${priority} negative ${size} Loading`}
132
+ </Button>
133
+ </div>
134
+ )),
135
+ )}
136
+ </div>
137
+ ),
138
+ },
139
+ { variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
140
+ );
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
+ );
@@ -1,10 +1,10 @@
1
1
  .wds-Button {
2
- --Button-background: var(--color-interactive-accent);
3
- --Button-background-hover: var(--color-interactive-accent-hover);
4
- --Button-background-active: var(--color-interactive-accent-active);
5
- --Button-color: var(--color-interactive-control);
6
- --Button-color-hover: var(--color-interactive-control-hover);
7
- --Button-color-active: var(--color-interactive-control-active);
2
+ --Button-background: var(--color-sentiment-interactive-primary, var(--color-interactive-accent));
3
+ --Button-background-hover: var(--color-sentiment-interactive-primary-hover, var(--color-interactive-accent-hover));
4
+ --Button-background-active: var(--color-sentiment-interactive-primary-active, var(--color-interactive-accent-active));
5
+ --Button-color: var(--color-sentiment-interactive-control, var(--color-interactive-control));
6
+ --Button-color-hover: var(--color-sentiment-interactive-control-hover, var(--color-interactive-control-hover));
7
+ --Button-color-active: var(--color-sentiment-interactive-control-active, var(--color-interactive-control-active));
8
8
  --Button-border-radius: var(--radius-full);
9
9
  --Button-label-gap: var(--size-4);
10
10
  --Button-large-padding: var(--size-12) var(--size-16);
@@ -13,16 +13,16 @@
13
13
  --Button-avatar-border-color: var(--color-border-neutral);
14
14
  --Button-transition-duration: 150ms;
15
15
  --Button-transition-easing: ease-in-out;
16
- --Button-secondary-background: var(--color-interactive-neutral);
17
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
18
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
19
- --Button-secondary-color: var(--color-interactive-primary);
20
- --Button-secondary-color-hover: var(--color-interactive-primary-hover);
21
- --Button-secondary-color-active: var(--color-interactive-primary-active);
22
- --Button-secondary-neutral-background: var(--color-background-neutral);
23
- --Button-secondary-neutral-background-hover: var(--color-background-neutral-hover);
24
- --Button-secondary-neutral-background-active: var(--color-background-neutral-active);
25
- --Button-secondary-neutral-color: var(--color-content-primary);
16
+ --Button-secondary-background: var(--color-sentiment-interactive-secondary-neutral, var(--color-interactive-neutral));
17
+ --Button-secondary-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-interactive-neutral-hover));
18
+ --Button-secondary-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-interactive-neutral-active));
19
+ --Button-secondary-color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
20
+ --Button-secondary-color-hover: var(--color-sentiment-content-primary-hover, var(--color-interactive-primary-hover));
21
+ --Button-secondary-color-active: var(--color-sentiment-content-primary-active, var(--color-interactive-primary-active));
22
+ --Button-secondary-neutral-background: var(--color-sentiment-interactive-secondary-neutral, var(--color-background-neutral));
23
+ --Button-secondary-neutral-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-neutral-hover));
24
+ --Button-secondary-neutral-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-neutral-active));
25
+ --Button-secondary-neutral-color: var(--color-sentiment-content-primary, var(--color-content-primary));
26
26
  --Button-tertiary-background: transparent;
27
27
  --Button-tertiary-background-hover: var(--color-background-screen-hover);
28
28
  --Button-tertiary-background-active: var(--color-background-screen-active);