@transferwise/components 0.0.0-experimental-e94d625 → 0.0.0-experimental-8e1de95

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 (69) hide show
  1. package/build/Snackbar/Snackbar.js +97 -101
  2. package/build/Snackbar/Snackbar.js.map +1 -1
  3. package/build/Snackbar/Snackbar.mjs +98 -102
  4. package/build/Snackbar/Snackbar.mjs.map +1 -1
  5. package/build/types/Carousel/_stories/constants.d.ts +25 -0
  6. package/build/types/Carousel/_stories/constants.d.ts.map +1 -1
  7. package/build/types/ListItem/_stories/variants/helpers.d.ts +38 -1
  8. package/build/types/ListItem/_stories/variants/helpers.d.ts.map +1 -1
  9. package/build/types/Snackbar/Snackbar.d.ts +1 -15
  10. package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
  11. package/package.json +1 -1
  12. package/src/Accordion/_stories/Accordion.test.story.tsx +74 -48
  13. package/src/AvatarLayout/_stories/AvatarLayout.test.story.tsx +46 -30
  14. package/src/Button/LegacyButton/_stories/LegacyButton.test.story.tsx +29 -19
  15. package/src/Calendar/_stories/Calendar.test.story.tsx +34 -21
  16. package/src/Carousel/_stories/Carousel.test.story.tsx +18 -8
  17. package/src/Carousel/_stories/constants.tsx +29 -4
  18. package/src/Checkbox/_stories/Checkbox.test.story.tsx +22 -13
  19. package/src/CheckboxButton/_stories/CheckboxButton.test.story.tsx +23 -14
  20. package/src/Chips/_stories/Chips.test.story.tsx +51 -36
  21. package/src/DateInput/_stories/DateInput.rtl.test.story.tsx +62 -12
  22. package/src/Decision/_stories/Decision.test.story.tsx +74 -58
  23. package/src/DefinitionList/_stories/DefinitionList.test.story.tsx +58 -42
  24. package/src/Drawer/_stories/Drawer.rtl.test.story.tsx +65 -38
  25. package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.rtl.test.story.tsx +107 -74
  26. package/src/Field/_stories/Field.test.story.tsx +1 -1
  27. package/src/FlowNavigation/_stories/FlowNavigation.rtl.test.story.tsx +81 -51
  28. package/src/Header/_stories/Header.test.story.tsx +30 -18
  29. package/src/Info/_stories/Info.rtl.test.story.tsx +124 -50
  30. package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +4 -2
  31. package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +106 -77
  32. package/src/InstructionsList/_stories/InstructionsList.test.story.tsx +43 -16
  33. package/src/Link/_stories/Link.test.story.tsx +27 -13
  34. package/src/ListItem/_stories/ListItem.rtl.test.story.tsx +126 -6
  35. package/src/ListItem/_stories/variants/helpers.tsx +174 -126
  36. package/src/Loader/_stories/Loader.test.story.tsx +17 -10
  37. package/src/Modal/_stories/Modal.rtl.test.story.tsx +58 -39
  38. package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +14 -2
  39. package/src/Nudge/_stories/Nudge.test.story.tsx +70 -21
  40. package/src/Popover/_stories/Popover.rtl.test.story.tsx +92 -49
  41. package/src/PromoCard/_stories/PromoCard.test.story.tsx +53 -29
  42. package/src/PromoCard/_stories/PromoCardGroup.test.story.tsx +60 -36
  43. package/src/Prompt/ActionPrompt/_stories/ActionPrompt.test.story.tsx +74 -38
  44. package/src/Prompt/CriticalBanner/_stories/CriticalBanner.test.story.tsx +68 -31
  45. package/src/Prompt/InfoPrompt/_stories/InfoPrompt.test.story.tsx +52 -22
  46. package/src/Prompt/InlinePrompt/_stories/InlinePrompt.test.story.tsx +36 -21
  47. package/src/Radio/_stories/Radio.test.story.tsx +60 -46
  48. package/src/RadioGroup/_stories/RadioGroup.test.story.tsx +70 -51
  49. package/src/Section/_stories/Section.test.story.tsx +30 -14
  50. package/src/SegmentedControl/_stories/SegmentedControl.test.story.tsx +38 -15
  51. package/src/SlidingPanel/_stories/SlidingPanel.rtl.test.story.tsx +58 -34
  52. package/src/Snackbar/Snackbar.tsx +90 -88
  53. package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +24 -12
  54. package/src/Stepper/_stories/Stepper.test.story.tsx +27 -9
  55. package/src/Switch/_stories/Switch.test.story.tsx +20 -12
  56. package/src/Table/_stories/Table.test.story.tsx +107 -86
  57. package/src/Tabs/_stories/Tabs.test.story.tsx +92 -52
  58. package/src/Tag/_stories/Tag.test.story.tsx +27 -16
  59. package/src/Tooltip/_stories/Tooltip.rtl.test.story.tsx +68 -25
  60. package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +3 -3
  61. package/src/Upload/_stories/Upload.rtl.test.story.tsx +49 -26
  62. package/src/UploadInput/_stories/UploadInput.test.story.tsx +63 -41
  63. package/src/_deprecated/Alert/_stories/Alert.test.story.tsx +45 -24
  64. package/src/_deprecated/Card/_stories/Card.test.story.tsx +47 -23
  65. package/src/_deprecated/CriticalBanner/_stories/CriticalCommsBanner.test.story.tsx +21 -15
  66. package/src/_deprecated/InlineAlert/_stories/InlineAlert.test.story.tsx +23 -12
  67. package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +76 -40
  68. package/src/common/BottomSheet/_stories/BottomSheet.test.story.tsx +38 -20
  69. package/src/common/Panel/_stories/Panel.rtl.test.story.tsx +135 -51
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { StoryObj } from '@storybook/react-webpack5';
2
3
  import List from '../../../List';
