@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.
Files changed (230) hide show
  1. package/package.json +2 -1
  2. package/src/App.tsx +50 -0
  3. package/src/bin/index.ts +71 -0
  4. package/src/bin/tsconfig.json +13 -0
  5. package/src/bin/util/index.test.ts +85 -0
  6. package/src/bin/util/index.ts +132 -0
  7. package/src/bin/util/test/data.json +13 -0
  8. package/src/colors.scss +1 -0
  9. package/src/font-weight.scss +1 -0
  10. package/src/grid.scss +1 -0
  11. package/src/index.tsx +37 -0
  12. package/src/intro.stories.mdx +41 -0
  13. package/src/lib/components/autocompleteAddress/demo.tsx +38 -0
  14. package/src/lib/components/autocompleteAddress/index.stories.mdx +44 -0
  15. package/src/lib/components/autocompleteAddress/index.tsx +316 -0
  16. package/src/lib/components/autocompleteAddress/mapStyle.ts +187 -0
  17. package/src/lib/components/autocompleteAddress/style.module.scss +82 -0
  18. package/src/lib/components/autocompleteAddress/util/index.test.ts +51 -0
  19. package/src/lib/components/autocompleteAddress/util/index.ts +55 -0
  20. package/src/lib/components/button/icons/index.ts +14 -0
  21. package/src/lib/components/button/icons/send-purple.svg +4 -0
  22. package/src/lib/components/button/icons/send-white.svg +4 -0
  23. package/src/lib/components/button/index.stories.mdx +121 -0
  24. package/src/lib/components/button/index.tsx +64 -0
  25. package/src/lib/components/button/styles.module.scss +5 -0
  26. package/src/lib/components/cards/a.stories.mdx +44 -0
  27. package/src/lib/components/cards/cardButton/index.stories.mdx +47 -0
  28. package/src/lib/components/cards/cardButton/index.tsx +61 -0
  29. package/src/lib/components/cards/cardButton/style.module.scss +33 -0
  30. package/src/lib/components/cards/cardWithLeftIcon/index.stories.mdx +103 -0
  31. package/src/lib/components/cards/cardWithLeftIcon/index.tsx +87 -0
  32. package/src/lib/components/cards/cardWithLeftIcon/style.module.scss +23 -0
  33. package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +105 -0
  34. package/src/lib/components/cards/cardWithTopIcon/index.tsx +60 -0
  35. package/src/lib/components/cards/cardWithTopIcon/style.module.scss +10 -0
  36. package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.mdx +101 -0
  37. package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +72 -0
  38. package/src/lib/components/cards/cardWithTopLeftIcon/style.module.scss +21 -0
  39. package/src/lib/components/cards/icons/arrow-right.svg +4 -0
  40. package/src/lib/components/cards/icons/chevron-right.svg +3 -0
  41. package/src/lib/components/cards/icons/feather-logo.svg +10 -0
  42. package/src/lib/components/cards/icons/index.ts +36 -0
  43. package/src/lib/components/cards/icons/info.svg +12 -0
  44. package/src/lib/components/cards/index.test.ts +37 -0
  45. package/src/lib/components/cards/index.tsx +57 -0
  46. package/src/lib/components/cards/infoCard/index.stories.mdx +61 -0
  47. package/src/lib/components/cards/infoCard/index.tsx +47 -0
  48. package/src/lib/components/cards/infoCard/style.module.scss +53 -0
  49. package/src/lib/components/chip/icons/remove-button-highlighted.svg +4 -0
  50. package/src/lib/components/chip/icons/remove-button.svg +4 -0
  51. package/src/lib/components/chip/index.stories.mdx +101 -0
  52. package/src/lib/components/chip/index.tsx +38 -0
  53. package/src/lib/components/chip/style.module.scss +54 -0
  54. package/src/lib/components/comparisonTable/components/Chevron.tsx +19 -0
  55. package/src/lib/components/comparisonTable/components/Row/index.tsx +68 -0
  56. package/src/lib/components/comparisonTable/components/Row/style.module.scss +114 -0
  57. package/src/lib/components/comparisonTable/components/TableArrows/Arrow.tsx +19 -0
  58. package/src/lib/components/comparisonTable/components/TableArrows/index.tsx +52 -0
  59. package/src/lib/components/comparisonTable/components/TableArrows/style.module.scss +53 -0
  60. package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +37 -0
  61. package/src/lib/components/comparisonTable/components/TableInfoButton/style.module.scss +30 -0
  62. package/src/lib/components/comparisonTable/components/TableRating/StarIcon.tsx +13 -0
  63. package/src/lib/components/comparisonTable/components/TableRating/ZapIcon.tsx +17 -0
  64. package/src/lib/components/comparisonTable/components/TableRating/index.tsx +45 -0
  65. package/src/lib/components/comparisonTable/components/TableRating/style.module.scss +13 -0
  66. package/src/lib/components/comparisonTable/components/TableRowHeader/index.tsx +35 -0
  67. package/src/lib/components/comparisonTable/components/TableRowHeader/style.module.scss +3 -0
  68. package/src/lib/components/comparisonTable/components/TableTrueFalse.tsx +40 -0
  69. package/src/lib/components/comparisonTable/hooks/useActiveTableArrows.ts +63 -0
  70. package/src/lib/components/comparisonTable/index.stories.mdx +254 -0
  71. package/src/lib/components/comparisonTable/index.tsx +211 -0
  72. package/src/lib/components/comparisonTable/style.module.scss +104 -0
  73. package/src/lib/components/dateSelector/datepicker.scss +406 -0
  74. package/src/lib/components/dateSelector/icons/calendar.svg +6 -0
  75. package/src/lib/components/dateSelector/icons/chevron-left.svg +3 -0
  76. package/src/lib/components/dateSelector/icons/chevron-right.svg +3 -0
  77. package/src/lib/components/dateSelector/index.stories.mdx +62 -0
  78. package/src/lib/components/dateSelector/index.test.ts +33 -0
  79. package/src/lib/components/dateSelector/index.tsx +247 -0
  80. package/src/lib/components/dateSelector/style.module.scss +77 -0
  81. package/src/lib/components/downloadButton/icons/check.svg +3 -0
  82. package/src/lib/components/downloadButton/icons/download.svg +5 -0
  83. package/src/lib/components/downloadButton/index.stories.mdx +59 -0
  84. package/src/lib/components/downloadButton/index.tsx +67 -0
  85. package/src/lib/components/downloadButton/style.module.scss +19 -0
  86. package/src/lib/components/downloadRing/icons/check-outside-circle.tsx +26 -0
  87. package/src/lib/components/downloadRing/icons/download-cloud.tsx +18 -0
  88. package/src/lib/components/downloadRing/icons/style.module.scss +7 -0
  89. package/src/lib/components/downloadRing/index.stories.mdx +35 -0
  90. package/src/lib/components/downloadRing/index.tsx +79 -0
  91. package/src/lib/components/downloadRing/style.module.scss +66 -0
  92. package/src/lib/components/dropzone/images/error.tsx +18 -0
  93. package/src/lib/components/dropzone/images/file.tsx +26 -0
  94. package/src/lib/components/dropzone/images/style.module.scss +7 -0
  95. package/src/lib/components/dropzone/images/upload-complete.tsx +24 -0
  96. package/src/lib/components/dropzone/images/upload.tsx +18 -0
  97. package/src/lib/components/dropzone/index.stories.mdx +44 -0
  98. package/src/lib/components/dropzone/index.tsx +152 -0
  99. package/src/lib/components/dropzone/style.module.scss +90 -0
  100. package/src/lib/components/input/a.stories.mdx +28 -0
  101. package/src/lib/components/input/autoSuggestInput/index.stories.mdx +137 -0
  102. package/src/lib/components/input/autoSuggestInput/index.tsx +81 -0
  103. package/src/lib/components/input/autoSuggestInput/style.module.scss +71 -0
  104. package/src/lib/components/input/autoSuggestMultiSelect/index.stories.mdx +115 -0
  105. package/src/lib/components/input/autoSuggestMultiSelect/index.tsx +75 -0
  106. package/src/lib/components/input/autoSuggestMultiSelect/style.module.scss +4 -0
  107. package/src/lib/components/input/currency/format/index.test.ts +49 -0
  108. package/src/lib/components/input/currency/format/index.ts +15 -0
  109. package/src/lib/components/input/currency/index.stories.mdx +25 -0
  110. package/src/lib/components/input/currency/index.test.tsx +56 -0
  111. package/src/lib/components/input/currency/index.tsx +53 -0
  112. package/src/lib/components/input/iban/formatIban/index.test.ts +11 -0
  113. package/src/lib/components/input/iban/formatIban/index.ts +22 -0
  114. package/src/lib/components/input/iban/index.stories.mdx +21 -0
  115. package/src/lib/components/input/iban/index.tsx +20 -0
  116. package/src/lib/components/input/index.stories.mdx +62 -0
  117. package/src/lib/components/input/index.tsx +51 -0
  118. package/src/lib/components/input/style.module.scss +94 -0
  119. package/src/lib/components/modal/bottomModal/img/close.svg +4 -0
  120. package/src/lib/components/modal/bottomModal/index.tsx +68 -0
  121. package/src/lib/components/modal/bottomModal/style.module.scss +104 -0
  122. package/src/lib/components/modal/bottomOrRegularModal/index.tsx +43 -0
  123. package/src/lib/components/modal/bottomOrRegularModal/style.module.scss +16 -0
  124. package/src/lib/components/modal/hooks/useOnClose.ts +51 -0
  125. package/src/lib/components/modal/index.stories.mdx +316 -0
  126. package/src/lib/components/modal/index.ts +14 -0
  127. package/src/lib/components/modal/regularModal/img/close.svg +4 -0
  128. package/src/lib/components/modal/regularModal/index.tsx +55 -0
  129. package/src/lib/components/modal/regularModal/style.module.scss +106 -0
  130. package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +138 -0
  131. package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +101 -0
  132. package/src/lib/components/multiDropzone/icons/bmp-complete.svg +10 -0
  133. package/src/lib/components/multiDropzone/icons/bmp.svg +10 -0
  134. package/src/lib/components/multiDropzone/icons/doc-complete.svg +11 -0
  135. package/src/lib/components/multiDropzone/icons/doc.svg +11 -0
  136. package/src/lib/components/multiDropzone/icons/docx-complete.svg +12 -0
  137. package/src/lib/components/multiDropzone/icons/docx.svg +12 -0
  138. package/src/lib/components/multiDropzone/icons/eye.svg +4 -0
  139. package/src/lib/components/multiDropzone/icons/generic-complete.svg +4 -0
  140. package/src/lib/components/multiDropzone/icons/generic-error.svg +7 -0
  141. package/src/lib/components/multiDropzone/icons/generic.svg +4 -0
  142. package/src/lib/components/multiDropzone/icons/heic-complete.svg +11 -0
  143. package/src/lib/components/multiDropzone/icons/heic.svg +11 -0
  144. package/src/lib/components/multiDropzone/icons/index.ts +51 -0
  145. package/src/lib/components/multiDropzone/icons/jpeg-complete.svg +11 -0
  146. package/src/lib/components/multiDropzone/icons/jpeg.svg +11 -0
  147. package/src/lib/components/multiDropzone/icons/jpg-complete.svg +10 -0
  148. package/src/lib/components/multiDropzone/icons/jpg.svg +10 -0
  149. package/src/lib/components/multiDropzone/icons/pdf-complete.svg +8 -0
  150. package/src/lib/components/multiDropzone/icons/pdf.svg +8 -0
  151. package/src/lib/components/multiDropzone/icons/png-complete.svg +10 -0
  152. package/src/lib/components/multiDropzone/icons/png.svg +10 -0
  153. package/src/lib/components/multiDropzone/icons/trash.svg +6 -0
  154. package/src/lib/components/multiDropzone/icons/upload.svg +5 -0
  155. package/src/lib/components/multiDropzone/index.stories.mdx +91 -0
  156. package/src/lib/components/multiDropzone/index.tsx +99 -0
  157. package/src/lib/components/multiDropzone/style.module.scss +32 -0
  158. package/src/lib/components/segmentedControl/index.stories.mdx +47 -0
  159. package/src/lib/components/segmentedControl/index.tsx +105 -0
  160. package/src/lib/components/segmentedControl/style.module.scss +36 -0
  161. package/src/lib/components/signaturePad/img/reset.svg +4 -0
  162. package/src/lib/components/signaturePad/img/sign.svg +3 -0
  163. package/src/lib/components/signaturePad/index.stories.mdx +17 -0
  164. package/src/lib/components/signaturePad/index.tsx +96 -0
  165. package/src/lib/components/signaturePad/style.module.scss +90 -0
  166. package/src/lib/index.tsx +71 -0
  167. package/src/lib/models/autoSuggestInput/index.ts +4 -0
  168. package/src/lib/models/download.ts +1 -0
  169. package/src/lib/models/downloadRing/index.ts +6 -0
  170. package/src/lib/scss/index.scss +22 -0
  171. package/src/lib/scss/private/_reset.scss +149 -0
  172. package/src/lib/scss/private/base/_colors.scss +19 -0
  173. package/src/lib/scss/private/base/_cursors.scss +31 -0
  174. package/src/lib/scss/private/base/_display.scss +35 -0
  175. package/src/lib/scss/private/base/_grid.scss +52 -0
  176. package/src/lib/scss/private/base/_index.scss +9 -0
  177. package/src/lib/scss/private/base/_shadows.scss +2 -0
  178. package/src/lib/scss/private/base/_spacing.scss +89 -0
  179. package/src/lib/scss/private/base/_typography.scss +128 -0
  180. package/src/lib/scss/private/base/_width_and_height.scss +25 -0
  181. package/src/lib/scss/private/base/cursors.stories.mdx +18 -0
  182. package/src/lib/scss/private/base/demo.tsx +119 -0
  183. package/src/lib/scss/private/base/display.stories.mdx +19 -0
  184. package/src/lib/scss/private/base/flex/_flex.scss +63 -0
  185. package/src/lib/scss/private/base/flex/flex.stories.mdx +139 -0
  186. package/src/lib/scss/private/base/flex/style.module.scss +24 -0
  187. package/src/lib/scss/private/base/spacing.stories.mdx +173 -0
  188. package/src/lib/scss/private/base/style.module.scss +42 -0
  189. package/src/lib/scss/private/base/typography.stories.mdx +71 -0
  190. package/src/lib/scss/private/base/width_and_height.stories.mdx +172 -0
  191. package/src/lib/scss/private/components/_badge.scss +41 -0
  192. package/src/lib/scss/private/components/_buttons.scss +193 -0
  193. package/src/lib/scss/private/components/_cards.scss +32 -0
  194. package/src/lib/scss/private/components/_index.scss +6 -0
  195. package/src/lib/scss/private/components/_input.scss +241 -0
  196. package/src/lib/scss/private/components/_notices.scss +39 -0
  197. package/src/lib/scss/private/components/_spinner.scss +60 -0
  198. package/src/lib/scss/private/components/assets/checkmark.svg +3 -0
  199. package/src/lib/scss/private/components/assets/icon-form-dropdown.svg +3 -0
  200. package/src/lib/scss/private/components/badge.stories.mdx +37 -0
  201. package/src/lib/scss/private/components/button.stories.mdx +107 -0
  202. package/src/lib/scss/private/components/cards.stories.mdx +35 -0
  203. package/src/lib/scss/private/components/checkbox.stories.mdx +47 -0
  204. package/src/lib/scss/private/components/input.stories.mdx +33 -0
  205. package/src/lib/scss/private/components/notices.stories.mdx +37 -0
  206. package/src/lib/scss/private/components/radio.stories.mdx +47 -0
  207. package/src/lib/scss/private/components/select.stories.mdx +17 -0
  208. package/src/lib/scss/private/components/spinner.stories.mdx +25 -0
  209. package/src/lib/scss/public/colors/_index.scss +2 -0
  210. package/src/lib/scss/public/colors/default.scss +125 -0
  211. package/src/lib/scss/public/colors/overrides.scss +0 -0
  212. package/src/lib/scss/public/colors.stories.mdx +27 -0
  213. package/src/lib/scss/public/demo.tsx +285 -0
  214. package/src/lib/scss/public/font/_index.scss +2 -0
  215. package/src/lib/scss/public/font/default.scss +3 -0
  216. package/src/lib/scss/public/font/overrides.scss +0 -0
  217. package/src/lib/scss/public/font-weight.scss +9 -0
  218. package/src/lib/scss/public/font-weight.stories.mdx +32 -0
  219. package/src/lib/scss/public/grid.scss +21 -0
  220. package/src/lib/scss/public/grid.stories.mdx +41 -0
  221. package/src/lib/scss/third-party/_google_places.scss +62 -0
  222. package/src/lib/scss/third-party/_index.scss +1 -0
  223. package/src/lib/scss/utils/_index.scss +3 -0
  224. package/src/lib/util/calendarDate/index.test.ts +32 -0
  225. package/src/lib/util/calendarDate/index.ts +30 -0
  226. package/src/lib/util/zeroFill.test.ts +15 -0
  227. package/src/lib/util/zeroFill.ts +7 -0
  228. package/src/react-app-env.d.ts +1 -0
  229. package/src/setupTests.js +8 -0
  230. package/src/theme.stories.mdx +54 -0
