@transferwise/components 0.0.0-experimental-5acc778 → 0.0.0-experimental-0ffb1f6
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/actionOption/ActionOption.js.map +1 -1
- package/build/actionOption/ActionOption.mjs.map +1 -1
- package/build/checkboxOption/CheckboxOption.js.map +1 -1
- package/build/checkboxOption/CheckboxOption.mjs.map +1 -1
- package/build/header/Header.js +44 -76
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +44 -73
- package/build/header/Header.mjs.map +1 -1
- package/build/i18n/cs.json +2 -0
- package/build/i18n/cs.json.js +2 -0
- package/build/i18n/cs.json.js.map +1 -1
- package/build/i18n/cs.json.mjs +2 -0
- package/build/i18n/cs.json.mjs.map +1 -1
- package/build/i18n/th.json +2 -0
- package/build/i18n/th.json.js +2 -0
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +2 -0
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/index.js +1 -1
- package/build/index.mjs +1 -1
- package/build/inputs/SelectInput.js +1 -1
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +1 -1
- package/build/legacylistItem/LegacyListItem.js.map +1 -1
- package/build/legacylistItem/LegacyListItem.mjs.map +1 -1
- package/build/main.css +14 -29
- package/build/navigationOption/NavigationOption.js.map +1 -1
- package/build/navigationOption/NavigationOption.mjs.map +1 -1
- package/build/navigationOptionsList/NavigationOptionsList.js.map +1 -1
- package/build/navigationOptionsList/NavigationOptionsList.mjs.map +1 -1
- package/build/radioOption/RadioOption.js.map +1 -1
- package/build/radioOption/RadioOption.mjs.map +1 -1
- package/build/styles/header/Header.css +14 -29
- package/build/styles/main.css +14 -29
- package/build/summary/Summary.js +8 -0
- package/build/summary/Summary.js.map +1 -1
- package/build/summary/Summary.mjs +8 -0
- package/build/summary/Summary.mjs.map +1 -1
- package/build/switchOption/SwitchOption.js +8 -0
- package/build/switchOption/SwitchOption.js.map +1 -1
- package/build/switchOption/SwitchOption.mjs +8 -0
- package/build/switchOption/SwitchOption.mjs.map +1 -1
- package/build/title/Title.js +4 -10
- package/build/title/Title.js.map +1 -1
- package/build/title/Title.mjs +4 -6
- package/build/title/Title.mjs.map +1 -1
- package/build/types/actionOption/ActionOption.d.ts +8 -0
- package/build/types/actionOption/ActionOption.d.ts.map +1 -1
- package/build/types/checkboxOption/CheckboxOption.d.ts +8 -0
- package/build/types/checkboxOption/CheckboxOption.d.ts.map +1 -1
- package/build/types/header/Header.d.ts +11 -27
- package/build/types/header/Header.d.ts.map +1 -1
- package/build/types/header/index.d.ts +0 -1
- package/build/types/header/index.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/legacylistItem/LegacyListItem.d.ts +8 -0
- package/build/types/legacylistItem/LegacyListItem.d.ts.map +1 -1
- package/build/types/navigationOption/NavigationOption.d.ts +8 -0
- package/build/types/navigationOption/NavigationOption.d.ts.map +1 -1
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts +9 -0
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts +8 -0
- package/build/types/radioOption/RadioOption.d.ts.map +1 -1
- package/build/types/summary/Summary.d.ts +8 -0
- package/build/types/summary/Summary.d.ts.map +1 -1
- package/build/types/switchOption/SwitchOption.d.ts +8 -0
- package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
- package/build/types/title/Title.d.ts +5 -4
- package/build/types/title/Title.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/actionButton/ActionButton.story.tsx +1 -1
- package/src/actionOption/ActionOption.story.tsx +4 -0
- package/src/actionOption/ActionOption.tsx +8 -0
- package/src/avatar/Avatar.story.tsx +1 -1
- package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -1
- package/src/badge/Badge.story.tsx +1 -1
- package/src/button/Button.story.tsx +1 -1
- package/src/button/LegacyButton.story.tsx +1 -1
- package/src/checkboxOption/CheckboxOption.story.tsx +4 -0
- package/src/checkboxOption/CheckboxOption.tsx +8 -0
- package/src/header/Header.css +14 -29
- package/src/header/Header.less +9 -24
- package/src/header/Header.spec.tsx +50 -68
- package/src/header/Header.story.tsx +36 -190
- package/src/header/Header.tsx +70 -110
- package/src/header/index.ts +0 -1
- package/src/i18n/cs.json +2 -0
- package/src/i18n/th.json +2 -0
- package/src/index.ts +0 -1
- package/src/legacylistItem/LegacyListItem.story.tsx +4 -0
- package/src/legacylistItem/LegacyListItem.tsx +8 -0
- package/src/listItem/_stories/ListItem.story.tsx +1 -1
- package/src/main.css +14 -29
- package/src/navigationOption/NavigationOption.story.tsx +4 -1
- package/src/navigationOption/NavigationOption.tsx +8 -0
- package/src/navigationOptionsList/NavigationOptionsList.story.tsx +4 -0
- package/src/navigationOptionsList/NavigationOptionsList.tsx +9 -0
- package/src/radioOption/RadioOption.story.tsx +4 -0
- package/src/radioOption/RadioOption.tsx +8 -0
- package/src/select/Select.story.tsx +1 -1
- package/src/summary/Summary.story.tsx +4 -0
- package/src/summary/Summary.tsx +8 -0
- package/src/switchOption/SwitchOption.story.tsx +4 -1
- package/src/switchOption/SwitchOption.tsx +8 -0
- package/src/title/Title.tsx +12 -25
- package/src/header/Header.accessibility.docs.mdx +0 -85
|
@@ -1,207 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Header, { HeaderProps } from './Header';
|
|
3
|
-
import { storyConfig } from '../test-utils';
|
|
1
|
+
import Header from './Header';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Not all stories need access to all controls as it causes unnecessary UI noise.
|
|
13
|
-
*/
|
|
14
|
-
const hideControls = (args: string[]) =>
|
|
15
|
-
Object.fromEntries(args.map((item) => [item, { table: { disable: true } }]));
|
|
3
|
+
export default {
|
|
4
|
+
component: Header,
|
|
5
|
+
title: 'Typography/Header',
|
|
6
|
+
};
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
const renderHeader = (args: HeaderProps) => {
|
|
21
|
-
if (args.as === 'legend') {
|
|
22
|
-
return (
|
|
23
|
-
<fieldset style={{ width: '100%' }}>
|
|
24
|
-
<Header {...args} />
|
|
25
|
-
</fieldset>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return <Header {...args} />;
|
|
8
|
+
export const Basic = () => {
|
|
9
|
+
return <Header title="Header title" />;
|
|
29
10
|
};
|
|
30
11
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
const renderVariants = () => (
|
|
35
|
-
<div
|
|
36
|
-
className="header-variants"
|
|
37
|
-
style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', maxWidth: '1200px' }}
|
|
38
|
-
>
|
|
39
|
-
{(['h1', 'h2', 'h3', 'legend'] as const).map((as) => (
|
|
40
|
-
<Header key={as} as={as} title={`Header as ${as}`} />
|
|
41
|
-
))}
|
|
42
|
-
{(['section', 'group'] as const).map((level) => (
|
|
43
|
-
<Header key={level} level={level} title={`Header level ${level}`} />
|
|
44
|
-
))}
|
|
12
|
+
export const WithAction = () => {
|
|
13
|
+
return (
|
|
45
14
|
<Header
|
|
46
|
-
|
|
47
|
-
title="Header with Action"
|
|
15
|
+
title="Header title"
|
|
48
16
|
action={{
|
|
49
|
-
'aria-label': '
|
|
50
|
-
text: '
|
|
51
|
-
onClick: () => alert('Action
|
|
17
|
+
'aria-label': 'Magic',
|
|
18
|
+
text: 'Click me!',
|
|
19
|
+
onClick: () => alert('Action!'),
|
|
52
20
|
}}
|
|
53
21
|
/>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const WithActionAsLink = () => {
|
|
26
|
+
return (
|
|
54
27
|
<Header
|
|
55
|
-
|
|
56
|
-
title="Header with link"
|
|
28
|
+
title="Header title"
|
|
57
29
|
action={{
|
|
58
|
-
|
|
59
|
-
text: 'Action',
|
|
30
|
+
text: 'This is a link',
|
|
60
31
|
href: 'https://wise.com',
|
|
61
32
|
}}
|
|
62
33
|
/>
|
|
63
|
-
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The stories below document the `Header` component, which is used to structure content and convey hierarchy. <br />
|
|
68
|
-
* For more details, refer to the [design documentation](https://wise.design/components/section-header).
|
|
69
|
-
*/
|
|
70
|
-
const meta: Meta<typeof Header> = {
|
|
71
|
-
component: Header,
|
|
72
|
-
title: 'Typography/Header',
|
|
73
|
-
argTypes: {
|
|
74
|
-
level: {
|
|
75
|
-
type: {
|
|
76
|
-
name: 'enum',
|
|
77
|
-
value: ['section', 'group'],
|
|
78
|
-
},
|
|
79
|
-
table: {
|
|
80
|
-
type: {
|
|
81
|
-
summary: 'HeaderLevel',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
description: 'Defines the hierarchical level of the header.',
|
|
85
|
-
},
|
|
86
|
-
as: {
|
|
87
|
-
type: {
|
|
88
|
-
name: 'enum',
|
|
89
|
-
value: ['h1', 'h2', 'h3', 'legend'],
|
|
90
|
-
},
|
|
91
|
-
table: {
|
|
92
|
-
type: {
|
|
93
|
-
summary: 'HeaderAs',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
description:
|
|
97
|
-
'Defines which HTML element the Header will render as. Use `legend` only as the first child of a `<fieldset>` — otherwise a warning will appear. The `action` prop is not supported with `legend`. You can also use heading tags like `h1`, `h2`, `h3`, or `header`.',
|
|
98
|
-
},
|
|
99
|
-
action: {
|
|
100
|
-
table: {
|
|
101
|
-
type: {
|
|
102
|
-
summary: 'HeaderAction',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
description: 'Defines an optional action (e.g., button or link) associated with the header.',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
args: {
|
|
109
|
-
title: 'Default Header',
|
|
110
|
-
level: 'group',
|
|
111
|
-
as: 'h1',
|
|
112
|
-
action: undefined,
|
|
113
|
-
},
|
|
114
|
-
tags: ['autodocs'],
|
|
115
|
-
decorators: [withContainer],
|
|
116
|
-
parameters: {
|
|
117
|
-
docs: {
|
|
118
|
-
toc: true,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export default meta;
|
|
124
|
-
|
|
125
|
-
type Story = StoryObj<typeof Header>;
|
|
126
|
-
|
|
127
|
-
export const Playground: Story = {
|
|
128
|
-
render: renderHeader,
|
|
129
|
-
args: {
|
|
130
|
-
title: 'Playground Header',
|
|
131
|
-
level: 'group',
|
|
132
|
-
as: 'h2',
|
|
133
|
-
action: {
|
|
134
|
-
'aria-label': 'Action',
|
|
135
|
-
text: 'Click me',
|
|
136
|
-
onClick: () => alert('Action clicked!'),
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Demonstrates a `Header` with an associated action.
|
|
143
|
-
*/
|
|
144
|
-
export const Action: Story = {
|
|
145
|
-
args: {
|
|
146
|
-
title: 'Header with Action',
|
|
147
|
-
action: {
|
|
148
|
-
'aria-label': 'Action',
|
|
149
|
-
text: 'Action',
|
|
150
|
-
onClick: () => alert('Action clicked!'),
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
argTypes: hideControls(['as', 'className', 'level', 'title', 'testId']),
|
|
34
|
+
);
|
|
154
35
|
};
|
|
155
36
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
href: 'https://wise.com',
|
|
166
|
-
target: '_blank',
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
argTypes: hideControls(['as', 'className', 'level', 'title', 'testId']),
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Demonstrates a `Header` rendered as a custom HTML element.
|
|
174
|
-
*/
|
|
175
|
-
export const CustomElement: Story = {
|
|
176
|
-
render: renderHeader,
|
|
177
|
-
args: {
|
|
178
|
-
title: 'Legend Header',
|
|
179
|
-
as: 'legend',
|
|
180
|
-
},
|
|
181
|
-
argTypes: hideControls(['action', 'className', 'level', 'testId']),
|
|
182
|
-
};
|
|
37
|
+
export const WithActionAsLinkPreventingNavigationWithTracking = () => {
|
|
38
|
+
return (
|
|
39
|
+
<Header
|
|
40
|
+
title="Header title"
|
|
41
|
+
action={{
|
|
42
|
+
text: 'This is a link',
|
|
43
|
+
href: 'https://wise.com',
|
|
44
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => {
|
|
45
|
+
alert('Running onClick handler');
|
|
183
46
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
level: 'section',
|
|
191
|
-
},
|
|
192
|
-
argTypes: hideControls(['action', 'as', 'className', 'title', 'testId']),
|
|
47
|
+
// we can stop the navigation from happening as onClick will always run before href redirect
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
193
53
|
};
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Displays all variants of the `Header` component, including different levels, tags, and actions.
|
|
197
|
-
*/
|
|
198
|
-
export const AllVariants = storyConfig(
|
|
199
|
-
{
|
|
200
|
-
tags: ['!autodocs'],
|
|
201
|
-
parameters: {
|
|
202
|
-
padding: '0',
|
|
203
|
-
},
|
|
204
|
-
render: renderVariants,
|
|
205
|
-
},
|
|
206
|
-
{ variants: ['default', 'dark', 'bright-green', 'forest-green', 'rtl'] },
|
|
207
|
-
);
|
package/src/header/Header.tsx
CHANGED
|
@@ -1,142 +1,102 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ActionButtonProps } from '../actionButton/ActionButton';
|
|
4
4
|
import Button from '../button';
|
|
5
|
+
import { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';
|
|
6
|
+
import Link from '../link';
|
|
5
7
|
import Title from '../title';
|
|
6
|
-
import
|
|
8
|
+
import { HTMLAttributes } from 'react';
|
|
7
9
|
|
|
8
10
|
type ActionProps = AriaLabelProperty & {
|
|
9
11
|
text: string;
|
|
10
|
-
onClick?: () => void;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
type ButtonActionProps = ActionProps;
|
|
14
|
+
type ButtonActionProps = ActionProps & ActionButtonProps;
|
|
15
|
+
|
|
14
16
|
type LinkActionProps = ActionProps & LinkProps;
|
|
15
17
|
|
|
16
|
-
export
|
|
18
|
+
export type HeaderProps = CommonProps & {
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
19
|
-
* is provided, a `Link` will be rendered instead of a `Button`.
|
|
20
|
+
* When the `href` property is provided to the `action`, we will render a `Link` instead of a `ActionButton`.
|
|
20
21
|
*/
|
|
21
22
|
action?: ButtonActionProps | LinkActionProps;
|
|
22
|
-
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* - When `as="legend"`, the `Header` will render as a `<legend>` element.
|
|
27
|
-
* **Note:** `<legend>` elements must be the first child of a `<fieldset>` to comply with HTML semantics.
|
|
28
|
-
* If this condition is not met, a warning will be logged to the console.
|
|
24
|
+
* Override the heading element rendered for the title, useful to specify the semantics of your header.
|
|
29
25
|
*
|
|
30
|
-
*
|
|
26
|
+
* @default "h5"
|
|
31
27
|
*/
|
|
32
28
|
as?: Heading | 'legend' | 'header';
|
|
33
|
-
|
|
34
|
-
/** Required prop to set the title of the Header. */
|
|
35
29
|
title: string;
|
|
30
|
+
} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'id'>;
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
testId?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Renders a header action which can be either a button or a link.
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} props - The properties object.
|
|
48
|
-
* @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.
|
|
49
|
-
* @returns {JSX.Element} The rendered header action component.
|
|
50
|
-
*/
|
|
51
|
-
const HeaderAction = React.forwardRef(
|
|
52
|
-
(
|
|
53
|
-
{ action }: { action: ButtonActionProps | LinkActionProps },
|
|
54
|
-
ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,
|
|
55
|
-
) => {
|
|
56
|
-
const baseProps = {
|
|
57
|
-
ref,
|
|
58
|
-
className: 'np-header__action-button',
|
|
59
|
-
priority: 'tertiary' as const,
|
|
60
|
-
size: 'sm' as const,
|
|
61
|
-
'aria-label': action['aria-label'],
|
|
62
|
-
onClick: action.onClick,
|
|
63
|
-
children: action.text,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const linkProps =
|
|
67
|
-
'href' in action ? { href: action.href, target: action.target, as: 'a' as const } : {};
|
|
32
|
+
const HeaderAction = ({ action }: { action: ButtonActionProps | LinkActionProps }) => {
|
|
33
|
+
const props = {
|
|
34
|
+
'aria-label': action['aria-label'],
|
|
35
|
+
};
|
|
68
36
|
|
|
37
|
+
if ('href' in action) {
|
|
69
38
|
return (
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
</
|
|
39
|
+
<Link href={action.href} target={action.target} onClick={action.onClick} {...props}>
|
|
40
|
+
{action.text}
|
|
41
|
+
</Link>
|
|
73
42
|
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Button
|
|
47
|
+
className="np-header__button"
|
|
48
|
+
priority="tertiary"
|
|
49
|
+
size="sm"
|
|
50
|
+
onClick={action.onClick}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
{action.text}
|
|
54
|
+
</Button>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
78
57
|
|
|
79
58
|
/**
|
|
80
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
81
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
82
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
83
|
-
* @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.
|
|
84
|
-
* @param {string} [className]
|
|
85
|
-
* @param {string} [testId]
|
|
86
59
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
60
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
61
|
+
*
|
|
89
62
|
*/
|
|
90
|
-
const Header
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const isLegendOrNoAction = !action || as === 'legend';
|
|
100
|
-
const headerClasses = clsx('np-header', className, {
|
|
101
|
-
'np-header--group': level === 'group',
|
|
102
|
-
'np-header__title': isLegendOrNoAction,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const commonProps = {
|
|
106
|
-
className: headerClasses,
|
|
107
|
-
'data-testid': testId,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (as === 'legend' && internalRef.current) {
|
|
112
|
-
const { parentElement } = internalRef.current;
|
|
113
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
114
|
-
console.warn(
|
|
115
|
-
'Legends should be the first child in a fieldset, and this is not possible when including an action',
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}, [as]);
|
|
120
|
-
|
|
121
|
-
if (!action) {
|
|
122
|
-
return (
|
|
123
|
-
<Title ref={internalRef} as={as} type={levelTypography} {...commonProps} {...props}>
|
|
124
|
-
{title}
|
|
125
|
-
</Title>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
63
|
+
export const Header = ({
|
|
64
|
+
id,
|
|
65
|
+
action,
|
|
66
|
+
as = 'h5',
|
|
67
|
+
title,
|
|
68
|
+
className,
|
|
69
|
+
role = undefined,
|
|
70
|
+
}: HeaderProps) => {
|
|
71
|
+
if (!action) {
|
|
129
72
|
return (
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
73
|
+
<Title
|
|
74
|
+
as={as}
|
|
75
|
+
id={id}
|
|
76
|
+
role={role}
|
|
77
|
+
type={Typography.TITLE_GROUP}
|
|
78
|
+
className={clsx('np-header', 'np-header__title', className)}
|
|
79
|
+
>
|
|
80
|
+
{title}
|
|
81
|
+
</Title>
|
|
136
82
|
);
|
|
137
|
-
}
|
|
138
|
-
);
|
|
83
|
+
}
|
|
139
84
|
|
|
140
|
-
|
|
85
|
+
if (as === 'legend') {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.warn(
|
|
88
|
+
'Legends should be the first child in a fieldset, and this is not possible when including an action',
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div className={clsx('np-header', className)}>
|
|
94
|
+
<Title as={as} type={Typography.TITLE_GROUP} id={id} className="np-header__title">
|
|
95
|
+
{title}
|
|
96
|
+
</Title>
|
|
97
|
+
<HeaderAction action={action} />
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
141
101
|
|
|
142
102
|
export default Header;
|
package/src/header/index.ts
CHANGED
package/src/i18n/cs.json
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"neptune.Upload.csFailureText": "Nahrání se nezdařilo. Zkuste to prosím později",
|
|
46
46
|
"neptune.Upload.csSuccessText": "Úspěšně nahráno!",
|
|
47
47
|
"neptune.Upload.csTooLargeMessage": "Nahrajte soubor menší než {maxSize} MB",
|
|
48
|
+
"neptune.Upload.csTooLargeNoLimitMessage": "Nahrajte menší soubor",
|
|
48
49
|
"neptune.Upload.csWrongTypeMessage": "Tento formát souboru není podporován. Zkuste to znovu s jiným souborem",
|
|
49
50
|
"neptune.Upload.psButtonText": "Zrušit",
|
|
50
51
|
"neptune.Upload.psProcessingText": "Načítání...",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"neptune.Upload.usButtonText": "Nebo vyberte soubor",
|
|
53
54
|
"neptune.Upload.usDropMessage": "Přetáhněte soubor a zahajte nahrávání",
|
|
54
55
|
"neptune.Upload.usPlaceholder": "Přetáhněte soubor menší než {maxSize} MB",
|
|
56
|
+
"neptune.Upload.usPlaceholderNoLimit": "Přetáhněte soubor",
|
|
55
57
|
"neptune.UploadButton.allFileTypes": "Všechny typy souborů",
|
|
56
58
|
"neptune.UploadButton.dropFiles": "Přetáhněte soubor a zahajte nahrávání",
|
|
57
59
|
"neptune.UploadButton.instructions": "{fileTypes}, menší než {size} MB",
|
package/src/i18n/th.json
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"neptune.Upload.csFailureText": "การอัปโหลดล้มเหลว กรุณาลองอีกครั้ง",
|
|
46
46
|
"neptune.Upload.csSuccessText": "อัปโหลดเรียบร้อย!",
|
|
47
47
|
"neptune.Upload.csTooLargeMessage": "กรุณาใช้ไฟล์ที่มีขนาดเล็กกว่า {maxSize} MB",
|
|
48
|
+
"neptune.Upload.csTooLargeNoLimitMessage": "โปรดอัปโหลดไฟล์ที่เล็กลง",
|
|
48
49
|
"neptune.Upload.csWrongTypeMessage": "ไม่รองรับประเภทไฟล์ โปรดลองอีกครั้งโดยใช้ไฟล์อื่น",
|
|
49
50
|
"neptune.Upload.psButtonText": "ยกเลิก",
|
|
50
51
|
"neptune.Upload.psProcessingText": "กำลังอัปโหลด...",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"neptune.Upload.usButtonText": "หรือเลือกไฟล์",
|
|
53
54
|
"neptune.Upload.usDropMessage": "วางไฟล์เพื่อเริ่มการอัปโหลด",
|
|
54
55
|
"neptune.Upload.usPlaceholder": "ลากและวางไฟล์ที่น้อยกว่า {maxSize} MB",
|
|
56
|
+
"neptune.Upload.usPlaceholderNoLimit": "ลากและวางไฟล์",
|
|
55
57
|
"neptune.UploadButton.allFileTypes": "ไฟล์ทุกประเภท",
|
|
56
58
|
"neptune.UploadButton.dropFiles": "วางไฟล์เพื่อเริ่มการอัปโหลด",
|
|
57
59
|
"neptune.UploadButton.instructions": "{fileTypes} น้อยกว่า {size} MB",
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,6 @@ export type { DefinitionListProps, DefinitionListDefinition } from './definition
|
|
|
31
31
|
export type { DimmerProps } from './dimmer';
|
|
32
32
|
export type { DrawerProps } from './drawer';
|
|
33
33
|
export type { DividerProps } from './divider';
|
|
34
|
-
export type { HeaderProps } from './header';
|
|
35
34
|
export type { EmphasisProps } from './emphasis';
|
|
36
35
|
export type { FieldProps } from './field/Field';
|
|
37
36
|
export type { InfoProps } from './info';
|
|
@@ -8,9 +8,13 @@ import Info from '../info';
|
|
|
8
8
|
import Title from '../title/Title';
|
|
9
9
|
import LegacyListItem from '.';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* > ⚠️ This component is **deprecated** and superseded by the [new ListItem component](?path=/docs/content-listitem--docs).
|
|
13
|
+
*/
|
|
11
14
|
export default {
|
|
12
15
|
component: LegacyListItem,
|
|
13
16
|
title: 'Content/LegacyListItem',
|
|
17
|
+
tags: ['deprecated'],
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
const Template = ({
|
|
@@ -13,6 +13,14 @@ export type LegacyListItemProps = {
|
|
|
13
13
|
as?: ElementType;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Please use `<ListItem />` instead.
|
|
18
|
+
* @deprecatedSince 46.104.0
|
|
19
|
+
* @see [Source](../listItem/ListItem.tsx)
|
|
20
|
+
* @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
|
|
21
|
+
* @see [Design docs](https://wise.design/components/list-item)
|
|
22
|
+
* @see [Release notes](https://transferwise.atlassian.net/wiki/spaces/DS/pages/3647251055/List+Item+release+notes)
|
|
23
|
+
*/
|
|
16
24
|
const LegacyListItem: FC<LegacyListItemProps> = ({
|
|
17
25
|
media,
|
|
18
26
|
action,
|
package/src/main.css
CHANGED
|
@@ -2433,45 +2433,30 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2433
2433
|
fill: var(--color-interactive-primary);
|
|
2434
2434
|
}
|
|
2435
2435
|
.np-header {
|
|
2436
|
-
display:
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
grid-column-gap: var(--size-24);
|
|
2440
|
-
-moz-column-gap: 24px;
|
|
2441
|
-
column-gap: 24px;
|
|
2442
|
-
-moz-column-gap: var(--size-24);
|
|
2443
|
-
column-gap: var(--size-24);
|
|
2444
|
-
align-items: center;
|
|
2445
|
-
margin-bottom: 8px;
|
|
2446
|
-
margin-bottom: var(--size-8);
|
|
2436
|
+
display: flex;
|
|
2437
|
+
justify-content: space-between;
|
|
2438
|
+
align-items: flex-end;
|
|
2447
2439
|
max-width: 100%;
|
|
2448
2440
|
padding: 8px 0;
|
|
2449
2441
|
padding: var(--size-8) 0;
|
|
2450
|
-
width: 100%;
|
|
2451
|
-
}
|
|
2452
|
-
.np-header--group {
|
|
2453
|
-
align-items: flex-end;
|
|
2454
2442
|
border-bottom: 1px solid rgba(0,0,0,0.10196);
|
|
2455
2443
|
border-bottom: 1px solid var(--color-border-neutral);
|
|
2444
|
+
margin-bottom: 8px;
|
|
2445
|
+
margin-bottom: var(--size-8);
|
|
2446
|
+
-moz-column-gap: 24px;
|
|
2447
|
+
column-gap: 24px;
|
|
2448
|
+
-moz-column-gap: var(--size-24);
|
|
2449
|
+
column-gap: var(--size-24);
|
|
2456
2450
|
}
|
|
2457
2451
|
.np-header__title {
|
|
2458
2452
|
color: #5d7079;
|
|
2459
2453
|
color: var(--color-content-secondary);
|
|
2460
|
-
margin: 0;
|
|
2461
|
-
}
|
|
2462
|
-
.np-header__action {
|
|
2463
|
-
margin: 0;
|
|
2464
|
-
height: 20px;
|
|
2465
|
-
display: flex;
|
|
2466
|
-
align-items: center;
|
|
2467
2454
|
}
|
|
2468
|
-
.np-
|
|
2469
|
-
margin-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
margin-right: -12.5px;
|
|
2474
|
-
}
|
|
2455
|
+
.np-header__button {
|
|
2456
|
+
margin-inline: calc(16px * -1);
|
|
2457
|
+
margin-inline: calc(var(--size-16) * -1);
|
|
2458
|
+
margin-bottom: calc(4px * -1);
|
|
2459
|
+
margin-bottom: calc(var(--size-4) * -1);
|
|
2475
2460
|
}
|
|
2476
2461
|
.tw-image {
|
|
2477
2462
|
max-width: none;
|
|
@@ -15,10 +15,13 @@ import { fn } from 'storybook/test';
|
|
|
15
15
|
|
|
16
16
|
type StoryArgs = NavigationOptionProps & { hasTitleOnly?: boolean };
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* > ⚠️ This component is **deprecated** and superseded by the [new ListItem component](?path=/docs/content-listitem--docs) with the [ListItem.Navigation control](?path=/docs/content-listitem-listitem-navigation--docs).
|
|
20
|
+
*/
|
|
18
21
|
const meta: Meta<StoryArgs> = {
|
|
19
22
|
component: NavigationOption,
|
|
20
23
|
title: 'Option/NavigationOption',
|
|
21
|
-
tags: ['
|
|
24
|
+
tags: ['deprecated'],
|
|
22
25
|
argTypes: {
|
|
23
26
|
href: { control: 'text' },
|
|
24
27
|
title: { control: 'text' },
|
|
@@ -8,6 +8,14 @@ import { OptionProps, ReferenceType } from '../common/Option/Option';
|
|
|
8
8
|
|
|
9
9
|
export type NavigationOptionProps = OptionProps;
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Please use `<ListItem />` instead.
|
|
13
|
+
* @deprecatedSince 46.104.0
|
|
14
|
+
* @see [Source](../listItem/ListItem.tsx)
|
|
15
|
+
* @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
|
|
16
|
+
* @see [Design docs](https://wise.design/components/list-item)
|
|
17
|
+
* @see [Release notes](https://transferwise.atlassian.net/wiki/spaces/DS/pages/3647251055/List+Item+release+notes)
|
|
18
|
+
*/
|
|
11
19
|
const NavigationOption = forwardRef<ReferenceType, NavigationOptionProps>(
|
|
12
20
|
({ as: component = 'button', disabled = false, onClick, className, ...rest }, reference) => {
|
|
13
21
|
if ('href' in rest && rest.href) {
|
|
@@ -2,9 +2,13 @@ import NavigationOption from '../navigationOption';
|
|
|
2
2
|
|
|
3
3
|
import NavigationOptionsList from '.';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* > ⚠️ This component is **deprecated** and superseded by the [List](?path=/docs/content-list--docs), [new ListItem component](?path=/docs/content-listitem--docs) with the [ListItem.Navigation control](?path=/docs/content-listitem-listitem-navigation--docs).
|
|
7
|
+
*/
|
|
5
8
|
export default {
|
|
6
9
|
component: NavigationOptionsList,
|
|
7
10
|
title: 'Option/NavigationOptionsList',
|
|
11
|
+
tags: ['deprecated'],
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
export const Basic = () => {
|
|
@@ -5,6 +5,15 @@ export interface NavigationOptionListProps {
|
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Please use `<List />` and `<ListItem />` instead.
|
|
10
|
+
* @deprecatedSince 46.104.0
|
|
11
|
+
* @see [List source](../list/List.tsx)
|
|
12
|
+
* @see [ListItem source](../listItem/ListItem.tsx)
|
|
13
|
+
* @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
|
|
14
|
+
* @see [Design docs](https://wise.design/components/list-item)
|
|
15
|
+
* @see [Release notes](https://transferwise.atlassian.net/wiki/spaces/DS/pages/3647251055/List+Item+release+notes)
|
|
16
|
+
*/
|
|
8
17
|
const NavigationOptionList = ({ children }: NavigationOptionListProps) => {
|
|
9
18
|
return (
|
|
10
19
|
<ul className="np-navigation-options-list">
|