@popsure/dirty-swan 0.41.0-alpha → 0.41.0-alpha.2

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 (52) hide show
  1. package/dist/cjs/index.js +82 -81
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/button/index.d.ts +19 -12
  4. package/dist/cjs/lib/components/button/index.stories.d.ts +57 -0
  5. package/dist/cjs/lib/components/button/index.test.d.ts +1 -0
  6. package/dist/cjs/lib/index.d.ts +1 -1
  7. package/dist/esm/components/button/index.js +20 -17
  8. package/dist/esm/components/button/index.js.map +1 -1
  9. package/dist/esm/components/button/index.stories.js +97 -0
  10. package/dist/esm/components/button/index.stories.js.map +1 -0
  11. package/dist/esm/components/button/index.test.js +50 -0
  12. package/dist/esm/components/button/index.test.js.map +1 -0
  13. package/dist/esm/components/comparisonTable/index.js.map +1 -1
  14. package/dist/esm/components/downloadButton/index.js +5 -6
  15. package/dist/esm/components/downloadButton/index.js.map +1 -1
  16. package/dist/esm/components/downloadButton/index.stories.js +3 -2
  17. package/dist/esm/components/downloadButton/index.stories.js.map +1 -1
  18. package/dist/esm/components/icon/icons/Download.js +2 -2
  19. package/dist/esm/components/icon/icons/Download.js.map +1 -1
  20. package/dist/esm/components/icon/icons.stories.js +3 -3
  21. package/dist/esm/components/icon/icons.stories.js.map +1 -1
  22. package/dist/esm/components/icon/index.stories.js +1 -1
  23. package/dist/esm/components/toast/index.stories.js +2 -2
  24. package/dist/esm/components/toast/index.stories.js.map +1 -1
  25. package/dist/esm/{index-b4cd59e9.js → index-39fa3631.js} +3 -3
  26. package/dist/esm/{index-b4cd59e9.js.map → index-39fa3631.js.map} +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/lib/components/button/index.d.ts +19 -12
  29. package/dist/esm/lib/components/button/index.stories.d.ts +57 -0
  30. package/dist/esm/lib/components/button/index.test.d.ts +1 -0
  31. package/dist/esm/lib/index.d.ts +1 -1
  32. package/dist/index.css +84 -27
  33. package/dist/index.css.map +1 -1
  34. package/dist/lib/scss/private/components/_buttons.scss +107 -26
  35. package/package.json +1 -1
  36. package/src/lib/components/button/index.stories.tsx +189 -0
  37. package/src/lib/components/button/index.test.tsx +51 -0
  38. package/src/lib/components/button/index.tsx +78 -59
  39. package/src/lib/components/comparisonTable/index.tsx +1 -1
  40. package/src/lib/components/downloadButton/index.tsx +9 -8
  41. package/src/lib/components/icon/icons.stories.tsx +4 -2
  42. package/src/lib/components/toast/index.stories.tsx +2 -5
  43. package/src/lib/index.tsx +1 -1
  44. package/src/lib/scss/private/components/_buttons.scss +107 -26
  45. package/dist/cjs/lib/components/button/icons/index.d.ts +0 -9
  46. package/dist/esm/lib/components/button/icons/index.d.ts +0 -9
  47. package/src/lib/components/button/icons/index.ts +0 -14
  48. package/src/lib/components/button/icons/send-purple.svg +0 -4
  49. package/src/lib/components/button/icons/send-white.svg +0 -4
  50. package/src/lib/components/button/index.stories.mdx +0 -142
  51. package/src/lib/components/button/styles.module.scss +0 -5
  52. package/src/lib/components/downloadButton/icons/download.svg +0 -5
@@ -1,7 +1,6 @@
1
- import Button from '../button';
1
+ import { Button } from '../button';
2
2
  import { DownloadStatus } from '../../models/download';
3
- import downloadIcon from './icons/download.svg';
4
- import { CheckIcon } from '../icon/icons';
3
+ import { CheckIcon, DownloadIcon } from '../icon/icons';
5
4
  import styles from './style.module.scss';
6
5
 