3
4
  import { ListItem, type ListItemProps } from '../../ListItem';
@@ -13,140 +14,187 @@ import {
13
14
  type VariantPartial = { title: string } & Partial<ListItemProps>;
14
15
  type Variant = 'default' | 'dark' | 'rtl' | 'forest-green' | 'bright-green' | 'mobile' | '400%';
15
16
 
16
- const { title, subtitle, valueTitle, valueSubtitle, longTitle, longSubtitle, longValueTitle } =
17
- TEXT;
18
- const prompt = PROMPT.nonInteractive;
19
- const media = MEDIA.avatarSingle;
17
+ const PARTIALLY_INTERACTIVE: ControlType[] = [
18
+ 'partialButton',
19
+ 'partialButtonAsLink',
20
+ 'partialIconButton',
21
+ 'partialIconButtonAsLink',
22
+ ];
20
23
 
21
- type VariantStoryProps = {
24
+ export type VariantText = {
25
+ title: string;
26
+ subtitle: string;
27
+ valueTitle: string;
28
+ valueSubtitle: string;
29
+ longTitle: string;
30
+ longSubtitle: string;
31
+ longValueTitle: ReactNode;
32
+ };
33
+
34
+ /**
35
+ * Every piece of copy and every slot the instance matrix is built from. Extracted so a story can
36
+ * render the same matrix with different content — the RTL diff swaps in localised versions.
37
+ */
38
+ export type VariantContent = {
39
+ text: VariantText;
40
+ media: ReactNode;
41
+ additionalInfo: { interactive: ReactNode; nonInteractive: ReactNode };
42
+ prompt: { interactive: ReactNode; nonInteractive: ReactNode };
43
+ };
44
+
45
+ export const DEFAULT_VARIANT_CONTENT: VariantContent = {
46
+ text: TEXT,
47
+ media: MEDIA.avatarSingle,
48
+ additionalInfo: INFO,
49
+ prompt: PROMPT,
50
+ };
51
+
52
+ export const getVariantInstances = (
53
+ controlType: ControlType,
54
+ { text, media, additionalInfo: info, prompt: prompts }: VariantContent,
55
+ ): VariantPartial[] => {
56
+ const { title, subtitle, valueTitle, valueSubtitle, longTitle, longSubtitle, longValueTitle } =
57
+ text;
58
+ const isInteractive = PARTIALLY_INTERACTIVE.includes(controlType);
59
+ const additionalInfo = isInteractive ? info.interactive : info.nonInteractive;
60
+ const prompt = prompts.nonInteractive;
61
+
62
+ return [
63
+ { title },
64
+ { title: longTitle },
65
+ { title, valueTitle },
66
+ { title, valueTitle: longValueTitle },
67
+ { title: longTitle, valueTitle },
68
+ { title, subtitle },
69
+ { title, subtitle: longSubtitle },
70
+ { title, additionalInfo },
71
+ { title, valueTitle, valueSubtitle },
72
+ { title, valueTitle: longValueTitle, valueSubtitle },
73
+ { title, subtitle, inverted: true },
74
+ { title, subtitle, valueTitle },
75
+ { title, subtitle, valueTitle, inverted: true },
76
+ { title, subtitle, valueTitle, valueSubtitle },
77
+ {
78
+ title: longTitle,
79
+ subtitle: longSubtitle,
80
+ valueTitle,
81
+ valueSubtitle,
82
+ additionalInfo: info.nonInteractive,
83
+ },
84
+ { title, subtitle, valueTitle, valueSubtitle, inverted: true },
85
+ { media, title },
86
+ { media, title: longTitle },
87
+ { media, title, valueTitle },
88
+ { media, title: longTitle, valueTitle },
89
+ { media, title: longTitle, valueSubtitle },
90
+ { media, title, valueTitle: longValueTitle },
91
+ { media, title, valueTitle: longValueTitle, valueSubtitle },
92
+ { media, title, subtitle },
93
+ { media, title: longTitle, subtitle },
94
+ { media, title, valueTitle, valueSubtitle },
95
+ { media, title, valueTitle },
96
+ { media, title, valueSubtitle },
97
+ { media, title, subtitle },
98
+ { media, title, additionalInfo },
99
+ { media, title, subtitle, valueTitle },
100
+ { media, title, subtitle, valueTitle, valueSubtitle },
101
+ { media, title, subtitle, additionalInfo: info.nonInteractive },
102
+ isInteractive ? { media, title, subtitle, additionalInfo: info.interactive } : null,
103
+ { media, title, subtitle, additionalInfo, valueTitle },
104
+ { media, title, subtitle, additionalInfo, valueTitle, valueSubtitle },
105
+ {
106
+ media,
107
+ title: longTitle,
108
+ subtitle: longSubtitle,
109
+ valueTitle,
110
+ valueSubtitle,
111
+ additionalInfo: info.nonInteractive,
112
+ },
113
+ { media, title, subtitle, additionalInfo, valueTitle, valueSubtitle, prompt },
114
+ {
115
+ media,
116
+ title,
117
+ subtitle,
118
+ additionalInfo,
119
+ valueTitle,
120
+ valueSubtitle,
121
+ prompt: prompts.interactive,
122
+ },
123
+ {
124
+ media,
125
+ title,
126
+ subtitle,
127
+ additionalInfo,
128
+ valueTitle,
129
+ valueSubtitle,
130
+ prompt: prompts.interactive,
131
+ inverted: true,
132
+ },
133
+ {
134
+ media,
135
+ title,
136
+ subtitle,
137
+ additionalInfo,
138
+ valueTitle,
139
+ valueSubtitle,
140
+ prompt: prompts.interactive,
141
+ spotlight: 'active',
142
+ },
143
+ {
144
+ media,
145
+ title,
146
+ subtitle,
147
+ additionalInfo,
148
+ valueTitle,
149
+ valueSubtitle,
150
+ prompt: prompts.interactive,
151
+ spotlight: 'inactive',
152
+ },
153
+ {
154
+ media,
155
+ title,
156
+ subtitle,
157
+ additionalInfo,
158
+ valueTitle,
159
+ valueSubtitle,
160
+ prompt: prompts.interactive,
161
+ spotlight: 'inactive',
162
+ disabled: true,
163
+ },
164
+ ].filter(Boolean) as VariantPartial[];
165
+ };
166
+
167
+ export type VariantStoryProps = {
22
168
  controlType: ControlType;
23
169
  variant?: Variant;
24
170
  };
25
171
 
172
+ type VariantListProps = VariantStoryProps & {
173
+ content?: VariantContent;
174
+ controls?: Record<ControlType, ReactNode>;
175
+ };
176
+
177
+ export const VariantList = ({
178
+ controlType,
179
+ variant = 'default',
180
+ content = DEFAULT_VARIANT_CONTENT,
181
+ controls = CONTROLS,
182
+ }: VariantListProps) => (
183
+ <List>
184
+ {getVariantInstances(controlType, content).map((instance, index) => (
185
+ <ListItem
186
+ key={`${variant}-${controlType}-${index}`}
187
+ control={controls[controlType]}
188
+ {...instance}
189
+ />
190
+ ))}
191
+ </List>
192
+ );
193
+
26
194
  type VariantStory = StoryObj<VariantStoryProps>;
27
195
 
28
196
  export const VariantStory: VariantStory = {
29
- render: ({ controlType, variant = 'default' }) => {
30
- const control = CONTROLS[controlType];
31
- const isInteractive = [
32
- 'partialButton',
33
- 'partialButtonAsLink',
34
- 'partialIconButton',
35
- 'partialIconButtonAsLink',
36
- ].includes(controlType);
37
- const additionalInfo = isInteractive ? INFO.interactive : INFO.nonInteractive;
38
- const instances = [
39
- { title },
40
- { title: longTitle },
41
- { title, valueTitle },
42
- { title, valueTitle: longValueTitle },
43
- { title: longTitle, valueTitle },
44
- { title, subtitle },
45
- { title, subtitle: longSubtitle },
46
- { title, additionalInfo },
47
- { title, valueTitle, valueSubtitle },
48
- { title, valueTitle: longValueTitle, valueSubtitle },
49
- { title, subtitle, inverted: true },
50
- { title, subtitle, valueTitle },
51
- { title, subtitle, valueTitle, inverted: true },
52
- { title, subtitle, valueTitle, valueSubtitle },
53
- {
54
- title: longTitle,
55
- subtitle: longSubtitle,
56
- valueTitle,
57
- valueSubtitle,
58
- additionalInfo: INFO.nonInteractive,
59
- },
60
- { title, subtitle, valueTitle, valueSubtitle, inverted: true },
61
- { media, title },
62
- { media, title: longTitle },
63
- { media, title, valueTitle },
64
- { media, title: longTitle, valueTitle },
65
- { media, title: longTitle, valueSubtitle },
66
- { media, title, valueTitle: longValueTitle },
67
- { media, title, valueTitle: longValueTitle, valueSubtitle },
68
- { media, title, subtitle },
69
- { media, title: longTitle, subtitle },
70
- { media, title, valueTitle, valueSubtitle },
71
- { media, title, valueTitle },
72
- { media, title, valueSubtitle },
73
- { media, title, subtitle },
74
- { media, title, additionalInfo },
75
- { media, title, subtitle, valueTitle },
76
- { media, title, subtitle, valueTitle, valueSubtitle },
77
- { media, title, subtitle, additionalInfo: INFO.nonInteractive },
78
- isInteractive ? { media, title, subtitle, additionalInfo: INFO.interactive } : null,
79
- { media, title, subtitle, additionalInfo, valueTitle },
80
- { media, title, subtitle, additionalInfo, valueTitle, valueSubtitle },
81
- {
82
- media,
83
- title: longTitle,
84
- subtitle: longSubtitle,
85
- valueTitle,
86
- valueSubtitle,
87
- additionalInfo: INFO.nonInteractive,
88
- },
89
- { media, title, subtitle, additionalInfo, valueTitle, valueSubtitle, prompt },
90
- {
91
- media,
92
- title,
93
- subtitle,
94
- additionalInfo,
95
- valueTitle,
96
- valueSubtitle,
97
- prompt: PROMPT.interactive,
98
- },
99
- {
100
- media,
101
- title,
102
- subtitle,
103
- additionalInfo,
104
- valueTitle,
105
- valueSubtitle,
106
- prompt: PROMPT.interactive,
107
- inverted: true,
108
- },
109
- {
110
- media,
111
- title,
112
- subtitle,
113
- additionalInfo,
114
- valueTitle,
115
- valueSubtitle,
116
- prompt: PROMPT.interactive,
117
- spotlight: 'active',
118
- },
119
- {
120
- media,
121
- title,
122
- subtitle,
123
- additionalInfo,
124
- valueTitle,
125
- valueSubtitle,
126
- prompt: PROMPT.interactive,
127
- spotlight: 'inactive',
128
- },
129
- {
130
- media,
131
- title,
132
- subtitle,
133
- additionalInfo,
134
- valueTitle,
135
- valueSubtitle,
136
- prompt: PROMPT.interactive,
137
- spotlight: 'inactive',
138
- disabled: true,
139
- },
140
- ].filter(Boolean) as VariantPartial[];
141
-
142
- return (
143
- <List>
144
- {instances.map((instance, index) => (
145
- <ListItem key={`${variant}-${controlType}-${index}`} control={control} {...instance} />
146
- ))}
147
- </List>
148
- );
149
- },
197
+ render: ({ controlType, variant }) => <VariantList controlType={controlType} variant={variant} />,
150
198
  parameters: {
151
199
  variants: ['default'],
152
200
  },
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
2
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
3
3
  import Loader from '..';
4
4
 
5
5
  export default {
@@ -11,13 +11,20 @@ export default {
11
11
  type Story = StoryObj<typeof Loader>;
12
12
 
13
13
  export const RTLDiff: Story = {
14
- render: () => (
15
- <>
16
- <Loader size="sm" displayInstantly />
17
- <Loader size="md" displayInstantly />
18
- <Loader size="sm" displayInstantly label="Sending your money" />
19
- <Loader size="md" displayInstantly label="Sending your money" />
20
- </>
21
- ),
22
- ...withRTLDiff(),
14
+ render: () => {
15
+ const i18n = useRtlDiffI18n();
16
+ return (
17
+ <>
18
+ <Loader size="sm" displayInstantly />
19
+ <Loader size="md" displayInstantly />
20
+ <Loader size="sm" displayInstantly label={i18n.label} />
21
+ <Loader size="md" displayInstantly label={i18n.label} />
22
+ </>
23
+ );
24
+ },
25
+ ...withRTLDiff({
26
+ i18n: {
27
+ label: { en: 'Sending your money', ar: 'جارٍ إرسال أموالك' },
28
+ },
29
+ }),
23
30
  };
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
 
3
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
3
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
4
4
  import { Button, Modal } from '../..';
5
5
 
6
6
  export default {
@@ -11,49 +11,68 @@ export default {
11
11
 
12
12
  type Story = StoryObj<typeof Modal>;
13
13
 
14
- const iframeDiff = withRTLDiff({ renderAs: 'iframe' });
15
-
16
14
  export const WithTitleAndFooter: Story = {
17
- render: () => (
18
- <Modal
19
- open
20
- title="Modal title"
21
- body="Body content for the modal dialog."
22
- footer={
23
- <Button v2 block>
24
- Confirm
25
- </Button>
26
- }
27
- onClose={() => {}}
28
- />
29
- ),
30
- ...iframeDiff,
15
+ render: () => {
16
+ const i18n = useRtlDiffI18n();
17
+ return (
18
+ <Modal
19
+ open
20
+ title={i18n.title}
21
+ body={i18n.body}
22
+ footer={
23
+ <Button v2 block>
24
+ {i18n.confirm}
25
+ </Button>
26
+ }
27
+ onClose={() => {}}
28
+ />
29
+ );
30
+ },
31
+ ...withRTLDiff({
32
+ renderAs: 'iframe',
33
+ i18n: {
34
+ title: { en: 'Modal title', ar: 'عنوان النافذة' },
35
+ body: { en: 'Body content for the modal dialog.', ar: 'محتوى النافذة الحوارية.' },
36
+ confirm: { en: 'Confirm', ar: 'تأكيد' },
37
+ },
38
+ }),
31
39
  };
32
40
 
33
41
  export const WithoutFooter: Story = {
34
- render: () => (
35
- <Modal
36
- open
37
- title="Modal without footer"
38
- body="Body content without a footer."
39
- onClose={() => {}}
40
- />
41
- ),
42
- ...iframeDiff,
42
+ render: () => {
43
+ const i18n = useRtlDiffI18n();
44
+ return <Modal open title={i18n.title} body={i18n.body} onClose={() => {}} />;
45
+ },
46
+ ...withRTLDiff({
47
+ renderAs: 'iframe',
48
+ i18n: {
49
+ title: { en: 'Modal without footer', ar: 'نافذة بدون تذييل' },
50
+ body: { en: 'Body content without a footer.', ar: 'محتوى بدون تذييل.' },
51
+ },
52
+ }),
43
53
  };
44
54
 
45
55
  export const WithoutTitle: Story = {
46
- render: () => (
47
- <Modal
48
- open
49
- body="Body content without a title."
50
- footer={
51
- <Button v2 block>
52
- Done
53
- </Button>
54
- }
55
- onClose={() => {}}
56
- />
57
- ),
58
- ...iframeDiff,
56
+ render: () => {
57
+ const i18n = useRtlDiffI18n();
58
+ return (
59
+ <Modal
60
+ open
61
+ body={i18n.body}
62
+ footer={
63
+ <Button v2 block>
64
+ {i18n.done}
65
+ </Button>
66
+ }
67
+ onClose={() => {}}
68
+ />
69
+ );
70
+ },
71
+ ...withRTLDiff({
72
+ renderAs: 'iframe',
73
+ i18n: {
74
+ body: { en: 'Body content without a title.', ar: 'محتوى بدون عنوان.' },
75
+ done: { en: 'Done', ar: 'تم' },
76
+ },
77
+ }),
59
78
  };
@@ -29,6 +29,15 @@ const gbpCurrency = {
29
29
 
30
30
  const multipleCurrencies = [eurCurrency, gbpCurrency] as const;
31
31
 
32
+ /**
33
+ * `note` holds the currency's full name and renders only in the open dropdown, so only
34
+ * OpenDropdown needs the localised variants.
35
+ */
36
+ const getLocalisedCurrencies = (i18n: Record<string, string>) => [
37
+ { ...eurCurrency, note: i18n.euro },
38
+ { ...gbpCurrency, note: i18n.britishPound },
39
+ ];
40
+
32
41
  const sharedProps = {
33
42
  amount: 1000,
34
43
  id: 'money-input',
@@ -72,12 +81,13 @@ export const TriggerVariants: Story = {
72
81
  export const OpenDropdown: Story = {
73
82
  render: () => {
74
83
  const i18n = useRtlDiffI18n();
84
+ const currencies = getLocalisedCurrencies(i18n);
75
85
  return (
76
86
  <MoneyInput
77
87
  {...sharedProps}
78
88
  size="lg"
79
- currencies={multipleCurrencies}
80
- selectedCurrency={eurCurrency}
89
+ currencies={currencies}
90
+ selectedCurrency={currencies[0]}
81
91
  searchPlaceholder={i18n.searchPlaceholder}
82
92
  />
83
93
  );
@@ -93,6 +103,8 @@ export const OpenDropdown: Story = {
93
103
  width: '40%',
94
104
  i18n: {
95
105
  searchPlaceholder: { en: 'Search currencies or countries', ar: 'ابحث عن العملات أو الدول' },
106
+ euro: { en: 'Euro', ar: 'اليورو' },
107
+ britishPound: { en: 'British pound', ar: 'الجنيه الإسترليني' },
96
108
  },
97
109
  }),
98
110
  };
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
2
+ import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
3
3
  import Nudge from '../Nudge';
4
4
 
5
5
  export default {
@@ -28,27 +28,76 @@ const MEDIA_NAMES = [
28
28
  ] as const;
29
29
 
30
30
  export const RTLDiff: Story = {
31
- render: () => (
32
- <>
33
- {MEDIA_NAMES.map((mediaName) => (
31
+ render: () => {
32
+ const i18n = useRtlDiffI18n();
33
+ const mediaTitles: Record<(typeof MEDIA_NAMES)[number], string> = {
34
+ globe: i18n.globe,
35
+ lock: i18n.lock,
36
+ wallet: i18n.wallet,
37
+ gear: i18n.gear,
38
+ 'invite-letter': i18n.inviteLetter,
39
+ 'personal-card': i18n.personalCard,
40
+ 'business-card': i18n.businessCard,
41
+ heart: i18n.heart,
42
+ 'multi-currency': i18n.multiCurrency,
43
+ 'shopping-bag': i18n.shoppingBag,
44
+ flower: i18n.flower,
45
+ 'gift-box': i18n.giftBox,
46
+ backpack: i18n.backpack,
47
+ documents: i18n.documents,
48
+ };
49
+
50
+ return (
51
+ <>
52
+ {MEDIA_NAMES.map((mediaName) => (
53
+ <Nudge
54
+ key={mediaName}
55
+ mediaName={mediaName}
56
+ title={mediaTitles[mediaName]}
57
+ link={i18n.link}
58
+ href="#"
59
+ onDismiss={() => {}}
60
+ />
61
+ ))}
34
62
  <Nudge
35
- key={mediaName}
36
- mediaName={mediaName}
37
- title={mediaName}
38
- link="Link"
39
- href="#"
63
+ mediaName="globe"
64
+ title={i18n.withAction}
65
+ action={{ text: i18n.learnMore, href: '#' }}
40
66
  onDismiss={() => {}}
41
67
  />
42
- ))}
43
- <Nudge
44
- mediaName="globe"
45
- title="With action"
46
- action={{ text: 'Learn more', href: '#' }}
47
- onDismiss={() => {}}
48
- />
49
- <Nudge title="Without media, with dismiss" link="Link" href="#" onDismiss={() => {}} />
50
- <Nudge title="Without media, no dismiss" link="Link" href="#" />
51
- </>
52
- ),
53
- ...withRTLDiff({ width: 'stretch' }),
68
+ <Nudge title={i18n.withDismiss} link={i18n.link} href="#" onDismiss={() => {}} />
69
+ <Nudge title={i18n.withoutDismiss} link={i18n.link} href="#" />
70
+ </>
71
+ );
72
+ },
73
+ ...withRTLDiff({
74
+ width: 'stretch',
75
+ i18n: {
76
+ globe: { en: 'globe', ar: 'الكرة الأرضية' },
77
+ lock: { en: 'lock', ar: 'قفل' },
78
+ wallet: { en: 'wallet', ar: 'محفظة' },
79
+ gear: { en: 'gear', ar: 'ترس' },
80
+ inviteLetter: { en: 'invite-letter', ar: 'رسالة دعوة' },
81
+ personalCard: { en: 'personal-card', ar: 'بطاقة شخصية' },
82
+ businessCard: { en: 'business-card', ar: 'بطاقة تجارية' },
83
+ heart: { en: 'heart', ar: 'قلب' },
84
+ multiCurrency: { en: 'multi-currency', ar: 'عملات متعددة' },
85
+ shoppingBag: { en: 'shopping-bag', ar: 'حقيبة تسوق' },
86
+ flower: { en: 'flower', ar: 'زهرة' },
87
+ giftBox: { en: 'gift-box', ar: 'علبة هدايا' },
88
+ backpack: { en: 'backpack', ar: 'حقيبة ظهر' },
89
+ documents: { en: 'documents', ar: 'مستندات' },
90
+ link: { en: 'Link', ar: 'رابط' },
91
+ withAction: { en: 'With action', ar: 'مع إجراء' },
92
+ learnMore: { en: 'Learn more', ar: 'اعرف المزيد' },
93
+ withDismiss: {
94
+ en: 'Without media, with dismiss',
95
+ ar: 'بدون وسائط، مع إمكانية الإغلاق',
96
+ },
97
+ withoutDismiss: {
98
+ en: 'Without media, no dismiss',
99
+ ar: 'بدون وسائط، بدون إمكانية الإغلاق',
100
+ },
101
+ },
102
+ }),
54
103
  };