@popsure/dirty-swan 0.26.10 → 0.26.11
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/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/_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 +52 -0
- package/src/lib/scss/private/base/_index.scss +9 -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/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 +173 -0
- package/src/lib/scss/private/base/style.module.scss +42 -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 +125 -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 +285 -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,62 @@
|
|
|
1
|
+
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
import Input from '.';
|
|
4
|
+
|
|
5
|
+
<Meta title="JSX/Inputs/Input" />
|
|
6
|
+
|
|
7
|
+
## Input
|
|
8
|
+
|
|
9
|
+
The default input component is used to gather informations from the user.
|
|
10
|
+
|
|
11
|
+
You are looking at the JSX definition of the Input component, if you want you can use the [css alternative](?path=/story/css-components-input--page)
|
|
12
|
+
|
|
13
|
+
<Preview>
|
|
14
|
+
<>
|
|
15
|
+
<h1 className="p-h1">Without placeholder</h1>
|
|
16
|
+
<h4 className="p-h4 mt24">Empty</h4>
|
|
17
|
+
<Input className="wmx5 mt8" />
|
|
18
|
+
<h4 className="p-h4 mt24">Filled</h4>
|
|
19
|
+
<Input className="wmx5 mt8" value="Lorem ipsum" />
|
|
20
|
+
<h4 className="p-h4 mt24">Disabled</h4>
|
|
21
|
+
<Input className="wmx5 mt8" value="Lorem ipsum" disabled={true} />
|
|
22
|
+
<h4 className="p-h4 mt24">Error</h4>
|
|
23
|
+
<Input
|
|
24
|
+
className="wmx5 mt8"
|
|
25
|
+
value="Lorem ipsum"
|
|
26
|
+
error="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
|
27
|
+
/>
|
|
28
|
+
<h1 className="p-h1 mt32">With placeholder</h1>
|
|
29
|
+
<h4 className="p-h4 mt24">Empty</h4>
|
|
30
|
+
<Input className="wmx5 mt8" placeholder="Email" />
|
|
31
|
+
<h4 className="p-h4 mt24">Filled</h4>
|
|
32
|
+
<Input
|
|
33
|
+
className="wmx5 mt8"
|
|
34
|
+
value="jane.doe@feather-insurance.com"
|
|
35
|
+
placeholder="Email"
|
|
36
|
+
/>
|
|
37
|
+
<h4 className="p-h4 mt24">Error</h4>
|
|
38
|
+
<Input
|
|
39
|
+
className="wmx5 mt8"
|
|
40
|
+
value="jane.doe@feather-insurance.com"
|
|
41
|
+
placeholder="Email"
|
|
42
|
+
error="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
|
43
|
+
/>
|
|
44
|
+
<h1 className="p-h1 mt32">With prefix</h1>
|
|
45
|
+
<h4 className="p-h4 mt24">Empty</h4>
|
|
46
|
+
<Input className="wmx5 mt8" prefix="€" />
|
|
47
|
+
<h4 className="p-h4 mt24">Filled</h4>
|
|
48
|
+
<Input className="wmx5 mt8" value="100" prefix="€" />
|
|
49
|
+
<h4 className="p-h4 mt24">Empty with placeholder</h4>
|
|
50
|
+
<Input className="wmx5 mt8" placeholder="amount" prefix="€" />
|
|
51
|
+
<h4 className="p-h4 mt24">Filled with placeholder</h4>
|
|
52
|
+
<Input className="wmx5 mt8" placeholder="amount" value="100" prefix="€" />
|
|
53
|
+
<h4 className="p-h4 mt24">Error</h4>
|
|
54
|
+
<Input
|
|
55
|
+
className="wmx5 mt8"
|
|
56
|
+
placeholder="amount"
|
|
57
|
+
value="100"
|
|
58
|
+
prefix="€"
|
|
59
|
+
error="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac hendrerit justo. Nunc nibh ex, vulputate ac leo id, feugiat rhoncus purus."
|
|
60
|
+
/>
|
|
61
|
+
</>
|
|
62
|
+
</Preview>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './style.module.scss';
|
|
4
|
+
|
|
5
|
+
// Something weird is going on with enterKeyHint that makes it a required field under certain circumstances. The & Omit<…> and & Pick<…> is a hacky way to go around that.
|
|
6
|
+
export type InputProps = {
|
|
7
|
+
error?: string;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
} & Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
|
|
10
|
+
Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>>;
|
|
11
|
+
|
|
12
|
+
export default React.forwardRef(
|
|
13
|
+
(
|
|
14
|
+
{ className, placeholder, prefix, error, ...props }: InputProps,
|
|
15
|
+
ref?: React.ForwardedRef<HTMLInputElement>
|
|
16
|
+
) => (
|
|
17
|
+
<div className={`${styles.container} ${className ?? ''}`}>
|
|
18
|
+
<input
|
|
19
|
+
data-testid="ds-input-input"
|
|
20
|
+
type="text"
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={`${error ? 'p-input--error' : 'p-input'} ${
|
|
23
|
+
placeholder && placeholder?.length > 0
|
|
24
|
+
? styles.input
|
|
25
|
+
: styles['input--no-placeholder']
|
|
26
|
+
} ${prefix ? styles['input--with-prefix'] : ''}`}
|
|
27
|
+
placeholder=" "
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
{prefix && (
|
|
31
|
+
<span
|
|
32
|
+
className={`${styles.prefix} ${
|
|
33
|
+
error ? styles['prefix--with-error'] : ''
|
|
34
|
+
}`}
|
|
35
|
+
>
|
|
36
|
+
{prefix}
|
|
37
|
+
</span>
|
|
38
|
+
)}
|
|
39
|
+
<span
|
|
40
|
+
className={`${styles.placeholder} ${
|
|
41
|
+
prefix ? styles['placeholder--with-prefix'] : ''
|
|
42
|
+
} ${error ? styles['placeholder--with-error'] : ''}`}
|
|
43
|
+
>
|
|
44
|
+
{placeholder}
|
|
45
|
+
</span>
|
|
46
|
+
{error && (
|
|
47
|
+
<p className={`p-p--small tc-red-500 w100 ${styles.error}`}>{error}</p>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.prefix {
|
|
6
|
+
position: absolute;
|
|
7
|
+
|
|
8
|
+
left: 16px;
|
|
9
|
+
top: 50%;
|
|
10
|
+
|
|
11
|
+
transform: translateY(-50%);
|
|
12
|
+
|
|
13
|
+
color: var(--ds-grey-300);
|
|
14
|
+
|
|
15
|
+
transition: 0.3s top;
|
|
16
|
+
|
|
17
|
+
&--with-error {
|
|
18
|
+
color: var(--ds-red-500);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.input:not(:placeholder-shown) ~ .placeholder,
|
|
23
|
+
.input:focus ~ .placeholder {
|
|
24
|
+
top: 7px;
|
|
25
|
+
left: 16px;
|
|
26
|
+
|
|
27
|
+
transform: translateY(0);
|
|
28
|
+
|
|
29
|
+
font-size: 10px;
|
|
30
|
+
line-height: 12px;
|
|
31
|
+
|
|
32
|
+
opacity: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.input:focus ~ .placeholder {
|
|
36
|
+
color: var(--ds-primary-500);
|
|
37
|
+
|
|
38
|
+
&--with-error {
|
|
39
|
+
color: var(--ds-red-500);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.input:focus ~ .prefix {
|
|
44
|
+
color: var(--ds-primary-500);
|
|
45
|
+
|
|
46
|
+
&--with-error {
|
|
47
|
+
color: var(--ds-red-500);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.input:not(:placeholder-shown) ~ .prefix,
|
|
52
|
+
.input:focus ~ .prefix {
|
|
53
|
+
top: 28px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.input {
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
padding-top: 9px;
|
|
59
|
+
|
|
60
|
+
font-family: inherit;
|
|
61
|
+
|
|
62
|
+
&--no-placeholder {
|
|
63
|
+
padding-top: 0px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&--with-prefix {
|
|
67
|
+
padding-left: 32px !important;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.placeholder {
|
|
72
|
+
position: absolute;
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
|
|
75
|
+
left: 16px;
|
|
76
|
+
top: 50%;
|
|
77
|
+
|
|
78
|
+
transform: translateY(-50%);
|
|
79
|
+
transition: 0.3s ease all;
|
|
80
|
+
|
|
81
|
+
color: var(--ds-grey-300);
|
|
82
|
+
|
|
83
|
+
&--with-prefix {
|
|
84
|
+
left: 32px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&--with-error {
|
|
88
|
+
color: var(--ds-red-500);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.error {
|
|
93
|
+
margin-top: 4px;
|
|
94
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M18 6L6 18" stroke="#26262E" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
3
|
+
<path d="M6 6L18 18" stroke="#26262E" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Props } from '..';
|
|
4
|
+
import styles from './style.module.scss';
|
|
5
|
+
|
|
6
|
+
import imageClose from './img/close.svg';
|
|
7
|
+
import useOnClose from '../hooks/useOnClose';
|
|
8
|
+
|
|
9
|
+
export default ({
|
|
10
|
+
title,
|
|
11
|
+
isOpen,
|
|
12
|
+
children,
|
|
13
|
+
onClose,
|
|
14
|
+
className = '',
|
|
15
|
+
dismissible = true,
|
|
16
|
+
}: Props) => {
|
|
17
|
+
const [containerXOffset, setContainerXOffset] = useState(0);
|
|
18
|
+
const { isClosing, handleContainerClick, handleOnClose } = useOnClose(
|
|
19
|
+
onClose,
|
|
20
|
+
isOpen,
|
|
21
|
+
dismissible
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const containerRef = useCallback((node: HTMLDivElement) => {
|
|
25
|
+
if (node !== null) {
|
|
26
|
+
setContainerXOffset(
|
|
27
|
+
Math.max(
|
|
28
|
+
window.innerHeight * 0.1,
|
|
29
|
+
window.innerHeight - node.getBoundingClientRect().height
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
if (!isOpen) {
|
|
36
|
+
return <></>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
className={isClosing ? styles['overlay--close'] : styles.overlay}
|
|
42
|
+
onClick={handleOnClose}
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
className={`${
|
|
46
|
+
isClosing ? styles['container--close'] : styles.container
|
|
47
|
+
} ${className}`}
|
|
48
|
+
ref={containerRef}
|
|
49
|
+
style={{ top: `${containerXOffset}px` }}
|
|
50
|
+
onClick={handleContainerClick}
|
|
51
|
+
>
|
|
52
|
+
<div className={styles.header}>
|
|
53
|
+
<div className={`p-h4 ${styles.title}`}>{title}</div>
|
|
54
|
+
{dismissible && (
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
className={styles.close}
|
|
58
|
+
onClick={handleOnClose}
|
|
59
|
+
>
|
|
60
|
+
<img src={imageClose} alt="Close" />
|
|
61
|
+
</button>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
<div className={styles.content}>{children}</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
@keyframes fade-in {
|
|
2
|
+
0% {
|
|
3
|
+
background-color: rgba($color: #000000, $alpha: 0);
|
|
4
|
+
}
|
|
5
|
+
100% {
|
|
6
|
+
background-color: rgba($color: #000000, $alpha: 0.3);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@keyframes fade-out {
|
|
11
|
+
from {
|
|
12
|
+
background-color: rgba($color: #000000, $alpha: 0.3);
|
|
13
|
+
}
|
|
14
|
+
to {
|
|
15
|
+
background-color: rgba($color: #000000, $alpha: 0);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@keyframes appear-in {
|
|
20
|
+
0% {
|
|
21
|
+
transform: translateY(100%);
|
|
22
|
+
}
|
|
23
|
+
10% {
|
|
24
|
+
}
|
|
25
|
+
80% {
|
|
26
|
+
transform: translateY(-2%);
|
|
27
|
+
}
|
|
28
|
+
100% {
|
|
29
|
+
transform: translateY(0);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@keyframes disappear-out {
|
|
34
|
+
0% {
|
|
35
|
+
transform: translateY(0);
|
|
36
|
+
}
|
|
37
|
+
100% {
|
|
38
|
+
transform: translateY(100%);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.close {
|
|
43
|
+
border: none;
|
|
44
|
+
background-color: transparent;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.overlay {
|
|
49
|
+
position: fixed;
|
|
50
|
+
|
|
51
|
+
z-index: 100;
|
|
52
|
+
|
|
53
|
+
overflow: auto;
|
|
54
|
+
|
|
55
|
+
top: 0;
|
|
56
|
+
bottom: 0;
|
|
57
|
+
left: 0;
|
|
58
|
+
right: 0;
|
|
59
|
+
|
|
60
|
+
animation: fade-in 0.3s both;
|
|
61
|
+
|
|
62
|
+
&--close {
|
|
63
|
+
@extend .overlay;
|
|
64
|
+
animation-delay: 0.1s;
|
|
65
|
+
animation: fade-out 0.3s both;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.container {
|
|
70
|
+
position: relative;
|
|
71
|
+
|
|
72
|
+
background-color: white;
|
|
73
|
+
|
|
74
|
+
border-top-left-radius: 8px;
|
|
75
|
+
border-top-right-radius: 8px;
|
|
76
|
+
|
|
77
|
+
width: 100%;
|
|
78
|
+
|
|
79
|
+
animation-name: appear-in;
|
|
80
|
+
animation-duration: 0.4s;
|
|
81
|
+
animation-fill-mode: both;
|
|
82
|
+
animation-timing-function: ease-out;
|
|
83
|
+
|
|
84
|
+
top: 0;
|
|
85
|
+
|
|
86
|
+
&--close {
|
|
87
|
+
@extend .container;
|
|
88
|
+
animation-name: disappear-out;
|
|
89
|
+
animation-duration: 0.4s;
|
|
90
|
+
animation-delay: 0s;
|
|
91
|
+
animation-fill-mode: both;
|
|
92
|
+
animation-timing-function: ease-out;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.header {
|
|
97
|
+
height: 60px;
|
|
98
|
+
|
|
99
|
+
display: flex;
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
align-items: center;
|
|
102
|
+
|
|
103
|
+
padding: 0 16px;
|
|
104
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Props, RegularModal } from '..';
|
|
4
|
+
import BottomModal from '../bottomModal';
|
|
5
|
+
|
|
6
|
+
import styles from './style.module.scss';
|
|
7
|
+
|
|
8
|
+
export default ({ isOpen, ...props }: Props) => {
|
|
9
|
+
const mobileRef = useRef<HTMLDivElement>(null);
|
|
10
|
+
const [visibleSize, setVisibleSize] = useState<'desktop' | 'mobile'>(
|
|
11
|
+
'desktop'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const handleResize = () => {
|
|
15
|
+
setVisibleSize(
|
|
16
|
+
mobileRef.current !== null &&
|
|
17
|
+
window.getComputedStyle(mobileRef.current).display !== 'none'
|
|
18
|
+
? 'mobile'
|
|
19
|
+
: 'desktop'
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
window.addEventListener('resize', handleResize);
|
|
25
|
+
handleResize();
|
|
26
|
+
return () => {
|
|
27
|
+
window.removeEventListener('resize', handleResize);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<div className={styles.mobile} ref={mobileRef}>
|
|
34
|
+
{visibleSize === 'mobile' && <BottomModal {...props} isOpen={isOpen} />}
|
|
35
|
+
</div>
|
|
36
|
+
{visibleSize === 'desktop' && (
|
|
37
|
+
<div className={styles.desktop}>
|
|
38
|
+
<RegularModal {...props} isOpen={isOpen} />
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const useOnClose = (
|
|
4
|
+
onClose: () => void,
|
|
5
|
+
isOpen: boolean,
|
|
6
|
+
dismissable: boolean
|
|
7
|
+
) => {
|
|
8
|
+
const [isClosing, setIsClosing] = useState(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
window.addEventListener('keydown', handleEscKey);
|
|
12
|
+
|
|
13
|
+
return () => {
|
|
14
|
+
window.removeEventListener('keydown', handleEscKey);
|
|
15
|
+
};
|
|
16
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
document.body.style.overflow = isOpen ? 'hidden' : 'auto';
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
document.body.style.overflow = 'auto';
|
|
23
|
+
};
|
|
24
|
+
}, [isOpen]);
|
|
25
|
+
|
|
26
|
+
const handleOnClose = () => {
|
|
27
|
+
if (!dismissable) return null;
|
|
28
|
+
|
|
29
|
+
setIsClosing(true);
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
onClose();
|
|
32
|
+
setIsClosing(false);
|
|
33
|
+
}, 300);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleEscKey = (e: KeyboardEvent) => {
|
|
37
|
+
if (e.code !== 'Escape') return;
|
|
38
|
+
|
|
39
|
+
handleOnClose();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleContainerClick = (
|
|
43
|
+
e: React.MouseEvent<HTMLDivElement, MouseEvent>
|
|
44
|
+
) => {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return { isClosing, handleContainerClick, handleOnClose };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default useOnClose;
|