7
6
  export interface DownloadButtonProps {
@@ -14,20 +13,22 @@ export interface DownloadButtonProps {
14
13
  const InitialButton = ({ onDownload }: { onDownload: () => void }) => (
15
14
  <Button
16
15
  className={`w100 ${styles.button}`}
17
- buttonTitle="Download"
18
- leftIcon={{ src: downloadIcon, alt: 'download arrow icon' }}
16
+ leftIcon={<DownloadIcon />}
19
17
  onClick={onDownload}
20
18
  data-cy="download-documents-button"
21
- />
19
+ >
20
+ Download
21
+ </Button>
22
22
  );
23
23
 
24
24
  // TODO: Allow setting loading to true to display text
25
25
  const GeneratingButton = () => (
26
26
  <Button
27
27
  className={`w100 ${styles.button}`}
28
- buttonTitle="Generating"
29
28
  loading={true}
30
- />
29
+ >
30
+ Generating
31
+ </Button>
31
32
  );
32
33
 
33
34
  const CompletedChip = () => (
@@ -1,7 +1,7 @@
1
1
  import { ChangeEvent, useState } from 'react';
2
2
  import { Input } from '../input';
3
3
  import * as icons from './icons';
4
- import Button from '../button';
4
+ import { Button } from '../button';
5
5
  import classNames from 'classnames';
6
6
  import styles from './style.module.scss';
7
7
 
@@ -45,7 +45,9 @@ export const IconsList = () => {
45
45
  placeholder='Search icon'
46
46
  value={value}
47
47
  />
48
- <Button className='w30' disabled={!value} buttonTitle='Clear search' onClick={clearSearch} />
48
+ <Button className='w30' disabled={!value} onClick={clearSearch}>
49
+ Clear search
50
+ </Button>
49
51
  </div>
50
52
  </div>
51
53
 
@@ -1,6 +1,6 @@
1
1
  import classNames from 'classnames';
2
2
  import { Toast, ToastProps, ToastType, Toaster, toast } from '.';
3
- import Button from '../button';
3
+ import { Button } from '../button';
4
4
  import styles from './style.module.scss';
5
5
 
6
6
  const toastTypes: ToastType[] = ['success', 'warning', 'error', 'information'];
@@ -87,10 +87,7 @@ export const ToastStory = ({ title, description, action, type, duration }: Toast
87
87
  </div>
88
88
  <Toaster />
89
89
 
90
- <Button
91
- buttonTitle='Click here to trigger toast'
92
- onClick={showToast}
93
- />
90
+ <Button onClick={showToast}>Click here to trigger toast</Button>
94
91
  </>
95
92
  );
96
93
  };
package/src/lib/index.tsx CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  InfoCard,
29
29
  CardButton,
30
30
  } from './components/cards';
31
- import Button from './components/button';
31
+ import { Button } from './components/button';
32
32
  import { AutoSuggestMultiSelect } from './components/input/autoSuggestMultiSelect';
33
33
  import Chip from './components/chip';
34
34
  import { AutoSuggestInput } from './components/input/autoSuggestInput';
@@ -12,13 +12,14 @@
12
12
  }
13
13
 
14
14
  .p-btn {
15
- display: inline-block;
16
-
15
+ display: inline-flex;
16
+ align-items: center;
17
+
17
18
  position: relative;
18
19
  cursor: pointer;
19
20
 
20
21
  height: 48px;
21
- padding: 12px 24px;
22
+ padding: 0 24px;
22
23
 
23
24
  line-height: 24px;
24
25
 
@@ -37,6 +38,12 @@
37
38
  &[disabled] {
38
39
  cursor: default;
39
40
  opacity: 0.5;
41
+ cursor: not-allowed;
42
+ }
43
+
44
+ &--icon-only {
45
+ width: 48px;
46
+ padding: 0;
40
47
  }
41
48
 
42
49
  &--primary {
@@ -95,6 +102,20 @@
95
102
  @extend .p-btn--secondary;
96
103
  background-color: $ds-primary-50;
97
104
  }
105
+
106
+ &-white {
107
+ @extend .p-btn--secondary;
108
+ background-color: $ds-white;
109
+ }
110
+
111
+ &-inverted {
112
+ @extend .p-btn--secondary;
113
+ color: $ds-white;
114
+
115
+ &:hover, &:focus {
116
+ background-color: $ds-primary-700;
117
+ }
118
+ }
98
119
  }
99
120
 
100
121
  &--danger {
@@ -122,30 +143,28 @@
122
143
  }
123
144
  }
124
145
 
