@transferwise/components 0.0.0-experimental-75fc27b → 0.0.0-experimental-8a932bb
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/avatarLayout/AvatarLayout.js +10 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +10 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button/src/Button.js +93 -0
- package/build/button/Button/src/Button.js.map +1 -0
- package/build/button/Button/src/Button.mjs +91 -0
- package/build/button/Button/src/Button.mjs.map +1 -0
- package/build/button/{Button.js → LegacyButton/Button.js} +25 -24
- package/build/button/LegacyButton/Button.js.map +1 -0
- package/build/button/{Button.mjs → LegacyButton/Button.mjs} +25 -24
- package/build/button/LegacyButton/Button.mjs.map +1 -0
- package/build/button/LegacyButton/classMap.js +42 -0
- package/build/button/LegacyButton/classMap.js.map +1 -0
- package/build/button/LegacyButton/classMap.mjs +39 -0
- package/build/button/LegacyButton/classMap.mjs.map +1 -0
- package/build/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.js +21 -21
- package/build/button/LegacyButton/legacyUtils/legacyUtils.js.map +1 -0
- package/build/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.mjs +21 -21
- package/build/button/LegacyButton/legacyUtils/legacyUtils.mjs.map +1 -0
- package/build/button/src/Button.js +76 -0
- package/build/button/src/Button.js.map +1 -0
- package/build/button/src/Button.mjs +74 -0
- package/build/button/src/Button.mjs.map +1 -0
- package/build/circularButton/CircularButton.js +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/action/Action.js +1 -1
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +1 -1
- package/build/common/action/Action.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/index.js +1 -1
- package/build/index.mjs +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +288 -29
- package/build/nudge/Nudge.js +1 -1
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +1 -1
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/select/Select.js +4 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +4 -2
- package/build/select/Select.mjs.map +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button/less/Button.css +253 -0
- package/build/styles/button/Button/less/Button.vars.css +57 -0
- package/build/styles/iconButton/IconButton.css +24 -29
- package/build/styles/main.css +288 -29
- package/build/types/avatarLayout/AvatarLayout.d.ts +1 -2
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarLayout/index.d.ts +1 -0
- package/build/types/avatarLayout/index.d.ts.map +1 -1
- package/build/types/button/Button/index.d.ts +3 -0
- package/build/types/button/Button/index.d.ts.map +1 -0
- package/build/types/button/Button/src/Button.d.ts +4 -0
- package/build/types/button/Button/src/Button.d.ts.map +1 -0
- package/build/types/button/Button/src/Button.types.d.ts +50 -0
- package/build/types/button/Button/src/Button.types.d.ts.map +1 -0
- package/build/types/button/Button/src/index.d.ts +2 -0
- package/build/types/button/Button/src/index.d.ts.map +1 -0
- package/build/types/button/{Button.d.ts → LegacyButton/Button.d.ts} +6 -4
- package/build/types/button/LegacyButton/Button.d.ts.map +1 -0
- package/build/types/button/LegacyButton/classMap.d.ts.map +1 -0
- package/build/types/button/LegacyButton/index.d.ts +3 -0
- package/build/types/button/LegacyButton/index.d.ts.map +1 -0
- package/build/types/button/LegacyButton/legacyUtils/index.d.ts.map +1 -0
- package/build/types/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.d.ts +1 -1
- package/build/types/button/LegacyButton/legacyUtils/legacyUtils.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/button/src/Button.d.ts +30 -0
- package/build/types/button/src/Button.d.ts.map +1 -0
- package/build/types/button/src/index.d.ts +3 -0
- package/build/types/button/src/index.d.ts.map +1 -0
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +5 -5
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.story.tsx +2 -0
- package/src/avatarLayout/AvatarLayout.tsx +14 -4
- package/src/avatarLayout/index.ts +1 -0
- package/src/avatarWrapper/AvatarWrapper.story.tsx +2 -0
- package/src/button/Button/index.ts +2 -0
- package/src/button/Button/less/Button.css +253 -0
- package/src/button/Button/less/Button.less +221 -0
- package/src/button/Button/less/Button.vars.css +57 -0
- package/src/button/Button/less/Button.vars.less +65 -0
- package/src/button/Button/src/Button.tsx +116 -0
- package/src/button/Button/src/Button.types.ts +70 -0
- package/src/button/Button/src/index.ts +1 -0
- package/src/button/Button/stories/Button.story.tsx +314 -0
- package/src/button/Button/stories/Button.tests.story.tsx +288 -0
- package/src/button/Button/test/Button.spec.tsx +328 -0
- package/src/button/{Button.less → LegacyButton/Button.less} +1 -1
- package/src/button/{Button.spec.tsx → LegacyButton/Button.spec.tsx} +3 -3
- package/src/button/LegacyButton/Button.story.tsx +224 -0
- package/src/button/{Button.tsx → LegacyButton/Button.tsx} +12 -8
- package/src/button/{classMap.ts → LegacyButton/classMap.ts} +1 -1
- package/src/button/LegacyButton/index.ts +3 -0
- package/src/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.spec.tsx +2 -2
- package/src/button/{legacyUtils → LegacyButton/legacyUtils}/legacyUtils.ts +2 -2
- package/src/button/index.ts +2 -3
- package/src/button/src/Button.tsx +118 -0
- package/src/button/src/index.ts +2 -0
- package/src/button/test/Button.spec.tsx +66 -0
- package/src/circularButton/CircularButton.tsx +1 -1
- package/src/common/action/Action.tsx +1 -1
- package/src/iconButton/IconButton.css +24 -29
- package/src/iconButton/IconButton.less +4 -4
- package/src/link/Link.tsx +15 -6
- package/src/main.css +288 -29
- package/src/main.less +2 -1
- package/src/nudge/Nudge.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -1
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -1
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +2 -3
- package/src/select/Select.tsx +1 -0
- package/src/test-utils/index.tsx +0 -1
- package/build/button/Button.js.map +0 -1
- package/build/button/Button.mjs.map +0 -1
- package/build/button/classMap.js +0 -42
- package/build/button/classMap.js.map +0 -1
- package/build/button/classMap.mjs +0 -39
- package/build/button/classMap.mjs.map +0 -1
- package/build/button/legacyUtils/legacyUtils.js.map +0 -1
- package/build/button/legacyUtils/legacyUtils.mjs.map +0 -1
- package/build/types/button/Button.d.ts.map +0 -1
- package/build/types/button/classMap.d.ts.map +0 -1
- package/build/types/button/legacyUtils/index.d.ts.map +0 -1
- package/build/types/button/legacyUtils/legacyUtils.d.ts.map +0 -1
- package/src/button/Button.story.tsx +0 -163
- /package/build/styles/button/{Button.css → LegacyButton/Button.css} +0 -0
- /package/build/types/button/{classMap.d.ts → LegacyButton/classMap.d.ts} +0 -0
- /package/build/types/button/{legacyUtils → LegacyButton/legacyUtils}/index.d.ts +0 -0
- /package/src/button/{Button.css → LegacyButton/Button.css} +0 -0
- /package/src/button/{__snapshots__ → LegacyButton/__snapshots__}/Button.spec.tsx.snap +0 -0
- /package/src/button/{legacyUtils → LegacyButton/legacyUtils}/index.ts +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import LegacyButton, { ButtonProps as LegacyButtonProps } from '../LegacyButton';
|
|
4
|
+
import NewButton from '../Button';
|
|
5
|
+
import { ButtonProps as NewButtonProps } from '../Button/src/Button.types';
|
|
6
|
+
|
|
7
|
+
type LegacyButtonType =
|
|
8
|
+
| 'accent'
|
|
9
|
+
| 'negative'
|
|
10
|
+
| 'positive'
|
|
11
|
+
| 'primary'
|
|
12
|
+
| 'pay'
|
|
13
|
+
| 'secondary'
|
|
14
|
+
| 'danger'
|
|
15
|
+
| 'link'
|
|
16
|
+
| null
|
|
17
|
+
| undefined;
|
|
18
|
+
type NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;
|
|
19
|
+
|
|
20
|
+
export type ButtonProps =
|
|
21
|
+
| (Omit<LegacyButtonProps, 'ref'> & {
|
|
22
|
+
type?: LegacyButtonType;
|
|
23
|
+
htmlType?: string;
|
|
24
|
+
useNewButton?: false;
|
|
25
|
+
href?: string;
|
|
26
|
+
ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;
|
|
27
|
+
})
|
|
28
|
+
| (Omit<Omit<NewButtonProps, 'type'>, 'ref'> & {
|
|
29
|
+
type?: NewButtonType;
|
|
30
|
+
useNewButton: true;
|
|
31
|
+
href?: string;
|
|
32
|
+
ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
36
|
+
const { priority, size, type, as, ...newProps } = props;
|
|
37
|
+
|
|
38
|
+
const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
|
|
39
|
+
accent: {
|
|
40
|
+
primary: 'primary',
|
|
41
|
+
secondary: 'tertiary',
|
|
42
|
+
tertiary: 'minimal',
|
|
43
|
+
},
|
|
44
|
+
positive: {
|
|
45
|
+
primary: 'primary',
|
|
46
|
+
secondary: 'tertiary',
|
|
47
|
+
tertiary: 'tertiary',
|
|
48
|
+
},
|
|
49
|
+
negative: {
|
|
50
|
+
primary: 'primary',
|
|
51
|
+
secondary: 'secondary',
|
|
52
|
+
tertiary: 'secondary',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const mappedPriority =
|
|
57
|
+
type && priority ? priorityMapping[type]?.[priority] || priority : priority || null;
|
|
58
|
+
const mappedAppearance = type === 'negative' ? 'negative' : null;
|
|
59
|
+
|
|
60
|
+
const legacyButtonTypes: LegacyButtonType[] = [
|
|
61
|
+
'accent',
|
|
62
|
+
'negative',
|
|
63
|
+
'positive',
|
|
64
|
+
'primary',
|
|
65
|
+
'pay',
|
|
66
|
+
'secondary',
|
|
67
|
+
'danger',
|
|
68
|
+
'link',
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
...newProps,
|
|
73
|
+
size:
|
|
74
|
+
size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
75
|
+
priority: mappedPriority,
|
|
76
|
+
appearance: mappedAppearance || ('appearance' in props ? props.appearance : null),
|
|
77
|
+
type:
|
|
78
|
+
type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,
|
|
79
|
+
href: as === 'a' ? props.href || '' : null,
|
|
80
|
+
} as NewButtonProps;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {
|
|
84
|
+
const { useNewButton, as, ...rest } = props;
|
|
85
|
+
|
|
86
|
+
if (useNewButton) {
|
|
87
|
+
const mappedProps = mapProps(props as LegacyButtonProps);
|
|
88
|
+
return (
|
|
89
|
+
<NewButton
|
|
90
|
+
{...mappedProps}
|
|
91
|
+
ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}
|
|
92
|
+
as={as}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (as === 'a') {
|
|
98
|
+
return (
|
|
99
|
+
<LegacyButton
|
|
100
|
+
{...(rest as LegacyButtonProps & React.AnchorHTMLAttributes<HTMLAnchorElement>)}
|
|
101
|
+
ref={ref as React.Ref<HTMLAnchorElement>}
|
|
102
|
+
as="a"
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<LegacyButton
|
|
109
|
+
{...(rest as LegacyButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>)}
|
|
110
|
+
ref={ref as React.Ref<HTMLButtonElement>}
|
|
111
|
+
as="button"
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
Button.displayName = 'Button';
|
|
117
|
+
|
|
118
|
+
export default Button;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { render, screen } from '../../test-utils';
|
|
2
|
+
import Button, { ButtonProps } from '..';
|
|
3
|
+
|
|
4
|
+
describe('Button', () => {
|
|
5
|
+
const legacyProps: ButtonProps = {
|
|
6
|
+
priority: 'primary',
|
|
7
|
+
size: 'md',
|
|
8
|
+
type: 'accent',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const newProps: ButtonProps = {
|
|
12
|
+
useNewButton: true,
|
|
13
|
+
priority: 'primary',
|
|
14
|
+
size: 'md',
|
|
15
|
+
type: 'accent',
|
|
16
|
+
testId: 'new-button',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it('renders LegacyButton when useNewButton is false', () => {
|
|
20
|
+
render(<Button {...legacyProps}>Legacy Button</Button>);
|
|
21
|
+
const button = screen.getByText('Legacy Button');
|
|
22
|
+
expect(button).toBeInTheDocument();
|
|
23
|
+
expect(button).toHaveClass('btn btn-md np-btn np-btn-md btn-accent btn-priority-1');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders the new Button when useNewButton is true', () => {
|
|
27
|
+
render(<Button {...newProps}>New Button</Button>);
|
|
28
|
+
const button = screen.getByTestId('new-button');
|
|
29
|
+
expect(button).toBeInTheDocument();
|
|
30
|
+
expect(button).toHaveClass('wds-Button wds-Button--medium wds-Button--primary');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders a button with href when as is "a"', () => {
|
|
34
|
+
const linkProps: ButtonProps = {
|
|
35
|
+
...legacyProps,
|
|
36
|
+
as: 'a',
|
|
37
|
+
href: 'https://example.com',
|
|
38
|
+
};
|
|
39
|
+
render(<Button {...linkProps}>Legacy Button</Button>);
|
|
40
|
+
const linkButton = screen.getByText('Legacy Button');
|
|
41
|
+
expect(linkButton).toBeInTheDocument();
|
|
42
|
+
expect(linkButton).toHaveAttribute('href', 'https://example.com');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('does not set type when type is in LegacyButtonType', () => {
|
|
46
|
+
const legacyTypeProps: ButtonProps = {
|
|
47
|
+
...newProps,
|
|
48
|
+
type: 'accent',
|
|
49
|
+
};
|
|
50
|
+
render(<Button {...legacyTypeProps}>Button Type</Button>);
|
|
51
|
+
const button = screen.getByTestId('new-button');
|
|
52
|
+
expect(button).toBeInTheDocument();
|
|
53
|
+
expect(button).not.toHaveAttribute('type');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('sets type when type is not in LegacyButtonType', () => {
|
|
57
|
+
const buttonTypeProps: ButtonProps = {
|
|
58
|
+
...newProps,
|
|
59
|
+
type: 'submit',
|
|
60
|
+
};
|
|
61
|
+
render(<Button {...buttonTypeProps}>Submit Button</Button>);
|
|
62
|
+
const button = screen.getByTestId('new-button');
|
|
63
|
+
expect(button).toBeInTheDocument();
|
|
64
|
+
expect(button).toHaveAttribute('type', 'submit');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -2,7 +2,7 @@ import { clsx } from 'clsx';
|
|
|
2
2
|
import { cloneElement } from 'react';
|
|
3
3
|
|
|
4
4
|
import Body from '../body/Body';
|
|
5
|
-
import { typeClassMap, priorityClassMap } from '../button/classMap';
|
|
5
|
+
import { typeClassMap, priorityClassMap } from '../button/LegacyButton/classMap';
|
|
6
6
|
import { Breakpoint, ControlType, Priority, Typography } from '../common';
|
|
7
7
|
import Circle from '../common/circle';
|
|
8
8
|
import { useMedia } from '../common/hooks/useMedia';
|
|
@@ -22,7 +22,7 @@ export function Action({ action, className, variant = 'button' }: Props) {
|
|
|
22
22
|
if ('href' in action) {
|
|
23
23
|
return (
|
|
24
24
|
<Link
|
|
25
|
-
href={action.href}
|
|
25
|
+
href={action.href ?? ''}
|
|
26
26
|
className={className}
|
|
27
27
|
aria-label={action['aria-label']}
|
|
28
28
|
target={action.target}
|
|
@@ -2,77 +2,72 @@
|
|
|
2
2
|
border: none;
|
|
3
3
|
}
|
|
4
4
|
.np-icon-button-tertiary-default {
|
|
5
|
-
color: var(--color-interactive-primary);
|
|
6
|
-
background
|
|
7
|
-
background-color: var(--color-background-neutral);
|
|
5
|
+
--Button-color: var(--color-interactive-primary);
|
|
6
|
+
--Button-background: var(--color-background-neutral);
|
|
8
7
|
}
|
|
9
8
|
.np-icon-button-tertiary-default:not(.disabled):not(:disabled):hover {
|
|
10
|
-
background-
|
|
9
|
+
--Button-background-hover: var(--color-background-neutral-hover);
|
|
11
10
|
}
|
|
12
11
|
.np-icon-button-tertiary-default:not(.disabled):not(:disabled):active {
|
|
13
|
-
background-
|
|
12
|
+
--Button-background-active: var(--color-background-neutral-active);
|
|
14
13
|
}
|
|
15
14
|
.np-icon-button-primary-default {
|
|
16
|
-
color: var(--color-interactive-control);
|
|
17
|
-
background
|
|
18
|
-
background-color: var(--color-interactive-accent);
|
|
15
|
+
--Button-color: var(--color-interactive-control);
|
|
16
|
+
--Button-background: var(--color-interactive-accent);
|
|
19
17
|
}
|
|
20
18
|
.np-icon-button-primary-default:not(.disabled):not(:disabled):hover {
|
|
21
|
-
background-
|
|
22
|
-
background-color: var(--color-interactive-accent-hover);
|
|
19
|
+
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
23
20
|
}
|
|
24
21
|
.np-icon-button-primary-default:not(.disabled):not(:disabled):active {
|
|
25
|
-
background-
|
|
26
|
-
background-color: var(--color-interactive-accent-active);
|
|
22
|
+
--Button-background-active: var(--color-interactive-accent-active);
|
|
27
23
|
}
|
|
28
24
|
.np-icon-button-primary-negative {
|
|
29
|
-
color: var(--color-contrast-overlay);
|
|
30
|
-
background
|
|
25
|
+
--Button-color: var(--color-contrast-overlay);
|
|
26
|
+
--Button-background: var(--color-sentiment-negative-primary);
|
|
31
27
|
}
|
|
32
28
|
.np-icon-button-primary-negative:not(.disabled):not(:disabled):hover {
|
|
33
|
-
background-
|
|
29
|
+
--Button-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
34
30
|
}
|
|
35
31
|
.np-icon-button-primary-negative:not(.disabled):not(:disabled):active {
|
|
36
|
-
background-
|
|
32
|
+
--Button-background-active: var(--color-sentiment-negative-primary-active);
|
|
37
33
|
}
|
|
38
34
|
.np-theme-personal--bright-green .np-icon-button-primary-negative {
|
|
39
35
|
color: var(--color-white);
|
|
40
36
|
}
|
|
41
37
|
.np-icon-button-minimal-default {
|
|
42
|
-
color: var(--color-interactive-primary);
|
|
43
|
-
background
|
|
44
|
-
background-color: var(--color-background-screen);
|
|
38
|
+
--Button-color: var(--color-interactive-primary);
|
|
39
|
+
--Button-background: var(--color-background-screen);
|
|
45
40
|
background-color: transparent;
|
|
46
41
|
}
|
|
47
42
|
.np-icon-button-minimal-default:not(.disabled):not(:disabled):hover {
|
|
48
|
-
background-
|
|
43
|
+
--Button-background-hover: var(--color-background-screen-hover);
|
|
49
44
|
}
|
|
50
45
|
.np-icon-button-minimal-default:not(.disabled):not(:disabled):active {
|
|
51
|
-
background-
|
|
46
|
+
--Button-background-active: var(--color-background-screen-active);
|
|
52
47
|
}
|
|
53
48
|
.np-icon-button-secondary-default {
|
|
54
|
-
color: var(--color-interactive-primary);
|
|
55
|
-
background
|
|
49
|
+
--Button-color: var(--color-interactive-primary);
|
|
50
|
+
--Button-background: var(--color-interactive-neutral);
|
|
56
51
|
}
|
|
57
52
|
.np-icon-button-secondary-default:not(.disabled):not(:disabled):hover {
|
|
58
|
-
background-
|
|
53
|
+
--Button-background-hover: var(--color-interactive-neutral-hover);
|
|
59
54
|
}
|
|
60
55
|
.np-icon-button-secondary-default:not(.disabled):not(:disabled):active {
|
|
61
|
-
background-
|
|
56
|
+
--Button-background-active: var(--color-interactive-neutral-active);
|
|
62
57
|
}
|
|
63
58
|
.np-theme-personal--bright-green .np-icon-button-secondary-default,
|
|
64
59
|
.np-theme-personal--forest-green .np-icon-button-secondary-default {
|
|
65
60
|
color: var(--color-interactive-control);
|
|
66
61
|
}
|
|
67
62
|
.np-icon-button-secondary-negative {
|
|
68
|
-
color: var(--color-sentiment-negative-primary);
|
|
69
|
-
background
|
|
63
|
+
--Button-color: var(--color-sentiment-negative-primary);
|
|
64
|
+
--Button-background: var(--color-sentiment-negative-secondary);
|
|
70
65
|
}
|
|
71
66
|
.np-icon-button-secondary-negative:not(.disabled):not(:disabled):hover {
|
|
72
|
-
background-
|
|
67
|
+
--Button-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
73
68
|
}
|
|
74
69
|
.np-icon-button-secondary-negative:not(.disabled):not(:disabled):active {
|
|
75
|
-
background-
|
|
70
|
+
--Button-background-active: var(--color-sentiment-negative-secondary-active);
|
|
76
71
|
}
|
|
77
72
|
.np-theme-personal--bright-green .np-icon-button-secondary-negative {
|
|
78
73
|
color: var(--color-white);
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.colors(@icon-color, @bg-color) {
|
|
45
|
-
color: var(@icon-color);
|
|
46
|
-
background
|
|
45
|
+
--Button-color: var(@icon-color);
|
|
46
|
+
--Button-background: var(@bg-color);
|
|
47
47
|
|
|
48
48
|
&:not(.disabled, :disabled):hover {
|
|
49
|
-
background-
|
|
49
|
+
--Button-background-hover:~"var(@{bg-color}-hover)";
|
|
50
50
|
}
|
|
51
51
|
&:not(.disabled, :disabled):active {
|
|
52
|
-
background-
|
|
52
|
+
--Button-background-active:~"var(@{bg-color}-active)";
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/link/Link.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { AnchorHTMLAttributes } from 'react';
|
|
4
3
|
import { useIntl } from 'react-intl';
|
|
4
|
+
import { PrimitiveAnchor } from '../primitives';
|
|
5
|
+
import type { PrimitiveAnchorProps } from '../primitives';
|
|
5
6
|
|
|
6
7
|
import { LinkLarge, LinkDefault } from '../common';
|
|
7
8
|
|
|
8
9
|
import messages from './Link.messages';
|
|
9
10
|
|
|
10
|
-
export type Props =
|
|
11
|
+
export type Props = PrimitiveAnchorProps & { type?: LinkLarge | LinkDefault };
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Standard Link component with navigate away icon
|
|
@@ -24,22 +25,30 @@ const Link = ({
|
|
|
24
25
|
onClick,
|
|
25
26
|
...props
|
|
26
27
|
}: Props) => {
|
|
28
|
+
const { formatMessage } = useIntl();
|
|
27
29
|
const isBlank = target === '_blank';
|
|
28
30
|
|
|
29
|
-
const
|
|
31
|
+
const classNames = clsx(
|
|
32
|
+
'np-link',
|
|
33
|
+
'd-inline-flex',
|
|
34
|
+
{
|
|
35
|
+
[`np-text-${type}`]: type,
|
|
36
|
+
},
|
|
37
|
+
className,
|
|
38
|
+
);
|
|
30
39
|
|
|
31
40
|
return (
|
|
32
|
-
<
|
|
41
|
+
<PrimitiveAnchor
|
|
33
42
|
href={href}
|
|
34
43
|
target={target}
|
|
35
|
-
className={
|
|
44
|
+
className={classNames}
|
|
36
45
|
aria-label={ariaLabel}
|
|
37
46
|
rel={isBlank ? 'noreferrer' : undefined}
|
|
38
47
|
onClick={onClick}
|
|
39
48
|
{...props}
|
|
40
49
|
>
|
|
41
50
|
{children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}
|
|
42
|
-
</
|
|
51
|
+
</PrimitiveAnchor>
|
|
43
52
|
);
|
|
44
53
|
};
|
|
45
54
|
|