@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.
Files changed (241) hide show
  1. package/dist/index.css +63 -1
  2. package/dist/index.css.map +1 -1
  3. package/dist/lib/scss/private/base/_border_radius.scss +15 -0
  4. package/dist/lib/scss/private/base/_grid.scss +8 -0
  5. package/dist/lib/scss/private/base/_index.scss +1 -0
  6. package/dist/lib/scss/private/base/style.module.scss +10 -0
  7. package/dist/lib/scss/private/components/_buttons.scss +1 -1
  8. package/dist/lib/scss/public/colors/default.scss +2 -0
  9. package/dist/lib/scss/public/demo.tsx +13 -1
  10. package/package.json +2 -1
  11. package/src/App.tsx +50 -0
  12. package/src/bin/index.ts +71 -0
  13. package/src/bin/tsconfig.json +13 -0
  14. package/src/bin/util/index.test.ts +85 -0
  15. package/src/bin/util/index.ts +132 -0
  16. package/src/bin/util/test/data.json +13 -0
  17. package/src/colors.scss +1 -0
  18. package/src/font-weight.scss +1 -0
  19. package/src/grid.scss +1 -0
  20. package/src/index.tsx +37 -0
  21. package/src/intro.stories.mdx +41 -0
  22. package/src/lib/components/autocompleteAddress/demo.tsx +38 -0
  23. package/src/lib/components/autocompleteAddress/index.stories.mdx +44 -0
  24. package/src/lib/components/autocompleteAddress/index.tsx +316 -0
  25. package/src/lib/components/autocompleteAddress/mapStyle.ts +187 -0
  26. package/src/lib/components/autocompleteAddress/style.module.scss +82 -0
  27. package/src/lib/components/autocompleteAddress/util/index.test.ts +51 -0
  28. package/src/lib/components/autocompleteAddress/util/index.ts +55 -0
  29. package/src/lib/components/button/icons/index.ts +14 -0
  30. package/src/lib/components/button/icons/send-purple.svg +4 -0
  31. package/src/lib/components/button/icons/send-white.svg +4 -0
  32. package/src/lib/components/button/index.stories.mdx +121 -0
  33. package/src/lib/components/button/index.tsx +64 -0
  34. package/src/lib/components/button/styles.module.scss +5 -0
  35. package/src/lib/components/cards/a.stories.mdx +44 -0
  36. package/src/lib/components/cards/cardButton/index.stories.mdx +47 -0
  37. package/src/lib/components/cards/cardButton/index.tsx +61 -0
  38. package/src/lib/components/cards/cardButton/style.module.scss +33 -0
  39. package/src/lib/components/cards/cardWithLeftIcon/index.stories.mdx +103 -0
  40. package/src/lib/components/cards/cardWithLeftIcon/index.tsx +87 -0
  41. package/src/lib/components/cards/cardWithLeftIcon/style.module.scss +23 -0
  42. package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +105 -0
  43. package/src/lib/components/cards/cardWithTopIcon/index.tsx +60 -0
  44. package/src/lib/components/cards/cardWithTopIcon/style.module.scss +10 -0
  45. package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.mdx +101 -0
  46. package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +72 -0
  47. package/src/lib/components/cards/cardWithTopLeftIcon/style.module.scss +21 -0
  48. package/src/lib/components/cards/icons/arrow-right.svg +4 -0
  49. package/src/lib/components/cards/icons/chevron-right.svg +3 -0
  50. package/src/lib/components/cards/icons/feather-logo.svg +10 -0
  51. package/src/lib/components/cards/icons/index.ts +36 -0
  52. package/src/lib/components/cards/icons/info.svg +12 -0
  53. package/src/lib/components/cards/index.test.ts +37 -0
  54. package/src/lib/components/cards/index.tsx +57 -0
  55. package/src/lib/components/cards/infoCard/index.stories.mdx +61 -0
  56. package/src/lib/components/cards/infoCard/index.tsx +47 -0
  57. package/src/lib/components/cards/infoCard/style.module.scss +53 -0
  58. package/src/lib/components/chip/icons/remove-button-highlighted.svg +4 -0
  59. package/src/lib/components/chip/icons/remove-button.svg +4 -0
  60. package/src/lib/components/chip/index.stories.mdx +101 -0
  61. package/src/lib/components/chip/index.tsx +38 -0
  62. package/src/lib/components/chip/style.module.scss +54 -0
  63. package/src/lib/components/comparisonTable/components/Chevron.tsx +19 -0
  64. package/src/lib/components/comparisonTable/components/Row/index.tsx +68 -0
  65. package/src/lib/components/comparisonTable/components/Row/style.module.scss +114 -0
  66. package/src/lib/components/comparisonTable/components/TableArrows/Arrow.tsx +19 -0
  67. package/src/lib/components/comparisonTable/components/TableArrows/index.tsx +52 -0
  68. package/src/lib/components/comparisonTable/components/TableArrows/style.module.scss +53 -0
  69. package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +37 -0
  70. package/src/lib/components/comparisonTable/components/TableInfoButton/style.module.scss +30 -0
  71. package/src/lib/components/comparisonTable/components/TableRating/StarIcon.tsx +13 -0
  72. package/src/lib/components/comparisonTable/components/TableRating/ZapIcon.tsx +17 -0
  73. package/src/lib/components/comparisonTable/components/TableRating/index.tsx +45 -0
  74. package/src/lib/components/comparisonTable/components/TableRating/style.module.scss +13 -0
  75. package/src/lib/components/comparisonTable/components/TableRowHeader/index.tsx +35 -0
  76. package/src/lib/components/comparisonTable/components/TableRowHeader/style.module.scss +3 -0
  77. package/src/lib/components/comparisonTable/components/TableTrueFalse.tsx +40 -0
  78. package/src/lib/components/comparisonTable/hooks/useActiveTableArrows.ts +63 -0
  79. package/src/lib/components/comparisonTable/index.stories.mdx +254 -0
  80. package/src/lib/components/comparisonTable/index.tsx +211 -0
  81. package/src/lib/components/comparisonTable/style.module.scss +104 -0
  82. package/src/lib/components/dateSelector/datepicker.scss +406 -0
  83. package/src/lib/components/dateSelector/icons/calendar.svg +6 -0
  84. package/src/lib/components/dateSelector/icons/chevron-left.svg +3 -0
  85. package/src/lib/components/dateSelector/icons/chevron-right.svg +3 -0
  86. package/src/lib/components/dateSelector/index.stories.mdx +62 -0
  87. package/src/lib/components/dateSelector/index.test.ts +33 -0
  88. package/src/lib/components/dateSelector/index.tsx +247 -0
  89. package/src/lib/components/dateSelector/style.module.scss +77 -0
  90. package/src/lib/components/downloadButton/icons/check.svg +3 -0
  91. package/src/lib/components/downloadButton/icons/download.svg +5 -0
  92. package/src/lib/components/downloadButton/index.stories.mdx +59 -0
  93. package/src/lib/components/downloadButton/index.tsx +67 -0
  94. package/src/lib/components/downloadButton/style.module.scss +19 -0
  95. package/src/lib/components/downloadRing/icons/check-outside-circle.tsx +26 -0
  96. package/src/lib/components/downloadRing/icons/download-cloud.tsx +18 -0
  97. package/src/lib/components/downloadRing/icons/style.module.scss +7 -0
  98. package/src/lib/components/downloadRing/index.stories.mdx +35 -0
  99. package/src/lib/components/downloadRing/index.tsx +79 -0
  100. package/src/lib/components/downloadRing/style.module.scss +66 -0
  101. package/src/lib/components/dropzone/images/error.tsx +18 -0
  102. package/src/lib/components/dropzone/images/file.tsx +26 -0
  103. package/src/lib/components/dropzone/images/style.module.scss +7 -0
  104. package/src/lib/components/dropzone/images/upload-complete.tsx +24 -0
  105. package/src/lib/components/dropzone/images/upload.tsx +18 -0
  106. package/src/lib/components/dropzone/index.stories.mdx +44 -0
  107. package/src/lib/components/dropzone/index.tsx +152 -0
  108. package/src/lib/components/dropzone/style.module.scss +90 -0
  109. package/src/lib/components/input/a.stories.mdx +28 -0
  110. package/src/lib/components/input/autoSuggestInput/index.stories.mdx +137 -0
  111. package/src/lib/components/input/autoSuggestInput/index.tsx +81 -0
  112. package/src/lib/components/input/autoSuggestInput/style.module.scss +71 -0
  113. package/src/lib/components/input/autoSuggestMultiSelect/index.stories.mdx +115 -0
  114. package/src/lib/components/input/autoSuggestMultiSelect/index.tsx +75 -0
  115. package/src/lib/components/input/autoSuggestMultiSelect/style.module.scss +4 -0
  116. package/src/lib/components/input/currency/format/index.test.ts +49 -0
  117. package/src/lib/components/input/currency/format/index.ts +15 -0
  118. package/src/lib/components/input/currency/index.stories.mdx +25 -0
  119. package/src/lib/components/input/currency/index.test.tsx +56 -0
  120. package/src/lib/components/input/currency/index.tsx +53 -0
  121. package/src/lib/components/input/iban/formatIban/index.test.ts +11 -0
  122. package/src/lib/components/input/iban/formatIban/index.ts +22 -0
  123. package/src/lib/components/input/iban/index.stories.mdx +21 -0
  124. package/src/lib/components/input/iban/index.tsx +20 -0
  125. package/src/lib/components/input/index.stories.mdx +62 -0
  126. package/src/lib/components/input/index.tsx +51 -0
  127. package/src/lib/components/input/style.module.scss +94 -0
  128. package/src/lib/components/modal/bottomModal/img/close.svg +4 -0
  129. package/src/lib/components/modal/bottomModal/index.tsx +68 -0
  130. package/src/lib/components/modal/bottomModal/style.module.scss +104 -0
  131. package/src/lib/components/modal/bottomOrRegularModal/index.tsx +43 -0
  132. package/src/lib/components/modal/bottomOrRegularModal/style.module.scss +16 -0
  133. package/src/lib/components/modal/hooks/useOnClose.ts +51 -0
  134. package/src/lib/components/modal/index.stories.mdx +316 -0
  135. package/src/lib/components/modal/index.ts +14 -0
  136. package/src/lib/components/modal/regularModal/img/close.svg +4 -0
  137. package/src/lib/components/modal/regularModal/index.tsx +55 -0
  138. package/src/lib/components/modal/regularModal/style.module.scss +106 -0
  139. package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +138 -0
  140. package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +101 -0
  141. package/src/lib/components/multiDropzone/icons/bmp-complete.svg +10 -0
  142. package/src/lib/components/multiDropzone/icons/bmp.svg +10 -0
  143. package/src/lib/components/multiDropzone/icons/doc-complete.svg +11 -0
  144. package/src/lib/components/multiDropzone/icons/doc.svg +11 -0
  145. package/src/lib/components/multiDropzone/icons/docx-complete.svg +12 -0
  146. package/src/lib/components/multiDropzone/icons/docx.svg +12 -0
  147. package/src/lib/components/multiDropzone/icons/eye.svg +4 -0
  148. package/src/lib/components/multiDropzone/icons/generic-complete.svg +4 -0
  149. package/src/lib/components/multiDropzone/icons/generic-error.svg +7 -0
  150. package/src/lib/components/multiDropzone/icons/generic.svg +4 -0
  151. package/src/lib/components/multiDropzone/icons/heic-complete.svg +11 -0
  152. package/src/lib/components/multiDropzone/icons/heic.svg +11 -0
  153. package/src/lib/components/multiDropzone/icons/index.ts +51 -0
  154. package/src/lib/components/multiDropzone/icons/jpeg-complete.svg +11 -0
  155. package/src/lib/components/multiDropzone/icons/jpeg.svg +11 -0
  156. package/src/lib/components/multiDropzone/icons/jpg-complete.svg +10 -0
  157. package/src/lib/components/multiDropzone/icons/jpg.svg +10 -0
  158. package/src/lib/components/multiDropzone/icons/pdf-complete.svg +8 -0
  159. package/src/lib/components/multiDropzone/icons/pdf.svg +8 -0
  160. package/src/lib/components/multiDropzone/icons/png-complete.svg +10 -0
  161. package/src/lib/components/multiDropzone/icons/png.svg +10 -0
  162. package/src/lib/components/multiDropzone/icons/trash.svg +6 -0
  163. package/src/lib/components/multiDropzone/icons/upload.svg +5 -0
  164. package/src/lib/components/multiDropzone/index.stories.mdx +91 -0
  165. package/src/lib/components/multiDropzone/index.tsx +99 -0
  166. package/src/lib/components/multiDropzone/style.module.scss +32 -0
  167. package/src/lib/components/segmentedControl/index.stories.mdx +47 -0
  168. package/src/lib/components/segmentedControl/index.tsx +105 -0
  169. package/src/lib/components/segmentedControl/style.module.scss +36 -0
  170. package/src/lib/components/signaturePad/img/reset.svg +4 -0
  171. package/src/lib/components/signaturePad/img/sign.svg +3 -0
  172. package/src/lib/components/signaturePad/index.stories.mdx +17 -0
  173. package/src/lib/components/signaturePad/index.tsx +96 -0
  174. package/src/lib/components/signaturePad/style.module.scss +90 -0
  175. package/src/lib/index.tsx +71 -0
  176. package/src/lib/models/autoSuggestInput/index.ts +4 -0
  177. package/src/lib/models/download.ts +1 -0
  178. package/src/lib/models/downloadRing/index.ts +6 -0
  179. package/src/lib/scss/index.scss +22 -0
  180. package/src/lib/scss/private/_reset.scss +149 -0
  181. package/src/lib/scss/private/base/_border_radius.scss +15 -0
  182. package/src/lib/scss/private/base/_colors.scss +19 -0
  183. package/src/lib/scss/private/base/_cursors.scss +31 -0
  184. package/src/lib/scss/private/base/_display.scss +35 -0
  185. package/src/lib/scss/private/base/_grid.scss +60 -0
  186. package/src/lib/scss/private/base/_index.scss +10 -0
  187. package/src/lib/scss/private/base/_shadows.scss +2 -0
  188. package/src/lib/scss/private/base/_spacing.scss +89 -0
  189. package/src/lib/scss/private/base/_typography.scss +128 -0
  190. package/src/lib/scss/private/base/_width_and_height.scss +25 -0
  191. package/src/lib/scss/private/base/border_radius.stories.mdx +43 -0
  192. package/src/lib/scss/private/base/cursors.stories.mdx +18 -0
  193. package/src/lib/scss/private/base/demo.tsx +119 -0
  194. package/src/lib/scss/private/base/display.stories.mdx +19 -0
  195. package/src/lib/scss/private/base/flex/_flex.scss +63 -0
  196. package/src/lib/scss/private/base/flex/flex.stories.mdx +139 -0
  197. package/src/lib/scss/private/base/flex/style.module.scss +24 -0
  198. package/src/lib/scss/private/base/spacing.stories.mdx +185 -0
  199. package/src/lib/scss/private/base/style.module.scss +52 -0
  200. package/src/lib/scss/private/base/typography.stories.mdx +71 -0
  201. package/src/lib/scss/private/base/width_and_height.stories.mdx +172 -0
  202. package/src/lib/scss/private/components/_badge.scss +41 -0
  203. package/src/lib/scss/private/components/_buttons.scss +193 -0
  204. package/src/lib/scss/private/components/_cards.scss +32 -0
  205. package/src/lib/scss/private/components/_index.scss +6 -0
  206. package/src/lib/scss/private/components/_input.scss +241 -0
  207. package/src/lib/scss/private/components/_notices.scss +39 -0
  208. package/src/lib/scss/private/components/_spinner.scss +60 -0
  209. package/src/lib/scss/private/components/assets/checkmark.svg +3 -0
  210. package/src/lib/scss/private/components/assets/icon-form-dropdown.svg +3 -0
  211. package/src/lib/scss/private/components/badge.stories.mdx +37 -0
  212. package/src/lib/scss/private/components/button.stories.mdx +107 -0
  213. package/src/lib/scss/private/components/cards.stories.mdx +35 -0
  214. package/src/lib/scss/private/components/checkbox.stories.mdx +47 -0
  215. package/src/lib/scss/private/components/input.stories.mdx +33 -0
  216. package/src/lib/scss/private/components/notices.stories.mdx +37 -0
  217. package/src/lib/scss/private/components/radio.stories.mdx +47 -0
  218. package/src/lib/scss/private/components/select.stories.mdx +17 -0
  219. package/src/lib/scss/private/components/spinner.stories.mdx +25 -0
  220. package/src/lib/scss/public/colors/_index.scss +2 -0
  221. package/src/lib/scss/public/colors/default.scss +127 -0
  222. package/src/lib/scss/public/colors/overrides.scss +0 -0
  223. package/src/lib/scss/public/colors.stories.mdx +27 -0
  224. package/src/lib/scss/public/demo.tsx +297 -0
  225. package/src/lib/scss/public/font/_index.scss +2 -0
  226. package/src/lib/scss/public/font/default.scss +3 -0
  227. package/src/lib/scss/public/font/overrides.scss +0 -0
  228. package/src/lib/scss/public/font-weight.scss +9 -0
  229. package/src/lib/scss/public/font-weight.stories.mdx +32 -0
  230. package/src/lib/scss/public/grid.scss +21 -0
  231. package/src/lib/scss/public/grid.stories.mdx +41 -0
  232. package/src/lib/scss/third-party/_google_places.scss +62 -0
  233. package/src/lib/scss/third-party/_index.scss +1 -0
  234. package/src/lib/scss/utils/_index.scss +3 -0
  235. package/src/lib/util/calendarDate/index.test.ts +32 -0
  236. package/src/lib/util/calendarDate/index.ts +30 -0
  237. package/src/lib/util/zeroFill.test.ts +15 -0
  238. package/src/lib/util/zeroFill.ts +7 -0
  239. package/src/react-app-env.d.ts +1 -0
  240. package/src/setupTests.js +8 -0
  241. package/src/theme.stories.mdx +54 -0
