@transferwise/components 0.0.0-experimental-9956441 → 0.0.0-experimental-f2cd6e1
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/divider/Divider.js +3 -3
- package/build/divider/Divider.js.map +1 -1
- package/build/divider/Divider.mjs +3 -3
- package/build/divider/Divider.mjs.map +1 -1
- package/build/types/divider/Divider.d.ts +6 -1
- package/build/types/divider/Divider.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/divider/Divider.accessibility.docs.mdx +6 -6
- package/src/divider/Divider.spec.tsx +4 -4
- package/src/divider/Divider.story.tsx +13 -13
- package/src/divider/Divider.tsx +9 -4
package/build/divider/Divider.js
CHANGED
|
@@ -8,12 +8,12 @@ const Divider = ({
|
|
|
8
8
|
className,
|
|
9
9
|
isContent = false,
|
|
10
10
|
testId,
|
|
11
|
-
|
|
11
|
+
level = 'section',
|
|
12
12
|
...props
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
14
|
+
const levelClass = level && level !== 'section' ? `wds-Divider--${level}` : '';
|
|
15
15
|
const commonProps = {
|
|
16
|
-
className: clsx.clsx('wds-Divider',
|
|
16
|
+
className: clsx.clsx('wds-Divider', levelClass, className),
|
|
17
17
|
'data-testid': testId
|
|
18
18
|
};
|
|
19
19
|
const divProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.js","sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { FunctionComponent } from 'react';\n\nexport interface DividerProps {\n /**\n * If `true`, renders the Divider as a semantic `<hr>`, providing clear separation to assistive technologies.\n * Otherwise, a non-semantic `<div role=\"presentation\">` is used for purely visual separation.\n * @default false\n */\n isContent?: boolean;\n\n /**\n * Appends additional class names to style the `Divider`.\n */\n className?: string;\n\n /**\n * Provides a `data-testid` attribute for testing.\n */\n testId?: string;\n\n /**\n * Alters the visual style of the divider, accommodating different types\n * of separated content. Accepts `'section'`, `'subsection'`, or `'content'`.\n * @default 'section'\n */\n
|
|
1
|
+
{"version":3,"file":"Divider.js","sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { FunctionComponent } from 'react';\n\nexport interface DividerProps {\n /**\n * If `true`, renders the Divider as a semantic `<hr>`, providing clear separation to assistive technologies.\n * Otherwise, a non-semantic `<div role=\"presentation\">` is used for purely visual separation.\n * @default false\n */\n isContent?: boolean;\n\n /**\n * Appends additional class names to style the `Divider`.\n */\n className?: string;\n\n /**\n * Provides a `data-testid` attribute for testing.\n */\n testId?: string;\n\n /**\n * Alters the visual style of the divider, accommodating different types\n * of separated content. Accepts `'section'`, `'subsection'`, or `'content'`.\n * @default 'section'\n */\n level?: 'section' | 'subsection' | 'content';\n}\n\n/**\n * @param {boolean} [isContent=false] - If `true`, uses a semantic `<hr>` for accessible separation; otherwise uses `<div role=\"presentation\">`.\n * @param {string} [className] - Optional class names for adding custom styling to the divider.\n * @param {string} [testId] - Provides a `data-testid` for testing frameworks.\n * @param {'section' | 'subsection' | 'content'} [level='section'] - Defines the visual style for the divider.\n *\n * @see {@link Divider} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/layouts-divider--docs|Storybook Wise Design}\n */\nconst Divider: FunctionComponent<DividerProps> = ({\n className,\n isContent = false,\n testId,\n level = 'section',\n ...props\n}) => {\n const levelClass = level && level !== 'section' ? `wds-Divider--${level}` : '';\n\n const commonProps = {\n className: clsx('wds-Divider', levelClass, className),\n 'data-testid': testId,\n };\n\n const divProps = {\n ...commonProps,\n role: 'presentation',\n };\n\n return isContent ? <hr {...commonProps} {...props} /> : <div {...divProps} {...props} />;\n};\n\nexport default Divider;\n"],"names":["Divider","className","isContent","testId","level","props","levelClass","commonProps","clsx","divProps","role","_jsx"],"mappings":";;;;;;AAsCMA,MAAAA,OAAO,GAAoCA,CAAC;EAChDC,SAAS;AACTC,EAAAA,SAAS,GAAG,KAAK;EACjBC,MAAM;AACNC,EAAAA,KAAK,GAAG,SAAS;EACjB,GAAGC,KAAAA;AAAK,CACT,KAAI;AACH,EAAA,MAAMC,UAAU,GAAGF,KAAK,IAAIA,KAAK,KAAK,SAAS,GAAG,CAAgBA,aAAAA,EAAAA,KAAK,CAAE,CAAA,GAAG,EAAE,CAAA;AAE9E,EAAA,MAAMG,WAAW,GAAG;IAClBN,SAAS,EAAEO,SAAI,CAAC,aAAa,EAAEF,UAAU,EAAEL,SAAS,CAAC;AACrD,IAAA,aAAa,EAAEE,MAAAA;GAChB,CAAA;AAED,EAAA,MAAMM,QAAQ,GAAG;AACf,IAAA,GAAGF,WAAW;AACdG,IAAAA,IAAI,EAAE,cAAA;GACP,CAAA;EAED,OAAOR,SAAS,gBAAGS,cAAA,CAAA,IAAA,EAAA;AAAA,IAAA,GAAQJ,WAAW;IAAA,GAAMF,KAAAA;GAAS,CAAA,gBAAGM,cAAA,CAAA,KAAA,EAAA;AAAA,IAAA,GAASF,QAAQ;IAAA,GAAMJ,KAAAA;AAAK,IAAI,CAAA;AAC1F;;;;"}
|
|
@@ -6,12 +6,12 @@ const Divider = ({
|
|
|
6
6
|
className,
|
|
7
7
|
isContent = false,
|
|
8
8
|
testId,
|
|
9
|
-
|
|
9
|
+
level = 'section',
|
|
10
10
|
...props
|
|
11
11
|
}) => {
|
|
12
|
-
const
|
|
12
|
+
const levelClass = level && level !== 'section' ? `wds-Divider--${level}` : '';
|
|
13
13
|
const commonProps = {
|
|
14
|
-
className: clsx('wds-Divider',
|
|
14
|
+
className: clsx('wds-Divider', levelClass, className),
|
|
15
15
|
'data-testid': testId
|
|
16
16
|
};
|
|
17
17
|
const divProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.mjs","sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { FunctionComponent } from 'react';\n\nexport interface DividerProps {\n /**\n * If `true`, renders the Divider as a semantic `<hr>`, providing clear separation to assistive technologies.\n * Otherwise, a non-semantic `<div role=\"presentation\">` is used for purely visual separation.\n * @default false\n */\n isContent?: boolean;\n\n /**\n * Appends additional class names to style the `Divider`.\n */\n className?: string;\n\n /**\n * Provides a `data-testid` attribute for testing.\n */\n testId?: string;\n\n /**\n * Alters the visual style of the divider, accommodating different types\n * of separated content. Accepts `'section'`, `'subsection'`, or `'content'`.\n * @default 'section'\n */\n
|
|
1
|
+
{"version":3,"file":"Divider.mjs","sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { FunctionComponent } from 'react';\n\nexport interface DividerProps {\n /**\n * If `true`, renders the Divider as a semantic `<hr>`, providing clear separation to assistive technologies.\n * Otherwise, a non-semantic `<div role=\"presentation\">` is used for purely visual separation.\n * @default false\n */\n isContent?: boolean;\n\n /**\n * Appends additional class names to style the `Divider`.\n */\n className?: string;\n\n /**\n * Provides a `data-testid` attribute for testing.\n */\n testId?: string;\n\n /**\n * Alters the visual style of the divider, accommodating different types\n * of separated content. Accepts `'section'`, `'subsection'`, or `'content'`.\n * @default 'section'\n */\n level?: 'section' | 'subsection' | 'content';\n}\n\n/**\n * @param {boolean} [isContent=false] - If `true`, uses a semantic `<hr>` for accessible separation; otherwise uses `<div role=\"presentation\">`.\n * @param {string} [className] - Optional class names for adding custom styling to the divider.\n * @param {string} [testId] - Provides a `data-testid` for testing frameworks.\n * @param {'section' | 'subsection' | 'content'} [level='section'] - Defines the visual style for the divider.\n *\n * @see {@link Divider} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/layouts-divider--docs|Storybook Wise Design}\n */\nconst Divider: FunctionComponent<DividerProps> = ({\n className,\n isContent = false,\n testId,\n level = 'section',\n ...props\n}) => {\n const levelClass = level && level !== 'section' ? `wds-Divider--${level}` : '';\n\n const commonProps = {\n className: clsx('wds-Divider', levelClass, className),\n 'data-testid': testId,\n };\n\n const divProps = {\n ...commonProps,\n role: 'presentation',\n };\n\n return isContent ? <hr {...commonProps} {...props} /> : <div {...divProps} {...props} />;\n};\n\nexport default Divider;\n"],"names":["Divider","className","isContent","testId","level","props","levelClass","commonProps","clsx","divProps","role","_jsx"],"mappings":";;;;AAsCMA,MAAAA,OAAO,GAAoCA,CAAC;EAChDC,SAAS;AACTC,EAAAA,SAAS,GAAG,KAAK;EACjBC,MAAM;AACNC,EAAAA,KAAK,GAAG,SAAS;EACjB,GAAGC,KAAAA;AAAK,CACT,KAAI;AACH,EAAA,MAAMC,UAAU,GAAGF,KAAK,IAAIA,KAAK,KAAK,SAAS,GAAG,CAAgBA,aAAAA,EAAAA,KAAK,CAAE,CAAA,GAAG,EAAE,CAAA;AAE9E,EAAA,MAAMG,WAAW,GAAG;IAClBN,SAAS,EAAEO,IAAI,CAAC,aAAa,EAAEF,UAAU,EAAEL,SAAS,CAAC;AACrD,IAAA,aAAa,EAAEE,MAAAA;GAChB,CAAA;AAED,EAAA,MAAMM,QAAQ,GAAG;AACf,IAAA,GAAGF,WAAW;AACdG,IAAAA,IAAI,EAAE,cAAA;GACP,CAAA;EAED,OAAOR,SAAS,gBAAGS,GAAA,CAAA,IAAA,EAAA;AAAA,IAAA,GAAQJ,WAAW;IAAA,GAAMF,KAAAA;GAAS,CAAA,gBAAGM,GAAA,CAAA,KAAA,EAAA;AAAA,IAAA,GAASF,QAAQ;IAAA,GAAMJ,KAAAA;AAAK,IAAI,CAAA;AAC1F;;;;"}
|
|
@@ -19,9 +19,14 @@ export interface DividerProps {
|
|
|
19
19
|
* of separated content. Accepts `'section'`, `'subsection'`, or `'content'`.
|
|
20
20
|
* @default 'section'
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
level?: 'section' | 'subsection' | 'content';
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
+
* @param {boolean} [isContent=false] - If `true`, uses a semantic `<hr>` for accessible separation; otherwise uses `<div role="presentation">`.
|
|
26
|
+
* @param {string} [className] - Optional class names for adding custom styling to the divider.
|
|
27
|
+
* @param {string} [testId] - Provides a `data-testid` for testing frameworks.
|
|
28
|
+
* @param {'section' | 'subsection' | 'content'} [level='section'] - Defines the visual style for the divider.
|
|
29
|
+
*
|
|
25
30
|
* @see {@link Divider} for further information.
|
|
26
31
|
* @see {@link https://storybook.wise.design/?path=/docs/layouts-divider--docs|Storybook Wise Design}
|
|
27
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.d.ts","sourceRoot":"","sources":["../../../src/divider/Divider.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"Divider.d.ts","sourceRoot":"","sources":["../../../src/divider/Divider.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAoB5C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-f2cd6e1",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"rollup-preserve-directives": "^1.1.1",
|
|
95
95
|
"storybook": "^8.2.2",
|
|
96
96
|
"@transferwise/less-config": "3.1.0",
|
|
97
|
-
"@transferwise/neptune-css": "14.22.0",
|
|
98
97
|
"@wise/components-theming": "1.6.1",
|
|
98
|
+
"@transferwise/neptune-css": "14.22.0",
|
|
99
99
|
"@wise/wds-configs": "0.0.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
@@ -35,18 +35,18 @@ Compared to a `<div>`, `<hr>` tells assistive technologies that a thematic break
|
|
|
35
35
|
|
|
36
36
|
<br />
|
|
37
37
|
|
|
38
|
-
##
|
|
38
|
+
## Levels
|
|
39
39
|
|
|
40
|
-
The Divider supports
|
|
40
|
+
The Divider supports levels like “section”, “subsection”, or “content” to visually change the separation style:
|
|
41
41
|
|
|
42
42
|
<Source
|
|
43
43
|
dark
|
|
44
44
|
code={`
|
|
45
|
-
// A few
|
|
45
|
+
// A few level examples
|
|
46
46
|
<>
|
|
47
|
-
<Divider
|
|
48
|
-
<Divider
|
|
49
|
-
<Divider
|
|
47
|
+
<Divider level="section" />
|
|
48
|
+
<Divider level="subsection" />
|
|
49
|
+
<Divider level="content" />
|
|
50
50
|
</>
|
|
51
51
|
`}
|
|
52
52
|
/>
|
|
@@ -47,16 +47,16 @@ describe('Divider', () => {
|
|
|
47
47
|
expect(screen.getByTestId('test-divider')).toHaveClass('custom-class');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
it('should apply the "content"
|
|
51
|
-
const props: DividerProps = {
|
|
50
|
+
it('should apply the "content" level styling', () => {
|
|
51
|
+
const props: DividerProps = { level: 'content' };
|
|
52
52
|
expect(screen.getByTestId('test-divider')).not.toHaveClass('wds-Divider--content');
|
|
53
53
|
|
|
54
54
|
rerenderDivider(props);
|
|
55
55
|
expect(screen.getByTestId('test-divider')).toHaveClass('wds-Divider', 'wds-Divider--content');
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it('should apply the "subsection"
|
|
59
|
-
const props: DividerProps = {
|
|
58
|
+
it('should apply the "subsection" level styling', () => {
|
|
59
|
+
const props: DividerProps = { level: 'subsection' };
|
|
60
60
|
expect(screen.getByTestId('test-divider')).not.toHaveClass('wds-Divider--subsection');
|
|
61
61
|
|
|
62
62
|
rerenderDivider(props);
|
|
@@ -15,14 +15,14 @@ const withContainer = (Story: any) => (
|
|
|
15
15
|
* Not all stories need access to all controls as it causes unnecessary UI noise.
|
|
16
16
|
*/
|
|
17
17
|
const hideControls = (args: string[]) => {
|
|
18
|
-
const hidden = ['
|
|
18
|
+
const hidden = ['level', 'as', 'className', 'testId', ...args];
|
|
19
19
|
|
|
20
20
|
return Object.fromEntries(hidden.map((item) => [item, { table: { disable: true } }]));
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The stories below document the `<Divider />` component, which can be rendered as either a semantic `<hr>` or a non-semantic `<div>`.
|
|
25
|
-
*
|
|
25
|
+
* levels allow customization for different visual separation needs.
|
|
26
26
|
*
|
|
27
27
|
* For more details, please refer to the [design documentation](https://wise.design/components/divider).
|
|
28
28
|
*
|
|
@@ -37,10 +37,10 @@ const meta: Meta<typeof Divider> = {
|
|
|
37
37
|
actions: { argTypesRegex: null },
|
|
38
38
|
},
|
|
39
39
|
argTypes: {
|
|
40
|
-
|
|
40
|
+
level: {
|
|
41
41
|
control: 'select',
|
|
42
42
|
options: ['section', 'subsection', 'content'],
|
|
43
|
-
description: 'Choose the Divider
|
|
43
|
+
description: 'Choose the Divider level.',
|
|
44
44
|
table: {
|
|
45
45
|
category: 'Appearance',
|
|
46
46
|
type: { summary: 'string' },
|
|
@@ -75,7 +75,7 @@ const meta: Meta<typeof Divider> = {
|
|
|
75
75
|
isContent: false,
|
|
76
76
|
className: '',
|
|
77
77
|
testId: '',
|
|
78
|
-
|
|
78
|
+
level: 'section',
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
81
|
export default meta;
|
|
@@ -84,7 +84,7 @@ type Story = StoryObj<typeof Divider>;
|
|
|
84
84
|
|
|
85
85
|
export const Playground: Story = {
|
|
86
86
|
args: {
|
|
87
|
-
|
|
87
|
+
level: 'section',
|
|
88
88
|
},
|
|
89
89
|
tags: ['!autodocs'],
|
|
90
90
|
};
|
|
@@ -94,12 +94,12 @@ export const Playground: Story = {
|
|
|
94
94
|
* each designed to visually separate or group content. <br />
|
|
95
95
|
* [Design documentation](https://wise.design/components/divider)
|
|
96
96
|
*/
|
|
97
|
-
export const
|
|
97
|
+
export const Level: Story = {
|
|
98
98
|
argTypes: {
|
|
99
99
|
...hideControls(['testId', 'className', 'isContent']),
|
|
100
100
|
},
|
|
101
101
|
args: {
|
|
102
|
-
|
|
102
|
+
level: 'section',
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
105
|
|
|
@@ -108,7 +108,7 @@ export const Variant: Story = {
|
|
|
108
108
|
*/
|
|
109
109
|
export const ContentDivider: Story = {
|
|
110
110
|
argTypes: {
|
|
111
|
-
...hideControls(['
|
|
111
|
+
...hideControls(['level', 'testId', 'className']),
|
|
112
112
|
},
|
|
113
113
|
args: {
|
|
114
114
|
isContent: true,
|
|
@@ -119,14 +119,14 @@ export const AllVariants: Story = {
|
|
|
119
119
|
render: function Render() {
|
|
120
120
|
return (
|
|
121
121
|
<>
|
|
122
|
-
<Divider
|
|
123
|
-
<Divider
|
|
124
|
-
<Divider
|
|
122
|
+
<Divider level="section" />
|
|
123
|
+
<Divider level="subsection" />
|
|
124
|
+
<Divider level="content" />
|
|
125
125
|
</>
|
|
126
126
|
);
|
|
127
127
|
},
|
|
128
128
|
argTypes: {
|
|
129
|
-
...hideControls(['
|
|
129
|
+
...hideControls(['level', 'testId', 'className', 'isContent']),
|
|
130
130
|
},
|
|
131
131
|
tags: ['!autodocs'],
|
|
132
132
|
};
|
package/src/divider/Divider.tsx
CHANGED
|
@@ -24,10 +24,15 @@ export interface DividerProps {
|
|
|
24
24
|
* of separated content. Accepts `'section'`, `'subsection'`, or `'content'`.
|
|
25
25
|
* @default 'section'
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
level?: 'section' | 'subsection' | 'content';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
+
* @param {boolean} [isContent=false] - If `true`, uses a semantic `<hr>` for accessible separation; otherwise uses `<div role="presentation">`.
|
|
32
|
+
* @param {string} [className] - Optional class names for adding custom styling to the divider.
|
|
33
|
+
* @param {string} [testId] - Provides a `data-testid` for testing frameworks.
|
|
34
|
+
* @param {'section' | 'subsection' | 'content'} [level='section'] - Defines the visual style for the divider.
|
|
35
|
+
*
|
|
31
36
|
* @see {@link Divider} for further information.
|
|
32
37
|
* @see {@link https://storybook.wise.design/?path=/docs/layouts-divider--docs|Storybook Wise Design}
|
|
33
38
|
*/
|
|
@@ -35,13 +40,13 @@ const Divider: FunctionComponent<DividerProps> = ({
|
|
|
35
40
|
className,
|
|
36
41
|
isContent = false,
|
|
37
42
|
testId,
|
|
38
|
-
|
|
43
|
+
level = 'section',
|
|
39
44
|
...props
|
|
40
45
|
}) => {
|
|
41
|
-
const
|
|
46
|
+
const levelClass = level && level !== 'section' ? `wds-Divider--${level}` : '';
|
|
42
47
|
|
|
43
48
|
const commonProps = {
|
|
44
|
-
className: clsx('wds-Divider',
|
|
49
|
+
className: clsx('wds-Divider', levelClass, className),
|
|
45
50
|
'data-testid': testId,
|
|
46
51
|
};
|
|
47
52
|
|