@popsure/dirty-swan 0.66.22 → 0.66.24
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 +32 -23
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/Table.stories.d.ts +4 -0
- package/dist/cjs/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +1 -1
- package/dist/esm/components/segmentedControl/index.js +4 -5
- package/dist/esm/components/segmentedControl/index.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +134 -1
- package/dist/esm/components/table/Table.stories.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js +1 -1
- package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.js +4 -5
- package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.test.js +14 -0
- package/dist/esm/components/table/components/TableCell/TableCell.test.js.map +1 -1
- package/dist/esm/components/table/components/TableContents/Collapsible.js +23 -12
- package/dist/esm/components/table/components/TableContents/Collapsible.js.map +1 -1
- package/dist/esm/lib/components/table/Table.stories.d.ts +4 -0
- package/dist/esm/lib/components/table/components/TableCell/BaseCell/BaseCell.d.ts +1 -1
- package/package.json +1 -1
- package/src/lib/components/segmentedControl/index.tsx +5 -11
- package/src/lib/components/segmentedControl/style.module.scss +7 -3
- package/src/lib/components/table/Table.stories.tsx +158 -0
- package/src/lib/components/table/components/TableCell/BaseCell/BaseCell.tsx +10 -1
- package/src/lib/components/table/components/TableCell/TableCell.module.scss +4 -0
- package/src/lib/components/table/components/TableCell/TableCell.test.tsx +18 -0
- package/src/lib/components/table/components/TableCell/TableCell.tsx +3 -3
- package/src/lib/components/table/components/TableContents/Collapsible.tsx +23 -11
|
@@ -27,8 +27,8 @@ import '../../../icon/icons/ChevronRight.js';
|
|
|
27
27
|
import '../../../icon/icons/CircleSelected.js';
|
|
28
28
|
import '../../../icon/icons/CircleUnselected.js';
|
|
29
29
|
|
|
30
|
-
var css_248z = ".TableCell-module_th__2rjCU {\n vertical-align: middle;\n scroll-snap-align: end;\n width: 50%;\n padding: 28px 24px;\n}\n@media (min-width: 34rem) {\n .TableCell-module_th__2rjCU {\n width: auto;\n scroll-snap-align: unset;\n }\n}\n.TableCell-module_thNavigation__qZ2sY {\n width: 100%;\n}\n@media (min-width: 34rem) {\n .TableCell-module_thNavigation__qZ2sY {\n width: auto;\n }\n}\n\n.TableCell-module_navigationTitle__2FiRB {\n padding-left: 0;\n}\n\n.TableCell-module_headerCell__aVTIn {\n vertical-align: top;\n}\n\n.TableCell-module_fixedCell__cL3-m {\n position: sticky;\n left: 0;\n z-index: 2;\n padding-left: 0;\n}\n\n.TableCell-module_selectedColumnTop__1GcJz {\n border-radius: 16px 16px 0 0;\n}\n\n.TableCell-module_selectedColumnBottom__qiMke {\n border-radius: 0 0 16px 16px;\n}\n\n.TableCell-module_fixedCard__2LO8s {\n position: sticky;\n left: 0;\n right: 0;\n z-index: 2;\n width: 100%;\n}";
|
|
31
|
-
var styles = {"th":"TableCell-module_th__2rjCU","thNavigation":"TableCell-module_thNavigation__qZ2sY","navigationTitle":"TableCell-module_navigationTitle__2FiRB","headerCell":"TableCell-module_headerCell__aVTIn","fixedCell":"TableCell-module_fixedCell__cL3-m","selectedColumnTop":"TableCell-module_selectedColumnTop__1GcJz","selectedColumnBottom":"TableCell-module_selectedColumnBottom__qiMke","fixedCard":"TableCell-module_fixedCard__2LO8s"};
|
|
30
|
+
var css_248z = ".TableCell-module_th__2rjCU {\n vertical-align: middle;\n scroll-snap-align: end;\n width: 50%;\n padding: 28px 24px;\n}\n@media (min-width: 34rem) {\n .TableCell-module_th__2rjCU {\n width: auto;\n scroll-snap-align: unset;\n }\n}\n.TableCell-module_thNavigation__qZ2sY {\n width: 100%;\n}\n@media (min-width: 34rem) {\n .TableCell-module_thNavigation__qZ2sY {\n width: auto;\n }\n}\n\n.TableCell-module_navigationTitle__2FiRB {\n padding-left: 0;\n}\n\n.TableCell-module_headerCell__aVTIn {\n vertical-align: top;\n}\n\n.TableCell-module_subtitleCell__1DzfG {\n vertical-align: middle;\n}\n\n.TableCell-module_fixedCell__cL3-m {\n position: sticky;\n left: 0;\n z-index: 2;\n padding-left: 0;\n}\n\n.TableCell-module_selectedColumnTop__1GcJz {\n border-radius: 16px 16px 0 0;\n}\n\n.TableCell-module_selectedColumnBottom__qiMke {\n border-radius: 0 0 16px 16px;\n}\n\n.TableCell-module_fixedCard__2LO8s {\n position: sticky;\n left: 0;\n right: 0;\n z-index: 2;\n width: 100%;\n}";
|
|
31
|
+
var styles = {"th":"TableCell-module_th__2rjCU","thNavigation":"TableCell-module_thNavigation__qZ2sY","navigationTitle":"TableCell-module_navigationTitle__2FiRB","headerCell":"TableCell-module_headerCell__aVTIn","subtitleCell":"TableCell-module_subtitleCell__1DzfG","fixedCell":"TableCell-module_fixedCell__cL3-m","selectedColumnTop":"TableCell-module_selectedColumnTop__1GcJz","selectedColumnBottom":"TableCell-module_selectedColumnBottom__qiMke","fixedCard":"TableCell-module_fixedCard__2LO8s"};
|
|
32
32
|
styleInject(css_248z);
|
|
33
33
|
|
|
34
34
|
var TableCell = React__default.memo(function (_a) {
|
|
@@ -50,15 +50,14 @@ var TableCell = React__default.memo(function (_a) {
|
|
|
50
50
|
'ta-left': isFirstCellInRow
|
|
51
51
|
},
|
|
52
52
|
_b[styles.headerCell] = isHeader,
|
|
53
|
+
_b[styles.subtitleCell] = !cellProps.type && cellProps.fontVariant === 'SUBTITLE',
|
|
53
54
|
_b[styles.thNavigation] = isNavigation,
|
|
54
55
|
_b[styles.navigationTitle] = isNavigation && isTopLeftCell,
|
|
55
56
|
_b[styles.fixedCell] = isFirstCellInRow && colSpan < 1,
|
|
56
57
|
_b[styles.fixedCard] = cellProps.type === 'CARD',
|
|
57
58
|
_b[styles.selectedColumnTop] = selectedColumnPosition === 'top',
|
|
58
59
|
_b[styles.selectedColumnBottom] = selectedColumnPosition === 'bottom',
|
|
59
|
-
_b)), colSpan: isBelowDesktop && cellProps.type === 'CARD' ? 2 : colSpan, children: [!cellProps.type && (jsx(BaseCell, __assign({}, cellProps, { fontVariant: isTopLeftCell
|
|
60
|
-
? 'TITLE'
|
|
61
|
-
: (_c = cellProps.fontVariant) !== null && _c !== void 0 ? _c : 'NORMAL' }))), cellProps.type === 'CTA' && (jsx(CTACell, __assign({}, cellProps, { centered: isNavigation }))), cellProps.type === 'BUTTON' && jsx(ButtonCell, __assign({}, cellProps)), cellProps.type === 'CARD' && jsx(CardCell, __assign({}, cellProps))] })));
|
|
60
|
+
_b)), colSpan: isBelowDesktop && cellProps.type === 'CARD' ? 2 : colSpan, children: [!cellProps.type && (jsx(BaseCell, __assign({}, cellProps, { fontVariant: (_c = cellProps.fontVariant) !== null && _c !== void 0 ? _c : (isTopLeftCell ? 'TITLE' : 'NORMAL') }))), cellProps.type === 'CTA' && (jsx(CTACell, __assign({}, cellProps, { centered: isNavigation }))), cellProps.type === 'BUTTON' && jsx(ButtonCell, __assign({}, cellProps)), cellProps.type === 'CARD' && jsx(CardCell, __assign({}, cellProps))] })));
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
export { TableCell };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.js","sources":["../../../../../../../src/lib/components/table/components/TableCell/TableCell.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './TableCell.module.scss';\nimport { BaseCell } from './BaseCell/BaseCell';\nimport { TableCellData } from '../../types';\nimport { CTACell } from './CTACell/CTACell';\nimport { CardCell } from './CardCell/CardCell';\nimport { ButtonCell } from './ButtonCell/ButtonCell';\nimport React from 'react';\n\ntype ExtraTableCellProps = {\n isHeader?: boolean;\n isFirstCellInRow?: boolean;\n isTopLeftCell?: boolean;\n isNavigation?: boolean;\n isSelectedColumn?: boolean;\n selectedColumnPosition?: 'top' | 'bottom' | 'middle';\n imageComponent?: (args: any) => JSX.Element;\n isBelowDesktop?: boolean;\n};\n\nexport type TableCellProps = TableCellData & ExtraTableCellProps;\n\nconst TableCell = React.memo(\n ({\n isFirstCellInRow = false,\n isHeader = false,\n isNavigation = false,\n isSelectedColumn = false,\n selectedColumnPosition,\n isTopLeftCell = false,\n colSpan = 0,\n isBelowDesktop,\n ...cellProps\n }: TableCellProps) => {\n // prettier-ignore\n const Tag = isNavigation\n ? 'div'\n : isHeader || isFirstCellInRow ? 'th' : 'td';\n\n // prettier-ignore\n const thScope = isHeader\n ? 'col'\n : isFirstCellInRow ? 'row' : undefined;\n\n const scope = {\n scope: thScope,\n };\n\n return (\n <Tag\n {...scope}\n className={classNames(isSelectedColumn ? 'bg-orange-50' : 'bg-white', styles.th, {\n 'ta-left': isFirstCellInRow,\n [styles.headerCell]: isHeader,\n [styles.thNavigation]: isNavigation,\n [styles.navigationTitle]: isNavigation && isTopLeftCell,\n [styles.fixedCell]: isFirstCellInRow && colSpan < 1 ,\n [styles.fixedCard]: cellProps.type === 'CARD',\n [styles.selectedColumnTop]: selectedColumnPosition === 'top',\n [styles.selectedColumnBottom]: selectedColumnPosition === 'bottom',\n })}\n colSpan={isBelowDesktop && cellProps.type === 'CARD' ? 2 : colSpan}\n >\n {!cellProps.type && (\n <BaseCell\n {...cellProps}\n fontVariant={\n isTopLeftCell
|
|
1
|
+
{"version":3,"file":"TableCell.js","sources":["../../../../../../../src/lib/components/table/components/TableCell/TableCell.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport styles from './TableCell.module.scss';\nimport { BaseCell } from './BaseCell/BaseCell';\nimport { TableCellData } from '../../types';\nimport { CTACell } from './CTACell/CTACell';\nimport { CardCell } from './CardCell/CardCell';\nimport { ButtonCell } from './ButtonCell/ButtonCell';\nimport React from 'react';\n\ntype ExtraTableCellProps = {\n isHeader?: boolean;\n isFirstCellInRow?: boolean;\n isTopLeftCell?: boolean;\n isNavigation?: boolean;\n isSelectedColumn?: boolean;\n selectedColumnPosition?: 'top' | 'bottom' | 'middle';\n imageComponent?: (args: any) => JSX.Element;\n isBelowDesktop?: boolean;\n};\n\nexport type TableCellProps = TableCellData & ExtraTableCellProps;\n\nconst TableCell = React.memo(\n ({\n isFirstCellInRow = false,\n isHeader = false,\n isNavigation = false,\n isSelectedColumn = false,\n selectedColumnPosition,\n isTopLeftCell = false,\n colSpan = 0,\n isBelowDesktop,\n ...cellProps\n }: TableCellProps) => {\n // prettier-ignore\n const Tag = isNavigation\n ? 'div'\n : isHeader || isFirstCellInRow ? 'th' : 'td';\n\n // prettier-ignore\n const thScope = isHeader\n ? 'col'\n : isFirstCellInRow ? 'row' : undefined;\n\n const scope = {\n scope: thScope,\n };\n\n return (\n <Tag\n {...scope}\n className={classNames(isSelectedColumn ? 'bg-orange-50' : 'bg-white', styles.th, {\n 'ta-left': isFirstCellInRow,\n [styles.headerCell]: isHeader,\n [styles.subtitleCell]:\n !cellProps.type && cellProps.fontVariant === 'SUBTITLE',\n [styles.thNavigation]: isNavigation,\n [styles.navigationTitle]: isNavigation && isTopLeftCell,\n [styles.fixedCell]: isFirstCellInRow && colSpan < 1 ,\n [styles.fixedCard]: cellProps.type === 'CARD',\n [styles.selectedColumnTop]: selectedColumnPosition === 'top',\n [styles.selectedColumnBottom]: selectedColumnPosition === 'bottom',\n })}\n colSpan={isBelowDesktop && cellProps.type === 'CARD' ? 2 : colSpan}\n >\n {!cellProps.type && (\n <BaseCell\n {...cellProps}\n fontVariant={\n cellProps.fontVariant ?? (isTopLeftCell ? 'TITLE' : 'NORMAL')\n }\n />\n )}\n {cellProps.type === 'CTA' && (\n <CTACell {...cellProps} centered={isNavigation} />\n )}\n {cellProps.type === 'BUTTON' && <ButtonCell {...cellProps} />}\n {cellProps.type === 'CARD' && <CardCell {...cellProps} />}\n </Tag>\n );\n }\n);\n\nexport { TableCell };\n"],"names":["React","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,SAAS,G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AAA,CAAC,UAAU,eAAK,SAAS,CAAA,CAAI,EAC5D,SAAS,CAAC,IAAI,KAAK,MAAM,IAAIA,GAAA,CAAC,QAAQ,eAAK,SAAS,CAAA,CAAI,CAAA,EAAA,CAAA,CACrD;AAEV,CAAC;;;;"}
|
|
@@ -86,5 +86,19 @@ describe('TableCell', function () {
|
|
|
86
86
|
title: '',
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
|
+
it('renders the top left cell as a title by default', function () {
|
|
90
|
+
setup({ isTopLeftCell: true, text: 'Choose a plan' });
|
|
91
|
+
expect(screen.getByText('Choose a plan')).toHaveClass('p-h2');
|
|
92
|
+
});
|
|
93
|
+
it('lets fontVariant override the top left cell title', function () {
|
|
94
|
+
setup({
|
|
95
|
+
isTopLeftCell: true,
|
|
96
|
+
fontVariant: 'SUBTITLE',
|
|
97
|
+
text: 'Choose a plan',
|
|
98
|
+
});
|
|
99
|
+
var cellText = screen.getByText('Choose a plan');
|
|
100
|
+
expect(cellText).toHaveClass('p-h4');
|
|
101
|
+
expect(cellText).not.toHaveClass('p-h2');
|
|
102
|
+
});
|
|
89
103
|
});
|
|
90
104
|
//# sourceMappingURL=TableCell.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.test.js","sources":["../../../../../../../src/lib/components/table/components/TableCell/TableCell.test.tsx"],"sourcesContent":["import { render, screen } from '../../../../util/testUtils';\nimport { TableCell, TableCellProps } from './TableCell';\n\nconst openModal = jest.fn();\n\nconst setup = ({ isNavigation, ...rest }: TableCellProps = {}) =>\n render(\n isNavigation ? (\n <TableCell {...rest} isNavigation />\n ) : (\n <table>\n <tbody>\n <tr>\n <TableCell {...rest} />\n </tr>\n </tbody>\n </table>\n )\n );\n\ndescribe('TableCell', () => {\n it('renders the component with boolean true', () => {\n setup({ checkmarkValue: true });\n\n expect(screen.getByTitle('Yes')).toBeInTheDocument();\n expect(screen.getByTestId('table-cell-boolean-yes')).toBeInTheDocument();\n });\n\n it('renders the component with boolean false', () => {\n setup({ checkmarkValue: false });\n\n expect(screen.getByTitle('No')).toBeInTheDocument();\n expect(screen.getByTestId('table-cell-boolean-no')).toBeInTheDocument();\n });\n\n it('renders the component without boolean', () => {\n setup();\n\n expect(screen.queryByTitle('Yes')).not.toBeInTheDocument();\n expect(screen.queryByTitle('No')).not.toBeInTheDocument();\n expect(\n screen.queryByTestId('table-cell-boolean-yes')\n ).not.toBeInTheDocument();\n expect(\n screen.queryByTestId('table-cell-boolean-no')\n ).not.toBeInTheDocument();\n });\n\n it('renders the component with rating', () => {\n setup({ rating: { type: 'star', value: 2 } });\n\n expect(screen.getByTitle('2 out of 3')).toBeInTheDocument();\n });\n\n it('renders the component without rating', () => {\n setup();\n\n expect(screen.queryByTestId('table-cell-rating')).not.toBeInTheDocument();\n });\n\n it('renders the component with text', () => {\n setup({ text: 'Sample text' });\n\n expect(screen.getByText('Sample text')).toBeInTheDocument();\n });\n\n it('renders the component without text', () => {\n setup();\n\n expect(screen.queryByTestId('table-cell-text')).not.toBeInTheDocument();\n });\n\n it('renders the component without info', () => {\n setup();\n\n expect(screen.queryByText('View more info')).not.toBeInTheDocument();\n });\n\n it('calls openModal when info button is clicked', () => {\n setup({ modalContent: 'Additional information', openModal });\n\n // Click info button\n screen.getByTestId('ds-table-info-button').click();\n\n // Assert openModal is called with info prop\n expect(openModal).toHaveBeenCalledWith({\n body: 'Additional information',\n title: '',\n });\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE;AAE3B,IAAM,KAAK,GAAG,UAAC,EAA8C,EAAA;AAA9C,IAAA,IAAA,EAAA,KAAA,MAAA,EAAA,EAAA,EAAA,GAAA,EAA8C,CAAA,CAAA;AAA5C,IAAA,IAAA,YAAY,GAAA,EAAA,CAAA,YAAA,EAAK,IAAI,GAAA,MAAA,CAAA,EAAA,EAAvB,gBAAyB,CAAF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AiB,EAAE;AACtE,IAAA,CAAC,CAAC;IAEF,EAAE,CAAC,6CAA6C,EAAE,YAAA;QAChD,KAAK,CAAC,EAAE,YAAY,EAAE,wBAAwB,EAAE,SAAS,EAAA,SAAA,EAAE,CAAC;;QAG5D,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC,KAAK,EAAE;;AAGlD,QAAA,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC;AACrC,YAAA,IAAI,EAAE,wBAAwB;AAC9B,YAAA,KAAK,EAAE,EAAE;AACV,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"TableCell.test.js","sources":["../../../../../../../src/lib/components/table/components/TableCell/TableCell.test.tsx"],"sourcesContent":["import { render, screen } from '../../../../util/testUtils';\nimport { TableCell, TableCellProps } from './TableCell';\n\nconst openModal = jest.fn();\n\nconst setup = ({ isNavigation, ...rest }: TableCellProps = {}) =>\n render(\n isNavigation ? (\n <TableCell {...rest} isNavigation />\n ) : (\n <table>\n <tbody>\n <tr>\n <TableCell {...rest} />\n </tr>\n </tbody>\n </table>\n )\n );\n\ndescribe('TableCell', () => {\n it('renders the component with boolean true', () => {\n setup({ checkmarkValue: true });\n\n expect(screen.getByTitle('Yes')).toBeInTheDocument();\n expect(screen.getByTestId('table-cell-boolean-yes')).toBeInTheDocument();\n });\n\n it('renders the component with boolean false', () => {\n setup({ checkmarkValue: false });\n\n expect(screen.getByTitle('No')).toBeInTheDocument();\n expect(screen.getByTestId('table-cell-boolean-no')).toBeInTheDocument();\n });\n\n it('renders the component without boolean', () => {\n setup();\n\n expect(screen.queryByTitle('Yes')).not.toBeInTheDocument();\n expect(screen.queryByTitle('No')).not.toBeInTheDocument();\n expect(\n screen.queryByTestId('table-cell-boolean-yes')\n ).not.toBeInTheDocument();\n expect(\n screen.queryByTestId('table-cell-boolean-no')\n ).not.toBeInTheDocument();\n });\n\n it('renders the component with rating', () => {\n setup({ rating: { type: 'star', value: 2 } });\n\n expect(screen.getByTitle('2 out of 3')).toBeInTheDocument();\n });\n\n it('renders the component without rating', () => {\n setup();\n\n expect(screen.queryByTestId('table-cell-rating')).not.toBeInTheDocument();\n });\n\n it('renders the component with text', () => {\n setup({ text: 'Sample text' });\n\n expect(screen.getByText('Sample text')).toBeInTheDocument();\n });\n\n it('renders the component without text', () => {\n setup();\n\n expect(screen.queryByTestId('table-cell-text')).not.toBeInTheDocument();\n });\n\n it('renders the component without info', () => {\n setup();\n\n expect(screen.queryByText('View more info')).not.toBeInTheDocument();\n });\n\n it('calls openModal when info button is clicked', () => {\n setup({ modalContent: 'Additional information', openModal });\n\n // Click info button\n screen.getByTestId('ds-table-info-button').click();\n\n // Assert openModal is called with info prop\n expect(openModal).toHaveBeenCalledWith({\n body: 'Additional information',\n title: '',\n });\n });\n\n it('renders the top left cell as a title by default', () => {\n setup({ isTopLeftCell: true, text: 'Choose a plan' });\n\n expect(screen.getByText('Choose a plan')).toHaveClass('p-h2');\n });\n\n it('lets fontVariant override the top left cell title', () => {\n setup({\n isTopLeftCell: true,\n fontVariant: 'SUBTITLE',\n text: 'Choose a plan',\n });\n\n const cellText = screen.getByText('Choose a plan');\n expect(cellText).toHaveClass('p-h4');\n expect(cellText).not.toHaveClass('p-h2');\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE;AAE3B,IAAM,KAAK,GAAG,UAAC,EAA8C,EAAA;AAA9C,IAAA,IAAA,EAAA,KAAA,MAAA,EAAA,EAAA,EAAA,GAAA,EAA8C,CAAA,CAAA;AAA5C,IAAA,IAAA,YAAY,GAAA,EAAA,CAAA,YAAA,EAAK,IAAI,GAAA,MAAA,CAAA,EAAA,EAAvB,gBAAyB,CAAF;AACpC,IAAA,OAAAA,YAAM,CACJ,YAAY,IACVC,GAAA,CAAC,SAAS,EAAA,QAAA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QAChD,KAAK,CAAC,EAAE,YAAY,EAAE,wBAAwB,EAAE,SAAS,EAAA,SAAA,EAAE,CAAC;;QAG5D,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC,KAAK,EAAE;;AAGlD,QAAA,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC;AACrC,YAAA,IAAI,EAAE,wBAAwB;AAC9B,YAAA,KAAK,EAAE,EAAE;AACV,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;IAEF,EAAE,CAAC,iDAAiD,EAAE,YAAA;QACpD,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;AAErD,QAAA,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;AAC/D,IAAA,CAAC,CAAC;IAEF,EAAE,CAAC,mDAAmD,EAAE,YAAA;AACtD,QAAA,KAAK,CAAC;AACJ,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,WAAW,EAAE,UAAU;AACvB,YAAA,IAAI,EAAE,eAAe;AACtB,SAAA,CAAC;QAEF,IAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;QAClD,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;QACpC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC;AAC1C,IAAA,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -8,6 +8,18 @@ var css_248z = ".Collapsible-module_collapsible__2wWKs {\n display: flow-root;\
|
|
|
8
8
|
var styles = {"collapsible":"Collapsible-module_collapsible__2wWKs"};
|
|
9
9
|
styleInject(css_248z);
|
|
10
10
|
|
|
11
|
+
var measureHeight = function (element) {
|
|
12
|
+
var height = 0;
|
|
13
|
+
for (var _i = 0, _a = Array.from(element.children); _i < _a.length; _i++) {
|
|
14
|
+
var child = _a[_i];
|
|
15
|
+
var childStyles = getComputedStyle(child);
|
|
16
|
+
height +=
|
|
17
|
+
child.getBoundingClientRect().height +
|
|
18
|
+
(parseFloat(childStyles.marginTop) || 0) +
|
|
19
|
+
(parseFloat(childStyles.marginBottom) || 0);
|
|
20
|
+
}
|
|
21
|
+
return Math.ceil(height);
|
|
22
|
+
};
|
|
11
23
|
var Collapsible = function (_a) {
|
|
12
24
|
var _b;
|
|
13
25
|
var children = _a.children, isExpanded = _a.isExpanded, onTransitionEnd = _a.onTransitionEnd;
|
|
@@ -16,24 +28,23 @@ var Collapsible = function (_a) {
|
|
|
16
28
|
var containerRef = useRef(null);
|
|
17
29
|
useEffect(function () {
|
|
18
30
|
if (!observerRef.current) {
|
|
19
|
-
observerRef.current = new ResizeObserver(function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
31
|
+
observerRef.current = new ResizeObserver(function () {
|
|
32
|
+
if (containerRef.current) {
|
|
33
|
+
setHeight(measureHeight(containerRef.current));
|
|
34
|
+
}
|
|
24
35
|
});
|
|
25
36
|
}
|
|
26
37
|
if (containerRef.current) {
|
|
27
38
|
observerRef.current.observe(containerRef.current);
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
Array.from(containerRef.current.children).forEach(function (child) {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.observe(child);
|
|
42
|
+
});
|
|
43
|
+
setHeight(measureHeight(containerRef.current));
|
|
30
44
|
}
|
|
31
45
|
return function () {
|
|
32
|
-
var _a
|
|
33
|
-
|
|
34
|
-
(_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.unobserve(containerRef.current);
|
|
35
|
-
}
|
|
36
|
-
(_b = observerRef.current) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = observerRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
37
48
|
};
|
|
38
49
|
}, [containerRef.current]);
|
|
39
50
|
return (jsx("div", { className: classNames(styles.collapsible, (_b = {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collapsible.js","sources":["../../../../../../../src/lib/components/table/components/TableContents/Collapsible.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport styles from './Collapsible.module.scss';\nimport classNames from 'classnames';\ninterface CollapsibleProps {\n children: ReactNode;\n isExpanded?: boolean;\n onTransitionEnd?: () => void;\n}\n\nexport const Collapsible = ({ children, isExpanded, onTransitionEnd }: CollapsibleProps) => {\n const [height, setHeight] = useState<number | undefined>();\n\n const observerRef = useRef<ResizeObserver | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!observerRef.current) {\n observerRef.current = new ResizeObserver((
|
|
1
|
+
{"version":3,"file":"Collapsible.js","sources":["../../../../../../../src/lib/components/table/components/TableContents/Collapsible.tsx"],"sourcesContent":["import { ReactNode, useEffect, useRef, useState } from 'react';\nimport styles from './Collapsible.module.scss';\nimport classNames from 'classnames';\ninterface CollapsibleProps {\n children: ReactNode;\n isExpanded?: boolean;\n onTransitionEnd?: () => void;\n}\n\nconst measureHeight = (element: Element) => {\n let height = 0;\n\n for (const child of Array.from(element.children)) {\n const childStyles = getComputedStyle(child);\n\n height +=\n child.getBoundingClientRect().height +\n (parseFloat(childStyles.marginTop) || 0) +\n (parseFloat(childStyles.marginBottom) || 0);\n }\n\n return Math.ceil(height);\n};\n\nexport const Collapsible = ({ children, isExpanded, onTransitionEnd }: CollapsibleProps) => {\n const [height, setHeight] = useState<number | undefined>();\n\n const observerRef = useRef<ResizeObserver | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!observerRef.current) {\n observerRef.current = new ResizeObserver(() => {\n if (containerRef.current) {\n setHeight(measureHeight(containerRef.current));\n }\n });\n }\n if (containerRef.current) {\n observerRef.current.observe(containerRef.current);\n Array.from(containerRef.current.children).forEach((child) => {\n observerRef.current?.observe(child);\n });\n setHeight(measureHeight(containerRef.current));\n }\n\n return () => {\n observerRef.current?.disconnect();\n };\n }, [containerRef.current]);\n\n return (\n <div\n className={classNames(styles.collapsible, {\n [styles.hideDelayed]: !isExpanded,\n })}\n ref={containerRef}\n style={{\n maxHeight: isExpanded ? height : '0px',\n }}\n onTransitionEnd={isExpanded ? onTransitionEnd : undefined}\n >\n {children}\n </div>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AASA,IAAM,aAAa,GAAG,UAAC,OAAgB,EAAA;IACrC,IAAI,MAAM,GAAG,CAAC;AAEd,IAAA,KAAoB,UAA4B,EAA5B,EAAA,GAAA,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAA5B,EAAA,GAAA,EAAA,CAAA,MAA4B,EAA5B,EAAA,EAA4B,EAAE;AAA7C,QAAA,IAAM,KAAK,GAAA,EAAA,CAAA,EAAA,CAAA;AACd,QAAA,IAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC;QAE3C,MAAM;AACJ,YAAA,KAAK,CAAC,qBAAqB,EAAE,CAAC,MAAM;iBACnC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;iBACvC,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/C;AAEA,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;AAC1B,CAAC;AAEM,IAAM,WAAW,GAAG,UAAC,EAA2D,EAAA;;AAAzD,IAAA,IAAA,QAAQ,cAAA,EAAE,UAAU,GAAA,EAAA,CAAA,UAAA,EAAE,eAAe,GAAA,EAAA,CAAA,eAAA;IAC3D,IAAA,EAAA,GAAsB,QAAQ,EAAsB,EAAnD,MAAM,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,SAAS,GAAA,EAAA,CAAA,CAAA,CAAkC;AAE1D,IAAA,IAAM,WAAW,GAAG,MAAM,CA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SAAS,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK;AACvC,SAAA,EACD,eAAe,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,EAAA,QAAA,EAExD,QAAQ,EAAA,CACL;AAEV;;;;"}
|
|
@@ -95,6 +95,10 @@ export declare const TwoPlanQuote: {
|
|
|
95
95
|
render: () => JSX.Element;
|
|
96
96
|
name: string;
|
|
97
97
|
};
|
|
98
|
+
export declare const PlanDetailsQuote: {
|
|
99
|
+
render: () => JSX.Element;
|
|
100
|
+
name: string;
|
|
101
|
+
};
|
|
98
102
|
export declare const ThreePlanQuoteWebsite: {
|
|
99
103
|
render: () => JSX.Element;
|
|
100
104
|
name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ModalFunction } from '../../../types';
|
|
3
|
-
export type FontVariant = 'NORMAL' | 'TITLE' | 'PRICE';
|
|
3
|
+
export type FontVariant = 'NORMAL' | 'TITLE' | 'SUBTITLE' | 'PRICE';
|
|
4
4
|
export type Alignment = 'center' | 'left' | 'right';
|
|
5
5
|
export type BaseCellProps = {
|
|
6
6
|
align?: Alignment;
|
package/package.json
CHANGED
|
@@ -45,6 +45,8 @@ const SegmentedControl = ({
|
|
|
45
45
|
style={{ height: `${height}px` }}
|
|
46
46
|
>
|
|
47
47
|
{values.map((value: TitleWithSubtitle | string, index: number) => {
|
|
48
|
+
const selectedColor = selectedIndex === index ? 'tc-white' : 'tc-neutral-900';
|
|
49
|
+
|
|
48
50
|
return (
|
|
49
51
|
<div
|
|
50
52
|
role="button"
|
|
@@ -62,27 +64,19 @@ const SegmentedControl = ({
|
|
|
62
64
|
>
|
|
63
65
|
{typeof value === 'string' ? (
|
|
64
66
|
<div
|
|
65
|
-
className={`p-h4 ta-center ${
|
|
66
|
-
selectedIndex === index ? '' : 'tc-purple-600'
|
|
67
|
-
}`}
|
|
67
|
+
className={`p-h4 ta-center ${selectedColor} ${styles['text-color']}`}
|
|
68
68
|
>
|
|
69
69
|
{value}
|
|
70
70
|
</div>
|
|
71
71
|
) : (
|
|
72
72
|
<>
|
|
73
73
|
<div
|
|
74
|
-
className={`p-h4 ta-center ${
|
|
75
|
-
selectedIndex === index ? '' : 'tc-purple-600'
|
|
76
|
-
}`}
|
|
74
|
+
className={`p-h4 ta-center ${selectedColor} ${styles['text-color']}`}
|
|
77
75
|
>
|
|
78
76
|
{value.title}
|
|
79
77
|
</div>
|
|
80
78
|
<div
|
|
81
|
-
className={`p-p--small ta-center ${
|
|
82
|
-
selectedIndex === index
|
|
83
|
-
? 'tc-neutral-600'
|
|
84
|
-
: 'tc-purple-600'
|
|
85
|
-
}`}
|
|
79
|
+
className={`p-p--small ta-center ${selectedColor} ${styles['text-color']}`}
|
|
86
80
|
>
|
|
87
81
|
{value.subtitle}
|
|
88
82
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
display: inline-block;
|
|
4
4
|
|
|
5
|
-
background-color: var(--ds-
|
|
5
|
+
background-color: var(--ds-orange-50);
|
|
6
6
|
border-radius: 8px;
|
|
7
7
|
|
|
8
8
|
padding: 0 8px;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
padding-right: 16px;
|
|
23
23
|
|
|
24
24
|
&:focus {
|
|
25
|
-
outline-color: var(--ds-
|
|
25
|
+
outline-color: var(--ds-primary-900);
|
|
26
26
|
outline-offset: 2px;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
.select-chip-background {
|
|
31
31
|
position: absolute;
|
|
32
32
|
|
|
33
|
-
background-color:
|
|
33
|
+
background-color: var(--ds-neutral-900);
|
|
34
34
|
border-radius: 8px;
|
|
35
35
|
|
|
36
36
|
top: 8px;
|
|
@@ -39,3 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
transition: width 0.3s, left 0.3s;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
.text-color {
|
|
44
|
+
transition: color 0.15s ease-in;
|
|
45
|
+
}
|
|
@@ -830,6 +830,164 @@ export const TwoPlanQuote = {
|
|
|
830
830
|
name: 'Two Plan Quote',
|
|
831
831
|
};
|
|
832
832
|
|
|
833
|
+
const getPlanDetailsData = (
|
|
834
|
+
selectedPlan: number,
|
|
835
|
+
setSelectedPlan: (plan: number) => void
|
|
836
|
+
): TableData => [
|
|
837
|
+
{
|
|
838
|
+
rows: [
|
|
839
|
+
[
|
|
840
|
+
{ text: 'Choose plan', fontVariant: 'SUBTITLE' },
|
|
841
|
+
{
|
|
842
|
+
type: 'BUTTON',
|
|
843
|
+
buttonCaption: 'Basic',
|
|
844
|
+
price: '€99/mo',
|
|
845
|
+
isSelected: selectedPlan === 1,
|
|
846
|
+
onClick: () => setSelectedPlan(1),
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
type: 'BUTTON',
|
|
850
|
+
buttonCaption: 'Advanced',
|
|
851
|
+
price: '€150/mo',
|
|
852
|
+
isSelected: selectedPlan === 2,
|
|
853
|
+
onClick: () => setSelectedPlan(2),
|
|
854
|
+
},
|
|
855
|
+
],
|
|
856
|
+
[
|
|
857
|
+
{
|
|
858
|
+
text: "General doctors' visits",
|
|
859
|
+
modalContent: 'Visits to general practitioners are covered in full.',
|
|
860
|
+
},
|
|
861
|
+
{ text: 'Up to €2 million' },
|
|
862
|
+
{ text: 'Up to €2 million' },
|
|
863
|
+
],
|
|
864
|
+
[
|
|
865
|
+
{
|
|
866
|
+
text: 'Specialists',
|
|
867
|
+
modalContent: 'Specialist visits are covered with a referral.',
|
|
868
|
+
},
|
|
869
|
+
{ text: '4 visits per year' },
|
|
870
|
+
{ text: 'Unlimited visits' },
|
|
871
|
+
],
|
|
872
|
+
[
|
|
873
|
+
{ text: 'Documents (not in a safe)' },
|
|
874
|
+
{ text: '20% of the insured sum', description: 'max €3,000' },
|
|
875
|
+
{ text: '30% of the insured sum', description: 'max €5,000' },
|
|
876
|
+
],
|
|
877
|
+
],
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
section: {
|
|
881
|
+
title: 'Theft, fraud and robberies',
|
|
882
|
+
},
|
|
883
|
+
rows: [
|
|
884
|
+
[
|
|
885
|
+
{ text: 'Burglary and vandalism' },
|
|
886
|
+
{ checkmarkValue: true },
|
|
887
|
+
{ checkmarkValue: true },
|
|
888
|
+
],
|
|
889
|
+
[
|
|
890
|
+
{ text: 'Valuables in bank safe deposits' },
|
|
891
|
+
{ text: '5% of the insured sum' },
|
|
892
|
+
{ text: '30% of the insured sum' },
|
|
893
|
+
],
|
|
894
|
+
[
|
|
895
|
+
{ text: 'Credit card misuse', description: 'E.g. after a robbery' },
|
|
896
|
+
{ checkmarkValue: false },
|
|
897
|
+
{ text: '€1,500', description: 'with a €150 deductible' },
|
|
898
|
+
],
|
|
899
|
+
],
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
section: {
|
|
903
|
+
title: 'Damage protection',
|
|
904
|
+
},
|
|
905
|
+
rows: [
|
|
906
|
+
[
|
|
907
|
+
{ text: 'Weather damage', description: 'Rain, storm, hail or snow' },
|
|
908
|
+
{ checkmarkValue: true },
|
|
909
|
+
{ checkmarkValue: true },
|
|
910
|
+
],
|
|
911
|
+
[
|
|
912
|
+
{
|
|
913
|
+
text: 'Weather damage due to negligence',
|
|
914
|
+
description: 'E.g. belongings damaged due to windows left open',
|
|
915
|
+
},
|
|
916
|
+
{ checkmarkValue: false },
|
|
917
|
+
{ text: '€5,000', description: 'with a €500 deductible' },
|
|
918
|
+
],
|
|
919
|
+
[
|
|
920
|
+
{ text: 'Rainwater pipe leaks (within building)' },
|
|
921
|
+
{ checkmarkValue: false },
|
|
922
|
+
{ checkmarkValue: true },
|
|
923
|
+
],
|
|
924
|
+
],
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
section: {
|
|
928
|
+
title: 'Loss & replacement',
|
|
929
|
+
},
|
|
930
|
+
rows: [
|
|
931
|
+
[
|
|
932
|
+
{ text: 'Luggage while travelling' },
|
|
933
|
+
{ text: 'Up to €2,000' },
|
|
934
|
+
{ text: 'Up to €5,000' },
|
|
935
|
+
],
|
|
936
|
+
[
|
|
937
|
+
{ text: 'Keys and locks', modalContent: 'Replacement of home keys and locks after theft.' },
|
|
938
|
+
{ checkmarkValue: true },
|
|
939
|
+
{ checkmarkValue: true },
|
|
940
|
+
],
|
|
941
|
+
],
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
section: {
|
|
945
|
+
title: 'Accommodation & relocation costs',
|
|
946
|
+
},
|
|
947
|
+
rows: [
|
|
948
|
+
[
|
|
949
|
+
{ text: 'Hotel costs', description: 'If your home is uninhabitable' },
|
|
950
|
+
{ text: 'Up to 100 days' },
|
|
951
|
+
{ text: 'Up to 200 days' },
|
|
952
|
+
],
|
|
953
|
+
[
|
|
954
|
+
{ text: 'Relocation costs' },
|
|
955
|
+
{ checkmarkValue: false },
|
|
956
|
+
{ checkmarkValue: true },
|
|
957
|
+
],
|
|
958
|
+
],
|
|
959
|
+
},
|
|
960
|
+
];
|
|
961
|
+
|
|
962
|
+
const PlanDetailsQuoteStory = () => {
|
|
963
|
+
const [selectedPlan, setSelectedPlan] = useState(1);
|
|
964
|
+
|
|
965
|
+
return (
|
|
966
|
+
<div style={{ maxWidth: 900 }}>
|
|
967
|
+
<p className="p-p tc-neutral-500 mb16">
|
|
968
|
+
Plan details table from the Sign-Ups designs: SUBTITLE top left cell,
|
|
969
|
+
plan selection buttons, selected column highlight, collapsible sections,
|
|
970
|
+
checkmarks, values with descriptions, and info modals.
|
|
971
|
+
</p>
|
|
972
|
+
<Table
|
|
973
|
+
tableData={getPlanDetailsData(selectedPlan, setSelectedPlan)}
|
|
974
|
+
title="Plan details"
|
|
975
|
+
collapsibleSections
|
|
976
|
+
showSelectedColumn
|
|
977
|
+
activeSection={selectedPlan}
|
|
978
|
+
onSelectionChanged={setSelectedPlan}
|
|
979
|
+
mobileNavigationMode="tabs"
|
|
980
|
+
/>
|
|
981
|
+
</div>
|
|
982
|
+
);
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
export const PlanDetailsQuote = {
|
|
986
|
+
render: () => <PlanDetailsQuoteStory />,
|
|
987
|
+
|
|
988
|
+
name: 'Plan Details - Quote',
|
|
989
|
+
};
|
|
990
|
+
|
|
833
991
|
const threePlanWebsiteData: TableData = [
|
|
834
992
|
{
|
|
835
993
|
rows: [
|
|
@@ -11,7 +11,7 @@ import { MiniProgressBar } from './MiniProgressBar/MiniProgressBar';
|
|
|
11
11
|
import { TableInfoButton } from '../../../../comparisonTable';
|
|
12
12
|
import { ModalFunction } from '../../../types';
|
|
13
13
|
|
|
14
|
-
export type FontVariant = 'NORMAL' | 'TITLE' | 'PRICE';
|
|
14
|
+
export type FontVariant = 'NORMAL' | 'TITLE' | 'SUBTITLE' | 'PRICE';
|
|
15
15
|
|
|
16
16
|
const progressLookup: Record<string, number> = {
|
|
17
17
|
'30%': 1,
|
|
@@ -157,6 +157,15 @@ export const BaseCell = ({
|
|
|
157
157
|
</h2>
|
|
158
158
|
)}
|
|
159
159
|
|
|
160
|
+
{text && fontVariant === 'SUBTITLE' && (
|
|
161
|
+
<h2
|
|
162
|
+
aria-hidden
|
|
163
|
+
className="tc-grey-800 p-h4"
|
|
164
|
+
>
|
|
165
|
+
{text}
|
|
166
|
+
</h2>
|
|
167
|
+
)}
|
|
168
|
+
|
|
160
169
|
{modalContent && openModal && (
|
|
161
170
|
<span className="ml8">
|
|
162
171
|
<TableInfoButton
|
|
@@ -88,4 +88,22 @@ describe('TableCell', () => {
|
|
|
88
88
|
title: '',
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
|
+
|
|
92
|
+
it('renders the top left cell as a title by default', () => {
|
|
93
|
+
setup({ isTopLeftCell: true, text: 'Choose a plan' });
|
|
94
|
+
|
|
95
|
+
expect(screen.getByText('Choose a plan')).toHaveClass('p-h2');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('lets fontVariant override the top left cell title', () => {
|
|
99
|
+
setup({
|
|
100
|
+
isTopLeftCell: true,
|
|
101
|
+
fontVariant: 'SUBTITLE',
|
|
102
|
+
text: 'Choose a plan',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const cellText = screen.getByText('Choose a plan');
|
|
106
|
+
expect(cellText).toHaveClass('p-h4');
|
|
107
|
+
expect(cellText).not.toHaveClass('p-h2');
|
|
108
|
+
});
|
|
91
109
|
});
|
|
@@ -53,6 +53,8 @@ const TableCell = React.memo(
|
|
|
53
53
|
className={classNames(isSelectedColumn ? 'bg-orange-50' : 'bg-white', styles.th, {
|
|
54
54
|
'ta-left': isFirstCellInRow,
|
|
55
55
|
[styles.headerCell]: isHeader,
|
|
56
|
+
[styles.subtitleCell]:
|
|
57
|
+
!cellProps.type && cellProps.fontVariant === 'SUBTITLE',
|
|
56
58
|
[styles.thNavigation]: isNavigation,
|
|
57
59
|
[styles.navigationTitle]: isNavigation && isTopLeftCell,
|
|
58
60
|
[styles.fixedCell]: isFirstCellInRow && colSpan < 1 ,
|
|
@@ -66,9 +68,7 @@ const TableCell = React.memo(
|
|
|
66
68
|
<BaseCell
|
|
67
69
|
{...cellProps}
|
|
68
70
|
fontVariant={
|
|
69
|
-
isTopLeftCell
|
|
70
|
-
? 'TITLE'
|
|
71
|
-
: cellProps.fontVariant ?? 'NORMAL'
|
|
71
|
+
cellProps.fontVariant ?? (isTopLeftCell ? 'TITLE' : 'NORMAL')
|
|
72
72
|
}
|
|
73
73
|
/>
|
|
74
74
|
)}
|
|
@@ -7,6 +7,21 @@ interface CollapsibleProps {
|
|
|
7
7
|
onTransitionEnd?: () => void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
const measureHeight = (element: Element) => {
|
|
11
|
+
let height = 0;
|
|
12
|
+
|
|
13
|
+
for (const child of Array.from(element.children)) {
|
|
14
|
+
const childStyles = getComputedStyle(child);
|
|
15
|
+
|
|
16
|
+
height +=
|
|
17
|
+
child.getBoundingClientRect().height +
|
|
18
|
+
(parseFloat(childStyles.marginTop) || 0) +
|
|
19
|
+
(parseFloat(childStyles.marginBottom) || 0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return Math.ceil(height);
|
|
23
|
+
};
|
|
24
|
+
|
|
10
25
|
export const Collapsible = ({ children, isExpanded, onTransitionEnd }: CollapsibleProps) => {
|
|
11
26
|
const [height, setHeight] = useState<number | undefined>();
|
|
12
27
|
|
|
@@ -15,24 +30,21 @@ export const Collapsible = ({ children, isExpanded, onTransitionEnd }: Collapsib
|
|
|
15
30
|
|
|
16
31
|
useEffect(() => {
|
|
17
32
|
if (!observerRef.current) {
|
|
18
|
-
observerRef.current = new ResizeObserver((
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setHeight(scrollheight);
|
|
23
|
-
});
|
|
33
|
+
observerRef.current = new ResizeObserver(() => {
|
|
34
|
+
if (containerRef.current) {
|
|
35
|
+
setHeight(measureHeight(containerRef.current));
|
|
36
|
+
}
|
|
24
37
|
});
|
|
25
38
|
}
|
|
26
39
|
if (containerRef.current) {
|
|
27
40
|
observerRef.current.observe(containerRef.current);
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
Array.from(containerRef.current.children).forEach((child) => {
|
|
42
|
+
observerRef.current?.observe(child);
|
|
43
|
+
});
|
|
44
|
+
setHeight(measureHeight(containerRef.current));
|
|
30
45
|
}
|
|
31
46
|
|
|
32
47
|
return () => {
|
|
33
|
-
if (containerRef.current) {
|
|
34
|
-
observerRef.current?.unobserve(containerRef.current);
|
|
35
|
-
}
|
|
36
48
|
observerRef.current?.disconnect();
|
|
37
49
|
};
|
|
38
50
|
}, [containerRef.current]);
|