@popsure/dirty-swan 0.54.2 → 0.54.4
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/dist/cjs/index.js +355 -262
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +17 -0
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/BaseCell.stories.d.ts +22 -0
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.d.ts +3 -0
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.stories.d.ts +25 -0
- package/dist/cjs/lib/components/table/components/TableCell/ButtonCell/ButtonCell.d.ts +9 -0
- package/dist/cjs/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.d.ts +17 -0
- package/dist/cjs/lib/components/table/components/TableCell/CTACell/CTACell.d.ts +10 -0
- package/dist/cjs/lib/components/table/components/TableCell/CTACell/CTACell.stories.d.ts +18 -0
- package/dist/cjs/lib/components/table/components/TableCell/TableCell.d.ts +5 -17
- package/dist/cjs/lib/components/table/types.d.ts +19 -2
- package/dist/cjs/lib/components/table/utils/useTableNavigation/useTableNavigation.d.ts +1 -2
- package/dist/esm/TableSection-f6d0028e.js +80 -0
- package/dist/esm/TableSection-f6d0028e.js.map +1 -0
- package/dist/esm/components/cards/card/index.stories.js +2 -2
- package/dist/esm/components/cards/card/index.stories.js.map +1 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +2 -2
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +1 -1
- package/dist/esm/components/comparisonTable/index.js +3 -1526
- package/dist/esm/components/comparisonTable/index.js.map +1 -1
- package/dist/esm/components/comparisonTable/index.stories.js +1 -0
- package/dist/esm/components/comparisonTable/index.stories.js.map +1 -1
- package/dist/esm/components/icon/icons/Info.js +2 -2
- package/dist/esm/components/icon/icons/Info.js.map +1 -1
- package/dist/esm/components/icon/icons.stories.js +1 -1
- package/dist/esm/components/icon/index.stories.js +1 -1
- package/dist/esm/components/table/Table.js +22 -13
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +100 -32
- package/dist/esm/components/table/Table.stories.js.map +1 -1
- package/dist/esm/components/table/Table.test.js +15 -12
- package/dist/esm/components/table/Table.test.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js +50 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.stories.js +43 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.stories.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.js +15 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.stories.js +31 -0
- package/dist/esm/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.stories.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.js +23 -0
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.stories.js +28 -0
- package/dist/esm/components/table/components/TableCell/ButtonCell/ButtonCell.stories.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.js +21 -0
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.stories.js +26 -0
- package/dist/esm/components/table/components/TableCell/CTACell/CTACell.stories.js.map +1 -0
- package/dist/esm/components/table/components/TableCell/TableCell.js +24 -20
- package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.test.js +26 -14
- package/dist/esm/components/table/components/TableCell/TableCell.test.js.map +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +11 -3
- package/dist/esm/components/table/components/TableContents/TableContents.js.map +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +14 -7
- package/dist/esm/components/table/components/TableContents/TableContents.test.js.map +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.js +17 -53
- package/dist/esm/components/table/components/TableSection/TableSection.js.map +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +12 -5
- package/dist/esm/components/table/components/TableSection/TableSection.test.js.map +1 -1
- package/dist/esm/components/table/utils/useTableNavigation/useTableNavigation.test.js +1 -5
- package/dist/esm/components/table/utils/useTableNavigation/useTableNavigation.test.js.map +1 -1
- package/dist/esm/index-3d286178.js +1529 -0
- package/dist/esm/index-3d286178.js.map +1 -0
- package/dist/esm/{index-0bb5a2ee.js → index-7506ae25.js} +3 -3
- package/dist/esm/{index-0bb5a2ee.js.map → index-7506ae25.js.map} +1 -1
- package/dist/esm/index.js +7 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +17 -0
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/BaseCell.stories.d.ts +22 -0
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.d.ts +3 -0
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.stories.d.ts +25 -0
- package/dist/esm/lib/components/table/components/TableCell/ButtonCell/ButtonCell.d.ts +9 -0
- package/dist/esm/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.d.ts +17 -0
- package/dist/esm/lib/components/table/components/TableCell/CTACell/CTACell.d.ts +10 -0
- package/dist/esm/lib/components/table/components/TableCell/CTACell/CTACell.stories.d.ts +18 -0
- package/dist/esm/lib/components/table/components/TableCell/TableCell.d.ts +5 -17
- package/dist/esm/lib/components/table/types.d.ts +19 -2
- package/dist/esm/lib/components/table/utils/useTableNavigation/useTableNavigation.d.ts +1 -2
- package/dist/esm/{useTableNavigation-8e50b121.js → useTableNavigation-2899712c.js} +12 -16
- package/dist/esm/useTableNavigation-2899712c.js.map +1 -0
- package/package.json +1 -1
- package/src/lib/components/table/Table.stories.tsx +87 -25
- package/src/lib/components/table/Table.test.tsx +3 -6
- package/src/lib/components/table/Table.tsx +11 -9
- package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.module.scss +36 -0
- package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.stories.tsx +45 -0
- package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.tsx +158 -0
- package/src/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.module.scss +44 -0
- package/src/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.stories.tsx +29 -0
- package/src/lib/components/table/components/TableCell/BaseCell/MiniProgressBar/MiniProgressBar.tsx +35 -0
- package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.module.scss +43 -0
- package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.stories.tsx +65 -0
- package/src/lib/components/table/components/TableCell/ButtonCell/ButtonCell.tsx +40 -0
- package/src/lib/components/table/components/TableCell/CTACell/CTACell.module.scss +3 -0
- package/src/lib/components/table/components/TableCell/CTACell/CTACell.stories.tsx +37 -0
- package/src/lib/components/table/components/TableCell/CTACell/CTACell.tsx +42 -0
- package/src/lib/components/table/components/TableCell/TableCell.module.scss +0 -43
- package/src/lib/components/table/components/TableCell/TableCell.test.tsx +26 -13
- package/src/lib/components/table/components/TableCell/TableCell.tsx +20 -122
- package/src/lib/components/table/components/TableContents/TableContents.test.tsx +6 -6
- package/src/lib/components/table/components/TableSection/TableSection.test.tsx +5 -5
- package/src/lib/components/table/components/TableSection/TableSection.tsx +67 -41
- package/src/lib/components/table/types.ts +16 -2
- package/src/lib/components/table/utils/useTableNavigation/useTableNavigation.test.tsx +0 -4
- package/src/lib/components/table/utils/useTableNavigation/useTableNavigation.ts +13 -20
- package/dist/esm/useTableNavigation-8e50b121.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ButtonCell } from './ButtonCell';
|
|
2
|
+
|
|
3
|
+
const story = {
|
|
4
|
+
title: 'JSX/Table/Cells',
|
|
5
|
+
component: ButtonCell,
|
|
6
|
+
argTypes: {},
|
|
7
|
+
args: {
|
|
8
|
+
buttonCaption: 'Premium',
|
|
9
|
+
price: '€277/mo',
|
|
10
|
+
isSelected: false,
|
|
11
|
+
disabled: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ButtonCellStory = ({
|
|
16
|
+
isSelected,
|
|
17
|
+
buttonCaption,
|
|
18
|
+
price,
|
|
19
|
+
disabled,
|
|
20
|
+
}: React.ComponentProps<typeof ButtonCell>) => (
|
|
21
|
+
<div className="p48 d-flex fd-column gap16 bg-white">
|
|
22
|
+
<ButtonCell
|
|
23
|
+
buttonCaption={buttonCaption}
|
|
24
|
+
price={price}
|
|
25
|
+
isSelected={isSelected}
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
onClick={() => {}}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<ButtonCell
|
|
31
|
+
buttonCaption={buttonCaption}
|
|
32
|
+
price={price}
|
|
33
|
+
isSelected
|
|
34
|
+
disabled={disabled}
|
|
35
|
+
onClick={() => {}}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<ButtonCell
|
|
39
|
+
buttonCaption={buttonCaption}
|
|
40
|
+
price={price}
|
|
41
|
+
disabled
|
|
42
|
+
onClick={() => {}}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
<ButtonCell
|
|
46
|
+
buttonCaption={buttonCaption}
|
|
47
|
+
isSelected={isSelected}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
onClick={() => {}}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<ButtonCell
|
|
53
|
+
buttonCaption={buttonCaption}
|
|
54
|
+
isSelected
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
onClick={() => {}}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
<ButtonCell buttonCaption={buttonCaption} disabled onClick={() => {}} />
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
ButtonCellStory.storyName = 'ButtonCell';
|
|
64
|
+
|
|
65
|
+
export default story;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
|
|
3
|
+
import styles from './ButtonCell.module.scss';
|
|
4
|
+
import { Button } from '../../../../button';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
export type ButtonCellProps = {
|
|
8
|
+
buttonCaption: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
isSelected?: boolean;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
price?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ButtonCell = ({
|
|
16
|
+
isSelected,
|
|
17
|
+
onClick,
|
|
18
|
+
buttonCaption,
|
|
19
|
+
price,
|
|
20
|
+
disabled,
|
|
21
|
+
}: ButtonCellProps) => {
|
|
22
|
+
return (
|
|
23
|
+
<div className="w100 d-flex fd-column ai-center jc-center gap8">
|
|
24
|
+
<Button
|
|
25
|
+
className={classNames('w100 wmx5 d-flex fd-column', styles.buttonCell, {
|
|
26
|
+
[styles.selected]: isSelected,
|
|
27
|
+
[styles.withoutPrice]: !price,
|
|
28
|
+
[styles.withPrice]: !!price,
|
|
29
|
+
})}
|
|
30
|
+
variant="filledWhite"
|
|
31
|
+
type="submit"
|
|
32
|
+
onClick={onClick}
|
|
33
|
+
disabled={disabled}
|
|
34
|
+
>
|
|
35
|
+
{buttonCaption}
|
|
36
|
+
{price && <span className="p-p tc-purple-500">{price}</span>}
|
|
37
|
+
</Button>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CTACell } from './CTACell';
|
|
2
|
+
|
|
3
|
+
const story = {
|
|
4
|
+
title: 'JSX/Table/Cells',
|
|
5
|
+
component: CTACell,
|
|
6
|
+
argTypes: {},
|
|
7
|
+
args: {
|
|
8
|
+
title: 'Premium',
|
|
9
|
+
price: '€277',
|
|
10
|
+
buttonCaption: 'Get covered',
|
|
11
|
+
grey: false,
|
|
12
|
+
narrow: false,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const CTACellStory = ({
|
|
17
|
+
title,
|
|
18
|
+
price,
|
|
19
|
+
buttonCaption,
|
|
20
|
+
grey,
|
|
21
|
+
narrow,
|
|
22
|
+
}: React.ComponentProps<typeof CTACell>) => (
|
|
23
|
+
<div className="p48 d-flex fd-column gap16 bg-white">
|
|
24
|
+
<CTACell
|
|
25
|
+
title={title}
|
|
26
|
+
price={price}
|
|
27
|
+
buttonCaption={buttonCaption}
|
|
28
|
+
href=""
|
|
29
|
+
grey={grey}
|
|
30
|
+
narrow={narrow}
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CTACellStory.storyName = 'CTACell';
|
|
36
|
+
|
|
37
|
+
export default story;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export type CTACellProps = {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
price?: ReactNode;
|
|
7
|
+
buttonCaption?: ReactNode;
|
|
8
|
+
grey?: boolean;
|
|
9
|
+
narrow?: boolean;
|
|
10
|
+
href: string;
|
|
11
|
+
};
|
|
12
|
+
import styles from './CTACell.module.scss';
|
|
13
|
+
|
|
14
|
+
export const CTACell = ({
|
|
15
|
+
title,
|
|
16
|
+
price,
|
|
17
|
+
grey,
|
|
18
|
+
narrow,
|
|
19
|
+
href,
|
|
20
|
+
buttonCaption,
|
|
21
|
+
}: CTACellProps) => {
|
|
22
|
+
return (
|
|
23
|
+
<div className="wmn3 ta-center">
|
|
24
|
+
<p className="p-h3">
|
|
25
|
+
{title}
|
|
26
|
+
{price && <span className="tc-purple-500"> {price}</span>}
|
|
27
|
+
</p>
|
|
28
|
+
<a
|
|
29
|
+
className={classNames('mt16', {
|
|
30
|
+
'p-btn--primary': !grey,
|
|
31
|
+
'p-btn--secondary-grey': grey,
|
|
32
|
+
[styles.narrow]: narrow,
|
|
33
|
+
})}
|
|
34
|
+
href={href}
|
|
35
|
+
target="_blank"
|
|
36
|
+
rel="noopener noreferrer"
|
|
37
|
+
>
|
|
38
|
+
{buttonCaption}
|
|
39
|
+
</a>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
@use '../../../../scss/public/colors' as *;
|
|
2
2
|
@use '../../../../scss/public/grid' as *;
|
|
3
3
|
|
|
4
|
-
.button {
|
|
5
|
-
min-height: initial;
|
|
6
|
-
height: initial;
|
|
7
|
-
width: initial;
|
|
8
|
-
padding: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.icon {
|
|
12
|
-
margin: 2px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
4
|
.th {
|
|
16
5
|
vertical-align: middle;
|
|
17
6
|
scroll-snap-align: end;
|
|
@@ -23,15 +12,6 @@
|
|
|
23
12
|
}
|
|
24
13
|
}
|
|
25
14
|
|
|
26
|
-
.thRow {
|
|
27
|
-
position: sticky;
|
|
28
|
-
top: 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.thCol {
|
|
32
|
-
text-align: left;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
15
|
.fixedCell {
|
|
36
16
|
position: sticky;
|
|
37
17
|
left: 0;
|
|
@@ -47,26 +27,3 @@
|
|
|
47
27
|
background-color: $ds-grey-200;
|
|
48
28
|
}
|
|
49
29
|
}
|
|
50
|
-
|
|
51
|
-
.topLeftCell {
|
|
52
|
-
position: relative;
|
|
53
|
-
display: none;
|
|
54
|
-
|
|
55
|
-
&:after {
|
|
56
|
-
content: '';
|
|
57
|
-
display: block;
|
|
58
|
-
position: absolute;
|
|
59
|
-
top: calc(
|
|
60
|
-
50% + 16px
|
|
61
|
-
); // Display bottom border at the same distance regardless of cell height
|
|
62
|
-
|
|
63
|
-
height: 4px;
|
|
64
|
-
width: 100%;
|
|
65
|
-
max-width: 140px;
|
|
66
|
-
background-color: $ds-primary-500;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@include p-size-tablet {
|
|
70
|
-
display: flex;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import { render, screen } from '../../../../util/testUtils';
|
|
2
|
-
import { TableCell } from './TableCell';
|
|
2
|
+
import { TableCell, TableCellProps } from './TableCell';
|
|
3
3
|
|
|
4
4
|
const openModal = jest.fn();
|
|
5
5
|
|
|
6
|
+
const setup = ({ isNavigation, ...rest }: TableCellProps = {}) =>
|
|
7
|
+
render(
|
|
8
|
+
isNavigation ? (
|
|
9
|
+
<TableCell {...rest} isNavigation />
|
|
10
|
+
) : (
|
|
11
|
+
<table>
|
|
12
|
+
<tbody>
|
|
13
|
+
<tr>
|
|
14
|
+
<TableCell {...rest} />
|
|
15
|
+
</tr>
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
|
|
6
21
|
describe('TableCell', () => {
|
|
7
22
|
it('renders the component with boolean true', () => {
|
|
8
|
-
|
|
23
|
+
setup({ checkmarkValue: true });
|
|
9
24
|
|
|
10
25
|
expect(screen.getByTitle('Yes')).toBeInTheDocument();
|
|
11
26
|
expect(screen.getByTestId('table-cell-boolean-yes')).toBeInTheDocument();
|
|
12
27
|
});
|
|
13
28
|
|
|
14
29
|
it('renders the component with boolean false', () => {
|
|
15
|
-
|
|
30
|
+
setup({ checkmarkValue: false });
|
|
16
31
|
|
|
17
32
|
expect(screen.getByTitle('No')).toBeInTheDocument();
|
|
18
33
|
expect(screen.getByTestId('table-cell-boolean-no')).toBeInTheDocument();
|
|
19
34
|
});
|
|
20
35
|
|
|
21
36
|
it('renders the component without boolean', () => {
|
|
22
|
-
|
|
37
|
+
setup();
|
|
23
38
|
|
|
24
39
|
expect(screen.queryByTitle('Yes')).not.toBeInTheDocument();
|
|
25
40
|
expect(screen.queryByTitle('No')).not.toBeInTheDocument();
|
|
@@ -32,42 +47,40 @@ describe('TableCell', () => {
|
|
|
32
47
|
});
|
|
33
48
|
|
|
34
49
|
it('renders the component with rating', () => {
|
|
35
|
-
|
|
50
|
+
setup({ rating: { type: 'star', value: 2 } });
|
|
36
51
|
|
|
37
52
|
expect(screen.getByTitle('2 out of 3')).toBeInTheDocument();
|
|
38
53
|
});
|
|
39
54
|
|
|
40
55
|
it('renders the component without rating', () => {
|
|
41
|
-
|
|
56
|
+
setup();
|
|
42
57
|
|
|
43
58
|
expect(screen.queryByTestId('table-cell-rating')).not.toBeInTheDocument();
|
|
44
59
|
});
|
|
45
60
|
|
|
46
61
|
it('renders the component with text', () => {
|
|
47
|
-
|
|
62
|
+
setup({ text: 'Sample text' });
|
|
48
63
|
|
|
49
64
|
expect(screen.getByText('Sample text')).toBeInTheDocument();
|
|
50
65
|
});
|
|
51
66
|
|
|
52
67
|
it('renders the component without text', () => {
|
|
53
|
-
|
|
68
|
+
setup();
|
|
54
69
|
|
|
55
70
|
expect(screen.queryByTestId('table-cell-text')).not.toBeInTheDocument();
|
|
56
71
|
});
|
|
57
72
|
|
|
58
73
|
it('renders the component without info', () => {
|
|
59
|
-
|
|
74
|
+
setup();
|
|
60
75
|
|
|
61
76
|
expect(screen.queryByText('View more info')).not.toBeInTheDocument();
|
|
62
77
|
});
|
|
63
78
|
|
|
64
79
|
it('calls openModal when info button is clicked', () => {
|
|
65
|
-
|
|
66
|
-
<TableCell modalContent="Additional information" openModal={openModal} />
|
|
67
|
-
);
|
|
80
|
+
setup({ modalContent: 'Additional information', openModal });
|
|
68
81
|
|
|
69
82
|
// Click info button
|
|
70
|
-
screen.
|
|
83
|
+
screen.getByTestId('ds-table-info-button').click();
|
|
71
84
|
|
|
72
85
|
// Assert openModal is called with info prop
|
|
73
86
|
expect(openModal).toHaveBeenCalledWith('Additional information');
|
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Button } from '../../../button';
|
|
3
|
-
import {
|
|
4
|
-
CheckIcon,
|
|
5
|
-
InfoIcon,
|
|
6
|
-
StarFilledIcon,
|
|
7
|
-
XIcon,
|
|
8
|
-
ZapFilledIcon,
|
|
9
|
-
} from '../../../icon';
|
|
10
1
|
import classNames from 'classnames';
|
|
11
2
|
|
|
12
3
|
import styles from './TableCell.module.scss';
|
|
4
|
+
import { BaseCell, BaseCellProps } from './BaseCell/BaseCell';
|
|
5
|
+
import { TableCellData } from '../../types';
|
|
6
|
+
import { CTACell } from './CTACell/CTACell';
|
|
7
|
+
import { ButtonCell } from './ButtonCell/ButtonCell';
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
align?: 'center' | 'left' | 'right';
|
|
16
|
-
checkmarkValue?: boolean;
|
|
17
|
-
content?: ReactNode;
|
|
18
|
-
modalContent?: ReactNode;
|
|
19
|
-
openModal?: (modalContent: ReactNode) => void;
|
|
20
|
-
subContent?: ReactNode;
|
|
21
|
-
rating?: {
|
|
22
|
-
value: number;
|
|
23
|
-
type: 'zap' | 'star';
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface PositionalTableCellProps {
|
|
9
|
+
type PositionalTableCellProps = {
|
|
28
10
|
isHeader?: boolean;
|
|
29
11
|
isFirstCellInRow?: boolean;
|
|
30
12
|
isTopLeftCell?: boolean;
|
|
31
13
|
isNavigation?: boolean;
|
|
32
|
-
}
|
|
14
|
+
};
|
|
33
15
|
|
|
34
|
-
export type TableCellProps =
|
|
16
|
+
export type TableCellProps = TableCellData & PositionalTableCellProps;
|
|
35
17
|
|
|
36
18
|
const TableCell = ({
|
|
37
|
-
align = 'center',
|
|
38
|
-
checkmarkValue,
|
|
39
|
-
content = '',
|
|
40
19
|
isFirstCellInRow = false,
|
|
41
20
|
isHeader = false,
|
|
42
21
|
isNavigation = false,
|
|
43
22
|
isTopLeftCell = false,
|
|
44
|
-
|
|
45
|
-
openModal,
|
|
46
|
-
rating,
|
|
47
|
-
subContent = '',
|
|
23
|
+
...cellProps
|
|
48
24
|
}: TableCellProps) => {
|
|
49
25
|
// prettier-ignore
|
|
50
26
|
const Tag = isNavigation
|
|
@@ -60,15 +36,6 @@ const TableCell = ({
|
|
|
60
36
|
scope: thScope,
|
|
61
37
|
};
|
|
62
38
|
|
|
63
|
-
const alignClassName = {
|
|
64
|
-
center: 'ta-center jc-center',
|
|
65
|
-
left: 'ta-left jc-start',
|
|
66
|
-
right: 'ta-right',
|
|
67
|
-
}[align];
|
|
68
|
-
|
|
69
|
-
const validRatingValues: number[] = [1, 2, 3];
|
|
70
|
-
const SelectedIcon = rating?.type === 'zap' ? ZapFilledIcon : StarFilledIcon;
|
|
71
|
-
|
|
72
39
|
return (
|
|
73
40
|
<Tag
|
|
74
41
|
{...scope}
|
|
@@ -78,87 +45,18 @@ const TableCell = ({
|
|
|
78
45
|
pl32: isFirstCellInRow,
|
|
79
46
|
})}
|
|
80
47
|
>
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
className={styles.icon}
|
|
94
|
-
/>
|
|
95
|
-
))}
|
|
96
|
-
</span>
|
|
97
|
-
)}
|
|
98
|
-
|
|
99
|
-
{checkmarkValue !== undefined && (
|
|
100
|
-
<span title={checkmarkValue ? 'Yes' : 'No'}>
|
|
101
|
-
{checkmarkValue ? (
|
|
102
|
-
<CheckIcon
|
|
103
|
-
data-testid="table-cell-boolean-yes"
|
|
104
|
-
size={24}
|
|
105
|
-
aria-hidden
|
|
106
|
-
color="primary-500"
|
|
107
|
-
/>
|
|
108
|
-
) : (
|
|
109
|
-
<XIcon
|
|
110
|
-
data-testid="table-cell-boolean-no"
|
|
111
|
-
size={24}
|
|
112
|
-
aria-hidden
|
|
113
|
-
color="grey-400"
|
|
114
|
-
/>
|
|
115
|
-
)}
|
|
116
|
-
</span>
|
|
117
|
-
)}
|
|
118
|
-
|
|
119
|
-
{content && !isTopLeftCell && (
|
|
120
|
-
<div className="p-p" data-testid="table-cell-content">
|
|
121
|
-
{content}
|
|
122
|
-
</div>
|
|
123
|
-
)}
|
|
124
|
-
|
|
125
|
-
{content && isTopLeftCell && (
|
|
126
|
-
<div
|
|
127
|
-
aria-hidden
|
|
128
|
-
className={classNames(
|
|
129
|
-
'tc-grey-800 p-h2 p--serif',
|
|
130
|
-
styles.topLeftCell
|
|
131
|
-
)}
|
|
132
|
-
>
|
|
133
|
-
{content}
|
|
134
|
-
</div>
|
|
135
|
-
)}
|
|
136
|
-
|
|
137
|
-
{modalContent && openModal && (
|
|
138
|
-
<Button
|
|
139
|
-
className={styles.button}
|
|
140
|
-
hideLabel
|
|
141
|
-
leftIcon={<InfoIcon size={20} />}
|
|
142
|
-
onClick={() => openModal(modalContent)}
|
|
143
|
-
type="button"
|
|
144
|
-
variant="textColor"
|
|
145
|
-
>
|
|
146
|
-
View more info
|
|
147
|
-
</Button>
|
|
148
|
-
)}
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
{subContent && (
|
|
152
|
-
<div
|
|
153
|
-
className={classNames(
|
|
154
|
-
'd-flex p-p--small tc-grey-500',
|
|
155
|
-
alignClassName
|
|
156
|
-
)}
|
|
157
|
-
>
|
|
158
|
-
{subContent}
|
|
159
|
-
</div>
|
|
160
|
-
)}
|
|
161
|
-
</div>
|
|
48
|
+
{!cellProps.type && (
|
|
49
|
+
<BaseCell
|
|
50
|
+
{...cellProps}
|
|
51
|
+
fontVariant={
|
|
52
|
+
isTopLeftCell
|
|
53
|
+
? 'BIG_WITH_UNDERLINE'
|
|
54
|
+
: cellProps.fontVariant ?? 'NORMAL'
|
|
55
|
+
}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
{cellProps.type === 'CTA' && <CTACell {...cellProps} />}
|
|
59
|
+
{cellProps.type === 'BUTTON' && <ButtonCell {...cellProps} />}
|
|
162
60
|
</Tag>
|
|
163
61
|
);
|
|
164
62
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { render, screen } from '../../../../util/testUtils';
|
|
2
|
-
import { TableContents,
|
|
2
|
+
import { TableContents, TableContentsProps } from './TableContents';
|
|
3
3
|
|
|
4
|
-
const mockData:
|
|
4
|
+
const mockData: TableContentsProps['tableData'] = [
|
|
5
5
|
{
|
|
6
6
|
rows: [
|
|
7
|
-
[{
|
|
8
|
-
[{
|
|
7
|
+
[{ text: 'Item 1.1.1' }, { text: 'Item 1.1.2' }],
|
|
8
|
+
[{ text: 'Item 1.2.1' }, { text: 'Item 1.2.2' }],
|
|
9
9
|
],
|
|
10
10
|
},
|
|
11
11
|
{
|
|
@@ -13,8 +13,8 @@ const mockData: TableSectionProps['tableData'] = [
|
|
|
13
13
|
title: 'Section 2',
|
|
14
14
|
},
|
|
15
15
|
rows: [
|
|
16
|
-
[{
|
|
17
|
-
[{
|
|
16
|
+
[{ text: 'Item 2.1.1' }, { text: 'Item 2.1.2' }],
|
|
17
|
+
[{ text: 'Item 2.2.1' }, { text: 'Item 2.2.2' }],
|
|
18
18
|
],
|
|
19
19
|
},
|
|
20
20
|
];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { render, screen } from '../../../../util/testUtils';
|
|
2
|
-
import { TableSection,
|
|
2
|
+
import { TableSection, TableSectionProps } from './TableSection';
|
|
3
3
|
|
|
4
|
-
const tableCellRows:
|
|
5
|
-
[{
|
|
6
|
-
[{
|
|
4
|
+
const tableCellRows: TableSectionProps['tableCellRows'] = [
|
|
5
|
+
[{ text: 'Cell 1.1' }, { text: 'Cell 1.2' }, { text: 'Cell 1.3' }],
|
|
6
|
+
[{ text: 'Cell 2.1' }, { text: 'Cell 2.2' }, { text: 'Cell 2.3' }],
|
|
7
7
|
];
|
|
8
8
|
|
|
9
9
|
const mockTitle = 'Test Table';
|
|
10
10
|
|
|
11
11
|
const mockOpenModal = jest.fn();
|
|
12
12
|
|
|
13
|
-
const defaultProps:
|
|
13
|
+
const defaultProps: TableSectionProps = {
|
|
14
14
|
tableCellRows,
|
|
15
15
|
title: mockTitle,
|
|
16
16
|
openModal: mockOpenModal,
|