@transferwise/components 0.0.0-experimental-a656242 → 0.0.0-experimental-887f2e6
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 +9 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +9 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +1 -12
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +1 -12
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/button/Button.js +78 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +79 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +78 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +76 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/circularButton/CircularButton.js +21 -18
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +22 -19
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/definitionList/DefinitionList.js.map +1 -1
- package/build/definitionList/DefinitionList.mjs.map +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/de.json +0 -1
- package/build/i18n/de.json.js +0 -1
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +0 -1
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/i18n/it.json +0 -1
- package/build/i18n/it.json.js +0 -1
- package/build/i18n/it.json.js.map +1 -1
- package/build/i18n/it.json.mjs +0 -1
- package/build/i18n/it.json.mjs.map +1 -1
- package/build/i18n/th.json +0 -1
- package/build/i18n/th.json.js +0 -1
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +0 -1
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/index.js +2 -2
- 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 +416 -17
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +1 -3
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +1 -3
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +1 -4
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +1 -4
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +5 -3
- 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.css +240 -16
- package/build/styles/button/Button.vars.css +55 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/circularButton/CircularButton.css +158 -17
- package/build/styles/main.css +416 -17
- 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/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +1 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +31 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +67 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +30 -0
- package/build/types/button/LegacyButton.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/circularButton/CircularButton.d.ts +4 -11
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/definitionList/DefinitionList.d.ts +2 -1
- package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +11 -3
- package/src/avatarLayout/index.ts +1 -0
- package/src/avatarView/AvatarView.tsx +1 -15
- package/src/button/Button.css +240 -16
- package/src/button/Button.less +208 -14
- package/src/button/Button.resolver.tsx +120 -0
- package/src/button/Button.spec.tsx +54 -231
- package/src/button/Button.story.tsx +610 -137
- package/src/button/Button.tsx +88 -132
- package/src/button/Button.types.ts +88 -0
- package/src/button/Button.vars.css +55 -0
- package/src/button/Button.vars.less +69 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +146 -0
- package/src/button/LegacyButton.story.tsx +224 -0
- package/src/button/LegacyButton.tsx +161 -0
- package/src/button/index.ts +2 -3
- package/src/circularButton/CircularButton.css +158 -17
- package/src/circularButton/CircularButton.less +91 -22
- package/src/circularButton/CircularButton.story.tsx +24 -45
- package/src/circularButton/CircularButton.tsx +25 -38
- package/src/circularButton/_button-label-states.less +34 -0
- package/src/definitionList/DefinitionList.spec.js +91 -0
- package/src/definitionList/DefinitionList.story.tsx +57 -57
- package/src/definitionList/DefinitionList.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
- package/src/i18n/de.json +0 -1
- package/src/i18n/it.json +0 -1
- package/src/i18n/th.json +0 -1
- package/src/iconButton/IconButton.story.tsx +6 -6
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +416 -17
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +1 -7
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +1 -8
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +2 -5
- package/src/select/Select.tsx +1 -0
- package/src/slidingPanel/SlidingPanel.spec.js +56 -0
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
- package/src/slidingPanel/SlidingPanel.spec.tsx +0 -69
|
@@ -1,36 +1,105 @@
|
|
|
1
|
+
@import (reference) "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
|
|
2
|
+
@import "./_button-label-states.less";
|
|
3
|
+
|
|
1
4
|
.np-circular-btn {
|
|
2
5
|
display: inline-flex;
|
|
3
6
|
flex-direction: column;
|
|
4
7
|
align-items: center;
|
|
8
|
+
text-align: center;
|
|
5
9
|
cursor: pointer;
|
|
10
|
+
position: relative;
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
.tw-icon {
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: var(--size-16);
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
color: white;
|
|
17
|
+
transition: color 0.15s ease-in-out;
|
|
18
|
+
width: 100%;
|
|
19
|
+
.left(0);
|
|
20
|
+
|
|
21
|
+
@media (--screen-400-zoom) {
|
|
22
|
+
top: var(--size-12);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
> svg {
|
|
26
|
+
margin: 0 auto;
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
&:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
&:not(.disabled, :disabled):active {
|
|
28
|
-
color: var(--color-sentiment-negative-primary-active);
|
|
30
|
+
.np-theme-personal & {
|
|
31
|
+
/* stylelint-disable-next-line no-duplicate-selectors */
|
|
32
|
+
.tw-icon {
|
|
33
|
+
&,
|
|
34
|
+
&:hover,
|
|
35
|
+
&:active {
|
|
36
|
+
color: var(--color-interactive-control);
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
|
-
}
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
&.negative .tw-icon,
|
|
41
|
+
&.negative.secondary:not(.disabled, :disabled):hover .tw-icon,
|
|
42
|
+
&.negative.secondary:not(.disabled, :disabled):active .tw-icon {
|
|
43
|
+
// TODO, this will need to be removed when we update our CSS architecture
|
|
44
|
+
color: var(--color-contrast) !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.negative.secondary:not(.disabled, :disabled) .tw-icon {
|
|
48
|
+
// TODO, this will need to be removed when we update our CSS architecture
|
|
49
|
+
color: var(--color-sentiment-negative) !important;
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
52
|
}
|
|
53
|
+
|
|
54
|
+
.button-label-states(
|
|
55
|
+
np-circular-btn,
|
|
56
|
+
accent,
|
|
57
|
+
var(--color-interactive-accent),
|
|
58
|
+
var(--color-interactive-accent-hover),
|
|
59
|
+
var(--color-interactive-accent-active)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
.button-label-states(
|
|
63
|
+
np-circular-btn,
|
|
64
|
+
positive,
|
|
65
|
+
var(--color-interactive-positive),
|
|
66
|
+
var(--color-interactive-positive-hover),
|
|
67
|
+
var(--color-interactive-positive-active)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
.button-label-states(
|
|
71
|
+
np-circular-btn,
|
|
72
|
+
negative,
|
|
73
|
+
var(--color-interactive-negative),
|
|
74
|
+
var(--color-interactive-negative-hover),
|
|
75
|
+
var(--color-interactive-negative-active)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
.np-theme-personal {
|
|
79
|
+
.button-label-states(
|
|
80
|
+
np-circular-btn,
|
|
81
|
+
accent,
|
|
82
|
+
var(--color-interactive-primary),
|
|
83
|
+
var(--color-interactive-primary-hover),
|
|
84
|
+
var(--color-interactive-primary-active),
|
|
85
|
+
true
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
.button-label-states(
|
|
89
|
+
np-circular-btn,
|
|
90
|
+
positive,
|
|
91
|
+
var(--color-interactive-primary),
|
|
92
|
+
var(--color-interactive-primary-hover),
|
|
93
|
+
var(--color-interactive-primary-active),
|
|
94
|
+
true
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
.button-label-states(
|
|
98
|
+
np-circular-btn,
|
|
99
|
+
negative,
|
|
100
|
+
var(--color-sentiment-negative),
|
|
101
|
+
var(--color-sentiment-negative-hover),
|
|
102
|
+
var(--color-sentiment-negative-active),
|
|
103
|
+
true
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -5,16 +5,14 @@ import { ControlType, Priority } from '../common';
|
|
|
5
5
|
import { Meta, StoryObj } from '@storybook/react';
|
|
6
6
|
import CircularButton from './CircularButton';
|
|
7
7
|
import { storyConfig } from '../test-utils';
|
|
8
|
-
import Title from '../title';
|
|
9
|
-
import Body from '../body';
|
|
10
8
|
|
|
11
9
|
export default {
|
|
12
10
|
component: CircularButton,
|
|
13
11
|
title: 'Actions/CircularButton',
|
|
14
|
-
tags: ['autodocs'],
|
|
15
12
|
args: {
|
|
16
13
|
children: 'Button text',
|
|
17
|
-
icon
|
|
14
|
+
// Needs to be cast because we're mapping icon names to components
|
|
15
|
+
icon: 'Freeze' as unknown as React.ReactElement,
|
|
18
16
|
},
|
|
19
17
|
argTypes: {
|
|
20
18
|
icon: {
|
|
@@ -30,8 +28,8 @@ type Story = StoryObj<typeof CircularButton>;
|
|
|
30
28
|
|
|
31
29
|
export const Basic: Story = {
|
|
32
30
|
args: {
|
|
33
|
-
priority:
|
|
34
|
-
type:
|
|
31
|
+
priority: Priority.PRIMARY,
|
|
32
|
+
type: ControlType.ACCENT,
|
|
35
33
|
disabled: false,
|
|
36
34
|
},
|
|
37
35
|
};
|
|
@@ -43,45 +41,26 @@ export const All: Story = {
|
|
|
43
41
|
render: (props) => {
|
|
44
42
|
return (
|
|
45
43
|
<>
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
<CircularButton {...props} priority=
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
<CircularButton {...props}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<Title type="title-body" className="m-y-2">
|
|
67
|
-
Accent (Deprecated)
|
|
68
|
-
</Title>
|
|
69
|
-
<Body>
|
|
70
|
-
<CircularButton {...props} priority="primary" type="accent" />
|
|
71
|
-
<CircularButton {...props} priority="secondary" type="accent" />
|
|
72
|
-
<CircularButton {...props} priority="primary" type="accent" disabled />
|
|
73
|
-
<CircularButton {...props} priority="secondary" type="accent" disabled />
|
|
74
|
-
</Body>
|
|
75
|
-
|
|
76
|
-
<Title type="title-body" className="m-y-2">
|
|
77
|
-
Positive (Deprecated)
|
|
78
|
-
</Title>
|
|
79
|
-
<Body>
|
|
80
|
-
<CircularButton {...props} priority="primary" type="positive" />
|
|
81
|
-
<CircularButton {...props} priority="secondary" type="positive" />
|
|
82
|
-
<CircularButton {...props} priority="primary" type="positive" disabled />
|
|
83
|
-
<CircularButton {...props} priority="secondary" type="positive" disabled />
|
|
84
|
-
</Body>
|
|
44
|
+
<div className="m-b-2">
|
|
45
|
+
<div className="title-4 m-b-1">Accent</div>
|
|
46
|
+
<CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.ACCENT} />
|
|
47
|
+
<CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.ACCENT} />
|
|
48
|
+
</div>
|
|
49
|
+
<div className="m-b-2">
|
|
50
|
+
<div className="title-4 m-b-1">Positive</div>
|
|
51
|
+
<CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.POSITIVE} />
|
|
52
|
+
<CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.POSITIVE} />
|
|
53
|
+
</div>
|
|
54
|
+
<div className="m-b-2">
|
|
55
|
+
<div className="title-4 m-b-1">Negative</div>
|
|
56
|
+
<CircularButton {...props} priority={Priority.PRIMARY} type={ControlType.NEGATIVE} />
|
|
57
|
+
<CircularButton {...props} priority={Priority.SECONDARY} type={ControlType.NEGATIVE} />
|
|
58
|
+
</div>
|
|
59
|
+
<div className="m-b-2">
|
|
60
|
+
<div className="title-4 m-b-1">Disabled</div>
|
|
61
|
+
<CircularButton {...props} disabled />
|
|
62
|
+
<CircularButton {...props} priority={Priority.SECONDARY} disabled />
|
|
63
|
+
</div>
|
|
85
64
|
</>
|
|
86
65
|
);
|
|
87
66
|
},
|
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
+
import { cloneElement } from 'react';
|
|
2
3
|
|
|
3
4
|
import Body from '../body/Body';
|
|
5
|
+
import { typeClassMap, priorityClassMap } from '../button/classMap';
|
|
4
6
|
import { Breakpoint, ControlType, Priority, Typography } from '../common';
|
|
5
|
-
import
|
|
7
|
+
import Circle from '../common/circle';
|
|
6
8
|
import { useMedia } from '../common/hooks/useMedia';
|
|
7
9
|
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated use `'default'` instead
|
|
10
|
-
*/
|
|
11
|
-
type DeprecatedTypes = `${ControlType.ACCENT | ControlType.POSITIVE}`;
|
|
12
|
-
|
|
13
10
|
export interface CircularButtonProps {
|
|
14
11
|
className?: string;
|
|
15
12
|
children: string;
|
|
16
13
|
disabled?: boolean;
|
|
17
|
-
icon: React.ReactElement<{ size?: unknown }
|
|
18
|
-
onClick?: React.MouseEventHandler<HTMLInputElement
|
|
19
|
-
React.MouseEventHandler<HTMLButtonElement> &
|
|
20
|
-
React.MouseEventHandler<HTMLAnchorElement>;
|
|
14
|
+
icon: React.ReactElement<{ size?: unknown }>;
|
|
15
|
+
onClick?: React.MouseEventHandler<HTMLInputElement>;
|
|
21
16
|
priority?: `${Priority.PRIMARY | Priority.SECONDARY}`;
|
|
22
|
-
|
|
23
|
-
* `"accent"` and `"positive"` values are **deprecated**, please use `"default"` instead
|
|
24
|
-
*/
|
|
25
|
-
type?: DeprecatedTypes | 'default' | `${ControlType.NEGATIVE}`;
|
|
17
|
+
type?: `${ControlType.ACCENT | ControlType.POSITIVE | ControlType.NEGATIVE}`;
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
const CircularButton = ({
|
|
@@ -30,35 +22,30 @@ const CircularButton = ({
|
|
|
30
22
|
children,
|
|
31
23
|
disabled,
|
|
32
24
|
icon,
|
|
33
|
-
onClick,
|
|
34
25
|
priority = Priority.PRIMARY,
|
|
35
|
-
type =
|
|
26
|
+
type = ControlType.ACCENT,
|
|
27
|
+
...rest
|
|
36
28
|
}: CircularButtonProps) => {
|
|
29
|
+
const classes = clsx('btn np-btn', 'm-b-1', typeClassMap[type], priorityClassMap[priority]);
|
|
30
|
+
|
|
31
|
+
const iconElement = Number(icon.props.size) !== 24 ? cloneElement(icon, { size: 24 }) : icon;
|
|
32
|
+
|
|
37
33
|
const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
|
|
34
|
+
|
|
38
35
|
return (
|
|
39
|
-
<label
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<IconButton
|
|
48
|
-
size={isTinyViewport ? 32 : 56}
|
|
49
|
-
priority={priority}
|
|
50
|
-
type={['accent', 'positive'].includes(type) ? 'default' : (type as IconButtonProps['type'])}
|
|
51
|
-
className={clsx('m-b-1')}
|
|
36
|
+
<label className={clsx('np-circular-btn', priority, type, disabled && 'disabled', className)}>
|
|
37
|
+
<Circle
|
|
38
|
+
as="input"
|
|
39
|
+
// @ts-expect-error it's input[type=button] element
|
|
40
|
+
type="button"
|
|
41
|
+
size={isTinyViewport ? 72 : 56}
|
|
42
|
+
aria-label={children}
|
|
43
|
+
className={classes}
|
|
52
44
|
disabled={disabled}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<Body
|
|
58
|
-
as="span"
|
|
59
|
-
className={clsx('np-circular-btn-label', { disabled })}
|
|
60
|
-
type={Typography.BODY_DEFAULT_BOLD}
|
|
61
|
-
>
|
|
45
|
+
{...rest}
|
|
46
|
+
/>
|
|
47
|
+
{iconElement}
|
|
48
|
+
<Body as="span" className="np-circular-btn__label" type={Typography.BODY_DEFAULT_BOLD}>
|
|
62
49
|
{children}
|
|
63
50
|
</Body>
|
|
64
51
|
</label>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.button-label-states(@prefix, @type, @normal, @hover, @active, @isModernTheme: false) {
|
|
2
|
+
.@{prefix}.@{type} {
|
|
3
|
+
.@{prefix}__label {
|
|
4
|
+
color: @normal;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
&:not(.disabled, :disabled):hover .@{prefix}__label {
|
|
8
|
+
color: @hover;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&:active .@{prefix}__label,
|
|
12
|
+
input[type="button"]:active ~ .@{prefix}__label {
|
|
13
|
+
color: @active;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.secondary {
|
|
17
|
+
.tw-icon {
|
|
18
|
+
color: @normal;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:not(.disabled, :disabled):hover .tw-icon,
|
|
22
|
+
input[type="button"]:active + .tw-icon {
|
|
23
|
+
color: white;
|
|
24
|
+
& when (@isModernTheme = true) {
|
|
25
|
+
color: var(--color-interactive-control);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:active input[type="button"] + .tw-icon when (@isModernTheme = true) {
|
|
30
|
+
color: var(--color-interactive-control);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme';
|
|
2
|
+
|
|
3
|
+
import { DefinitionList } from '..';
|
|
4
|
+
import { Layout } from '../common';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
VERTICAL_TWO_COLUMN,
|
|
8
|
+
VERTICAL_ONE_COLUMN,
|
|
9
|
+
HORIZONTAL_LEFT_ALIGNED,
|
|
10
|
+
HORIZONTAL_RIGHT_ALIGNED,
|
|
11
|
+
HORIZONTAL_JUSTIFIED,
|
|
12
|
+
} = Layout;
|
|
13
|
+
|
|
14
|
+
describe('DefinitionList', () => {
|
|
15
|
+
const someDefinitions = () => [{ title: 'First', value: 'first value', key: 'first' }, null];
|
|
16
|
+
|
|
17
|
+
const withLayout = (layout) =>
|
|
18
|
+
shallow(<DefinitionList layout={layout} definitions={someDefinitions()} />);
|
|
19
|
+
|
|
20
|
+
const listHasClass = (layout, className) =>
|
|
21
|
+
withLayout(layout).find('dl.tw-definition-list').hasClass(className);
|
|
22
|
+
|
|
23
|
+
const valueHasClass = (layout, className) =>
|
|
24
|
+
withLayout(layout).find('dl.tw-definition-list dd').hasClass(className);
|
|
25
|
+
|
|
26
|
+
it('applies correct flex class', () => {
|
|
27
|
+
const colClass = 'flex-column';
|
|
28
|
+
|
|
29
|
+
expect(listHasClass(VERTICAL_ONE_COLUMN, colClass)).toBe(true);
|
|
30
|
+
expect(listHasClass(VERTICAL_TWO_COLUMN, colClass)).toBe(true);
|
|
31
|
+
expect(listHasClass(HORIZONTAL_LEFT_ALIGNED, colClass)).toBe(true);
|
|
32
|
+
expect(listHasClass(HORIZONTAL_RIGHT_ALIGNED, colClass)).toBe(true);
|
|
33
|
+
expect(listHasClass(HORIZONTAL_JUSTIFIED, colClass)).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('applies correct class for vertical two-column layout', () => {
|
|
37
|
+
const colClass = 'tw-definition-list--columns flex-column flex-row--sm';
|
|
38
|
+
|
|
39
|
+
expect(listHasClass(VERTICAL_TWO_COLUMN, colClass)).toBe(true);
|
|
40
|
+
expect(listHasClass(VERTICAL_ONE_COLUMN, colClass)).toBe(false);
|
|
41
|
+
expect(listHasClass(HORIZONTAL_LEFT_ALIGNED, colClass)).toBe(false);
|
|
42
|
+
expect(listHasClass(HORIZONTAL_RIGHT_ALIGNED, colClass)).toBe(false);
|
|
43
|
+
expect(listHasClass(HORIZONTAL_JUSTIFIED, colClass)).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('applies correct class for horiztonal layouts', () => {
|
|
47
|
+
const rowClass = 'tw-definition-list--horizontal flex-column';
|
|
48
|
+
|
|
49
|
+
expect(listHasClass(VERTICAL_TWO_COLUMN, rowClass)).toBe(false);
|
|
50
|
+
expect(listHasClass(VERTICAL_ONE_COLUMN, rowClass)).toBe(false);
|
|
51
|
+
expect(listHasClass(HORIZONTAL_LEFT_ALIGNED, rowClass)).toBe(true);
|
|
52
|
+
expect(listHasClass(HORIZONTAL_RIGHT_ALIGNED, rowClass)).toBe(true);
|
|
53
|
+
expect(listHasClass(HORIZONTAL_JUSTIFIED, rowClass)).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('applies correct class for alignment', () => {
|
|
57
|
+
expect(valueHasClass(VERTICAL_TWO_COLUMN, 'd-flex justify-content-between')).toBe(true);
|
|
58
|
+
expect(valueHasClass(VERTICAL_ONE_COLUMN, 'd-flex justify-content-between')).toBe(true);
|
|
59
|
+
expect(valueHasClass(HORIZONTAL_LEFT_ALIGNED, 'd-flex justify-content-between')).toBe(true);
|
|
60
|
+
expect(valueHasClass(HORIZONTAL_RIGHT_ALIGNED, 'text-sm-right')).toBe(true);
|
|
61
|
+
expect(valueHasClass(HORIZONTAL_JUSTIFIED, 'text-sm-justify')).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('has muted text class on title and value when muted flag is passed', () => {
|
|
65
|
+
const muted = shallow(<DefinitionList muted definitions={someDefinitions()} />);
|
|
66
|
+
const notMuted = shallow(<DefinitionList definitions={someDefinitions()} />);
|
|
67
|
+
|
|
68
|
+
expect(muted.find('dl.tw-definition-list').hasClass('text-muted')).toBe(true);
|
|
69
|
+
expect(notMuted.find('dl.tw-definition-list').hasClass('text-muted')).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('shows action button when one is passed in', () => {
|
|
73
|
+
const buttonSpy = jest.fn();
|
|
74
|
+
|
|
75
|
+
const definitionList = mount(
|
|
76
|
+
<DefinitionList
|
|
77
|
+
definitions={[
|
|
78
|
+
{
|
|
79
|
+
title: 'Name',
|
|
80
|
+
value: 'Jenkins',
|
|
81
|
+
key: '1',
|
|
82
|
+
action: { label: 'A button', onClick: buttonSpy },
|
|
83
|
+
},
|
|
84
|
+
]}
|
|
85
|
+
/>,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
definitionList.find('button').simulate('click');
|
|
89
|
+
expect(buttonSpy).toHaveBeenCalledTimes(1);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions';
|
|
2
|
+
import { select, text, boolean } from '@storybook/addon-knobs';
|
|
2
3
|
|
|
3
4
|
import { Layout } from '../common';
|
|
4
5
|
|
|
5
|
-
import DefinitionList
|
|
6
|
-
import { lorem10 } from '../test-utils';
|
|
7
|
-
import Section from '../section';
|
|
8
|
-
import Header from '../header';
|
|
6
|
+
import DefinitionList from './DefinitionList';
|
|
9
7
|
|
|
10
8
|
export default {
|
|
11
9
|
component: DefinitionList,
|
|
12
10
|
title: 'Typography/DefinitionList',
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
const layouts: DefinitionListLayout[] = [
|
|
16
|
-
Layout.VERTICAL_TWO_COLUMN,
|
|
17
|
-
Layout.VERTICAL_ONE_COLUMN,
|
|
18
|
-
Layout.HORIZONTAL_JUSTIFIED,
|
|
19
|
-
Layout.HORIZONTAL_LEFT_ALIGNED,
|
|
20
|
-
Layout.HORIZONTAL_RIGHT_ALIGNED,
|
|
21
|
-
];
|
|
22
|
-
|
|
23
13
|
const definitions = [
|
|
24
14
|
{
|
|
25
|
-
title: '
|
|
26
|
-
value: '
|
|
15
|
+
title: text('title', 'Editable title'),
|
|
16
|
+
value: text('value', 'Editable value'),
|
|
27
17
|
key: 'first',
|
|
28
18
|
},
|
|
29
19
|
{
|
|
@@ -33,57 +23,67 @@ const definitions = [
|
|
|
33
23
|
},
|
|
34
24
|
{
|
|
35
25
|
title: 'Long strings will wrap',
|
|
36
|
-
value:
|
|
26
|
+
value: 'And values with long words will eventuallybreakontothenextline',
|
|
37
27
|
key: 'third',
|
|
38
28
|
},
|
|
39
29
|
];
|
|
40
30
|
|
|
41
31
|
export const Basic = () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
const muted = boolean('muted', false);
|
|
33
|
+
const layout = select(
|
|
34
|
+
'layout',
|
|
35
|
+
[
|
|
36
|
+
Layout.VERTICAL_TWO_COLUMN,
|
|
37
|
+
Layout.VERTICAL_ONE_COLUMN,
|
|
38
|
+
Layout.HORIZONTAL_JUSTIFIED,
|
|
39
|
+
Layout.HORIZONTAL_LEFT_ALIGNED,
|
|
40
|
+
Layout.HORIZONTAL_RIGHT_ALIGNED,
|
|
41
|
+
],
|
|
42
|
+
Layout.HORIZONTAL_LEFT_ALIGNED,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return <DefinitionList layout={layout} muted={muted} definitions={definitions} />;
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
export const WithActionButtons = () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
title: 'Action buttons are useful',
|
|
63
|
-
value: lorem10,
|
|
64
|
-
key: 'fourth',
|
|
65
|
-
action: {
|
|
66
|
-
label: 'Epic button',
|
|
67
|
-
onClick: action(lorem10),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
title: 'tiny',
|
|
72
|
-
value: 'tiny',
|
|
73
|
-
key: 'fifth',
|
|
74
|
-
action: {
|
|
75
|
-
label: 'Epic button',
|
|
76
|
-
onClick: action(lorem10),
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
]}
|
|
80
|
-
/>
|
|
81
|
-
</Section>
|
|
82
|
-
))}
|
|
83
|
-
</>
|
|
49
|
+
const muted = boolean('muted', false);
|
|
50
|
+
const layout = select(
|
|
51
|
+
'layout',
|
|
52
|
+
[
|
|
53
|
+
Layout.VERTICAL_TWO_COLUMN,
|
|
54
|
+
Layout.VERTICAL_ONE_COLUMN,
|
|
55
|
+
Layout.HORIZONTAL_JUSTIFIED,
|
|
56
|
+
Layout.HORIZONTAL_LEFT_ALIGNED,
|
|
57
|
+
Layout.HORIZONTAL_RIGHT_ALIGNED,
|
|
58
|
+
],
|
|
59
|
+
Layout.HORIZONTAL_LEFT_ALIGNED,
|
|
84
60
|
);
|
|
85
|
-
};
|
|
86
61
|
|
|
87
|
-
|
|
88
|
-
|
|
62
|
+
return (
|
|
63
|
+
<DefinitionList
|
|
64
|
+
layout={layout}
|
|
65
|
+
muted={muted}
|
|
66
|
+
definitions={[
|
|
67
|
+
...definitions,
|
|
68
|
+
{
|
|
69
|
+
title: 'Action buttons are useful',
|
|
70
|
+
value: 'You can do all kinds of neat things with actions buttons!',
|
|
71
|
+
key: 'fourth',
|
|
72
|
+
action: {
|
|
73
|
+
label: 'Epic button',
|
|
74
|
+
onClick: action('Probably the best action event you have ever seen, in the world!'),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: 'tiny',
|
|
79
|
+
value: 'tiny',
|
|
80
|
+
key: 'fifth',
|
|
81
|
+
action: {
|
|
82
|
+
label: 'Epic button',
|
|
83
|
+
onClick: action('Hello from the Tiny Button :)'),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
]}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
89
|
};
|
|
@@ -13,7 +13,7 @@ export interface DefinitionListDefinition {
|
|
|
13
13
|
key: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
type DefinitionListLayout =
|
|
17
17
|
`${Layout.VERTICAL_TWO_COLUMN | Layout.VERTICAL_ONE_COLUMN | Layout.HORIZONTAL_JUSTIFIED | Layout.HORIZONTAL_LEFT_ALIGNED | Layout.HORIZONTAL_RIGHT_ALIGNED}`;
|
|
18
18
|
|
|
19
19
|
export interface DefinitionListProps {
|
|
@@ -12,7 +12,7 @@ exports[`FlowNavigation on mobile renders as expected 1`] = `
|
|
|
12
12
|
aria-disabled="false"
|
|
13
13
|
aria-label="back to previous step"
|
|
14
14
|
aria-live="off"
|
|
15
|
-
class="
|
|
15
|
+
class="np-circle d-flex align-items-center justify-content-center np-icon-button np-icon-button-tertiary-default"
|
|
16
16
|
style="--circle-size: 40px; --circle-icon-size: 20px; --circle-font-size: 18px;"
|
|
17
17
|
type="button"
|
|
18
18
|
>
|
package/src/i18n/de.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Alle Dateiformate",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Datei zum Hochladen in dieses Feld ziehen",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, kleiner als {size} MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Maximal {maxFiles} Dateien.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Datei hochladen",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Dateien hochladen",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Wenn du diese Datei entfernst, wird sie aus unserem System gelöscht werden.",
|
package/src/i18n/it.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Tutti i tipi di file",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Rilascia file per iniziare a caricare",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, minore di {size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Max {maxFiles} file.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Carica un file",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Carica i file",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Rimuovere questo file lo cancellerà dal nostro sistema.",
|
package/src/i18n/th.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "ไฟล์ทุกประเภท",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "วางไฟล์เพื่อเริ่มการอัปโหลด",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes} น้อยกว่า {size} MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "สูงสุด {maxFiles} ไฟล์",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "อัปโหลดไฟล์",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "อัปโหลดไฟล์",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "การลบไฟล์นี้จะลบออกจากระบบของเรา",
|