@@ -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,5 @@
1
+ .content-container {
2
+ display: flex;
3
+ justify-content: center;
4
+ align-items: center;
5
+ }
@@ -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
+ }
@@ -0,0 +1,103 @@
1
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
2
+
3
+ import CardWithLeftIcon from '.';
4
+ import { featherLogo } from '../icons';
5
+
6
+ <Meta title="JSX/Cards/Card with left icon" />
7
+
8
+ # Card with left icon
9
+
10
+ | attribute | unit | description | default value | required |
11
+ | ---------- | ------------------------------------------------------------------------------------ | ------------------------------------------------- | ------------- | -------- |
12
+ | title | string | The title text that needs to be displayed | n/a | true |
13
+ | cardSize | [Card Size (xs,s,m,b)](?path=/story/jsx-cards-intro--page#card-size-xsmall-small-medium-big) | Size of the card | medium | false |
14
+ | leftIcon | [Icon](?path=/story/jsx-cards-intro--page#icon) | Icon displayed on the left hand side of the card | n/a | false |
15
+ | rightIcon | [Icon](?path=/story/jsx-cards-intro--page#icon) | Icon displayed on the right hand side of the card | n/a | false |
16
+ | state | [Card State](?path=/story/jsx-cards-intro--page#card-state) | State that describe the interation with the card | actionable | false |
17
+ | dropshadow | boolean | If the card should have a box-shadow or not | true | false |
18
+ | className | string | Class name for most top parent element | 'n/a' | false |
19
+
20
+ <Preview>
21
+ <>
22
+ <h4 className="p-h4">Extra small card</h4>
23
+ <CardWithLeftIcon
24
+ title="Lorem ipsum"
25
+ cardSize="xsmall"
26
+ className="wmx6 mt8"
27
+ rightIcon="arrow"
28
+ leftIcon={featherLogo}
29
+ >
30
+ Praesent euismod porta odio at tempus.{' '}
31
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
32
+ eros at, rhoncus imperdiet nunc
33
+ </CardWithLeftIcon>
34
+ <h4 className="p-h4">Small card</h4>
35
+ <CardWithLeftIcon
36
+ title="Lorem ipsum"
37
+ cardSize="small"
38
+ className="wmx6 mt8"
39
+ rightIcon="arrow"
40
+ leftIcon={featherLogo}
41
+ >
42
+ Praesent euismod porta odio at tempus.{' '}
43
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
44
+ eros at, rhoncus imperdiet nunc
45
+ </CardWithLeftIcon>
46
+ <h4 className="p-h4 mt24">Medium card</h4>
47
+ <CardWithLeftIcon
48
+ title="Lorem ipsum"
49
+ cardSize="medium"
50
+ className="wmx6 mt8"
51
+ rightIcon="arrow"
52
+ leftIcon={featherLogo}
53
+ >
54
+ Praesent euismod porta odio at tempus.{' '}
55
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
56
+ eros at, rhoncus imperdiet nunc
57
+ </CardWithLeftIcon>
58
+ <h4 className="p-h4 mt24">Big card</h4>
59
+ <CardWithLeftIcon
60
+ title="Lorem ipsum"
61
+ cardSize="big"
62
+ className="wmx6 mt8"
63
+ rightIcon="arrow"
64
+ leftIcon={featherLogo}
65
+ >
66
+ Praesent euismod porta odio at tempus.{' '}
67
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
68
+ eros at, rhoncus imperdiet nunc
69
+ </CardWithLeftIcon>
70
+ <h4 className="p-h4 mt24">Muted</h4>
71
+ <CardWithLeftIcon
72
+ state="muted"
73
+ title="Lorem ipsum"
74
+ cardSize="big"
75
+ className="wmx6 mt8"
76
+ rightIcon="arrow"
77
+ leftIcon={featherLogo}
78
+ >
79
+ Praesent euismod porta odio at tempus.{' '}
80
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
81
+ eros at, rhoncus imperdiet nunc
82
+ </CardWithLeftIcon>
83
+ <h4 className="p-h4 mt24">No left icon and right icon</h4>
84
+ <CardWithLeftIcon title="Lorem ipsum" cardSize="big" className="wmx6 mt8">
85
+ Praesent euismod porta odio at tempus.{' '}
86
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
87
+ eros at, rhoncus imperdiet nunc
88
+ </CardWithLeftIcon>
89
+ <h4 className="p-h4 mt24">No dropshadow</h4>
90
+ <CardWithLeftIcon
91
+ title="Lorem ipsum"
92
+ cardSize="medium"
93
+ className="wmx6 mt8"
94
+ rightIcon="arrow"
95
+ leftIcon={featherLogo}
96
+ dropshadow={false}
97
+ >
98
+ Praesent euismod porta odio at tempus.{' '}
99
+ <span className="fw-bold">Aenean urna massa</span>, facilisis malesuada
100
+ eros at, rhoncus imperdiet nunc
101
+ </CardWithLeftIcon>
102
+ </>
103
+ </Preview>
@@ -0,0 +1,87 @@
1
+ import { associatedClassForCardState, CardProps, headingForCardSize } from '..';
2
+ import { Icon, arrowRight } from '../icons';
3
+
4
+ import styles from './style.module.scss';
5
+
6
+ const containerStyleFromCardSize = (
7
+ cardSize: 'xsmall' | 'small' | 'medium' | 'big'
8
+ ): string => {
9
+ switch (cardSize) {
10
+ case 'xsmall':
11
+ return 'container--xsmall';
12
+ case 'small':
13
+ return 'container--small';
14
+ default:
15
+ return 'container';
16
+ }
17
+ };
18
+
19
+ const cardTextStyleFromCardSize = (
20
+ cardSize: 'xsmall' | 'small' | 'medium' | 'big'
21
+ ): string => {
22
+ switch (cardSize) {
23
+ case 'xsmall':
24
+ case 'small':
25
+ return 'card-text--small';
26
+ case 'medium':
27
+ return 'card-text--medium';
28
+ default:
29
+ return 'card-text--big';
30
+ }
31
+ };
32
+
33
+ export default ({
34
+ className = '',
35
+ title,
36
+ cardSize = 'medium',
37
+ children,
38
+ leftIcon,
39
+ rightIcon,
40
+ state = 'actionable',
41
+ dropshadow = true,
42
+ ...props
43
+ }: CardProps & {
44
+ cardSize?: 'xsmall' | 'small' | 'medium' | 'big';
45
+ leftIcon?: Icon;
46
+ rightIcon?: 'arrow' | Icon;
47
+ }) => {
48
+ const cardStyle = `d-flex ai-center ${className} ${associatedClassForCardState(
49
+ state,
50
+ dropshadow
51
+ )} ${styles[containerStyleFromCardSize(cardSize)]}`;
52
+
53
+ const headingStyle = headingForCardSize(cardSize);
54
+ const iconStyle = cardSize === 'xsmall' ? 'mr16' : 'mr32';
55
+ const cardTextStyle = `tc-grey-600 ${
56
+ cardSize === 'xsmall' ? 'p-p--small' : 'p-p '
57
+ } ${styles[cardTextStyleFromCardSize(cardSize)]}`;
58
+
59
+ return (
60
+ <div className={cardStyle} {...props}>
61
+ {leftIcon && (
62
+ <img
63
+ width="48px"
64
+ height="48px"
65
+ className={iconStyle}
66
+ src={leftIcon.src}
67
+ alt={leftIcon.alt}
68
+ />
69
+ )}
70
+ <div>
71
+ <div className="d-flex">
72
+ <div className={headingStyle}>{title}</div>
73
+ {rightIcon && (
74
+ <img
75
+ className="ml-auto"
76
+ width="24px"
77
+ height="24px"
78
+ src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}
79
+ alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}
80
+ />
81
+ )}
82
+ </div>
83
+ <p className={cardTextStyle}>{children}</p>
84
+ </div>
85
+ </div>
86
+ );
87
+ };
@@ -0,0 +1,23 @@
1
+ .container {
2
+ padding: 24px 24px 24px 32px;
3
+
4
+ &--small {
5
+ padding: 16px 24px 16px 32px;
6
+ }
7
+
8
+ &--xsmall {
9
+ padding: 16px 16px 16px 24px;
10
+ }
11
+ }
12
+
13
+ .card-text--small {
14
+ margin-top: 2px;
15
+ }
16
+
17
+ .card-text--medium {
18
+ margin-top: 4px;
19
+ }
20
+
21
+ .card-text--big {
22
+ margin-top: 6px;
23
+ }