@@ -0,0 +1,91 @@
1
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
2
+
3
+ import MultiDropzone from '.';
4
+
5
+ <Meta title="JSX/MultiDropzone" component={MultiDropzone} />
6
+
7
+ # MultiDropzone
8
+
9
+ MultiDropzone component allows upload of multiple documents / files.
10
+
11
+ ## Examples
12
+
13
+ ### Idle state
14
+
15
+ <Preview>
16
+ <MultiDropzone
17
+ uploadedFiles={[]}
18
+ onFileSelect={() => {}}
19
+ uploading={false}
20
+ onRemoveFile={() => {}}
21
+ />
22
+ </Preview>
23
+
24
+ ### Uploading state
25
+
26
+ <Preview>
27
+ <MultiDropzone
28
+ uploadedFiles={[
29
+ {
30
+ id: '123',
31
+ type: 'pdf',
32
+ progress: '72',
33
+ name: 'test_file_name.pdf',
34
+ token: 'abc',
35
+ previewUrl: 'http://getpopsure.com/test_file_name.pdf',
36
+ },
37
+ {
38
+ id: '456',
39
+ type: 'pdf',
40
+ progress: '100',
41
+ name: 'test_file_name2.pdf',
42
+ token: 'def',
43
+ previewUrl: 'http://getpopsure.com/test_file_name2.pdf',
44
+ },
45
+ ]}
46
+ onFileSelect={() => {}}
47
+ uploading={true}
48
+ onRemoveFile={() => {}}
49
+ />
50
+ </Preview>
51
+
52
+ ### Uploaded state
53
+
54
+ <Preview>
55
+ <MultiDropzone
56
+ uploadedFiles={[
57
+ {
58
+ id: '123',
59
+ type: 'pdf',
60
+ progress: '100',
61
+ name: 'test_file_name.pdf',
62
+ token: 'abc',
63
+ previewUrl: 'http://getpopsure.com/test_file_name.pdf',
64
+ },
65
+ ]}
66
+ onFileSelect={() => {}}
67
+ uploading={false}
68
+ onRemoveFile={() => {}}
69
+ />
70
+ </Preview>
71
+
72
+ ### Error state
73
+
74
+ <Preview>
75
+ <MultiDropzone
76
+ uploadedFiles={[
77
+ {
78
+ id: '123',
79
+ type: 'pdf',
80
+ progress: '0',
81
+ name: 'test_file_name.pdf',
82
+ token: 'abc',
83
+ previewUrl: 'http://getpopsure.com/test_file_name.pdf',
84
+ error: 'File is too big!',
85
+ },
86
+ ]}
87
+ onFileSelect={() => {}}
88
+ uploading={false}
89
+ onRemoveFile={() => {}}
90
+ />
91
+ </Preview>
@@ -0,0 +1,99 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useDropzone } from 'react-dropzone';
3
+ import classnames from 'classnames';
4
+
5
+ import styles from './style.module.scss';
6
+ import icons from './icons/index'; // TODO: inline all of the svgs
7
+ import UploadFileCell from './UploadFileCell';
8
+
9
+ export type UploadStatus = 'UPLOADING' | 'COMPLETE' | 'ERROR';
10
+
11
+ export type FileType =
12
+ | 'heic'
13
+ | 'bmp'
14
+ | 'jpeg'
15
+ | 'jpg'
16
+ | 'png'
17
+ | 'doc'
18
+ | 'docx'
19
+ | 'pdf';
20
+
21
+ const getUploadStatus = (progress: number, error?: string): UploadStatus => {
22
+ if (error) {
23
+ return 'ERROR';
24
+ }
25
+
26
+ if (progress < 100) {
27
+ return 'UPLOADING';
28
+ }
29
+
30
+ return 'COMPLETE';
31
+ };
32
+
33
+ export interface UploadedFile {
34
+ id: string;
35
+ name: string;
36
+ type: FileType | string;
37
+ previewUrl?: string;
38
+ progress: number;
39
+ error?: string;
40
+ }
41
+
42
+ interface Props {
43
+ onFileSelect: (file: File) => void;
44
+ uploadedFiles: UploadedFile[];
45
+ uploading: boolean;
46
+ onRemoveFile: (id: string) => void;
47
+ }
48
+
49
+ export default ({
50
+ uploadedFiles,
51
+ onFileSelect,
52
+ uploading,
53
+ onRemoveFile,
54
+ }: Props) => {
55
+ const onDrop = useCallback(
56
+ (acceptedFiles) => {
57
+ onFileSelect(acceptedFiles[0]);
58
+ },
59
+ [onFileSelect]
60
+ );
61
+
62
+ const { getRootProps, getInputProps } = useDropzone({ onDrop });
63
+
64
+ return (
65
+ <div className={`w100 ${styles.container}`}>
66
+ <div
67
+ className={classnames(`w100 ta-center ${styles['upload-container']}`, {
68
+ [styles['upload-container-disabled']]: uploading,
69
+ })}
70
+ {...getRootProps()}
71
+ >
72
+ <input {...getInputProps()} />
73
+ <img src={icons.uploadIcon} alt="" />
74
+ <div className="p-h4 mt8">
75
+ {uploading
76
+ ? 'Please wait while uploading file...'
77
+ : 'Choose file or drag & drop'}
78
+ </div>
79
+ <div className="p-p--small tc-grey-500">Supports JPEG, PNG, PDF</div>
80
+ </div>
81
+ {uploadedFiles.length > 0 && (
82
+ <div className={`w100 mt16`}>
83
+ {uploadedFiles.map((file) => {
84
+ const uploadStatus = getUploadStatus(file.progress, file.error);
85
+ return (
86
+ <UploadFileCell
87
+ uploadStatus={uploadStatus}
88
+ file={file}
89
+ key={file.id}
90
+ onRemoveFile={onRemoveFile}
91
+ uploading={uploading}
92
+ />
93
+ );
94
+ })}
95
+ </div>
96
+ )}
97
+ </div>
98
+ );
99
+ };
@@ -0,0 +1,32 @@
1
+ @use "../../scss/public/grid" as *;
2
+
3
+ .container {
4
+ background-color: white;
5
+ padding: 24px;
6
+ box-shadow: 0px 2px 3px rgba(38, 38, 46, 0.04);
7
+ border-radius: 8px;
8
+
9
+ @include p-size-mobile {
10
+ padding: 16px;
11
+ }
12
+ }
13
+
14
+ .upload-container {
15
+ border: 1px dashed var(--ds-primary-500);
16
+ padding: 32px 0;
17
+ cursor: pointer;
18
+ border-radius: 8px;
19
+ }
20
+
21
+ .upload-container:focus {
22
+ outline: none;
23
+ }
24
+
25
+ .upload-container:hover {
26
+ background-color: var(--ds-primary-100);
27
+ transition: 0.5s ease;
28
+ }
29
+
30
+ .upload-container-disabled {
31
+ pointer-events: none;
32
+ }
@@ -0,0 +1,47 @@
1
+ import { useState } from 'react';
2
+
3
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
4
+
5
+ import SegmentedControl from '.';
6
+
7
+ <Meta title="JSX/SegmentedControl" />
8
+
9
+ # SegmentedControl
10
+
11
+ A segmented control is a linear set of two or more segments, each of which functions as a mutually exclusive button.
12
+
13
+ | attribute | unit | description | default value | required |
14
+ | ------------- | ------------------------------------------------- | ---------------------------------------------------- | ------------- | -------- |
15
+ | values | string[] OR { title: string; subtitle: string;}[] | Array containing the text that needs to be displayed | n/a | true |
16
+ | selectedIndex | number | The currently selected index | n/a | true |
17
+ | onChange | (newSelectedIndex: number) => void; | Callback when the select index changes | n/a | true |
18
+
19
+ export const SegmentedControlStory = () => {
20
+ const [selectedFirstIndex, setSelectedFirstIndex] = useState(0);
21
+ const [selectedSecondIndex, setSelectedSecondIndex] = useState(0);
22
+ return (
23
+ <Preview>
24
+ <>
25
+ <h1 className="p-h1">Single lined SegmentedControl</h1>
26
+ <SegmentedControl
27
+ className="mt8"
28
+ values={['Earth', 'Sun', 'Moon']}
29
+ selectedIndex={selectedFirstIndex}
30
+ onChange={(newIndex) => setSelectedFirstIndex(newIndex)}
31
+ />
32
+ <h1 className="p-h1 mt24">SegmentedControl with subtitle</h1>
33
+ <SegmentedControl
34
+ className="mt8"
35
+ values={[
36
+ { title: 'Basic', subtitle: '€288,65' },
37
+ { title: 'Premium', subtitle: '€288,65' },
38
+ ]}
39
+ selectedIndex={selectedSecondIndex}
40
+ onChange={(newIndex) => setSelectedSecondIndex(newIndex)}
41
+ />
42
+ </>
43
+ </Preview>
44
+ );
45
+ };
46
+
47
+ <SegmentedControlStory />
@@ -0,0 +1,105 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import styles from './style.module.scss';
3
+
4
+ interface TitleWithSubtitle {
5
+ title: string;
6
+ subtitle: string;
7
+ }
8
+
9
+ const SegmentedControl = ({
10
+ className = '',
11
+ values,
12
+ selectedIndex,
13
+ onChange,
14
+ }: {
15
+ className?: string;
16
+ values: Array<TitleWithSubtitle> | Array<string>;
17
+ selectedIndex: number;
18
+ onChange: (selectedIndex: number) => void;
19
+ }) => {
20
+ const [selectedChipBackgroundWidthLeft, setSelectedChipBackgroundWidthLeft] =
21
+ useState<{
22
+ left: number;
23
+ width: number;
24
+ }>({ left: 0, width: 0 });
25
+ const chipContainer = useRef<HTMLDivElement | null>(null);
26
+ const height = typeof values[0] === 'string' ? 48 : 66;
27
+
28
+ useEffect(() => {
29
+ const selectedChip = chipContainer.current?.children[
30
+ selectedIndex
31
+ ] as HTMLDivElement;
32
+ const left = selectedChip.offsetLeft;
33
+ const width = selectedChip.offsetWidth;
34
+ setSelectedChipBackgroundWidthLeft({ left, width });
35
+ }, [selectedIndex]);
36
+
37
+ return (
38
+ <div className={className}>
39
+ <div className={styles['background-container']}>
40
+ <div
41
+ ref={chipContainer}
42
+ className={styles['chip-container']}
43
+ style={{ height: `${height}px` }}
44
+ >
45
+ {values.map((value: TitleWithSubtitle | string, index: number) => {
46
+ return (
47
+ <div
48
+ role="button"
49
+ tabIndex={0}
50
+ onKeyDown={(e) => {
51
+ if (e.key === 'Enter') {
52
+ onChange(index);
53
+ }
54
+ }}
55
+ onClick={() => {
56
+ onChange(index);
57
+ }}
58
+ className={styles.chip}
59
+ >
60
+ {typeof value === 'string' ? (
61
+ <div
62
+ className={`p-h4 ta-center ${
63
+ selectedIndex === index ? '' : 'tc-primary-500'
64
+ }`}
65
+ >
66
+ {value}
67
+ </div>
68
+ ) : (
69
+ <>
70
+ <div
71
+ className={`p-h4 ta-center ${
72
+ selectedIndex === index ? '' : 'tc-primary-500'
73
+ }`}
74
+ >
75
+ {value.title}
76
+ </div>
77
+ <div
78
+ className={`p-p--small ta-center ${
79
+ selectedIndex === index
80
+ ? 'tc-grey-500'
81
+ : 'tc-primary-500'
82
+ }`}
83
+ >
84
+ {value.subtitle}
85
+ </div>
86
+ </>
87
+ )}
88
+ </div>
89
+ );
90
+ })}
91
+ </div>
92
+ <div
93
+ className={styles['select-chip-background']}
94
+ style={{
95
+ width: `${selectedChipBackgroundWidthLeft.width}px`,
96
+ height: `${height - 16}px`,
97
+ left: `${selectedChipBackgroundWidthLeft.left}px`,
98
+ }}
99
+ />
100
+ </div>
101
+ </div>
102
+ );
103
+ };
104
+
105
+ export default SegmentedControl;
@@ -0,0 +1,36 @@
1
+ .background-container {
2
+ position: relative;
3
+ display: inline-block;
4
+
5
+ background-color: var(--ds-primary-100);
6
+ border-radius: 8px;
7
+
8
+ padding: 0 8px;
9
+ }
10
+
11
+ .chip-container {
12
+ display: flex;
13
+ align-items: center;
14
+ }
15
+
16
+ .chip {
17
+ cursor: pointer;
18
+
19
+ z-index: 2;
20
+
21
+ padding-left: 16px;
22
+ padding-right: 16px;
23
+ }
24
+
25
+ .select-chip-background {
26
+ position: absolute;
27
+
28
+ background-color: white;
29
+ border-radius: 8px;
30
+
31
+ top: 8px;
32
+
33
+ z-index: 1;
34
+
35
+ transition: width 0.3s, left 0.3s;
36
+ }
@@ -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="M1 4V10H7" stroke="#8E8CEE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
3
+ <path d="M3.51 14.9999C4.15839 16.8403 5.38734 18.4201 7.01166 19.5013C8.63598 20.5825 10.5677 21.1065 12.5157 20.9944C14.4637 20.8823 16.3226 20.1401 17.8121 18.8797C19.3017 17.6193 20.3413 15.9089 20.7742 14.0063C21.2072 12.1037 21.0101 10.1119 20.2126 8.33105C19.4152 6.55019 18.0605 5.07674 16.3528 4.13271C14.6451 3.18868 12.6769 2.82521 10.7447 3.09707C8.81245 3.36892 7.02091 4.26137 5.64 5.63995L1 9.99995" stroke="#8E8CEE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M13.7 3.70001C13.3 4.00001 13.5 5.10001 14.1 6.20001C14.7 7.30001 14.9 9.20001 14.6 10.5C14.1 12.3 15.3 14.4 19.3 19.7C22.2 23.4 25.6 28 26.9 29.8L29.2 33L23 39.7C19.7 43.4 17.1 46.9 17.4 47.6C17.7 48.3 17.2 49.4 16.4 50C14.8 51.4 14.5 54 16.1 54C17.5 54 23.6 49.5 29 44.4L33.5 40.1L41 51.3C49.2 63.6 53.7 69 55.8 69C56.6 69 56.8 68.5 56.4 67.7C56 67.1 57.8 68.9 60.5 71.8C63.1 74.7 65.5 76.9 65.7 76.6C65.9 76.4 65.2 74.4 64.1 72.1C62.9 69.9 62 67.2 62 66.2C62 63.3 54.5 47.6 48.9 39C46.2 34.8 44 31 44 30.6C44 30.2 46.2 27.3 48.9 24.2C54.3 17.9 59 11.2 59 9.80001C59 9.30001 57.7 9.10001 56 9.50001C54.2 9.90001 50.5 12.7 46.4 17.1C42.7 20.9 39.4 24 39.1 24C38.8 24 36.3 20.7 33.6 16.8C30.9 12.9 27.9 9.50001 27 9.30001C26 9.00001 24.3 7.60001 23.2 6.10001C21.7 4.10001 20.3 3.30001 17.7 3.20001C15.8 3.10001 14 3.30001 13.7 3.70001Z" fill="#8E8CEE"/>
3
+ </svg>
@@ -0,0 +1,17 @@
1
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
2
+
3
+ import Signaturepad from '.';
4
+
5
+ <Meta title="JSX/Signaturepad" component={Signaturepad} />
6
+
7
+ # Signature pad
8
+
9
+ Signature pad are user interface elements which allow user sign any legal document.
10
+
11
+ ## Examples
12
+
13
+ ### Default example
14
+
15
+ <Preview>
16
+ <Signaturepad onChange={() => {}} />
17
+ </Preview>
@@ -0,0 +1,96 @@
1
+ import React, { Component } from 'react';
2
+
3
+ import SignaturePad from 'signature_pad';
4
+
5
+ import styles from './style.module.scss';
6
+
7
+ import sign from './img/sign.svg';
8
+ import reset from './img/reset.svg';
9
+
10
+ interface Props {
11
+ onChange: (base64signature: string) => void;
12
+ }
13
+
14
+ interface State {
15
+ hasContent: boolean;
16
+ }
17
+
18
+ class Signature extends Component<Props, State> {
19
+ private canvasRef: React.RefObject<HTMLCanvasElement>;
20
+ private canvas: any;
21
+ private signaturePad: any;
22
+
23
+ constructor(props: Props) {
24
+ super(props);
25
+ this.state = {
26
+ hasContent: false,
27
+ };
28
+ this.canvasRef = React.createRef();
29
+ this.notifyOnChange = this.notifyOnChange.bind(this);
30
+ this.resizeCanvas = this.resizeCanvas.bind(this);
31
+ this.clear = this.clear.bind(this);
32
+ }
33
+
34
+ public componentDidMount() {
35
+ this.canvas = this.canvasRef.current;
36
+ this.signaturePad = new SignaturePad(this.canvas, {
37
+ onEnd: this.notifyOnChange,
38
+ });
39
+ this.resizeCanvas();
40
+ }
41
+
42
+ public render() {
43
+ const { hasContent } = this.state;
44
+
45
+ return (
46
+ <>
47
+ <style
48
+ dangerouslySetInnerHTML={{
49
+ __html: `.${styles.reset}::before {
50
+ -webkit-mask-image: url("${reset}");
51
+ mask-image: url("${reset}");
52
+ }`,
53
+ }}
54
+ />
55
+ <div className={styles.container}>
56
+ <canvas className={styles.canvas} ref={this.canvasRef} />
57
+ <div className={styles.separator} />
58
+ <div
59
+ className={styles.sign}
60
+ style={{
61
+ WebkitMaskImage: `url("${sign}")`,
62
+ maskImage: `url("${sign}")`,
63
+ }}
64
+ />
65
+ <button
66
+ className={styles.reset}
67
+ onClick={this.clear}
68
+ disabled={!hasContent}
69
+ >
70
+ Reset
71
+ </button>
72
+ </div>
73
+ </>
74
+ );
75
+ }
76
+
77
+ private notifyOnChange() {
78
+ const { onChange } = this.props;
79
+ onChange(this.signaturePad.isEmpty() ? '' : this.signaturePad.toDataURL());
80
+ this.setState({ hasContent: !this.signaturePad.isEmpty() });
81
+ }
82
+
83
+ private resizeCanvas() {
84
+ const ratio = Math.max(window.devicePixelRatio || 1, 1);
85
+ this.canvas.width = this.canvas.offsetWidth * ratio;
86
+ this.canvas.height = this.canvas.offsetHeight * ratio;
87
+ this.canvas.getContext('2d').scale(ratio, ratio);
88
+ }
89
+
90
+ private clear() {
91
+ this.signaturePad.clear();
92
+ this.notifyOnChange();
93
+ }
94
+ }
95
+
96
+ export default Signature;
@@ -0,0 +1,90 @@
1
+ .container {
2
+ position: relative;
3
+ background-color: var(--ds-grey-200);
4
+ border-radius: 8px;
5
+ height: 272px;
6
+ }
7
+
8
+ .canvas {
9
+ width: 100%;
10
+ height: 100%;
11
+ }
12
+
13
+ .separator {
14
+ position: absolute;
15
+
16
+ height: 2px;
17
+
18
+ right: 112px;
19
+ left: 72px;
20
+ bottom: 32px;
21
+
22
+ background-color: var(--ds-grey-300);
23
+
24
+ border-radius: 1px;
25
+ }
26
+
27
+ .reset {
28
+ display: flex;
29
+ position: absolute;
30
+
31
+ right: 16px;
32
+ bottom: 32px;
33
+
34
+ color: var(--ds-primary-500);
35
+ cursor: pointer;
36
+
37
+ border: none;
38
+ text-decoration: none;
39
+ font-size: 16px;
40
+ line-height: 24px;
41
+
42
+ background-color: transparent;
43
+
44
+ &:hover {
45
+ color: var(--ds-primary-700);
46
+ }
47
+
48
+ &:before {
49
+ content: '';
50
+
51
+ display: inline-block;
52
+
53
+ height: 24px;
54
+ width: 24px;
55
+
56
+ mask-repeat: no-repeat;
57
+ mask-position: center;
58
+ background-color: currentColor;
59
+
60
+ -webkit-mask-repeat: no-repeat;
61
+ -webkit-mask-position: center;
62
+ -webkit-background-color: currentColor;
63
+
64
+ margin-right: 4px;
65
+ }
66
+
67
+ &[disabled] {
68
+ color: var(--ds-grey-500);
69
+ }
70
+ }
71
+
72
+ .sign {
73
+ position: absolute;
74
+
75
+ bottom: 32px;
76
+ left: 16px;
77
+
78
+ height: 24px;
79
+ width: 24px;
80
+
81
+ mask-size: 24px 24px;
82
+ mask-repeat: no-repeat;
83
+ mask-position: center;
84
+
85
+ -webkit-mask-size: 24px 24px;
86
+ -webkit-mask-repeat: no-repeat;
87
+ -webkit-mask-position: center;
88
+
89
+ background-color: var(--ds-grey-500);
90
+ }
@@ -0,0 +1,71 @@
1
+ import DateSelector from './components/dateSelector';
2
+ import Dropzone from './components/dropzone';
3
+ import SignaturePad from './components/signaturePad';
4
+ import AutocompleteAddress from './components/autocompleteAddress';
5
+ import Input from './components/input';
6
+ import MultiDropzone from './components/multiDropzone';
7
+ import DownloadRing from './components/downloadRing';
8
+ import DownloadButton from './components/downloadButton';
9
+ import IbanInput from './components/input/iban';
10
+ import CurrencyInput from './components/input/currency';
11
+ import {
12
+ BottomModal,
13
+ RegularModal,
14
+ BottomOrRegularModal,
15
+ } from './components/modal';
16
+ import {
17
+ CardWithTopLeftIcon,
18
+ CardWithLeftIcon,
19
+ CardWithTopIcon,
20
+ InfoCard,
21
+ CardButton,
22
+ } from './components/cards';
23
+ import Button from './components/button';
24
+ import AutoSuggestMultiSelect from './components/input/autoSuggestMultiSelect';
25
+ import Chip from './components/chip';
26
+ import AutoSuggestInput from './components/input/autoSuggestInput';
27
+ import {
28
+ ComparisonTable,
29
+ TableRating,
30
+ TableTrueFalse,
31
+ TableRowHeader,
32
+ TableInfoButton,
33
+ TableHeader,
34
+ } from './components/comparisonTable';
35
+ import SegmentedControl from './components/segmentedControl';
36
+
37
+ export {
38
+ DateSelector,
39
+ Dropzone,
40
+ SignaturePad,
41
+ AutocompleteAddress,
42
+ Input,
43
+ MultiDropzone,
44
+ DownloadRing,
45
+ DownloadButton,
46
+ IbanInput,
47
+ BottomModal,
48
+ RegularModal,
49
+ BottomOrRegularModal,
50
+ CardWithTopLeftIcon,
51
+ CardWithLeftIcon,
52
+ CardWithTopIcon,
53
+ InfoCard,
54
+ CardButton,
55
+ Button,
56
+ CurrencyInput,
57
+ AutoSuggestMultiSelect,
58
+ Chip,
59
+ AutoSuggestInput,
60
+ ComparisonTable,
61
+ TableRating,
62
+ TableTrueFalse,
63
+ TableRowHeader,
64
+ TableInfoButton,
65
+ SegmentedControl,
66
+ };
67
+
68
+ export type { TableHeader };
69
+
70
+ export type { DownloadRingDownloadStatus } from './models/downloadRing';
71
+ export type { DownloadStatus } from './models/download'