@popsure/dirty-swan 0.26.9 → 0.26.12
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 +63 -1
- 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/private/components/_buttons.scss +1 -1
- package/dist/lib/scss/public/colors/default.scss +2 -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 +127 -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,82 @@
|
|
|
1
|
+
@use "../../scss/public/grid" as *;
|
|
2
|
+
@use "../../scss/public/colors" as *;
|
|
3
|
+
|
|
4
|
+
.input-line {
|
|
5
|
+
margin-left: -16px;
|
|
6
|
+
|
|
7
|
+
> * {
|
|
8
|
+
margin-left: 16px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@include p-size-mobile {
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
|
|
14
|
+
> *:not(:first-child) {
|
|
15
|
+
margin-top: 16px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.house-number-input {
|
|
21
|
+
@include p-size-mobile {
|
|
22
|
+
max-width: none;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.map-container {
|
|
27
|
+
position: relative;
|
|
28
|
+
|
|
29
|
+
height: 112px;
|
|
30
|
+
margin-bottom: 16px;
|
|
31
|
+
|
|
32
|
+
border-radius: 8px;
|
|
33
|
+
|
|
34
|
+
transition: 0.3s height ease-in-out, 0.3s margin-top ease-in-out;
|
|
35
|
+
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
|
|
38
|
+
&--hidden {
|
|
39
|
+
height: 0;
|
|
40
|
+
margin: 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@keyframes appear-in {
|
|
45
|
+
from {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
}
|
|
48
|
+
to {
|
|
49
|
+
opacity: 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.appear-in-animate {
|
|
54
|
+
animation-name: appear-in;
|
|
55
|
+
animation-duration: 0.3s;
|
|
56
|
+
animation-fill-mode: both;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.loading-spinner {
|
|
60
|
+
display: flex;
|
|
61
|
+
|
|
62
|
+
justify-content: center;
|
|
63
|
+
align-items: center;
|
|
64
|
+
|
|
65
|
+
position: absolute !important;
|
|
66
|
+
background-color: rgba($ds-primary-500, 0.25);
|
|
67
|
+
|
|
68
|
+
top: 0;
|
|
69
|
+
left: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
right: 0;
|
|
72
|
+
z-index: 100;
|
|
73
|
+
|
|
74
|
+
animation-name: appear-in;
|
|
75
|
+
animation-duration: 0.3s;
|
|
76
|
+
animation-fill-mode: both;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.map {
|
|
80
|
+
width: 100%;
|
|
81
|
+
height: 100%;
|
|
82
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { geocoderAddressComponentToPartialAddress } from '.';
|
|
2
|
+
|
|
3
|
+
describe('geocoderAddressComponentToPartialAddress text', () => {
|
|
4
|
+
it('Should extract street, houseNumber, postcode, city, country from GeocoderAddressComponent[]', () => {
|
|
5
|
+
const input = [
|
|
6
|
+
{ long_name: '103A', short_name: '103A', types: ['street_number'] },
|
|
7
|
+
{
|
|
8
|
+
long_name: 'Kottbusser Damm',
|
|
9
|
+
short_name: 'Kottbusser Damm',
|
|
10
|
+
types: ['route'],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
long_name: 'Bezirk Neukölln',
|
|
14
|
+
short_name: 'Bezirk Neukölln',
|
|
15
|
+
types: ['sublocality_level_1', 'sublocality', 'political'],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
long_name: 'Berlin',
|
|
19
|
+
short_name: 'Berlin',
|
|
20
|
+
types: ['locality', 'political'],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
long_name: 'Berlin',
|
|
24
|
+
short_name: 'Berlin',
|
|
25
|
+
types: ['administrative_area_level_1', 'political'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
long_name: 'Germany',
|
|
29
|
+
short_name: 'DE',
|
|
30
|
+
types: ['country', 'political'],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
long_name: '10967',
|
|
34
|
+
short_name: '10967',
|
|
35
|
+
types: ['postal_code'],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const expectedOutput = {
|
|
40
|
+
street: 'Kottbusser Damm',
|
|
41
|
+
houseNumber: '103A',
|
|
42
|
+
postcode: '10967',
|
|
43
|
+
city: 'Berlin',
|
|
44
|
+
country: 'DE',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
expect(geocoderAddressComponentToPartialAddress(input)).toEqual(
|
|
48
|
+
expectedOutput
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Address, countryNameFromAlphaCode } from '@popsure/public-models';
|
|
2
|
+
|
|
3
|
+
export const geocoderAddressComponentToPartialAddress = (
|
|
4
|
+
input: google.maps.GeocoderAddressComponent[]
|
|
5
|
+
): Partial<Address> => {
|
|
6
|
+
interface MappedType {
|
|
7
|
+
key: keyof Address;
|
|
8
|
+
value: 'long_name' | 'short_name';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const mapping: {
|
|
12
|
+
route: MappedType;
|
|
13
|
+
street_number: MappedType;
|
|
14
|
+
postal_code: MappedType;
|
|
15
|
+
locality: MappedType;
|
|
16
|
+
country: MappedType;
|
|
17
|
+
} = {
|
|
18
|
+
route: {
|
|
19
|
+
key: 'street',
|
|
20
|
+
value: 'long_name',
|
|
21
|
+
},
|
|
22
|
+
street_number: {
|
|
23
|
+
key: 'houseNumber',
|
|
24
|
+
value: 'long_name',
|
|
25
|
+
},
|
|
26
|
+
postal_code: {
|
|
27
|
+
key: 'postcode',
|
|
28
|
+
value: 'long_name',
|
|
29
|
+
},
|
|
30
|
+
locality: {
|
|
31
|
+
key: 'city',
|
|
32
|
+
value: 'long_name',
|
|
33
|
+
},
|
|
34
|
+
country: {
|
|
35
|
+
key: 'country',
|
|
36
|
+
value: 'short_name',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const toReturn: Partial<Address> = {};
|
|
41
|
+
input.forEach((value) => {
|
|
42
|
+
const type = value.types[0] as keyof typeof mapping;
|
|
43
|
+
const mappedValue = mapping[type];
|
|
44
|
+
if (mappedValue) {
|
|
45
|
+
toReturn[mappedValue.key] = value[mappedValue.value];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return toReturn;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const inlineAddress = (address: Address) =>
|
|
53
|
+
`${address.street} ${address.houseNumber}, ${
|
|
54
|
+
address.city
|
|
55
|
+
}, ${countryNameFromAlphaCode(address.country)}`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import purpleSendImage from './send-purple.svg';
|
|
2
|
+
import whiteSendImage from './send-white.svg';
|
|
3
|
+
|
|
4
|
+
const purpleSend = {
|
|
5
|
+
src: purpleSendImage,
|
|
6
|
+
alt: 'Paper plane',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const whiteSend = {
|
|
10
|
+
src: whiteSendImage,
|
|
11
|
+
alt: 'Paper plane',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { purpleSend, whiteSend };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M18.3334 1.66667L9.16675 10.8333" stroke="#8E8CEE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
3
|
+
<path d="M18.3334 1.66667L12.5001 18.3333L9.16675 10.8333L1.66675 7.5L18.3334 1.66667Z" stroke="#8E8CEE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M18.3334 1.66667L9.16675 10.8333" stroke="#FFFFFF" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
3
|
+
<path d="M18.3334 1.66667L12.5001 18.3333L9.16675 10.8333L1.66675 7.5L18.3334 1.66667Z" stroke="#FFFFFF" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
import Button from '.';
|
|
4
|
+
import { purpleSend, whiteSend } from './icons';
|
|
5
|
+
|
|
6
|
+
<Meta title="JSX/Button" />
|
|
7
|
+
|
|
8
|
+
# Button
|
|
9
|
+
|
|
10
|
+
Buttons allow users to take actions, and make choices, with a single tap. Buttons communicate actions that users can take.
|
|
11
|
+
|
|
12
|
+
You are looking at the JSX definition of the Button component, if you want you can use the [css alternative](?path=/story/css-components-button--page)
|
|
13
|
+
|
|
14
|
+
<Preview>
|
|
15
|
+
<iframe
|
|
16
|
+
width="100%"
|
|
17
|
+
height="450"
|
|
18
|
+
src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FMKs4cbojdVOBKUxv7okb93%2FDirty-Swan-Pattern-Library%3Fnode-id%3D251%253A26"
|
|
19
|
+
allowFullScreen
|
|
20
|
+
></iframe>
|
|
21
|
+
</Preview>
|
|
22
|
+
|
|
23
|
+
| attribute | unit | description | default value | required |
|
|
24
|
+
| ----------- | ------------------------------------------ | ------------------------------------------------------- | ------------- | -------- |
|
|
25
|
+
| buttonTitle | string | The title text that needs to be displayed | n/a | true |
|
|
26
|
+
| buttonType | 'primary' 'secondary' | Button type will influence the look of the button | 'primary' | false |
|
|
27
|
+
| leftIcon | [Icon](?path=/story/jsx-button--page#icon) | Icon displayed left side of the button (w:20px, h:20px) | n/a | false |
|
|
28
|
+
| loading | boolean | Wether the button should display a loading spinner | false | false |
|
|
29
|
+
|
|
30
|
+
<Preview>
|
|
31
|
+
<>
|
|
32
|
+
<h1 className="p-h1">Primary button</h1>
|
|
33
|
+
<h4 className="p-h4 mt24">Default</h4>
|
|
34
|
+
<Button className="wmn3 mt8" buttonTitle="Click me" />
|
|
35
|
+
<h4 className="p-h4 mt24">Loading</h4>
|
|
36
|
+
<Button className="wmn3 mt8" buttonTitle="Click me" loading={true} />
|
|
37
|
+
<h4 className="p-h4 mt24">Disabled</h4>
|
|
38
|
+
<Button className="wmn3 mt8" buttonTitle="Click me" disabled={true} />
|
|
39
|
+
<h4 className="p-h4 mt24">With left icon</h4>
|
|
40
|
+
<Button className="wmn3 mt8" buttonTitle="Click me" leftIcon={whiteSend} />
|
|
41
|
+
<h1 className="p-h1 mt32">Secondary button</h1>
|
|
42
|
+
<h4 className="p-h4 mt24">Default</h4>
|
|
43
|
+
<Button
|
|
44
|
+
className="wmn3 mt8"
|
|
45
|
+
buttonTitle="Click me"
|
|
46
|
+
buttonType="secondary"
|
|
47
|
+
/>
|
|
48
|
+
<h4 className="p-h4 mt24">Loading</h4>
|
|
49
|
+
<Button
|
|
50
|
+
className="wmn3 mt8"
|
|
51
|
+
buttonTitle="Click me"
|
|
52
|
+
buttonType="secondary"
|
|
53
|
+
loading={true}
|
|
54
|
+
/>
|
|
55
|
+
<h4 className="p-h4 mt24">Disabled</h4>
|
|
56
|
+
<Button
|
|
57
|
+
className="wmn3 mt8"
|
|
58
|
+
buttonTitle="Click me"
|
|
59
|
+
buttonType="secondary"
|
|
60
|
+
disabled={true}
|
|
61
|
+
/>
|
|
62
|
+
<h4 className="p-h4 mt24">With left icon</h4>
|
|
63
|
+
<Button
|
|
64
|
+
className="wmn3 mt8"
|
|
65
|
+
buttonTitle="Click me"
|
|
66
|
+
buttonType="secondary"
|
|
67
|
+
leftIcon={purpleSend}
|
|
68
|
+
/>
|
|
69
|
+
<h1 className="p-h1 mt32">Outline button</h1>
|
|
70
|
+
<h4 className="p-h4 mt24">Default</h4>
|
|
71
|
+
<Button className="wmn3 mt8" buttonTitle="Click me" buttonType="outline" />
|
|
72
|
+
<h4 className="p-h4 mt24">Disabled</h4>
|
|
73
|
+
<Button
|
|
74
|
+
className="wmn3 mt8"
|
|
75
|
+
buttonTitle="Click me"
|
|
76
|
+
buttonType="outline"
|
|
77
|
+
disabled={true}
|
|
78
|
+
/>
|
|
79
|
+
<h4 className="p-h4 mt24">With left icon</h4>
|
|
80
|
+
<Button
|
|
81
|
+
className="wmn3 mt8"
|
|
82
|
+
buttonTitle="Click me"
|
|
83
|
+
buttonType="outline"
|
|
84
|
+
leftIcon={purpleSend}
|
|
85
|
+
/>
|
|
86
|
+
<h1 className="p-h1 mt32">Outline Grey button</h1>
|
|
87
|
+
<h4 className="p-h4 mt24">Default</h4>
|
|
88
|
+
<Button
|
|
89
|
+
className="wmn3 mt8"
|
|
90
|
+
buttonTitle="Click me"
|
|
91
|
+
buttonType="outlineGrey"
|
|
92
|
+
/>
|
|
93
|
+
<h4 className="p-h4 mt24">Disabled</h4>
|
|
94
|
+
<Button
|
|
95
|
+
className="wmn3 mt8"
|
|
96
|
+
buttonTitle="Click me"
|
|
97
|
+
buttonType="outlineGrey"
|
|
98
|
+
disabled={true}
|
|
99
|
+
/>
|
|
100
|
+
<h4 className="p-h4 mt24">With left icon</h4>
|
|
101
|
+
<Button
|
|
102
|
+
className="wmn3 mt8"
|
|
103
|
+
buttonTitle="Click me"
|
|
104
|
+
buttonType="outlineGrey"
|
|
105
|
+
leftIcon={purpleSend}
|
|
106
|
+
/>
|
|
107
|
+
</>
|
|
108
|
+
</Preview>
|
|
109
|
+
|
|
110
|
+
# Models
|
|
111
|
+
|
|
112
|
+
## Icon
|
|
113
|
+
|
|
114
|
+
The icon object is defined with the following poperties
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
export interface Icon {
|
|
118
|
+
src: string; // source of the image
|
|
119
|
+
alt: string; // alternate text if the image can't be displayed
|
|
120
|
+
}
|
|
121
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
type ButtonType = 'primary' | 'secondary' | 'outline' | 'outlineGrey';
|
|
6
|
+
|
|
7
|
+
const buttonTypeClassNameMap: { [K in ButtonType]: string } = {
|
|
8
|
+
primary: 'p-btn--primary',
|
|
9
|
+
secondary: 'p-btn--secondary',
|
|
10
|
+
outline: 'p-btn--outline',
|
|
11
|
+
outlineGrey: 'p-btn--outline-grey',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface Icon {
|
|
15
|
+
src: string;
|
|
16
|
+
alt: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type InputProps = {
|
|
20
|
+
buttonTitle: string;
|
|
21
|
+
buttonType?: ButtonType;
|
|
22
|
+
leftIcon?: Icon;
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
} & Omit<JSX.IntrinsicElements['button'], 'children'>;
|
|
25
|
+
|
|
26
|
+
export default React.forwardRef(
|
|
27
|
+
(
|
|
28
|
+
{
|
|
29
|
+
className,
|
|
30
|
+
loading = false,
|
|
31
|
+
buttonTitle,
|
|
32
|
+
buttonType = 'primary',
|
|
33
|
+
leftIcon,
|
|
34
|
+
type,
|
|
35
|
+
...props
|
|
36
|
+
}: InputProps,
|
|
37
|
+
ref?: React.ForwardedRef<HTMLButtonElement>
|
|
38
|
+
) => {
|
|
39
|
+
const buttonClassName = buttonTypeClassNameMap[buttonType];
|
|
40
|
+
const loadingClassName = loading ? 'p-btn--loading' : '';
|
|
41
|
+
return (
|
|
42
|
+
<button
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={`${buttonClassName} ${loadingClassName} ${className ?? ''}`}
|
|
45
|
+
{...props}
|
|
46
|
+
>
|
|
47
|
+
{leftIcon ? (
|
|
48
|
+
<div className={styles['content-container']}>
|
|
49
|
+
<img
|
|
50
|
+
width="20px"
|
|
51
|
+
height="20px"
|
|
52
|
+
className="mr8"
|
|
53
|
+
src={leftIcon.src}
|
|
54
|
+
alt={leftIcon.alt}
|
|
55
|
+
/>
|
|
56
|
+
<div>{buttonTitle}</div>
|
|
57
|
+
</div>
|
|
58
|
+
) : (
|
|
59
|
+
<>{buttonTitle}</>
|
|
60
|
+
)}
|
|
61
|
+
</button>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="JSX/Cards/Intro" />
|
|
4
|
+
|
|
5
|
+
# Cards
|
|
6
|
+
|
|
7
|
+
Cards are interactive elements that can be used to display an action that a user can take.
|
|
8
|
+
|
|
9
|
+
<Preview>
|
|
10
|
+
<iframe
|
|
11
|
+
width="100%"
|
|
12
|
+
height="450"
|
|
13
|
+
src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FMKs4cbojdVOBKUxv7okb93%2FDirty-Swan-Pattern-Library%3Fnode-id%3D358%253A19"
|
|
14
|
+
allowFullScreen
|
|
15
|
+
/>
|
|
16
|
+
</Preview>
|
|
17
|
+
|
|
18
|
+
# Models
|
|
19
|
+
|
|
20
|
+
## Card Size (xsmall, small, medium, big)
|
|
21
|
+
|
|
22
|
+
The card size can be set with the following properties: `xsmall`, `small`, `medium`, `big`. Depending on the type of card this setting
|
|
23
|
+
affects the font size of the title and card padding.
|
|
24
|
+
|
|
25
|
+
## Card State
|
|
26
|
+
|
|
27
|
+
The card state is an string literral type with the following properties:
|
|
28
|
+
|
|
29
|
+
| state | description |
|
|
30
|
+
| ------------ | -------------------------------------------------------- |
|
|
31
|
+
| `actionable` | User can hover on the card, the cursor is set as pointer |
|
|
32
|
+
| `static` | Card is displayed as is, no hovering. |
|
|
33
|
+
| `muted` | Card is displayed faded, no hovering. |
|
|
34
|
+
|
|
35
|
+
## Icon
|
|
36
|
+
|
|
37
|
+
The icon object is defined with the following poperties
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
export interface Icon {
|
|
41
|
+
src: string; // source of the image
|
|
42
|
+
alt: string; // alternate text if the image can't be displayed
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
import CardButton from '.';
|
|
4
|
+
|
|
5
|
+
<Meta title="JSX/Cards/Card Button" />
|
|
6
|
+
|
|
7
|
+
# Card Button
|
|
8
|
+
|
|
9
|
+
| attribute | unit | description | default value | required |
|
|
10
|
+
| ----------- | ------------------------ | ---------------------------------------------- | ------------- | ----------------------------------- |
|
|
11
|
+
| title | string | Title text that needs to be displayed | n/a | true |
|
|
12
|
+
| description | string / ReactNode (JSX) | Description text that is displayed under title | n/a | true |
|
|
13
|
+
| disabled | boolean | Disabled state of the button | false | false |
|
|
14
|
+
| className | string | Class name for most top parent element | n/a | false |
|
|
15
|
+
| onClick | function | Function that runs on click of the button | n/a | true (false if href prop exists) |
|
|
16
|
+
| href | string | Redirect URL on click of the button | n/a | true (false if onClick prop exists) |
|
|
17
|
+
|
|
18
|
+
<Preview>
|
|
19
|
+
<>
|
|
20
|
+
<h4 className="p-h4">Normal state</h4>
|
|
21
|
+
<br />
|
|
22
|
+
<CardButton
|
|
23
|
+
title="Name"
|
|
24
|
+
description="Seungha Kong"
|
|
25
|
+
onClick={() => console.log('This is a button component')}
|
|
26
|
+
/>
|
|
27
|
+
<br />
|
|
28
|
+
<br />
|
|
29
|
+
<h4 className="p-h4">Long description</h4>
|
|
30
|
+
<br />
|
|
31
|
+
<CardButton
|
|
32
|
+
title="Risky Sports"
|
|
33
|
+
description="Mountain or rock climbing, Bouldering, Martial arts, Extreme sports, Scuba diving, Sky diving, Bungee jumping, Mountain or rock climbing, Bouldering, Martial arts,"
|
|
34
|
+
onClick={() => console.log('This is a button component')}
|
|
35
|
+
/>
|
|
36
|
+
<br />
|
|
37
|
+
<br />
|
|
38
|
+
<h4 className="p-h4">Disabled state</h4>
|
|
39
|
+
<br />
|
|
40
|
+
<CardButton
|
|
41
|
+
title="Address"
|
|
42
|
+
description="Lohmühlenstraße 65 10557 Berlin"
|
|
43
|
+
onClick={() => console.log('This is a button component')}
|
|
44
|
+
disabled
|
|
45
|
+
/>
|
|
46
|
+
</>
|
|
47
|
+
</Preview>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FormEvent, createElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './style.module.scss';
|
|
4
|
+
import { chevronRight } from '../icons';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string | ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type ActionProps =
|
|
14
|
+
| { href: string; onClick?: (e: FormEvent) => void }
|
|
15
|
+
| { href?: string; onClick: (e: FormEvent) => void };
|
|
16
|
+
|
|
17
|
+
const CardContent = ({
|
|
18
|
+
title,
|
|
19
|
+
description,
|
|
20
|
+
}: {
|
|
21
|
+
title: string;
|
|
22
|
+
description: string | ReactNode;
|
|
23
|
+
}) => (
|
|
24
|
+
<>
|
|
25
|
+
<div>
|
|
26
|
+
<div className="p-p--small">{title}</div>
|
|
27
|
+
{typeof description === 'string' ? (
|
|
28
|
+
<div className="tc-primary-500 p-p">{description}</div>
|
|
29
|
+
) : (
|
|
30
|
+
description
|
|
31
|
+
)}
|
|
32
|
+
</div>
|
|
33
|
+
<img {...chevronRight} alt="Expander icon" />
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const CardButton = ({
|
|
38
|
+
title,
|
|
39
|
+
description,
|
|
40
|
+
disabled = false,
|
|
41
|
+
onClick,
|
|
42
|
+
href,
|
|
43
|
+
className,
|
|
44
|
+
}: Props & ActionProps) => {
|
|
45
|
+
const component = href ? 'a' : 'button';
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
{createElement(component, {
|
|
49
|
+
className: `c-pointer ta-left w100 ${styles.container} ${
|
|
50
|
+
className ?? ''
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
children: <CardContent title={title} description={description} />,
|
|
54
|
+
disabled,
|
|
55
|
+
...(component === 'a' ? { href } : { onClick }),
|
|
56
|
+
})}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default CardButton;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@use "../../../scss/public/colors" as *;
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
background-color: white;
|
|
5
|
+
|
|
6
|
+
padding: 8px 16px;
|
|
7
|
+
|
|
8
|
+
box-shadow: 0px 2px 20px rgba(97, 96, 162, 0.07);
|
|
9
|
+
|
|
10
|
+
border-radius: 8px;
|
|
11
|
+
border: 2px solid white;
|
|
12
|
+
|
|
13
|
+
transition: border 0.2s ease-in-out;
|
|
14
|
+
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
align-items: center;
|
|
18
|
+
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
border: 2px solid $ds-primary-300;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&[disabled] {
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
opacity: 0.25;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:focus {
|
|
31
|
+
border: 2px solid $ds-primary-500;
|
|
32
|
+
}
|
|
33
|
+
}
|