@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.26.10",
3
+ "version": "0.26.11",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -16,6 +16,7 @@
16
16
  "bin": "dist/bin/index.js",
17
17
  "files": [
18
18
  "dist",
19
+ "src",
19
20
  "Readme.md"
20
21
  ],
21
22
  "dependencies": {
package/src/App.tsx ADDED
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import './lib/scss/index.scss';
3
+
4
+ import DateSelector from './lib/components/dateSelector';
5
+ import Dropzone from './lib/components/dropzone';
6
+ import SignaturePad from './lib/components/signaturePad';
7
+ import { CardWithLeftIcon } from './lib/components/cards';
8
+ import AutocompleteAddress from './lib/components/autocompleteAddress';
9
+
10
+ function App() {
11
+ return (
12
+ <div>
13
+ <div className="p-btn p-btn--primary">Hello world</div>
14
+ <DateSelector
15
+ onChange={() => {}}
16
+ yearBoundaries={{ min: 1990, max: 2010 }}
17
+ />
18
+ <div className="p-notice p-notice--info d-flex">
19
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
20
+ malesuada laoreet nulla, non maximus ante porta sit amet. Aenean non
21
+ ipsum nec quam gravida convallis vitae sit amet nisi.
22
+ </div>
23
+ <Dropzone
24
+ uploading={true}
25
+ progress={32}
26
+ onSelectedFile={() => {}}
27
+ // uploadedFileUrl="http://foo.com/my-file.png"
28
+ />
29
+ <div style={{ backgroundColor: 'white', padding: '24px' }}>
30
+ <SignaturePad
31
+ onChange={(v) => {
32
+ console.log(v);
33
+ }}
34
+ />
35
+ </div>
36
+ <div className="mt80"></div>
37
+ <CardWithLeftIcon
38
+ title="Lorem ipsum"
39
+ cardSize="small"
40
+ className="wmx6 mt8"
41
+ rightIcon="arrow"
42
+ >
43
+ Praesent euismod porta odio at tempus. Aenean urna massa, facilisis
44
+ malesuada eros at, rhoncus imperdiet nunc
45
+ </CardWithLeftIcon>
46
+ </div>
47
+ );
48
+ }
49
+
50
+ export default App;
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
3
+
4
+ import {
5
+ readConfigurationFile,
6
+ generateSass,
7
+ createConfigurationFile,
8
+ resetToDefaultTheme,
9
+ } from './util';
10
+ import * as path from 'path';
11
+ import * as yargs from 'yargs';
12
+
13
+ const DEFAULT_FILENAME = 'dirty-swan.config.json';
14
+ const DEFAULT_PATH = './';
15
+
16
+ yargs
17
+ .command(
18
+ 'init [path]',
19
+ 'initialize dirty swan with a configuration file',
20
+ (yargs) => {
21
+ yargs.positional('path', {
22
+ describe: 'path to where the configuration file should be at',
23
+ type: 'string',
24
+ default: `${DEFAULT_PATH}${DEFAULT_FILENAME}`,
25
+ });
26
+ },
27
+ ({ path }: { path: string }) => {
28
+ console.log(`🦢 Creating configuration file at: ${path}`);
29
+ createConfigurationFile(path);
30
+ console.log(`🦢 Successfully created configuration file at: ${path}`);
31
+ }
32
+ )
33
+ .command(
34
+ 'theme [configuration]',
35
+ 'theme dirty swan according to the configuration file',
36
+ (yargs) => {
37
+ yargs.positional('configuration', {
38
+ describe: '',
39
+ default: `${DEFAULT_PATH}${DEFAULT_FILENAME}`,
40
+ });
41
+ yargs.option('reset', { alias: '-R', default: false, type: 'boolean' });
42
+ },
43
+ ({
44
+ configuration: configurationFile,
45
+ reset,
46
+ }: {
47
+ configuration: string;
48
+ reset: boolean;
49
+ }) => {
50
+ if (reset === true) {
51
+ console.log('🦢 Reseting to default theme');
52
+ resetToDefaultTheme();
53
+ console.log('🦢 Successfully reseted to default theme 💫');
54
+ } else {
55
+ const configurationFileAbsolutePath = path.resolve(
56
+ process.cwd(),
57
+ configurationFile
58
+ );
59
+ console.log(`🦢 Reading configuration file ${configurationFile}`);
60
+
61
+ const configuration = readConfigurationFile(
62
+ configurationFileAbsolutePath
63
+ );
64
+ generateSass(configuration);
65
+ console.log(`🦢 Successfully updated with new theme 💫`);
66
+ }
67
+ }
68
+ )
69
+ .demandCommand()
70
+ .showHelpOnFail(true)
71
+ .help('help', 'Show usage instructions.').argv;
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "CommonJS",
4
+ "declaration": true,
5
+ "target": "ES5",
6
+ "moduleResolution": "node",
7
+ "rootDir": "./",
8
+ "outDir": "../../dist/bin",
9
+ "strict": true
10
+ },
11
+ "include": ["./index.ts"],
12
+ "exclude": ["*.test.ts"]
13
+ }
@@ -0,0 +1,85 @@
1
+ import { generatePrimaryColors, generateFont, readConfigurationFile } from '.';
2
+
3
+ describe('Generate primary colors', () => {
4
+ it('Should skip unspecified primary colors', () => {
5
+ expect(
6
+ generatePrimaryColors({
7
+ theme: {
8
+ colors: {
9
+ primary: {
10
+ 100: '#FFA07A',
11
+ 300: '',
12
+ 500: '',
13
+ 700: '',
14
+ 900: '',
15
+ },
16
+ },
17
+ },
18
+ })
19
+ ).toEqual(`$ds-primary-100: #FFA07A;`);
20
+ });
21
+
22
+ it('Should generate sass primary colors', () => {
23
+ expect(
24
+ generatePrimaryColors({
25
+ theme: {
26
+ colors: {
27
+ primary: {
28
+ 100: '#FFA07A',
29
+ 300: '#E9967A',
30
+ 500: '#FA8072',
31
+ 700: '#F08080',
32
+ 900: '#CD5C5C',
33
+ },
34
+ },
35
+ },
36
+ })
37
+ ).toEqual(
38
+ `$ds-primary-100: #FFA07A;\n$ds-primary-300: #E9967A;\n$ds-primary-500: #FA8072;\n$ds-primary-700: #F08080;\n$ds-primary-900: #CD5C5C;`
39
+ );
40
+ });
41
+
42
+ it('Shouldn’t generate sass primary colors if no entry for primary colors', () => {
43
+ expect(generatePrimaryColors({})).toBeUndefined();
44
+ });
45
+ });
46
+
47
+ describe('Generate font', () => {
48
+ it('Should generate sass font with url', () => {
49
+ expect(
50
+ generateFont({
51
+ theme: {
52
+ font: {
53
+ sans: {
54
+ url:
55
+ 'https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap',
56
+ family: ['Ubuntu', 'sans-serif'],
57
+ },
58
+ },
59
+ },
60
+ })
61
+ ).toEqual(
62
+ `@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap');\n\n$font-family: 'Ubuntu', 'sans-serif';`
63
+ );
64
+ });
65
+
66
+ it('Should generate sass font without url', () => {
67
+ expect(
68
+ generateFont({
69
+ theme: {
70
+ font: { sans: { family: ['Arial', 'Helvetica', 'sans-serif'] } },
71
+ },
72
+ })
73
+ ).toEqual("$font-family: 'Arial', 'Helvetica', 'sans-serif';");
74
+ });
75
+
76
+ it('Shouldn’t generate sass font', () => {
77
+ expect(generateFont({})).toBeUndefined();
78
+ });
79
+ });
80
+
81
+ describe('Read configuration file', () => {
82
+ it('Should read the configuration file', () => {
83
+ expect(readConfigurationFile(`${__dirname}/test/data.json`)).toBeDefined();
84
+ });
85
+ });
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as fs from 'fs';
4
+ import * as sass from 'sass';
5
+
6
+ interface ConfigurationFile {
7
+ theme?: {
8
+ colors?: {
9
+ primary?: {
10
+ 100: string;
11
+ 300: string;
12
+ 500: string;
13
+ 700: string;
14
+ 900: string;
15
+ };
16
+ };
17
+ font?: {
18
+ sans: {
19
+ family: string[];
20
+ url?: string;
21
+ };
22
+ };
23
+ };
24
+ }
25
+
26
+ export function generatePrimaryColors(configuration: ConfigurationFile) {
27
+ if (configuration.theme?.colors?.primary) {
28
+ const primaryColors = configuration.theme.colors.primary;
29
+ return Object.entries(primaryColors)
30
+ .filter(([shade, hex]) => {
31
+ if (hex.length === 0) {
32
+ console.warn(
33
+ `🦢 value wasn’t specified for shade ${shade}, skipping.`
34
+ );
35
+ return false;
36
+ }
37
+ return true;
38
+ })
39
+ .reduce(
40
+ (result, [shade, hex], index, arr) =>
41
+ result +
42
+ `$ds-primary-${shade}: ${hex};${index < arr.length - 1 ? '\n' : ''}`,
43
+ ''
44
+ );
45
+ }
46
+ return undefined;
47
+ }
48
+
49
+ export function generateFont(configuration: ConfigurationFile) {
50
+ if (configuration.theme?.font?.sans) {
51
+ const sans = configuration.theme.font.sans;
52
+ let result = '';
53
+ if (sans.url && sans.url.length > 0) {
54
+ result = `@import url('${sans.url}');\n\n`;
55
+ }
56
+
57
+ result =
58
+ result +
59
+ `$font-family: ${sans.family.reduce(
60
+ (result, family, index) =>
61
+ `${index === 0 ? '' : result + ', '}'${family}'`,
62
+ ''
63
+ )};`;
64
+
65
+ return result;
66
+ }
67
+
68
+ return undefined;
69
+ }
70
+
71
+ export function createConfigurationFile(path: string) {
72
+ type RecursiveRequired<T> = {
73
+ [P in keyof T]-?: RecursiveRequired<T[P]>;
74
+ };
75
+ const exampleConfigurationFile: RecursiveRequired<ConfigurationFile> = {
76
+ theme: {
77
+ colors: {
78
+ primary: {
79
+ 100: '',
80
+ 300: '',
81
+ 500: '',
82
+ 700: '',
83
+ 900: '',
84
+ },
85
+ },
86
+ font: {
87
+ sans: {
88
+ family: [],
89
+ url: '',
90
+ },
91
+ },
92
+ },
93
+ };
94
+
95
+ fs.appendFileSync(path, JSON.stringify(exampleConfigurationFile, null, 2));
96
+ }
97
+
98
+ export function readConfigurationFile(path: string): ConfigurationFile {
99
+ const configurationFile = fs.readFileSync(path, 'utf8');
100
+ const parsedConfigurationFile = JSON.parse(configurationFile);
101
+ return parsedConfigurationFile;
102
+ }
103
+
104
+ const SCSS_LIB_FOLDER_PATH = __dirname + '/../../lib/scss';
105
+ const COLORS_OVERRIDE_PATH =
106
+ SCSS_LIB_FOLDER_PATH + '/public/colors/overrides.scss';
107
+ const FONT_OVERRIDE_PATH = SCSS_LIB_FOLDER_PATH + '/public/font/overrides.scss';
108
+
109
+ export function resetToDefaultTheme() {
110
+ fs.writeFileSync(COLORS_OVERRIDE_PATH, '');
111
+ fs.writeFileSync(FONT_OVERRIDE_PATH, '');
112
+ const result = sass.renderSync({
113
+ file: SCSS_LIB_FOLDER_PATH + '/index.scss',
114
+ outFile: SCSS_LIB_FOLDER_PATH + '/../index.css',
115
+ });
116
+ fs.writeFileSync(SCSS_LIB_FOLDER_PATH + '/../../index.css', result.css);
117
+ }
118
+
119
+ export function generateSass(configuration: ConfigurationFile) {
120
+ const colors = generatePrimaryColors(configuration);
121
+ const font = generateFont(configuration);
122
+
123
+ colors && fs.writeFileSync(COLORS_OVERRIDE_PATH, colors);
124
+ font && fs.writeFileSync(FONT_OVERRIDE_PATH, font);
125
+
126
+ const result = sass.renderSync({
127
+ file: SCSS_LIB_FOLDER_PATH + '/index.scss',
128
+ outFile: SCSS_LIB_FOLDER_PATH + '/../index.css',
129
+ });
130
+
131
+ fs.writeFileSync(SCSS_LIB_FOLDER_PATH + '/../../index.css', result.css);
132
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "theme": {
3
+ "colors": {
4
+ "primary": {
5
+ "100": "#FFA07A",
6
+ "300": "#E9967A",
7
+ "500": "#FA8072",
8
+ "700": "#F08080",
9
+ "900": "#CD5C5C"
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ @import 'lib/scss/public/colors';
@@ -0,0 +1 @@
1
+ @import 'lib/scss/public/font-weight';
package/src/grid.scss ADDED
@@ -0,0 +1 @@
1
+ @import 'lib/scss/public/grid';
package/src/index.tsx ADDED
@@ -0,0 +1,37 @@
1
+ import ReactDOM from 'react-dom';
2
+ import App from './App';
3
+
4
+ export {
5
+ DateSelector,
6
+ Dropzone,
7
+ SignaturePad,
8
+ AutocompleteAddress,
9
+ Input,
10
+ MultiDropzone,
11
+ DownloadRing,
12
+ IbanInput,
13
+ CurrencyInput,
14
+ BottomModal,
15
+ RegularModal,
16
+ BottomOrRegularModal,
17
+ CardWithTopLeftIcon,
18
+ CardWithLeftIcon,
19
+ CardWithTopIcon,
20
+ InfoCard,
21
+ CardButton,
22
+ Button,
23
+ AutoSuggestMultiSelect,
24
+ Chip,
25
+ AutoSuggestInput,
26
+ ComparisonTable,
27
+ TableRating,
28
+ TableTrueFalse,
29
+ TableRowHeader,
30
+ TableInfoButton,
31
+ SegmentedControl,
32
+ DownloadButton
33
+ } from './lib';
34
+
35
+ export type { TableHeader, DownloadRingDownloadStatus, DownloadStatus } from './lib';
36
+
37
+ ReactDOM.render(<App />, document.getElementById('root'));
@@ -0,0 +1,41 @@
1
+ # Dirty Swan
2
+
3
+ <Meta title="Intro" />
4
+
5
+ Dirty Swan is the Design System build and maintained at [Feather](https://feather-insurance.com/).
6
+
7
+ ## Installation
8
+
9
+ Run the following command using [npm](https://www.npmjs.com):
10
+
11
+ ```bash
12
+ npm install @popsure/dirty-swan --save
13
+ ```
14
+
15
+ If you prefer [Yarn](https://www.npmjs.com), use the following command instead:
16
+
17
+ ```bash
18
+ yarn add @popsure/dirty-swan
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ To use Dirty Swan, import the scss file in one of your App entry point (typically `index/js` or `App.js` if you’re using [create react app](https://create-react-app.dev))
24
+
25
+ ```javaScript
26
+ import '@popsure/dirty-swan/dist/index.css';
27
+ ```
28
+
29
+ ## Design values
30
+
31
+ ### Simple Swan
32
+
33
+ We are a company that believes in the simplicity of things. We don't want to over complicate something that is already a thousand headed hydra at the best of times. We believe that problems can be solved elegantly but most importantly, simply.
34
+
35
+ We aren't ones to break the wheel, if it works we'll make full use of it. That's why we believe in a design system that is usable and reusable, designing with simplicity and durability in mind.
36
+
37
+ ### Lego Swan
38
+
39
+ Our design system, like many before it, uses the fundamental methodology of Atomic Design. Building from what is as a foundation and continuously improving from what was.
40
+
41
+ We believe in building a solid foundation in order to continue solidly from where we began. Future proofing is one of our fundamental values and beliefs. Everything that we design and implement is done with future features in mind.
@@ -0,0 +1,38 @@
1
+ import React, { useState } from 'react';
2
+ import { Address } from '@popsure/public-models';
3
+
4
+ import AutoCompleteAddress from '.';
5
+
6
+ export const WithoutAddress = () => {
7
+ const [address, setAddress] = useState<Partial<Address> | undefined>(
8
+ undefined
9
+ );
10
+ return (
11
+ <AutoCompleteAddress
12
+ onAddressChange={(address) => {
13
+ setAddress(address);
14
+ }}
15
+ address={address}
16
+ apiKey="AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8"
17
+ />
18
+ );
19
+ };
20
+
21
+ export const WithAddress = () => {
22
+ const [address, setAddress] = useState<Partial<Address> | undefined>({
23
+ street: 'Lohmuehlenstraße',
24
+ houseNumber: '65',
25
+ city: 'Berlin',
26
+ country: 'DE',
27
+ additionalInformation: 'c/o Factory',
28
+ });
29
+ return (
30
+ <AutoCompleteAddress
31
+ onAddressChange={(address) => {
32
+ setAddress(address);
33
+ }}
34
+ address={address}
35
+ apiKey="AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8"
36
+ />
37
+ );
38
+ };
@@ -0,0 +1,44 @@
1
+ import { useState } from 'react';
2
+
3
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
4
+
5
+ import AutocompleteAddress from '.';
6
+ import { WithoutAddress, WithAddress } from './demo';
7
+
8
+ <Meta title="JSX/Autocomplete Address" component={AutocompleteAddress} />
9
+
10
+ # Autocomplete Address
11
+
12
+ | attribute | unit | description | default value | required |
13
+ | --------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------- | -------- |
14
+ | address | `Partial<Address>` | The address | undefined | false |
15
+ | onAddressChange | `function (newAddress: Partial<Address>)` | Callback with the updated address, this function will get called everytime the address gets updated. | n/a | true |
16
+ | apiKey | string | Your private API key for the [Google Places API](https://developers.google.com/maps/documentation/places/web-service/overview) | n/a | true |
17
+
18
+ Autocomplete Address are user interface elements which allow users start typing an address and get autocompletion suggestions on the address.
19
+
20
+ ## Important notes
21
+
22
+ This component is for now only restricted to "address" types and will restrict every query to Germany.
23
+
24
+ ## Default example
25
+
26
+ ### Input without an address filled
27
+
28
+ <WithoutAddress />
29
+
30
+ ### Input with an address filled
31
+
32
+ <WithAddress />
33
+
34
+ ```typescript
35
+ import React, { useState } from 'react';
36
+ import { Address } from '@popsure/public-models';
37
+
38
+ import AutoCompleteAddress from '.';
39
+
40
+ export default () => {
41
+ const [address, setAddress] = useState<Address>(undefined);
42
+ return <AutoCompleteAddress onAddressChange={setAddress} address={address} />;
43
+ };
44
+ ```