125
- &--loading {
126
- color: transparent;
127
- cursor: default;
128
-
129
- opacity: 1 !important;
130
-
131
- &::before {
132
- content: '';
133
-
134
- $size: 26px;
135
-
136
- position: absolute;
146
+ &--success {
147
+ @extend .p-btn;
148
+ background-color: $ds-green-500;
149
+ color: white;
137
150
 
138
- width: $size;
139
- height: $size;
151
+ &:hover {
152
+ background-color: $ds-green-700;
140
153
 
141
- left: calc(50% - 13px);
142
- top: calc(50% - 13px);
154
+ @include p-size-mobile {
155
+ background-color: $ds-green-500;
156
+ }
157
+ }
143
158
 
144
- border-radius: 50%;
145
- border: 2px solid rgba($color: #ffffff, $alpha: 0.5);
146
- border-left-color: white;
159
+ &[disabled] {
160
+ background-color: $ds-green-300;
161
+ opacity: 1;
162
+ }
147
163
 
148
- animation: spinner-rotate 0.9s infinite;
164
+ &:focus {
165
+ outline: none;
166
+ box-shadow: 0 0 0 1px white,
167
+ 0 0 0 3px rgba($color: $ds-primary-500, $alpha: 0.5);
149
168
  }
150
169
  }
151
170
 
@@ -155,7 +174,7 @@
155
174
  color: $ds-primary-500;
156
175
  background-color: transparent;
157
176
 
158
- border: 1px dashed $ds-primary-300;
177
+ border: 1px solid $ds-primary-300;
159
178
 
160
179
  &:hover {
161
180
  color: $ds-primary-700;
@@ -170,7 +189,33 @@
170
189
 
171
190
  &:focus {
172
191
  color: $ds-primary-700;
173
- border-color: $ds-primary-700;
192
+ outline: none;
193
+ box-shadow: 0 0 0 1px white,
194
+ 0 0 0 3px rgba($color: $ds-primary-500, $alpha: 0.5);
195
+ }
196
+
197
+ &-white {
198
+ @extend .p-btn;
199
+
200
+ color: $ds-white;
201
+ border: 1px solid $ds-white;
202
+ background-color: transparent;
203
+
204
+ &:hover {
205
+ background-color: $ds-primary-700;
206
+ border-color: $ds-primary-700;
207
+ }
208
+
209
+ &[disabled] {
210
+ background-color: transparent;
211
+ opacity: 0.5;
212
+ }
213
+
214
+ &:focus {
215
+ outline: none;
216
+ box-shadow: 0 0 0 1px white,
217
+ 0 0 0 3px rgba($color: $ds-primary-500, $alpha: 0.5);
218
+ }
174
219
  }
175
220
 
176
221
  &-grey {
@@ -179,7 +224,7 @@
179
224
  color: $ds-grey-500;
180
225
  background-color: transparent;
181
226
 
182
- border: 1px dashed $ds-grey-400;
227
+ border: 1px solid $ds-grey-400;
183
228
 
184
229
  &:hover {
185
230
  color: $ds-grey-600;
@@ -198,4 +243,40 @@
198
243
  }
199
244
  }
200
245
  }
246
+
247
+ &--loading {
248
+ color: transparent;
249
+ cursor: default;
250
+
251
+ opacity: 1 !important;
252
+
253
+ &::before {
254
+ content: '';
255
+
256
+ $size: 26px;
257
+
258
+ position: absolute;
259
+
260
+ width: $size;
261
+ height: $size;
262
+
263
+ left: calc(50% - 13px);
264
+ top: calc(50% - 13px);
265
+
266
+ border-radius: 50%;
267
+ border: 2px solid rgba($color: #ffffff, $alpha: 0.5);
268
+ border-left-color: white;
269
+
270
+ animation: spinner-rotate 0.9s infinite;
271
+ }
272
+
273
+ &.p-btn--secondary-grey,
274
+ &.p-btn--secondary-white {
275
+ &::before {
276
+ border-color: rgba($color: $ds-primary-500, $alpha: 0.5);
277
+ border-left-color: $ds-primary-500;
278
+ }
279
+ }
280
+ }
281
+
201
282
  }
@@ -1,9 +0,0 @@
1
- declare const purpleSend: {
2
- src: string;
3
- alt: string;
4
- };
5
- declare const whiteSend: {
6
- src: string;
7
- alt: string;
8
- };
9
- export { purpleSend, whiteSend };
@@ -1,9 +0,0 @@
1
- declare const purpleSend: {
2
- src: string;
3
- alt: string;
4
- };
5
- declare const whiteSend: {
6
- src: string;
7
- alt: string;
8
- };
9
- export { purpleSend, whiteSend };
@@ -1,14 +0,0 @@
1
- import purpleSendImage from './send-purple.svg';
2
- import whiteSendImage from './send-white.svg';
3
-
4
- const purpleSend = {
5
- src: purpleSendImage,
6
- alt: 'Paper plane',
7
- };
8
-
9
- const whiteSend = {
10
- src: whiteSendImage,
11
- alt: 'Paper plane',
12
- };
13
-
14
- export { purpleSend, whiteSend };
@@ -1,4 +0,0 @@
1
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M18.3334 1.66667L9.16675 10.8333" stroke="#8E8CEE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
3
- <path d="M18.3334 1.66667L12.5001 18.3333L9.16675 10.8333L1.66675 7.5L18.3334 1.66667Z" stroke="#8E8CEE" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
4
- </svg>
@@ -1,4 +0,0 @@
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>
@@ -1,142 +0,0 @@
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">Secondary grey button</h1>
70
- <h4 className="p-h4 mt24">Default</h4>
71
- <Button
72
- className="wmn3 mt8"
73
- buttonTitle="Click me"
74
- buttonType="secondaryGrey"
75
- />
76
- <h4 className="p-h4 mt24">Disabled</h4>
77
- <Button
78
- className="wmn3 mt8"
79
- buttonTitle="Click me"
80
- buttonType="secondaryGrey"
81
- disabled={true}
82
- />
83
- <h4 className="p-h4 mt24">With left icon</h4>
84
- <Button
85
- className="wmn3 mt8"
86
- buttonTitle="Click me"
87
- buttonType="secondaryGrey"
88
- leftIcon={purpleSend}
89
- />
90
- <h1 className="p-h1 mt32">Outline button</h1>
91
- <h4 className="p-h4 mt24">Default</h4>
92
- <Button className="wmn3 mt8" buttonTitle="Click me" buttonType="outline" />
93
- <h4 className="p-h4 mt24">Disabled</h4>
94
- <Button
95
- className="wmn3 mt8"
96
- buttonTitle="Click me"
97
- buttonType="outline"
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="outline"
105
- leftIcon={purpleSend}
106
- />
107
- <h1 className="p-h1 mt32">Outline Grey button</h1>
108
- <h4 className="p-h4 mt24">Default</h4>
109
- <Button
110
- className="wmn3 mt8"
111
- buttonTitle="Click me"
112
- buttonType="outlineGrey"
113
- />
114
- <h4 className="p-h4 mt24">Disabled</h4>
115
- <Button
116
- className="wmn3 mt8"
117
- buttonTitle="Click me"
118
- buttonType="outlineGrey"
119
- disabled={true}
120
- />
121
- <h4 className="p-h4 mt24">With left icon</h4>
122
- <Button
123
- className="wmn3 mt8"
124
- buttonTitle="Click me"
125
- buttonType="outlineGrey"
126
- leftIcon={purpleSend}
127
- />
128
- </>
129
- </Preview>
130
-
131
- # Models
132
-
133
- ## Icon
134
-
135
- The icon object is defined with the following poperties
136
-
137
- ```typescript
138
- export interface Icon {
139
- src: string; // source of the image
140
- alt: string; // alternate text if the image can't be displayed
141
- }
142
- ```
@@ -1,5 +0,0 @@
1
- .content-container {
2
- display: flex;
3
- justify-content: center;
4
- align-items: center;
5
- }
@@ -1,5 +0,0 @@
1
- <svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M18 12.5V15.8333C18 16.2754 17.8244 16.6993 17.5118 17.0118C17.1993 17.3244 16.7754 17.5 16.3333 17.5H4.66667C4.22464 17.5 3.80072 17.3244 3.48816 17.0118C3.17559 16.6993 3 16.2754 3 15.8333V12.5" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
3
- <path d="M6.33325 8.33301L10.4999 12.4997L14.6666 8.33301" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
4
- <path d="M10.5 12.5V2.5" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
5
- </svg>