@onewelcome/react-lib-components 0.1.4-alpha → 0.1.7-alpha

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 (47) hide show
  1. package/dist/Button/IconButton.d.ts +2 -1
  2. package/dist/ContextMenu/ContextMenu.d.ts +2 -3
  3. package/dist/ContextMenu/ContextMenuItem.d.ts +10 -3
  4. package/dist/Form/Checkbox/Checkbox.d.ts +2 -2
  5. package/dist/Form/Toggle/Toggle.d.ts +1 -1
  6. package/dist/Link/Link.d.ts +4 -3
  7. package/dist/Notifications/BaseModal/BaseModal.d.ts +4 -2
  8. package/dist/Notifications/SlideInModal/SlideInModal.d.ts +4 -0
  9. package/dist/StatusIndicator/StatusIndicator.d.ts +9 -0
  10. package/dist/index.d.ts +43 -42
  11. package/dist/react-lib-components.cjs.development.js +2208 -2033
  12. package/dist/react-lib-components.cjs.development.js.map +1 -1
  13. package/dist/react-lib-components.cjs.production.min.js +1 -1
  14. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  15. package/dist/react-lib-components.esm.js +2207 -2034
  16. package/dist/react-lib-components.esm.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/Button/BaseButton.module.scss +3 -18
  19. package/src/Button/Button.module.scss +4 -311
  20. package/src/Button/IconButton.module.scss +21 -128
  21. package/src/Button/IconButton.test.tsx +24 -0
  22. package/src/Button/IconButton.tsx +6 -1
  23. package/src/ContextMenu/ContextMenu.test.tsx +121 -6
  24. package/src/ContextMenu/ContextMenu.tsx +84 -6
  25. package/src/ContextMenu/ContextMenuItem.tsx +57 -9
  26. package/src/Form/Checkbox/Checkbox.test.tsx +144 -8
  27. package/src/Form/Checkbox/Checkbox.tsx +8 -8
  28. package/src/Form/Toggle/Toggle.test.tsx +45 -19
  29. package/src/Form/Toggle/Toggle.tsx +3 -3
  30. package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +1 -1
  31. package/src/Link/Link.module.scss +20 -0
  32. package/src/Link/Link.test.tsx +33 -0
  33. package/src/Link/Link.tsx +8 -2
  34. package/src/Notifications/BaseModal/BaseModal.test.tsx +75 -11
  35. package/src/Notifications/BaseModal/BaseModal.tsx +27 -6
  36. package/src/Notifications/Dialog/Dialog.tsx +1 -1
  37. package/src/Notifications/SlideInModal/SlideInModal.module.scss +36 -0
  38. package/src/Notifications/SlideInModal/SlideInModal.test.tsx +69 -0
  39. package/src/Notifications/SlideInModal/SlideInModal.tsx +31 -0
  40. package/src/StatusIndicator/StatusIndicator.module.scss +27 -0
  41. package/src/StatusIndicator/StatusIndicator.test.tsx +127 -0
  42. package/src/StatusIndicator/StatusIndicator.tsx +25 -0
  43. package/src/Tiles/Tile.module.scss +1 -1
  44. package/src/Tiles/Tile.test.tsx +4 -4
  45. package/src/index.ts +79 -47
  46. package/src/mixins.module.scss +171 -0
  47. package/src/readyclasses.module.scss +0 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onewelcome/react-lib-components",
3
- "version": "0.1.4-alpha",
3
+ "version": "0.1.7-alpha",
4
4
  "license": "Apache-2.0",
5
5
  "author": "OneWelcome B.V.",
6
6
  "main": "dist/index.js",
