@transferwise/components 0.0.0-experimental-991400c → 0.0.0-experimental-fb447f5
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/index.esm.js +12 -21
- package/build/index.esm.js.map +1 -1
- package/build/index.js +12 -21
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/instructionsList/InstructionsList.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/instructionsList/InstructionsList.d.ts +9 -1
- package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/alert/Alert.js +0 -8
- package/src/alert/Alert.spec.js +0 -9
- package/src/instructionsList/InstructionList.story.js +31 -0
- package/src/instructionsList/InstructionsList.css +1 -1
- package/src/instructionsList/InstructionsList.less +3 -15
- package/src/instructionsList/InstructionsList.spec.tsx +50 -0
- package/src/instructionsList/InstructionsList.tsx +17 -10
- package/src/main.css +1 -1
- package/src/instructionsList/InstructionsList.spec.js +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/alert/Alert.js"],"names":[],"mappings":";AA8BA,
|
|
1
|
+
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/alert/Alert.js"],"names":[],"mappings":";AA8BA,gEAyFC"}
|
|
@@ -3,7 +3,15 @@ import { CommonProps } from '../common';
|
|
|
3
3
|
type Props = CommonProps & {
|
|
4
4
|
dos?: ReactNode[];
|
|
5
5
|
donts?: ReactNode[];
|
|
6
|
+
/**
|
|
7
|
+
* Add meaning to "do" icon of "do" items
|
|
8
|
+
*/
|
|
9
|
+
['do-aria-label']?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Add meaning to "don't" icon of "don't" items
|
|
12
|
+
*/
|
|
13
|
+
['dont-aria-label']?: string;
|
|
6
14
|
};
|
|
7
|
-
declare const InstructionsList: (
|
|
15
|
+
declare const InstructionsList: ({ dos, donts, "do-aria-label": doAriaLabel, "dont-aria-label": dontAriaLabel, }: Props) => import("react").JSX.Element;
|
|
8
16
|
export default InstructionsList;
|
|
9
17
|
//# sourceMappingURL=InstructionsList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructionsList.d.ts","sourceRoot":"","sources":["../../../src/instructionsList/InstructionsList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InstructionsList.d.ts","sourceRoot":"","sources":["../../../src/instructionsList/InstructionsList.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,KAAK,KAAK,GAAG,WAAW,GAAG;IACzB,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB;;OAEG;IACH,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,gBAAgB,oFAKnB,KAAK,gCAyBP,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/package.json
CHANGED
package/src/alert/Alert.js
CHANGED
|
@@ -62,13 +62,6 @@ const Alert = (props) => {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
function calculateAriaLive() {
|
|
66
|
-
if ([Sentiment.NEGATIVE, Sentiment.POSITIVE, Sentiment.WARNING].includes(mappedType)) {
|
|
67
|
-
return 'assertive';
|
|
68
|
-
}
|
|
69
|
-
return 'polite';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
65
|
const handleTouchStart = () => setShouldFire(true);
|
|
73
66
|
const handleTouchMove = () => setShouldFire(false);
|
|
74
67
|
const handleTouchEnd = (event) => {
|
|
@@ -87,7 +80,6 @@ const Alert = (props) => {
|
|
|
87
80
|
return (
|
|
88
81
|
<div
|
|
89
82
|
role="alert"
|
|
90
|
-
aria-live={calculateAriaLive()}
|
|
91
83
|
className={classNames('alert d-flex', `alert-${mappedType}`, className)}
|
|
92
84
|
onTouchStart={handleTouchStart}
|
|
93
85
|
onTouchEnd={handleTouchEnd}
|
package/src/alert/Alert.spec.js
CHANGED
|
@@ -277,15 +277,6 @@ describe('Alert', () => {
|
|
|
277
277
|
expect(component).toHaveClass(classForType(Sentiment.WARNING));
|
|
278
278
|
expect(screen.getByTestId('warning-icon')).toBeInTheDocument();
|
|
279
279
|
});
|
|
280
|
-
|
|
281
|
-
it('renders warning alerts with aria-live assertive', () => {
|
|
282
|
-
component = getComponentWithType(Sentiment.WARNING);
|
|
283
|
-
expect(component).toHaveAttribute('aria-live', 'assertive');
|
|
284
|
-
});
|
|
285
|
-
it('renders neutral alerts with aria-live polite', () => {
|
|
286
|
-
component = getComponentWithType(Sentiment.NEUTRAL);
|
|
287
|
-
expect(component).toHaveAttribute('aria-live', 'polite');
|
|
288
|
-
});
|
|
289
280
|
});
|
|
290
281
|
|
|
291
282
|
describe('on touch devices', () => {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';
|
|
2
|
+
|
|
3
|
+
import Body from '../body';
|
|
4
|
+
import { Typography } from '../common';
|
|
1
5
|
import Link from '../link';
|
|
6
|
+
import Title from '../title';
|
|
2
7
|
|
|
3
8
|
import InstructionsList from './InstructionsList';
|
|
4
9
|
|
|
@@ -25,3 +30,29 @@ export const Basic = () => {
|
|
|
25
30
|
/>
|
|
26
31
|
);
|
|
27
32
|
};
|
|
33
|
+
|
|
34
|
+
export const IconsProvideDescription = () => {
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<Body as="p">
|
|
38
|
+
In following example icons have visual meaning. <DontIcon className="d-inline-flex" /> means
|
|
39
|
+
"doesn't support" while <DoIcon className="d-inline-flex" /> means "supports". So we have to
|
|
40
|
+
make sure that this is works same for visually impaired users which use screen readers.
|
|
41
|
+
</Body>
|
|
42
|
+
<Body as="p">
|
|
43
|
+
We can do this by adding meaning to each icon via <code>do-aria-label="Supports"</code> and{' '}
|
|
44
|
+
<code>dont-aria-label="Doesn't support"</code> props. So screen reader will read "Supports
|
|
45
|
+
Multiple currencies" / "Doesn't support Create recipients".
|
|
46
|
+
</Body>
|
|
47
|
+
<Title type={Typography.TITLE_SUBSECTION} className="m-t-3">
|
|
48
|
+
List of Supported Features
|
|
49
|
+
</Title>
|
|
50
|
+
<InstructionsList
|
|
51
|
+
do-aria-label="Supports"
|
|
52
|
+
dos={['Multiple currencies', 'Existing recipients']}
|
|
53
|
+
dont-aria-label="Doesn't support"
|
|
54
|
+
donts={['Create recipients', 'Edit recipients']}
|
|
55
|
+
/>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.tw-instructions{display:flex;flex-direction:column}.tw-instructions .instruction{display:flex;margin-top:8px;margin-top:var(--padding-x-small)}.tw-instructions .instruction .do,.tw-instructions .instruction .dont{flex-shrink:0;margin-bottom:0;margin-right:
|
|
1
|
+
.tw-instructions{display:flex;flex-direction:column}.tw-instructions .instruction{display:flex;margin-top:8px;margin-top:var(--padding-x-small)}.tw-instructions .instruction .do,.tw-instructions .instruction .dont{flex-shrink:0;margin-bottom:0;margin-right:8px;margin-right:var(--padding-x-small)}.tw-instructions .instruction .do{color:var(--color-sentiment-positive)}.tw-instructions .instruction .dont{color:var(--color-sentiment-negative)}
|
|
@@ -9,28 +9,16 @@
|
|
|
9
9
|
.do,
|
|
10
10
|
.dont {
|
|
11
11
|
flex-shrink: 0;
|
|
12
|
-
margin-right: var(--padding-small);
|
|
12
|
+
margin-right: var(--padding-x-small);
|
|
13
13
|
margin-bottom: 0;
|
|
14
|
-
|
|
15
|
-
.np-theme-personal & {
|
|
16
|
-
margin-right: var(--padding-x-small);
|
|
17
|
-
}
|
|
18
14
|
}
|
|
19
15
|
|
|
20
16
|
.do {
|
|
21
|
-
color: var(--color-
|
|
22
|
-
|
|
23
|
-
.np-theme-personal & {
|
|
24
|
-
color: var(--color-sentiment-positive);
|
|
25
|
-
}
|
|
17
|
+
color: var(--color-sentiment-positive);
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
.dont {
|
|
29
|
-
color: var(--color-
|
|
30
|
-
|
|
31
|
-
.np-theme-personal & {
|
|
32
|
-
color: var(--color-sentiment-negative);
|
|
33
|
-
}
|
|
21
|
+
color: var(--color-sentiment-negative);
|
|
34
22
|
}
|
|
35
23
|
}
|
|
36
24
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { render, screen } from '../test-utils';
|
|
2
|
+
|
|
3
|
+
import InstructionsList from '.';
|
|
4
|
+
|
|
5
|
+
describe('InstructionsList', () => {
|
|
6
|
+
it('should render dos list only', () => {
|
|
7
|
+
const dos = ['Test this component', 'With multiple dos'];
|
|
8
|
+
render(<InstructionsList dos={dos} />);
|
|
9
|
+
|
|
10
|
+
expect(screen.getByText(dos[0])).toBeInTheDocument();
|
|
11
|
+
expect(screen.getByText(dos[1])).toBeInTheDocument();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should render do items with description for icons', () => {
|
|
15
|
+
const dos = ['Card validation', 'ID verification'];
|
|
16
|
+
render(<InstructionsList dos={dos} do-aria-label="Do" />);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByText(dos[0])).toBeInTheDocument();
|
|
19
|
+
expect(screen.getByText(dos[1])).toBeInTheDocument();
|
|
20
|
+
expect(screen.getAllByText('Do')).toHaveLength(2);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should render donts list only', () => {
|
|
24
|
+
const donts = ['Card validation', 'ID verification'];
|
|
25
|
+
|
|
26
|
+
render(<InstructionsList donts={donts} />);
|
|
27
|
+
expect(screen.getByText(donts[0])).toBeInTheDocument();
|
|
28
|
+
expect(screen.getByText(donts[1])).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should render do/dont lists with description for icons', () => {
|
|
32
|
+
const dos = ['Card validation'];
|
|
33
|
+
const donts = ['ID verification'];
|
|
34
|
+
const doIconDescription = 'Do';
|
|
35
|
+
const dontIconDescription = 'No';
|
|
36
|
+
|
|
37
|
+
render(
|
|
38
|
+
<InstructionsList
|
|
39
|
+
dos={dos}
|
|
40
|
+
do-aria-label={doIconDescription}
|
|
41
|
+
donts={donts}
|
|
42
|
+
dont-aria-label={dontIconDescription}
|
|
43
|
+
/>,
|
|
44
|
+
);
|
|
45
|
+
expect(screen.getByText(dos[0])).toBeInTheDocument();
|
|
46
|
+
expect(screen.getByText(donts[0])).toBeInTheDocument();
|
|
47
|
+
expect(screen.getByText('Do')).toBeInTheDocument();
|
|
48
|
+
expect(screen.getByText('No')).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useTheme } from '@wise/components-theming';
|
|
1
|
+
import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
|
|
5
4
|
import Body from '../body/Body';
|
|
@@ -9,21 +8,29 @@ import { Typography } from '../common/propsValues/typography';
|
|
|
9
8
|
type Props = CommonProps & {
|
|
10
9
|
dos?: ReactNode[];
|
|
11
10
|
donts?: ReactNode[];
|
|
11
|
+
/**
|
|
12
|
+
* Add meaning to "do" icon of "do" items
|
|
13
|
+
*/
|
|
14
|
+
['do-aria-label']?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Add meaning to "don't" icon of "don't" items
|
|
17
|
+
*/
|
|
18
|
+
['dont-aria-label']?: string;
|
|
12
19
|
};
|
|
13
20
|
|
|
14
|
-
const InstructionsList = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
const InstructionsList = ({
|
|
22
|
+
dos,
|
|
23
|
+
donts,
|
|
24
|
+
'do-aria-label': doAriaLabel = undefined,
|
|
25
|
+
'dont-aria-label': dontAriaLabel = undefined,
|
|
26
|
+
}: Props) => {
|
|
20
27
|
return (
|
|
21
28
|
<div className="tw-instructions">
|
|
22
29
|
{dos &&
|
|
23
30
|
dos.map((doThis, index) => (
|
|
24
31
|
// eslint-disable-next-line react/no-array-index-key
|
|
25
32
|
<div key={index} className="instruction">
|
|
26
|
-
<DoIcon size={24} className="do" />
|
|
33
|
+
<DoIcon size={24} className="do" title={doAriaLabel} />
|
|
27
34
|
<Body className="text-primary" type={Typography.BODY_LARGE}>
|
|
28
35
|
{doThis}
|
|
29
36
|
</Body>
|
|
@@ -33,7 +40,7 @@ const InstructionsList = (props: Props) => {
|
|
|
33
40
|
donts.map((dont, index) => (
|
|
34
41
|
// eslint-disable-next-line react/no-array-index-key
|
|
35
42
|
<div key={index} className="instruction">
|
|
36
|
-
<DontIcon size={24} className="dont" />
|
|
43
|
+
<DontIcon size={24} className="dont" title={dontAriaLabel} />
|
|
37
44
|
<Body className="text-primary" type={Typography.BODY_LARGE}>
|
|
38
45
|
{dont}
|
|
39
46
|
</Body>
|