@transferwise/components 46.120.1 → 46.121.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.
@@ -53,8 +53,7 @@
53
53
  }
54
54
 
55
55
  &-personal-card,
56
- &-business-card
57
- {
56
+ &-business-card {
58
57
  .media-position(104px, -15px, 2px);
59
58
  }
60
59
 
@@ -69,7 +68,7 @@
69
68
  &-shopping-bag {
70
69
  .media-position(116px, -9px, 14px);
71
70
  }
72
-
71
+
73
72
  &-flower {
74
73
  .media-position(156px, -24px, 11px);
75
74
  }
@@ -77,6 +76,10 @@
77
76
  &-backpack {
78
77
  .media-position(123px, -16px, 6px);
79
78
  }
79
+
80
+ &-gift-box {
81
+ .media-position(129px, -22px, 6px);
82
+ }
80
83
  }
81
84
 
82
85
  &-container {
@@ -85,11 +88,13 @@
85
88
  flex: 1;
86
89
  gap: var(--nudge-flex-gap);
87
90
  justify-content: space-between;
88
- padding: var(--nudge-container-padding) var(--nudge-container-padding) var(--nudge-container-padding) 0;
91
+ padding: var(--nudge-container-padding) var(--nudge-container-padding)
92
+ var(--nudge-container-padding) 0;
89
93
  width: 100%;
90
94
 
91
95
  [dir="rtl"] & {
92
- padding: var(--nudge-container-padding) 0 var(--nudge-container-padding) var(--nudge-container-padding);
96
+ padding: var(--nudge-container-padding) 0 var(--nudge-container-padding)
97
+ var(--nudge-container-padding);
93
98
  }
94
99
 
95
100
  .np-theme-personal & {
@@ -117,14 +122,6 @@
117
122
  text-decoration: var(--nudge-link-text-decoration);
118
123
  }
119
124
  }
120
-
121
- .wds-nudge-control {
122
- max-width: var(--nudge-control-width);
123
- flex-basis: var(--nudge-control-width);
124
- flex: 0 0 var(--nudge-control-width);
125
- height: var(--nudge-control-width);
126
- background-color: var(--nudge-control-background-color);
127
- }
128
125
  }
129
126
  }
130
127
 
@@ -1,14 +1,11 @@
1
- import { render, fireEvent, cleanup, screen } from '../test-utils';
1
+ import { render, fireEvent, cleanup, screen, mockMatchMedia } from '../test-utils';
2
2
 
3
3
  import Nudge from '.';
4
4
 
5
+ mockMatchMedia();
6
+
5
7
  describe('Nudge', () => {
6
8
  const defaultProps = {
7
- media: (
8
- <span role="img" aria-label="Party popper emoji">
9
- 🎉
10
- </span>
11
- ),
12
9
  title: 'A nudge title',
13
10
  link: 'CTA',
14
11
  href: '#',
@@ -75,6 +72,7 @@ describe('Nudge', () => {
75
72
  });
76
73
 
77
74
  it('shows a nudge if localStorage has been set with a different id for a different nudge and calls is previously dismissed with FALSE', () => {
75
+ mockMatchMedia();
78
76
  jest.spyOn(Storage.prototype, 'getItem').mockReturnValue('["BANANA"]');
79
77
  const isPreviouslyDismissed = jest.fn();
80
78
 
@@ -92,6 +90,7 @@ describe('Nudge', () => {
92
90
  });
93
91
 
94
92
  it('calls local storage with updated dismissed nudges value', () => {
93
+ mockMatchMedia();
95
94
  jest.spyOn(Storage.prototype, 'getItem').mockReturnValue('["BANANA"]');
96
95
  const setItem = jest.spyOn(Storage.prototype, 'setItem');
97
96
 
@@ -119,6 +119,15 @@ export const Default = () => {
119
119
  onClick={action('action clicked')}
120
120
  onDismiss={action('dismissed')}
121
121
  />
122
+ <Nudge
123
+ mediaName={Assets.GIFT_BOX}
124
+ className="m-b-2"
125
+ title="Text that is no longer than two lines."
126
+ link="Link"
127
+ href="#"
128
+ onClick={action('action clicked')}
129
+ onDismiss={action('dismissed')}
130
+ />
122
131
  </div>
123
132
  );
124
133
  };
@@ -4,9 +4,12 @@ import { ReactNode, useEffect, useState, MouseEvent } from 'react';
4
4
 
5
5
  import Body from '../body';
6
6
  import { Typography } from '../common';
7
- import { CloseButton } from '../common/closeButton';
8
7
  import Link from '../link';
9
8
  import type { AlertAction } from '../alert';
9
+ import IconButton from '../iconButton';
10
+ import { Cross } from '@transferwise/icons';
11
+ import { useIntl } from 'react-intl';
12
+ import closeBtnMessages from '../common/closeButton/CloseButton.messages';
10
13
 
11
14
  // WARNING: Changing this will cause nudges to reappear wherever persist nudge is used and privacy team will need to be updated too
12
15
  export const STORAGE_NAME = 'dismissedNudges';
@@ -39,6 +42,7 @@ type MediaNameType =
39
42
  | `${Assets.MULTI_CURRENCY}`
40
43
  | `${Assets.SHOPPING_BAG}`
41
44
  | `${Assets.FLOWER}`
45
+ | `${Assets.GIFT_BOX}`
42
46
  | `${Assets.BACKPACK}`;
43
47
 
44
48
  type BaseProps = {
@@ -79,7 +83,6 @@ export interface RequiredPersistProps extends BaseProps {
79
83
  export type Props = OptionalId | RequiredPersistProps;
80
84
 
81
85
  const Nudge = ({
82
- media,
83
86
  mediaName,
84
87
  title,
85
88
  link,
@@ -92,6 +95,7 @@ const Nudge = ({
92
95
  className,
93
96
  action,
94
97
  }: Props) => {
98
+ const intl = useIntl();
95
99
  const [isDismissed, setIsDismissed] = useState(false);
96
100
  const [isMounted, setIsMounted] = useState(false);
97
101
 
@@ -177,7 +181,14 @@ const Nudge = ({
177
181
  )}
178
182
  </div>
179
183
  {onDismiss || persistDismissal ? (
180
- <CloseButton className="wds-nudge-control" size="sm" onClick={handleOnDismiss} />
184
+ <IconButton
185
+ size={24}
186
+ priority="tertiary"
187
+ aria-label={intl.formatMessage(closeBtnMessages.ariaLabel)}
188
+ onClick={handleOnDismiss}
189
+ >
190
+ <Cross />
191
+ </IconButton>
181
192
  ) : null}
182
193
  </div>
183
194
  </div>