@@ -1,20 +1,5 @@
1
- .button {
2
- border-width: var(--button-border-width);
3
- border-style: var(--button-border-style);
4
- border-radius: var(--button-border-radius);
5
- font-size: var(--button-font-size);
6
- line-height: var(--button-font-size);
7
- margin: 0;
8
- padding: 0.5rem 1.25rem;
9
- min-height: 2.5rem;
10
- cursor: pointer;
11
- transition-property: color, background-color, border-color;
12
- transition-duration: 0.2s;
13
- transition-timing-function: ease-in-out;
14
- font-family: var(--font-family);
1
+ @import '../mixins.module.scss';
15
2
 
16
- &:disabled {
17
- color: var(--greyed-out);
18
- cursor: not-allowed;
19
- }
3
+ .button {
4
+ @include buttonBase();
20
5
  }
@@ -1,323 +1,16 @@
1
1
  @import '../readyclasses.module.scss';
2
+ @import '../mixins.module.scss';
2
3
 
3
4
  .fill {
4
- color: var(--button-fill-text-color);
5
- font-weight: bold;
6
-
7
- &.primary:not(:disabled) {
8
- background-color: var(--color-primary);
9
- border-color: var(--color-primary);
10
-
11
- @include focusOutline(var(--color-primary));
12
-
13
- &:hover,
14
- &:focus {
15
- color: var(--color-primary);
16
- }
17
-
18
- &:active {
19
- position: relative;
20
- color: var(--color-primary);
21
-
22
- &:after {
23
- content: '';
24
- position: absolute;
25
- top: calc(-1 * var(--button-border-width));
26
- left: 0;
27
- width: 100%;
28
- height: calc(100% + var(--button-border-width));
29
- background-color: var(--color-primary);
30
- border-radius: var(--button-border-radius);
31
- filter: opacity(0.1);
32
- }
33
- }
34
- }
35
-
36
- &.secondary:not(:disabled) {
37
- background-color: var(--color-secondary);
38
- border-color: var(--color-secondary);
39
-
40
- @include focusOutline(var(--color-secondary));
41
-
42
- &:hover,
43
- &:focus {
44
- color: var(--color-secondary);
45
- }
46
-
47
- &:active {
48
- position: relative;
49
- color: var(--color-secondary);
50
-
51
- &:after {
52
- content: '';
53
- position: absolute;
54
- top: calc(-1 * var(--button-border-width));
55
- left: 0;
56
- width: 100%;
57
- height: calc(100% + var(--button-border-width));
58
- background-color: var(--color-secondary);
59
- border-radius: var(--button-border-radius);
60
- filter: opacity(0.1);
61
- }
62
- }
63
- }
64
-
65
- &.tertiary:not(:disabled) {
66
- background-color: var(--color-tertiary);
67
- border-color: var(--color-tertiary);
68
-
69
- @include focusOutline(var(--color-tertiary));
70
-
71
- &:hover,
72
- &:focus {
73
- color: var(--color-tertiary);
74
- }
75
-
76
- &:active {
77
- position: relative;
78
- color: var(--color-tertiary);
79
-
80
- &:after {
81
- content: '';
82
- position: absolute;
83
- top: calc(-1 * var(--button-border-width));
84
- left: 0;
85
- width: 100%;
86
- height: calc(100% + var(--button-border-width));
87
- background-color: var(--color-tertiary);
88
- border-radius: var(--button-border-radius);
89
- filter: opacity(0.1);
90
- }
91
- }
92
- }
93
-
94
- &.default:not(:disabled) {
95
- background-color: var(--default);
96
- border-color: var(--default);
97
-
98
- @include focusOutline(var(--default));
99
-
100
- &:hover,
101
- &:focus {
102
- color: var(--default);
103
- }
104
-
105
- &:active {
106
- position: relative;
107
- color: var(--default);
108
-
109
- &:after {
110
- content: '';
111
- position: absolute;
112
- top: calc(-1 * var(--button-border-width));
113
- left: 0;
114
- width: 100%;
115
- height: calc(100% + var(--button-border-width));
116
- background-color: var(--default);
117
- border-radius: var(--button-border-radius);
118
- filter: opacity(0.1);
119
- }
120
- }
121
- }
122
-
123
- &:hover:not(:disabled),
124
- &:focus:not(:disabled),
125
- &:active:not(:disabled) {
126
- background-color: var(--button-fill-background-color);
127
- }
128
-
129
- &:disabled {
130
- background-color: var(--disabled);
131
- border-color: var(--disabled);
132
- }
5
+ @include button('fill');
133
6
  }
134
7
 
135
8
  .outline {
136
- background-color: var(--button-fill-background-color);
137
- font-weight: bold;
138
-
139
- &.primary:not(:disabled) {
140
- border-color: var(--color-primary);
141
- color: var(--color-primary);
142
-
143
- @include focusOutline(var(--color-primary));
144
-
145
- &:hover,
146
- &:focus {
147
- background-color: var(--color-primary);
148
- }
149
- }
150
-
151
- &.secondary:not(:disabled) {
152
- border-color: var(--color-secondary);
153
- color: var(--color-secondary);
154
-
155
- @include focusOutline(var(--color-secondary));
156
-
157
- &:hover,
158
- &:focus {
159
- background-color: var(--color-secondary);
160
- }
161
- }
162
-
163
- &.tertiary:not(:disabled) {
164
- border-color: var(--color-tertiary);
165
- color: var(--color-tertiary);
166
-
167
- @include focusOutline(var(--color-tertiary));
168
-
169
- &:hover,
170
- &:focus {
171
- background-color: var(--color-tertiary);
172
- }
173
- }
174
-
175
- &.default:not(:disabled) {
176
- border-color: var(--default);
177
- color: var(--default);
178
-
179
- @include focusOutline(var(--default));
180
-
181
- &:hover,
182
- &:focus {
183
- background-color: var(--default);
184
- }
185
- }
186
-
187
- &:hover:not(:disabled),
188
- &:focus:not(:disabled) {
189
- color: var(--button-outline-hover-text-color);
190
- }
191
-
192
- &:disabled {
193
- border-color: var(--greyed-out);
194
- background-color: transparent;
195
- }
9
+ @include button('outline');
196
10
  }
197
11
 
198
12
  .text {
199
- border-color: transparent;
200
- background-color: transparent;
201
-
202
- &.primary:not(:disabled) {
203
- color: var(--color-primary);
204
-
205
- @include focusOutline(var(--color-primary));
206
-
207
- &:hover,
208
- &:focus {
209
- border-color: var(--color-primary);
210
- }
211
-
212
- &:active {
213
- background-color: transparent;
214
- position: relative;
215
- color: var(--color-primary);
216
- border-color: var(--button-fill-background-color);
217
-
218
- &:after {
219
- content: '';
220
- position: absolute;
221
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
222
- left: 0;
223
- width: 100%;
224
- height: calc(100% + var(--button-border-width));
225
- background-color: var(--color-primary);
226
- border-radius: var(--button-border-radius);
227
- filter: opacity(0.1);
228
- }
229
- }
230
- }
231
-
232
- &.secondary:not(:disabled) {
233
- color: var(--color-secondary);
234
-
235
- @include focusOutline(var(--color-secondary));
236
-
237
- &:hover,
238
- &:focus {
239
- border-color: var(--color-secondary);
240
- }
241
-
242
- &:active {
243
- background-color: transparent;
244
- position: relative;
245
- color: var(--color-secondary);
246
- border-color: var(--button-fill-background-color);
247
-
248
- &:after {
249
- content: '';
250
- position: absolute;
251
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
252
- left: 0;
253
- width: 100%;
254
- height: calc(100% + var(--button-border-width));
255
- background-color: var(--color-secondary);
256
- border-radius: var(--button-border-radius);
257
- filter: opacity(0.1);
258
- }
259
- }
260
- }
261
-
262
- &.tertiary:not(:disabled) {
263
- color: var(--color-tertiary);
264
-
265
- @include focusOutline(var(--color-tertiary));
266
-
267
- &:hover,
268
- &:focus {
269
- border-color: var(--color-tertiary);
270
- }
271
-
272
- &:active {
273
- background-color: transparent;
274
- position: relative;
275
- color: var(--color-tertiary);
276
- border-color: var(--button-fill-background-color);
277
-
278
- &:after {
279
- content: '';
280
- position: absolute;
281
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
282
- left: 0;
283
- width: 100%;
284
- height: calc(100% + var(--button-border-width));
285
- background-color: var(--color-tertiary);
286
- border-radius: var(--button-border-radius);
287
- filter: opacity(0.1);
288
- }
289
- }
290
- }
291
-
292
- &.default:not(:disabled) {
293
- color: var(--default);
294
-
295
- @include focusOutline(var(--default));
296
-
297
- &:hover,
298
- &:focus {
299
- border-color: var(--default);
300
- }
301
-
302
- &:active {
303
- background-color: transparent;
304
- position: relative;
305
- color: var(--default);
306
- border-color: var(--button-fill-background-color);
307
-
308
- &:after {
309
- content: '';
310
- position: absolute;
311
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
312
- left: 0;
313
- width: 100%;
314
- height: calc(100% + var(--button-border-width));
315
- background-color: var(--default);
316
- border-radius: var(--button-border-radius);
317
- filter: opacity(0.1);
318
- }
319
- }
320
- }
13
+ @include button('text');
321
14
  }
322
15
 
323
16
  .has-icon {
@@ -1,4 +1,5 @@
1
1
  @import '../readyclasses.module.scss';
2
+ @import '../mixins.module.scss';
2
3
 
3
4
  .icon-button {
4
5
  border: var(--button-border-width) var(--button-border-style) transparent;
@@ -8,154 +9,46 @@
8
9
  display: flex;
9
10
  align-items: center;
10
11
  justify-content: center;
12
+ min-height: auto;
11
13
 
12
- svg {
14
+ span {
13
15
  vertical-align: top;
14
16
  }
15
17
 
16
18
  /** Sizes **/
17
19
  &.button-s {
18
- svg {
19
- font-size: 14px;
20
+ span {
21
+ font-size: 0.75rem;
20
22
  }
21
- width: 30px;
22
- height: 30px;
23
+ width: 1.875rem;
24
+ height: 1.875rem;
23
25
  }
24
26
 
25
27
  &.button-m {
26
- svg {
27
- font-size: 24px;
28
+ span {
29
+ font-size: 1rem;
28
30
  }
29
- width: 40px;
30
- height: 40px;
31
+ width: 2.5rem;
32
+ height: 2.5rem;
31
33
  }
32
34
 
33
35
  &.button-l {
34
- svg {
35
- font-size: 34px;
36
+ span {
37
+ font-size: 1.375rem;
36
38
  }
37
- width: 50px;
38
- height: 50px;
39
+ width: 3.125rem;
40
+ height: 3.125rem;
39
41
  }
40
42
 
41
- /** Colors **/
42
- &.primary:not(:disabled) {
43
- color: var(--color-primary);
44
-
45
- @include focusOutline(var(--color-primary));
46
-
47
- &:hover,
48
- &:focus {
49
- border-color: var(--color-primary);
50
- }
51
-
52
- &:active {
53
- background-color: transparent;
54
- position: relative;
55
- color: var(--color-primary);
56
- border-color: var(--button-fill-background-color);
57
-
58
- &:after {
59
- content: '';
60
- position: absolute;
61
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
62
- left: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
63
- width: calc(100% + var(--button-border-width));
64
- height: calc(100% + var(--button-border-width));
65
- background-color: var(--color-primary);
66
- border-radius: var(--button-border-radius);
67
- filter: opacity(0.1);
68
- }
69
- }
70
- }
71
-
72
- &.secondary:not(:disabled) {
73
- color: var(--color-secondary);
74
-
75
- @include focusOutline(var(--color-secondary));
76
-
77
- &:hover,
78
- &:focus {
79
- border-color: var(--color-secondary);
80
- }
81
-
82
- &:active {
83
- background-color: transparent;
84
- position: relative;
85
- color: var(--color-secondary);
86
- border-color: var(--button-fill-background-color);
87
-
88
- &:after {
89
- content: '';
90
- position: absolute;
91
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
92
- left: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
93
- width: calc(100% + var(--button-border-width));
94
- height: calc(100% + var(--button-border-width));
95
- background-color: var(--color-secondary);
96
- border-radius: var(--button-border-radius);
97
- filter: opacity(0.1);
98
- }
99
- }
43
+ &.fill {
44
+ @include button('fill', 'icon');
100
45
  }
101
46
 
102
- &.tertiary:not(:disabled) {
103
- color: var(--color-tertiary);
104
-
105
- @include focusOutline(var(--color-tertiary));
106
-
107
- &:hover,
108
- &:focus {
109
- border-color: var(--color-tertiary);
110
- }
111
-
112
- &:active {
113
- background-color: transparent;
114
- position: relative;
115
- color: var(--color-tertiary);
116
- border-color: var(--button-fill-background-color);
117
-
118
- &:after {
119
- content: '';
120
- position: absolute;
121
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
122
- left: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
123
- width: calc(100% + var(--button-border-width));
124
- height: calc(100% + var(--button-border-width));
125
- background-color: var(--color-tertiary);
126
- border-radius: var(--button-border-radius);
127
- filter: opacity(0.1);
128
- }
129
- }
47
+ &.text {
48
+ @include button('text', 'icon');
130
49
  }
131
50
 
132
- &.default {
133
- color: var(--default);
134
-
135
- @include focusOutline(var(--default));
136
-
137
- &:hover,
138
- &:focus {
139
- border-color: var(--default);
140
- }
141
-
142
- &:active {
143
- background-color: transparent;
144
- position: relative;
145
- color: var(--default);
146
- border-color: var(--button-fill-background-color);
147
-
148
- &:after {
149
- content: '';
150
- position: absolute;
151
- top: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
152
- left: calc(-1 * var(--button-border-width) + (var(--button-border-width) / 2));
153
- width: calc(100% + var(--button-border-width));
154
- height: calc(100% + var(--button-border-width));
155
- background-color: var(--default);
156
- border-radius: var(--button-border-radius);
157
- filter: opacity(0.1);
158
- }
159
- }
51
+ &.outline {
52
+ @include button('outline', 'icon');
160
53
  }
161
54
  }
@@ -79,4 +79,28 @@ describe('Different variants of the button', () => {
79
79
  }));
80
80
  expect(iconButton.classList.contains('tertiary')).toBe(true);
81
81
  });
82
+
83
+ it('should have a class of "fill"', () => {
84
+ const { iconButton } = createIconButton((defaultParams) => ({
85
+ ...defaultParams,
86
+ variant: 'fill',
87
+ }));
88
+ expect(iconButton.classList.contains('fill')).toBe(true);
89
+ });
90
+
91
+ it('should have a class of "outline"', () => {
92
+ const { iconButton } = createIconButton((defaultParams) => ({
93
+ ...defaultParams,
94
+ variant: 'outline',
95
+ }));
96
+ expect(iconButton.classList.contains('outline')).toBe(true);
97
+ });
98
+
99
+ it('should have a class of "text"', () => {
100
+ const { iconButton } = createIconButton((defaultParams) => ({
101
+ ...defaultParams,
102
+ variant: 'text',
103
+ }));
104
+ expect(iconButton.classList.contains('text')).toBe(true);
105
+ });
82
106
  });
@@ -6,18 +6,23 @@ import readyclasses from '../readyclasses.module.scss';
6
6
  export interface Props extends BaseButtonProps {
7
7
  children?: React.ReactNode;
8
8
  iconSize?: 's' | 'm' | 'l';
9
+ variant?: 'text' | 'fill' | 'outline';
9
10
  className?: string;
10
11
  title?: string;
11
12
  }
12
13
 
13
14
  export const IconButton = React.forwardRef<HTMLButtonElement, Props>(
14
- ({ children, color = 'primary', iconSize = 'm', title, className, ...rest }, ref) => {
15
+ (
16
+ { children, color = 'primary', variant = 'text', iconSize = 'm', title, className, ...rest },
17
+ ref
18
+ ) => {
15
19
  if (!title) {
16
20
  console.error("Please make sure to specify a 'title' prop to your IconButton component! ");
17
21
  }
18
22
 
19
23
  const iconButtonClasses = [
20
24
  classes['icon-button'],
25
+ classes[variant],
21
26
  classes[color],
22
27
  classes['button-' + iconSize],
23
28
  ];