@popsure/dirty-swan 0.26.10 → 0.26.13
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/index.css +62 -0
- package/dist/index.css.map +1 -1
- package/dist/lib/scss/private/base/_border_radius.scss +15 -0
- package/dist/lib/scss/private/base/_grid.scss +8 -0
- package/dist/lib/scss/private/base/_index.scss +1 -0
- package/dist/lib/scss/private/base/style.module.scss +10 -0
- package/dist/lib/scss/public/colors/default.scss +5 -0
- package/dist/lib/scss/public/demo.tsx +13 -1
- package/package.json +2 -1
- package/src/App.tsx +50 -0
- package/src/bin/index.ts +71 -0
- package/src/bin/tsconfig.json +13 -0
- package/src/bin/util/index.test.ts +85 -0
- package/src/bin/util/index.ts +132 -0
- package/src/bin/util/test/data.json +13 -0
- package/src/colors.scss +1 -0
- package/src/font-weight.scss +1 -0
- package/src/grid.scss +1 -0
- package/src/index.tsx +37 -0
- package/src/intro.stories.mdx +41 -0
- package/src/lib/components/autocompleteAddress/demo.tsx +38 -0
- package/src/lib/components/autocompleteAddress/index.stories.mdx +44 -0
- package/src/lib/components/autocompleteAddress/index.tsx +316 -0
- package/src/lib/components/autocompleteAddress/mapStyle.ts +187 -0
- package/src/lib/components/autocompleteAddress/style.module.scss +82 -0
- package/src/lib/components/autocompleteAddress/util/index.test.ts +51 -0
- package/src/lib/components/autocompleteAddress/util/index.ts +55 -0
- package/src/lib/components/button/icons/index.ts +14 -0
- package/src/lib/components/button/icons/send-purple.svg +4 -0
- package/src/lib/components/button/icons/send-white.svg +4 -0
- package/src/lib/components/button/index.stories.mdx +121 -0
- package/src/lib/components/button/index.tsx +64 -0
- package/src/lib/components/button/styles.module.scss +5 -0
- package/src/lib/components/cards/a.stories.mdx +44 -0
- package/src/lib/components/cards/cardButton/index.stories.mdx +47 -0
- package/src/lib/components/cards/cardButton/index.tsx +61 -0
- package/src/lib/components/cards/cardButton/style.module.scss +33 -0
- package/src/lib/components/cards/cardWithLeftIcon/index.stories.mdx +103 -0
- package/src/lib/components/cards/cardWithLeftIcon/index.tsx +87 -0
- package/src/lib/components/cards/cardWithLeftIcon/style.module.scss +23 -0
- package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +105 -0
- package/src/lib/components/cards/cardWithTopIcon/index.tsx +60 -0
- package/src/lib/components/cards/cardWithTopIcon/style.module.scss +10 -0
- package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.mdx +101 -0
- package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +72 -0
- package/src/lib/components/cards/cardWithTopLeftIcon/style.module.scss +21 -0
- package/src/lib/components/cards/icons/arrow-right.svg +4 -0
- package/src/lib/components/cards/icons/chevron-right.svg +3 -0
- package/src/lib/components/cards/icons/feather-logo.svg +10 -0
- package/src/lib/components/cards/icons/index.ts +36 -0
- package/src/lib/components/cards/icons/info.svg +12 -0
- package/src/lib/components/cards/index.test.ts +37 -0
- package/src/lib/components/cards/index.tsx +57 -0
- package/src/lib/components/cards/infoCard/index.stories.mdx +61 -0
- package/src/lib/components/cards/infoCard/index.tsx +47 -0
- package/src/lib/components/cards/infoCard/style.module.scss +53 -0
- package/src/lib/components/chip/icons/remove-button-highlighted.svg +4 -0
- package/src/lib/components/chip/icons/remove-button.svg +4 -0
- package/src/lib/components/chip/index.stories.mdx +101 -0
- package/src/lib/components/chip/index.tsx +38 -0
- package/src/lib/components/chip/style.module.scss +54 -0
- package/src/lib/components/comparisonTable/components/Chevron.tsx +19 -0
- package/src/lib/components/comparisonTable/components/Row/index.tsx +68 -0
- package/src/lib/components/comparisonTable/components/Row/style.module.scss +114 -0
- package/src/lib/components/comparisonTable/components/TableArrows/Arrow.tsx +19 -0
- package/src/lib/components/comparisonTable/components/TableArrows/index.tsx +52 -0
- package/src/lib/components/comparisonTable/components/TableArrows/style.module.scss +53 -0
- package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +37 -0
- package/src/lib/components/comparisonTable/components/TableInfoButton/style.module.scss +30 -0
- package/src/lib/components/comparisonTable/components/TableRating/StarIcon.tsx +13 -0
- package/src/lib/components/comparisonTable/components/TableRating/ZapIcon.tsx +17 -0
- package/src/lib/components/comparisonTable/components/TableRating/index.tsx +45 -0
- package/src/lib/components/comparisonTable/components/TableRating/style.module.scss +13 -0
- package/src/lib/components/comparisonTable/components/TableRowHeader/index.tsx +35 -0
- package/src/lib/components/comparisonTable/components/TableRowHeader/style.module.scss +3 -0
- package/src/lib/components/comparisonTable/components/TableTrueFalse.tsx +40 -0
- package/src/lib/components/comparisonTable/hooks/useActiveTableArrows.ts +63 -0
- package/src/lib/components/comparisonTable/index.stories.mdx +254 -0
- package/src/lib/components/comparisonTable/index.tsx +211 -0
- package/src/lib/components/comparisonTable/style.module.scss +104 -0
- package/src/lib/components/dateSelector/datepicker.scss +406 -0
- package/src/lib/components/dateSelector/icons/calendar.svg +6 -0
- package/src/lib/components/dateSelector/icons/chevron-left.svg +3 -0
- package/src/lib/components/dateSelector/icons/chevron-right.svg +3 -0
- package/src/lib/components/dateSelector/index.stories.mdx +62 -0
- package/src/lib/components/dateSelector/index.test.ts +33 -0
- package/src/lib/components/dateSelector/index.tsx +247 -0
- package/src/lib/components/dateSelector/style.module.scss +77 -0
- package/src/lib/components/downloadButton/icons/check.svg +3 -0
- package/src/lib/components/downloadButton/icons/download.svg +5 -0
- package/src/lib/components/downloadButton/index.stories.mdx +59 -0
- package/src/lib/components/downloadButton/index.tsx +67 -0
- package/src/lib/components/downloadButton/style.module.scss +19 -0
- package/src/lib/components/downloadRing/icons/check-outside-circle.tsx +26 -0
- package/src/lib/components/downloadRing/icons/download-cloud.tsx +18 -0
- package/src/lib/components/downloadRing/icons/style.module.scss +7 -0
- package/src/lib/components/downloadRing/index.stories.mdx +35 -0
- package/src/lib/components/downloadRing/index.tsx +79 -0
- package/src/lib/components/downloadRing/style.module.scss +66 -0
- package/src/lib/components/dropzone/images/error.tsx +18 -0
- package/src/lib/components/dropzone/images/file.tsx +26 -0
- package/src/lib/components/dropzone/images/style.module.scss +7 -0
- package/src/lib/components/dropzone/images/upload-complete.tsx +24 -0
- package/src/lib/components/dropzone/images/upload.tsx +18 -0
- package/src/lib/components/dropzone/index.stories.mdx +44 -0
- package/src/lib/components/dropzone/index.tsx +152 -0
- package/src/lib/components/dropzone/style.module.scss +90 -0
- package/src/lib/components/input/a.stories.mdx +28 -0
- package/src/lib/components/input/autoSuggestInput/index.stories.mdx +137 -0
- package/src/lib/components/input/autoSuggestInput/index.tsx +81 -0
- package/src/lib/components/input/autoSuggestInput/style.module.scss +71 -0
- package/src/lib/components/input/autoSuggestMultiSelect/index.stories.mdx +115 -0
- package/src/lib/components/input/autoSuggestMultiSelect/index.tsx +75 -0
- package/src/lib/components/input/autoSuggestMultiSelect/style.module.scss +4 -0
- package/src/lib/components/input/currency/format/index.test.ts +49 -0
- package/src/lib/components/input/currency/format/index.ts +15 -0
- package/src/lib/components/input/currency/index.stories.mdx +25 -0
- package/src/lib/components/input/currency/index.test.tsx +56 -0
- package/src/lib/components/input/currency/index.tsx +53 -0
- package/src/lib/components/input/iban/formatIban/index.test.ts +11 -0
- package/src/lib/components/input/iban/formatIban/index.ts +22 -0
- package/src/lib/components/input/iban/index.stories.mdx +21 -0
- package/src/lib/components/input/iban/index.tsx +20 -0
- package/src/lib/components/input/index.stories.mdx +62 -0
- package/src/lib/components/input/index.tsx +51 -0
- package/src/lib/components/input/style.module.scss +94 -0
- package/src/lib/components/modal/bottomModal/img/close.svg +4 -0
- package/src/lib/components/modal/bottomModal/index.tsx +68 -0
- package/src/lib/components/modal/bottomModal/style.module.scss +104 -0
- package/src/lib/components/modal/bottomOrRegularModal/index.tsx +43 -0
- package/src/lib/components/modal/bottomOrRegularModal/style.module.scss +16 -0
- package/src/lib/components/modal/hooks/useOnClose.ts +51 -0
- package/src/lib/components/modal/index.stories.mdx +316 -0
- package/src/lib/components/modal/index.ts +14 -0
- package/src/lib/components/modal/regularModal/img/close.svg +4 -0
- package/src/lib/components/modal/regularModal/index.tsx +55 -0
- package/src/lib/components/modal/regularModal/style.module.scss +106 -0
- package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +138 -0
- package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +101 -0
- package/src/lib/components/multiDropzone/icons/bmp-complete.svg +10 -0
- package/src/lib/components/multiDropzone/icons/bmp.svg +10 -0
- package/src/lib/components/multiDropzone/icons/doc-complete.svg +11 -0
- package/src/lib/components/multiDropzone/icons/doc.svg +11 -0
- package/src/lib/components/multiDropzone/icons/docx-complete.svg +12 -0
- package/src/lib/components/multiDropzone/icons/docx.svg +12 -0
- package/src/lib/components/multiDropzone/icons/eye.svg +4 -0
- package/src/lib/components/multiDropzone/icons/generic-complete.svg +4 -0
- package/src/lib/components/multiDropzone/icons/generic-error.svg +7 -0
- package/src/lib/components/multiDropzone/icons/generic.svg +4 -0
- package/src/lib/components/multiDropzone/icons/heic-complete.svg +11 -0
- package/src/lib/components/multiDropzone/icons/heic.svg +11 -0
- package/src/lib/components/multiDropzone/icons/index.ts +51 -0
- package/src/lib/components/multiDropzone/icons/jpeg-complete.svg +11 -0
- package/src/lib/components/multiDropzone/icons/jpeg.svg +11 -0
- package/src/lib/components/multiDropzone/icons/jpg-complete.svg +10 -0
- package/src/lib/components/multiDropzone/icons/jpg.svg +10 -0
- package/src/lib/components/multiDropzone/icons/pdf-complete.svg +8 -0
- package/src/lib/components/multiDropzone/icons/pdf.svg +8 -0
- package/src/lib/components/multiDropzone/icons/png-complete.svg +10 -0
- package/src/lib/components/multiDropzone/icons/png.svg +10 -0
- package/src/lib/components/multiDropzone/icons/trash.svg +6 -0
- package/src/lib/components/multiDropzone/icons/upload.svg +5 -0
- package/src/lib/components/multiDropzone/index.stories.mdx +91 -0
- package/src/lib/components/multiDropzone/index.tsx +99 -0
- package/src/lib/components/multiDropzone/style.module.scss +32 -0
- package/src/lib/components/segmentedControl/index.stories.mdx +47 -0
- package/src/lib/components/segmentedControl/index.tsx +105 -0
- package/src/lib/components/segmentedControl/style.module.scss +36 -0
- package/src/lib/components/signaturePad/img/reset.svg +4 -0
- package/src/lib/components/signaturePad/img/sign.svg +3 -0
- package/src/lib/components/signaturePad/index.stories.mdx +17 -0
- package/src/lib/components/signaturePad/index.tsx +96 -0
- package/src/lib/components/signaturePad/style.module.scss +90 -0
- package/src/lib/index.tsx +71 -0
- package/src/lib/models/autoSuggestInput/index.ts +4 -0
- package/src/lib/models/download.ts +1 -0
- package/src/lib/models/downloadRing/index.ts +6 -0
- package/src/lib/scss/index.scss +22 -0
- package/src/lib/scss/private/_reset.scss +149 -0
- package/src/lib/scss/private/base/_border_radius.scss +15 -0
- package/src/lib/scss/private/base/_colors.scss +19 -0
- package/src/lib/scss/private/base/_cursors.scss +31 -0
- package/src/lib/scss/private/base/_display.scss +35 -0
- package/src/lib/scss/private/base/_grid.scss +60 -0
- package/src/lib/scss/private/base/_index.scss +10 -0
- package/src/lib/scss/private/base/_shadows.scss +2 -0
- package/src/lib/scss/private/base/_spacing.scss +89 -0
- package/src/lib/scss/private/base/_typography.scss +128 -0
- package/src/lib/scss/private/base/_width_and_height.scss +25 -0
- package/src/lib/scss/private/base/border_radius.stories.mdx +43 -0
- package/src/lib/scss/private/base/cursors.stories.mdx +18 -0
- package/src/lib/scss/private/base/demo.tsx +119 -0
- package/src/lib/scss/private/base/display.stories.mdx +19 -0
- package/src/lib/scss/private/base/flex/_flex.scss +63 -0
- package/src/lib/scss/private/base/flex/flex.stories.mdx +139 -0
- package/src/lib/scss/private/base/flex/style.module.scss +24 -0
- package/src/lib/scss/private/base/spacing.stories.mdx +185 -0
- package/src/lib/scss/private/base/style.module.scss +52 -0
- package/src/lib/scss/private/base/typography.stories.mdx +71 -0
- package/src/lib/scss/private/base/width_and_height.stories.mdx +172 -0
- package/src/lib/scss/private/components/_badge.scss +41 -0
- package/src/lib/scss/private/components/_buttons.scss +193 -0
- package/src/lib/scss/private/components/_cards.scss +32 -0
- package/src/lib/scss/private/components/_index.scss +6 -0
- package/src/lib/scss/private/components/_input.scss +241 -0
- package/src/lib/scss/private/components/_notices.scss +39 -0
- package/src/lib/scss/private/components/_spinner.scss +60 -0
- package/src/lib/scss/private/components/assets/checkmark.svg +3 -0
- package/src/lib/scss/private/components/assets/icon-form-dropdown.svg +3 -0
- package/src/lib/scss/private/components/badge.stories.mdx +37 -0
- package/src/lib/scss/private/components/button.stories.mdx +107 -0
- package/src/lib/scss/private/components/cards.stories.mdx +35 -0
- package/src/lib/scss/private/components/checkbox.stories.mdx +47 -0
- package/src/lib/scss/private/components/input.stories.mdx +33 -0
- package/src/lib/scss/private/components/notices.stories.mdx +37 -0
- package/src/lib/scss/private/components/radio.stories.mdx +47 -0
- package/src/lib/scss/private/components/select.stories.mdx +17 -0
- package/src/lib/scss/private/components/spinner.stories.mdx +25 -0
- package/src/lib/scss/public/colors/_index.scss +2 -0
- package/src/lib/scss/public/colors/default.scss +130 -0
- package/src/lib/scss/public/colors/overrides.scss +0 -0
- package/src/lib/scss/public/colors.stories.mdx +27 -0
- package/src/lib/scss/public/demo.tsx +297 -0
- package/src/lib/scss/public/font/_index.scss +2 -0
- package/src/lib/scss/public/font/default.scss +3 -0
- package/src/lib/scss/public/font/overrides.scss +0 -0
- package/src/lib/scss/public/font-weight.scss +9 -0
- package/src/lib/scss/public/font-weight.stories.mdx +32 -0
- package/src/lib/scss/public/grid.scss +21 -0
- package/src/lib/scss/public/grid.stories.mdx +41 -0
- package/src/lib/scss/third-party/_google_places.scss +62 -0
- package/src/lib/scss/third-party/_index.scss +1 -0
- package/src/lib/scss/utils/_index.scss +3 -0
- package/src/lib/util/calendarDate/index.test.ts +32 -0
- package/src/lib/util/calendarDate/index.ts +30 -0
- package/src/lib/util/zeroFill.test.ts +15 -0
- package/src/lib/util/zeroFill.ts +7 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/setupTests.js +8 -0
- package/src/theme.stories.mdx +54 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import styles from './style.module.scss';
|
|
2
|
+
|
|
3
|
+
const TableInfoButton = ({
|
|
4
|
+
onClick,
|
|
5
|
+
className = '',
|
|
6
|
+
}: {
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}) => (
|
|
10
|
+
<span
|
|
11
|
+
role="button"
|
|
12
|
+
className={`p-btn--secondary ${styles.button} ${className}`}
|
|
13
|
+
onClick={onClick}
|
|
14
|
+
>
|
|
15
|
+
<svg
|
|
16
|
+
width="20"
|
|
17
|
+
height="20"
|
|
18
|
+
viewBox="0 0 20 20"
|
|
19
|
+
fill="none"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
fillRule="evenodd"
|
|
24
|
+
clipRule="evenodd"
|
|
25
|
+
d="M10 2.66667C5.94991 2.66667 2.66667 5.94991 2.66667 10C2.66667 14.0501 5.94991 17.3333 10 17.3333C14.0501 17.3333 17.3333 14.0501 17.3333 10C17.3333 5.94991 14.0501 2.66667 10 2.66667ZM0.666667 10C0.666667 4.84534 4.84534 0.666667 10 0.666667C15.1547 0.666667 19.3333 4.84534 19.3333 10C19.3333 15.1547 15.1547 19.3333 10 19.3333C4.84534 19.3333 0.666667 15.1547 0.666667 10Z"
|
|
26
|
+
/>
|
|
27
|
+
<path
|
|
28
|
+
fillRule="evenodd"
|
|
29
|
+
clipRule="evenodd"
|
|
30
|
+
d="M10 9C10.5523 9 11 9.44772 11 10V13.3333C11 13.8856 10.5523 14.3333 10 14.3333C9.44772 14.3333 9 13.8856 9 13.3333V10C9 9.44772 9.44772 9 10 9Z"
|
|
31
|
+
/>
|
|
32
|
+
<path d="M10.8333 6.66667C10.8333 7.1269 10.4602 7.5 10 7.5C9.53976 7.5 9.16667 7.1269 9.16667 6.66667C9.16667 6.20643 9.53976 5.83333 10 5.83333C10.4602 5.83333 10.8333 6.20643 10.8333 6.66667Z" />
|
|
33
|
+
</svg>
|
|
34
|
+
</span>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default TableInfoButton;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@use "../../../../scss/public/colors" as *;
|
|
2
|
+
|
|
3
|
+
.button {
|
|
4
|
+
padding: 0;
|
|
5
|
+
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
|
|
10
|
+
vertical-align: bottom;
|
|
11
|
+
|
|
12
|
+
width: 24px;
|
|
13
|
+
height: 24px;
|
|
14
|
+
|
|
15
|
+
transition: all 0.3s ease;
|
|
16
|
+
|
|
17
|
+
&:hover,
|
|
18
|
+
&:focus {
|
|
19
|
+
background-color: $ds-primary-50;
|
|
20
|
+
|
|
21
|
+
svg {
|
|
22
|
+
fill: $ds-primary-300;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
svg {
|
|
27
|
+
fill: $ds-primary-100;
|
|
28
|
+
transition: all 0.3s ease;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const StarIcon = ({ className }: { className: string }) => (
|
|
2
|
+
<svg
|
|
3
|
+
width="12"
|
|
4
|
+
height="12"
|
|
5
|
+
fill="none"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
className={className}
|
|
8
|
+
>
|
|
9
|
+
<path d="M5.933.004a.73.73 0 01.756.468L7.891 3.67l3.407.16c.677.03.954.886.422 1.306l-2.66 2.145.899 3.296c.17.647-.545 1.166-1.105.8l-2.85-1.872-2.858 1.873c-.561.368-1.28-.152-1.107-.801l.9-3.296L.278 5.136C-.253 4.716.024 3.86.7 3.831l3.407-.161L5.322.472a.73.73 0 01.61-.468z" />
|
|
10
|
+
</svg>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default StarIcon;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const ZapIcon = ({ className }: { className: string }) => (
|
|
2
|
+
<svg
|
|
3
|
+
width="12"
|
|
4
|
+
height="12"
|
|
5
|
+
fill="none"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
className={className}
|
|
8
|
+
>
|
|
9
|
+
<path
|
|
10
|
+
fillRule="evenodd"
|
|
11
|
+
clipRule="evenodd"
|
|
12
|
+
d="M7.492 1.124A1 1 0 005.732.36l-5 6A1 1 0 001.5 8h3.367l-.36 2.876a1 1 0 001.761.764l5-6A1 1 0 0010.5 4H7.133l.36-2.876z"
|
|
13
|
+
/>
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default ZapIcon;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
|
|
3
|
+
import StarIcon from './StarIcon';
|
|
4
|
+
import ZapIcon from './ZapIcon';
|
|
5
|
+
|
|
6
|
+
import styles from './style.module.scss';
|
|
7
|
+
|
|
8
|
+
type RatingTypes = 'star' | 'zap';
|
|
9
|
+
|
|
10
|
+
interface TableRatingProps {
|
|
11
|
+
type: RatingTypes;
|
|
12
|
+
rating: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const getRatingIcon = (type: RatingTypes) => {
|
|
16
|
+
const iconDictionary = {
|
|
17
|
+
zap: ZapIcon,
|
|
18
|
+
star: StarIcon,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return iconDictionary[type] || iconDictionary['star'];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const VALID_VALUES = [1, 2, 3];
|
|
25
|
+
|
|
26
|
+
const TableRating = (props: TableRatingProps) => {
|
|
27
|
+
const { rating, type } = props;
|
|
28
|
+
const SelectedIcon = getRatingIcon(type);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
{VALID_VALUES.map((value) => (
|
|
33
|
+
<SelectedIcon
|
|
34
|
+
key={value}
|
|
35
|
+
className={classNames(
|
|
36
|
+
styles.icon,
|
|
37
|
+
value <= rating ? styles.filled : styles.empty
|
|
38
|
+
)}
|
|
39
|
+
/>
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default TableRating;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
|
|
4
|
+
import TableInfoButton from '../TableInfoButton';
|
|
5
|
+
|
|
6
|
+
import styles from './style.module.scss';
|
|
7
|
+
|
|
8
|
+
const TableRowHeader = (props: {
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
onClickInfo?: () => void;
|
|
13
|
+
}) => {
|
|
14
|
+
const { icon, label, subtitle, onClickInfo } = props;
|
|
15
|
+
return (
|
|
16
|
+
<div className="d-flex">
|
|
17
|
+
<span className={`mr8 ${styles.icon}`}>{icon}</span>
|
|
18
|
+
<div>
|
|
19
|
+
<p className="p-p d-inline">
|
|
20
|
+
<span
|
|
21
|
+
className={classNames({
|
|
22
|
+
mr8: onClickInfo,
|
|
23
|
+
})}
|
|
24
|
+
>
|
|
25
|
+
{label}
|
|
26
|
+
</span>
|
|
27
|
+
{onClickInfo && <TableInfoButton onClick={onClickInfo} />}
|
|
28
|
+
</p>
|
|
29
|
+
{subtitle && <p className="p-p--small tc-grey-500">{subtitle}</p>}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default TableRowHeader;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const TableTrueFalse = ({
|
|
2
|
+
value,
|
|
3
|
+
className = '',
|
|
4
|
+
}: {
|
|
5
|
+
value: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
}) => {
|
|
8
|
+
if (value) {
|
|
9
|
+
return (
|
|
10
|
+
<svg
|
|
11
|
+
width="18"
|
|
12
|
+
height="13"
|
|
13
|
+
fill="none"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
className={className}
|
|
16
|
+
>
|
|
17
|
+
<path
|
|
18
|
+
d="M15.667 1.833L6.5 11 2.333 6.833"
|
|
19
|
+
stroke="#8E8CEE"
|
|
20
|
+
strokeWidth="3"
|
|
21
|
+
strokeLinecap="round"
|
|
22
|
+
strokeLinejoin="round"
|
|
23
|
+
/>
|
|
24
|
+
</svg>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<svg width="12" height="12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
30
|
+
<path
|
|
31
|
+
fillRule="evenodd"
|
|
32
|
+
clipRule="evenodd"
|
|
33
|
+
d="M11.707 1.707A1 1 0 0010.293.293L6 4.586 1.707.293A1 1 0 00.293 1.707L4.586 6 .293 10.293a1 1 0 101.414 1.414L6 7.414l4.293 4.293a1 1 0 001.414-1.414L7.414 6l4.293-4.293z"
|
|
34
|
+
fill="#D2D2D8"
|
|
35
|
+
/>
|
|
36
|
+
</svg>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default TableTrueFalse;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import debounce from 'lodash.debounce';
|
|
3
|
+
|
|
4
|
+
export interface ActiveTableArrows {
|
|
5
|
+
left: boolean;
|
|
6
|
+
right: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useActiveTableArrows = (): {
|
|
10
|
+
activeArrows: ActiveTableArrows;
|
|
11
|
+
contentContainerRef: React.Ref<HTMLDivElement>;
|
|
12
|
+
contentWrapperRef: React.Ref<HTMLDivElement>;
|
|
13
|
+
} => {
|
|
14
|
+
const [activeArrows, setActiveArrows] = useState<ActiveTableArrows>({
|
|
15
|
+
left: false,
|
|
16
|
+
right: true,
|
|
17
|
+
});
|
|
18
|
+
const contentContainerRef = useRef<HTMLDivElement | null>(null);
|
|
19
|
+
const contentWrapperRef = useRef<HTMLDivElement | null>(null);
|
|
20
|
+
|
|
21
|
+
const handleTableScroll = (e: Event) => {
|
|
22
|
+
const width = window.innerWidth;
|
|
23
|
+
|
|
24
|
+
if (
|
|
25
|
+
e.target === contentWrapperRef.current &&
|
|
26
|
+
contentContainerRef.current &&
|
|
27
|
+
contentContainerRef.current
|
|
28
|
+
) {
|
|
29
|
+
const left =
|
|
30
|
+
contentContainerRef.current.getBoundingClientRect().left * -1;
|
|
31
|
+
|
|
32
|
+
setActiveArrows({
|
|
33
|
+
left: left > 0,
|
|
34
|
+
right:
|
|
35
|
+
left + width <
|
|
36
|
+
contentContainerRef.current.getBoundingClientRect().width,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const debouncedTableScroll = debounce(handleTableScroll, 150);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
contentWrapperRef.current?.addEventListener(
|
|
45
|
+
'scroll',
|
|
46
|
+
debouncedTableScroll,
|
|
47
|
+
{
|
|
48
|
+
passive: true,
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return contentWrapperRef.current?.removeEventListener(
|
|
53
|
+
'scroll',
|
|
54
|
+
handleTableScroll
|
|
55
|
+
);
|
|
56
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
activeArrows,
|
|
60
|
+
contentContainerRef,
|
|
61
|
+
contentWrapperRef,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
import { ComparisonTable, TableRating, TableTrueFalse } from '.';
|
|
4
|
+
|
|
5
|
+
<Meta title="JSX/Comparison Table" component={ComparisonTable} />
|
|
6
|
+
|
|
7
|
+
# Comparison Table
|
|
8
|
+
|
|
9
|
+
The Comparison Table component provides an easy way to compare vast amounts of information in a fast and easy way.
|
|
10
|
+
|
|
11
|
+
<Preview>
|
|
12
|
+
<iframe
|
|
13
|
+
width="100%"
|
|
14
|
+
height="450"
|
|
15
|
+
src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FMKs4cbojdVOBKUxv7okb93%2FDirty-Swan-Design-System%3Fnode-id%3D2025%253A12194"
|
|
16
|
+
allowFullScreen
|
|
17
|
+
/>
|
|
18
|
+
</Preview>
|
|
19
|
+
|
|
20
|
+
## Arguments
|
|
21
|
+
|
|
22
|
+
| attribute | unit | description | default value | required |
|
|
23
|
+
| ----------- | ------------------- | ---------------------------------------------------------- | ------------- | -------- |
|
|
24
|
+
| headers | [Header[]](#header) | The structure of the table | n/a | true |
|
|
25
|
+
| data | array | The title text that needs to be displayed | n/a | true |
|
|
26
|
+
| hideDetails | boolean | Hide table groups that do not have the `default` attribute | false | false |
|
|
27
|
+
|
|
28
|
+
## Types
|
|
29
|
+
|
|
30
|
+
### Cell
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
export interface CellBaseProps<T> {
|
|
34
|
+
label?: React.ReactNode;
|
|
35
|
+
render?: (value: any, element: T) => React.ReactNode;
|
|
36
|
+
key: Extract<keyof T, string>;
|
|
37
|
+
addonId?: string | number;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Header
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
export interface Header<T> {
|
|
45
|
+
id: number;
|
|
46
|
+
label?: React.ReactNode;
|
|
47
|
+
cells: Array<Cell<T>>;
|
|
48
|
+
default?: boolean;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Default example
|
|
53
|
+
|
|
54
|
+
export const ComparisonTableWithData = () => {
|
|
55
|
+
const headers = [
|
|
56
|
+
{
|
|
57
|
+
id: 1,
|
|
58
|
+
cells: [
|
|
59
|
+
{
|
|
60
|
+
id: 1,
|
|
61
|
+
key: 'name',
|
|
62
|
+
label: 'Films',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 2,
|
|
66
|
+
key: 'country',
|
|
67
|
+
label: 'Country',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: 4,
|
|
71
|
+
key: 'imdb',
|
|
72
|
+
label: 'IMDB rating',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 3,
|
|
76
|
+
key: 'rating',
|
|
77
|
+
label: 'Our rating',
|
|
78
|
+
render: (value) => <TableRating type="star" rating={value} />,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 5,
|
|
82
|
+
key: 'recommended',
|
|
83
|
+
label: 'Recommended',
|
|
84
|
+
render: (value) => <TableRating type="zap" rating={value} />,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 5,
|
|
88
|
+
key: 'familyFriendly',
|
|
89
|
+
label: 'Family friendly',
|
|
90
|
+
render: (value) => <TableTrueFalse value={value} />,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 6,
|
|
94
|
+
key: 'boxOffice',
|
|
95
|
+
label: 'Box office',
|
|
96
|
+
render: (value) =>
|
|
97
|
+
value.toLocaleString('de-DE', {
|
|
98
|
+
style: 'currency',
|
|
99
|
+
currency: 'EUR',
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
const data = [
|
|
106
|
+
{
|
|
107
|
+
id: 1,
|
|
108
|
+
name: 'Pulp Fiction',
|
|
109
|
+
country: 'United States',
|
|
110
|
+
year: '1994',
|
|
111
|
+
rating: 3,
|
|
112
|
+
imdb: 8.9,
|
|
113
|
+
recommended: 3,
|
|
114
|
+
familyFriendly: false,
|
|
115
|
+
boxOffice: 213928762,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 2,
|
|
119
|
+
name: 'Parasite',
|
|
120
|
+
country: 'South Korea',
|
|
121
|
+
year: '2019',
|
|
122
|
+
rating: 2,
|
|
123
|
+
imdb: 8.6,
|
|
124
|
+
recommended: 3,
|
|
125
|
+
familyFriendly: false,
|
|
126
|
+
boxOffice: 355475245,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 3,
|
|
130
|
+
name: 'Spirited Away',
|
|
131
|
+
country: 'Japan',
|
|
132
|
+
year: '2001',
|
|
133
|
+
rating: 3,
|
|
134
|
+
imdb: 8.6,
|
|
135
|
+
recommended: 3,
|
|
136
|
+
familyFriendly: true,
|
|
137
|
+
boxOffice: 258908054,
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
return <ComparisonTable data={data} headers={headers} />;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
<ComparisonTableWithData />
|
|
144
|
+
|
|
145
|
+
```typescript jsx
|
|
146
|
+
import ComparisonTable, {
|
|
147
|
+
TableRating,
|
|
148
|
+
TableTrueFalse,
|
|
149
|
+
TableHeader,
|
|
150
|
+
} from '@popsure/dirty-swan';
|
|
151
|
+
|
|
152
|
+
interface TableData {
|
|
153
|
+
id: number;
|
|
154
|
+
name: string;
|
|
155
|
+
country: string;
|
|
156
|
+
year: string;
|
|
157
|
+
rating: number;
|
|
158
|
+
imdb: number;
|
|
159
|
+
recommended: number;
|
|
160
|
+
familyFriendly: boolean;
|
|
161
|
+
boxOffice: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const ComparisonTableWithData = () => {
|
|
165
|
+
const headers: Array<TableHeader<TableData>> = [
|
|
166
|
+
{
|
|
167
|
+
id: 1,
|
|
168
|
+
cells: [
|
|
169
|
+
{
|
|
170
|
+
id: 1,
|
|
171
|
+
key: 'name',
|
|
172
|
+
label: 'Films',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: 2,
|
|
176
|
+
key: 'country',
|
|
177
|
+
label: 'Country',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 4,
|
|
181
|
+
key: 'imdb',
|
|
182
|
+
label: 'IMDB rating',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: 3,
|
|
186
|
+
key: 'rating',
|
|
187
|
+
label: 'Our rating',
|
|
188
|
+
render: (value) => <TableRating type="star" rating={value} />,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: 5,
|
|
192
|
+
key: 'recommended',
|
|
193
|
+
label: 'Recommended',
|
|
194
|
+
render: (value) => <TableRating type="zap" rating={value} />,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: 5,
|
|
198
|
+
key: 'familyFriendly',
|
|
199
|
+
label: 'Family friendly',
|
|
200
|
+
render: (value) => <TableTrueFalse value={value} />,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: 6,
|
|
204
|
+
key: 'boxOffice',
|
|
205
|
+
label: 'Box office',
|
|
206
|
+
render: (value) =>
|
|
207
|
+
value.toLocaleString('de-DE', {
|
|
208
|
+
style: 'currency',
|
|
209
|
+
currency: 'EUR',
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
];
|
|
215
|
+
const data: Array<TableData> = [
|
|
216
|
+
{
|
|
217
|
+
id: 1,
|
|
218
|
+
name: 'Pulp Fiction',
|
|
219
|
+
country: 'United States',
|
|
220
|
+
year: '1994',
|
|
221
|
+
rating: 3,
|
|
222
|
+
imdb: 8.9,
|
|
223
|
+
recommended: 3,
|
|
224
|
+
familyFriendly: false,
|
|
225
|
+
boxOffice: 213928762,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
id: 2,
|
|
229
|
+
name: 'Parasite',
|
|
230
|
+
country: 'South Korea',
|
|
231
|
+
year: '2019',
|
|
232
|
+
rating: 2,
|
|
233
|
+
imdb: 8.6,
|
|
234
|
+
recommended: 3,
|
|
235
|
+
familyFriendly: false,
|
|
236
|
+
boxOffice: 355475245,
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
id: 3,
|
|
240
|
+
name: 'Spirited Away',
|
|
241
|
+
country: 'Japan',
|
|
242
|
+
year: '2001',
|
|
243
|
+
rating: 3,
|
|
244
|
+
imdb: 8.6,
|
|
245
|
+
recommended: 3,
|
|
246
|
+
familyFriendly: true,
|
|
247
|
+
boxOffice: 258908054,
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
return <ComparisonTable data={data} headers={headers} />;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
<ComparisonTableWithData />;
|
|
254
|
+
```
|