jamespot-react-components 1.0.0 → 1.0.1

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 (53) hide show
  1. package/.github/workflows/deploy-dev-branches.yml +1 -1
  2. package/.github/workflows/npm-package.yml +33 -0
  3. package/build/jamespot-react-components.js +503 -308
  4. package/build/jamespot-react-components.js.map +1 -1
  5. package/build/src/components/Common/util/getColor.util.d.ts +2 -0
  6. package/build/src/components/Form/Common/FormHelper.d.ts +1 -0
  7. package/build/src/components/Form/Input/JRCFormCheckbox/JRCFormCheckbox.style.d.ts +5 -2
  8. package/build/src/components/Form/Input/JRCFormCheckbox/JRCToggle.d.ts +2 -1
  9. package/build/src/components/Form/Input/{JRCFormCheckbox → JRCInputCheckbox}/JRCInputCheckbox.d.ts +1 -1
  10. package/build/src/components/Form/Input/{JRCFormCheckbox → JRCInputCheckbox}/JRCInputCheckbox.stories.d.ts +1 -1
  11. package/build/src/components/Form/Input/JRCInputCheckbox/JRCInputCheckbox.types.d.ts +25 -0
  12. package/build/src/components/JRCAlert/JRCAlert.d.ts +2 -2
  13. package/build/src/components/JRCAppContainer/JRCAppContainer.d.ts +6 -0
  14. package/build/src/components/JRCAppHeader/JRCAppHeader.d.ts +4 -1
  15. package/build/src/components/JRCAppHeader/JRCAppHeader.styles.d.ts +3 -1
  16. package/build/src/components/JRCAppLeftColumn/JRCAppLeftColumn.d.ts +9 -0
  17. package/build/src/components/JRCAppLeftColumn/JRCAppLeftColumn.stories.d.ts +8 -0
  18. package/build/src/components/JRCAppLeftColumn/JRCAppLeftColumn.styles.d.ts +55 -0
  19. package/build/src/components/JRCAppLeftColumn/JRCAppLeftColumn.types.d.ts +59 -0
  20. package/build/src/components/JRCAppLeftColumn/JRCDefaultMenu.d.ts +2 -0
  21. package/build/src/components/JRCButtonDropdown/JRCButtonDropdown.d.ts +4 -0
  22. package/build/src/components/JRCCard/JRCCard.d.ts +5 -1
  23. package/build/src/components/JRCFileOpen/JRCFileOpen.d.ts +9 -0
  24. package/build/src/components/JRCFileOpen/extensions.d.ts +1 -0
  25. package/build/src/components/JRCIconButton/JRCIconButton.d.ts +5 -0
  26. package/build/src/components/JRCList/JRCList.d.ts +8 -3
  27. package/build/src/components/JRCList/JRCList.stories.d.ts +2 -1
  28. package/build/src/components/JRCList/JRCList.styles.d.ts +8 -7
  29. package/build/src/components/JRCLoader/JRCLoader.d.ts +6 -2
  30. package/build/src/components/JRCLoader/JRCLoader.stories.d.ts +2 -1
  31. package/build/src/components/JRCLoader/JRCSkeleton.d.ts +1 -0
  32. package/build/src/components/JRCMenuItem/JRCMenuItem.d.ts +21 -0
  33. package/build/src/components/JRCModal/JRCModal.d.ts +6 -4
  34. package/build/src/components/JRCModal/JRCModal.stories.d.ts +1 -0
  35. package/build/src/components/JRCModal/JRCModal.styles.d.ts +3 -9
  36. package/build/src/components/JRCTabs/JRCTabs.d.ts +7 -5
  37. package/build/src/components/JRCTooltip/JRCTooltip.d.ts +1 -1
  38. package/build/src/hooks/UseTimeout.d.ts +7 -0
  39. package/build/src/index.d.ts +10 -2
  40. package/build/src/types.d.ts +6 -2
  41. package/package.json +8 -8
  42. package/src/components/Common/util/getColor.util.ts +12 -0
  43. package/src/components/Form/Input/JRCFormColor/JRCFormColor.stories.tsx +1 -1
  44. package/src/components/Form/Input/JRCFormColor/JRCFormColor.tsx +5 -345
  45. package/src/components/JRCAlert/JRCAlert.tsx +3 -15
  46. package/src/components/JRCCard/JRCCard.tsx +6 -4
  47. package/src/components/JRCLoader/JRCLoader.stories.tsx +6 -1
  48. package/src/components/JRCLoader/JRCLoader.tsx +13 -3
  49. package/src/components/JRCLoader/JRCSkeleton.tsx +77 -0
  50. package/src/components/JRCModal/JRCModal.styles.tsx +1 -0
  51. package/src/translation/lang.json +1 -0
  52. package/src/types.ts +2 -1
  53. package/.github/workflows/create-stable-branch.yml +0 -80
@@ -1,4 +1,6 @@
1
1
  export { JRCAppHeaderProps } from './components/JRCAppHeader/JRCAppHeader.types';
2
+ export { JRCAppLeftColumnProps, SectionEntry } from './components/JRCAppLeftColumn/JRCAppLeftColumn.types';
3
+ export { JRCAppContainerProps } from './components/JRCAppContainer/JRCAppContainer';
2
4
  import { JRCAutocompleteAudienceProps } from './components/Form/Input/JRCFormAutocomplete/JRCFormAutocompleteAudience';
3
5
  export { JRCAutocompleteAudienceProps };
4
6
  import { JRCAutocompleteTaxonomyProps } from './components/Form/Input/JRCFormAutocomplete/JRCFormAutocompleteTaxonomy';
@@ -20,7 +22,8 @@ import { JRCFormSendAlertInputProps } from './components/Form/Input/JRCFormSendA
20
22
  export { JRCFormSendAlertInputProps };
21
23
  import { TextareaFormInputProps } from './components/Form/Input/JRCFormTextarea/JRCFormTextarea';
22
24
  export { TextareaFormInputProps };
23
- export { JRCAlertProps, AlertType } from './components/JRCAlert/JRCAlert';
25
+ export { MessageType } from './components/Common/util/getColor.util';
26
+ export { JRCAlertProps } from './components/JRCAlert/JRCAlert';
24
27
  import { JRCAvatarProps } from './components/JRCAvatar/JRCAvatar';
25
28
  export { JRCAvatarProps };
26
29
  import { JRCButtonProps } from './components/JRCButton/JRCButton';
@@ -36,6 +39,7 @@ import { JRCColumnRightProps } from './components/JRCColumnRight/JRCColumnRight'
36
39
  export { JRCColumnRightProps };
37
40
  export { JRCDateProps } from './components/JRCDate/JRCDate';
38
41
  export { JRCDropDownProps } from './components/JRCDropDown/JRCDropDown';
42
+ export { JRCFileOpenProps } from './components/JRCFileOpen/JRCFileOpen';
39
43
  import { JRCGridProps } from './components/JRCGrid/JRCGrid';
40
44
  export { JRCGridProps };
41
45
  import { JRCH1Props, JRCH2Props, JRCH3Props, JRCH4Props, JRCH5Props, JRCTextProps } from './components/JRCTypo/JRCTypo';
@@ -75,7 +79,7 @@ export { JRCWritableFormInputProps };
75
79
  import { JRCTypographyProps } from './components/JRCTypography/JRCTypography.d';
76
80
  export { JRCTypographyProps };
77
81
  export { JRCValidationButtonProps } from './components/JRCButton/JRCValidationButton';
78
- export { JRCInputCheckboxProps } from './components/Form/Input/JRCFormCheckbox/JRCInputCheckbox';
82
+ export * from './components/Form/Input/JRCInputCheckbox/JRCInputCheckbox.types';
79
83
  export { JRCInputFieldProps } from './components/Form/Input/Common/JRCFormFieldRenderer.types';
80
84
  export { JRCInputSelectProps } from './components/Form/Input/JRCSelect/JRCInputSelect.types';
81
85
  export { JRCAutocompleteProps } from './components/Form/Input/JRCSelect/JRCInputSelect.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jamespot-react-components",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "./build/jamespot-react-components.js",
6
6
  "types": "./build/src/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "@babel/preset-env": "^7.12.7",
32
32
  "@babel/preset-react": "^7.12.7",
33
33
  "@babel/preset-typescript": "^7.12.7",
34
- "@storybook/addon-actions": "^6.4.0",
35
- "@storybook/addon-docs": "^6.4.0",
36
- "@storybook/addon-essentials": "^6.4.0",
37
- "@storybook/addon-links": "^6.4.0",
38
- "@storybook/builder-webpack5": "^6.4.0",
39
- "@storybook/manager-webpack5": "^6.4.0",
40
- "@storybook/react": "^6.4.0",
34
+ "@storybook/addon-actions": "^6.4.19",
35
+ "@storybook/addon-docs": "^6.4.19",
36
+ "@storybook/addon-essentials": "^6.4.19",
37
+ "@storybook/addon-links": "^6.4.19",
38
+ "@storybook/builder-webpack5": "^6.4.19",
39
+ "@storybook/manager-webpack5": "^6.4.19",
40
+ "@storybook/react": "^6.4.19",
41
41
  "@testing-library/dom": "^8.11.0",
42
42
  "@testing-library/jest-dom": "^5.12.0",
43
43
  "@testing-library/react": "^12.1.2",
@@ -0,0 +1,12 @@
1
+ export type MessageType = 'success' | 'error' | 'warning';
2
+
3
+ export const getColor = (type: MessageType) => {
4
+ switch (type) {
5
+ case 'error':
6
+ return 'orange';
7
+ case 'warning':
8
+ return 'yellow';
9
+ default:
10
+ return 'green';
11
+ }
12
+ };
@@ -10,7 +10,7 @@ export default {
10
10
  decorators: [withReduxForm],
11
11
  } as Meta;
12
12
 
13
- const Template: Story<JRCWritableFormInputProps> = (args) => <JRCFormColorField {...args} />;
13
+ const Template: Story<JRCWritableFormInputProps> = (args: any) => <JRCFormColorField {...args} />;
14
14
 
15
15
  export const InputColor = Template.bind({});
16
16
  InputColor.args = {
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { Field, WrappedFieldInputProps } from 'redux-form';
3
- import JRCIcon from '../../../JRCIcon/JRCIcon';
4
3
  import JRCFormFieldRender, { FormInputProps, JRCWritableFormInputProps } from '../JRCFormFieldRender';
5
4
  import { useControls } from '../ReduxFormControls';
6
5
  import { useIntl } from 'react-intl';
@@ -15,6 +14,8 @@ const StyledInputColor = styled.input.attrs(() => ({ type: 'color' }))<FormInput
15
14
  height: 40px;
16
15
  cursor: pointer;
17
16
  border-radius: 4px;
17
+ text-align: center;
18
+ box-sizing: border-box;
18
19
  ::-webkit-color-swatch {
19
20
  border-color: transparent;
20
21
  }
@@ -24,372 +25,31 @@ const StyledInputColor = styled.input.attrs(() => ({ type: 'color' }))<FormInput
24
25
  }
25
26
  `;
26
27
 
27
- const colors = [
28
- 'rgb(255, 235, 238)',
29
- 'rgb(255, 205, 210)',
30
- 'rgb(239, 154, 154)',
31
- 'rgb(229, 115, 115)',
32
- 'rgb(239, 83, 80)',
33
- 'rgb(244, 67, 54)',
34
- 'rgb(229, 57, 53)',
35
- 'rgb(211, 47, 47)',
36
- 'rgb(198, 40, 40)',
37
- 'rgb(183, 28, 28)',
38
- 'rgb(252, 228, 236)',
39
- 'rgb(248, 187, 208)',
40
- 'rgb(244, 143, 177)',
41
- 'rgb(240, 98, 146)',
42
- 'rgb(236, 64, 122)',
43
- 'rgb(233, 30, 99)',
44
- 'rgb(216, 27, 96)',
45
- 'rgb(194, 24, 91)',
46
- 'rgb(173, 20, 87)',
47
- 'rgb(136, 14, 79)',
48
- 'rgb(243, 229, 245)',
49
- 'rgb(225, 190, 231)',
50
- 'rgb(206, 147, 216)',
51
- 'rgb(186, 104, 200)',
52
- 'rgb(171, 71, 188)',
53
- 'rgb(156, 39, 176)',
54
- 'rgb(142, 36, 170)',
55
- 'rgb(123, 31, 162)',
56
- 'rgb(106, 27, 154)',
57
- 'rgb(74, 20, 140)',
58
- 'rgb(237, 231, 246)',
59
- 'rgb(209, 196, 233)',
60
- 'rgb(179, 157, 219)',
61
- 'rgb(149, 117, 205)',
62
- 'rgb(126, 87, 194)',
63
- 'rgb(103, 58, 183)',
64
- 'rgb(94, 53, 177)',
65
- 'rgb(81, 45, 168)',
66
- 'rgb(69, 39, 160)',
67
- 'rgb(49, 27, 146)',
68
- 'rgb(232, 234, 246)',
69
- 'rgb(197, 202, 233)',
70
- 'rgb(159, 168, 218)',
71
- 'rgb(121, 134, 203)',
72
- 'rgb(92, 107, 192)',
73
- 'rgb(63, 81, 181)',
74
- 'rgb(57, 73, 171)',
75
- 'rgb(48, 63, 159)',
76
- 'rgb(40, 53, 147)',
77
- 'rgb(26, 35, 126)',
78
- 'rgb(227, 242, 253)',
79
- 'rgb(187, 222, 251)',
80
- 'rgb(144, 202, 249)',
81
- 'rgb(100, 181, 246)',
82
- 'rgb(66, 165, 245)',
83
- 'rgb(33, 150, 243)',
84
- 'rgb(30, 136, 229)',
85
- 'rgb(25, 118, 210)',
86
- 'rgb(21, 101, 192)',
87
- 'rgb(13, 71, 161)',
88
- 'rgb(225, 245, 254)',
89
- 'rgb(179, 229, 252)',
90
- 'rgb(129, 212, 250)',
91
- 'rgb(79, 195, 247)',
92
- 'rgb(41, 182, 246)',
93
- 'rgb(3, 169, 244)',
94
- 'rgb(3, 155, 229)',
95
- 'rgb(2, 136, 209)',
96
- 'rgb(2, 119, 189)',
97
- 'rgb(1, 87, 155)',
98
- 'rgb(224, 247, 250)',
99
- 'rgb(178, 235, 242)',
100
- 'rgb(128, 222, 234)',
101
- 'rgb(77, 208, 225)',
102
- 'rgb(38, 198, 218)',
103
- 'rgb(0, 188, 212)',
104
- 'rgb(0, 172, 193)',
105
- 'rgb(0, 151, 167)',
106
- 'rgb(0, 131, 143)',
107
- 'rgb(0, 96, 100)',
108
- 'rgb(224, 242, 241)',
109
- 'rgb(178, 223, 219)',
110
- 'rgb(128, 203, 196)',
111
- 'rgb(77, 182, 172)',
112
- 'rgb(38, 166, 154)',
113
- 'rgb(0, 150, 136)',
114
- 'rgb(0, 137, 123)',
115
- 'rgb(0, 121, 107)',
116
- 'rgb(0, 105, 92)',
117
- 'rgb(0, 77, 64)',
118
- 'rgb(232, 245, 233)',
119
- 'rgb(200, 230, 201)',
120
- 'rgb(165, 214, 167)',
121
- 'rgb(129, 199, 132)',
122
- 'rgb(102, 187, 106)',
123
- 'rgb(76, 175, 80)',
124
- 'rgb(67, 160, 71)',
125
- 'rgb(56, 142, 60)',
126
- 'rgb(46, 125, 50)',
127
- 'rgb(27, 94, 32)',
128
- 'rgb(241, 248, 233)',
129
- 'rgb(220, 237, 200)',
130
- 'rgb(197, 225, 165)',
131
- 'rgb(174, 213, 129)',
132
- 'rgb(156, 204, 101)',
133
- 'rgb(139, 195, 74)',
134
- 'rgb(124, 179, 66)',
135
- 'rgb(104, 159, 56)',
136
- 'rgb(85, 139, 47)',
137
- 'rgb(51, 105, 30)',
138
- 'rgb(249, 251, 231)',
139
- 'rgb(240, 244, 195)',
140
- 'rgb(230, 238, 156)',
141
- 'rgb(220, 231, 117)',
142
- 'rgb(212, 225, 87)',
143
- 'rgb(205, 220, 57)',
144
- 'rgb(192, 202, 51)',
145
- 'rgb(175, 180, 43)',
146
- 'rgb(158, 157, 36)',
147
- 'rgb(130, 119, 23)',
148
- 'rgb(255, 253, 231)',
149
- 'rgb(255, 249, 196)',
150
- 'rgb(255, 245, 157)',
151
- 'rgb(255, 241, 118)',
152
- 'rgb(255, 238, 88)',
153
- 'rgb(255, 235, 59)',
154
- 'rgb(253, 216, 53)',
155
- 'rgb(251, 192, 45)',
156
- 'rgb(249, 168, 37)',
157
- 'rgb(245, 127, 23)',
158
- 'rgb(255, 248, 225)',
159
- 'rgb(255, 236, 179)',
160
- 'rgb(255, 224, 130)',
161
- 'rgb(255, 213, 79)',
162
- 'rgb(255, 202, 40)',
163
- 'rgb(255, 193, 7)',
164
- 'rgb(255, 179, 0)',
165
- 'rgb(255, 160, 0)',
166
- 'rgb(255, 143, 0)',
167
- 'rgb(255, 111, 0)',
168
- 'rgb(255, 243, 224)',
169
- 'rgb(255, 224, 178)',
170
- 'rgb(255, 204, 128)',
171
- 'rgb(255, 183, 77)',
172
- 'rgb(255, 167, 38)',
173
- 'rgb(255, 152, 0)',
174
- 'rgb(251, 140, 0)',
175
- 'rgb(245, 124, 0)',
176
- 'rgb(239, 108, 0)',
177
- 'rgb(230, 81, 0)',
178
- 'rgb(251, 233, 231)',
179
- 'rgb(255, 204, 188)',
180
- 'rgb(255, 171, 145)',
181
- 'rgb(255, 138, 101)',
182
- 'rgb(255, 112, 67)',
183
- 'rgb(255, 87, 34)',
184
- 'rgb(244, 81, 30)',
185
- 'rgb(230, 74, 25)',
186
- 'rgb(216, 67, 21)',
187
- 'rgb(191, 54, 12)',
188
- 'rgb(239, 235, 233)',
189
- 'rgb(215, 204, 200)',
190
- 'rgb(188, 170, 164)',
191
- 'rgb(161, 136, 127)',
192
- 'rgb(141, 110, 99)',
193
- 'rgb(121, 85, 72)',
194
- 'rgb(109, 76, 65)',
195
- 'rgb(93, 64, 55)',
196
- 'rgb(78, 52, 46)',
197
- 'rgb(62, 39, 35)',
198
- 'rgb(250, 250, 250)',
199
- 'rgb(245, 245, 245)',
200
- 'rgb(238, 238, 238)',
201
- 'rgb(224, 224, 224)',
202
- 'rgb(189, 189, 189)',
203
- 'rgb(158, 158, 158)',
204
- 'rgb(117, 117, 117)',
205
- 'rgb(97, 97, 97)',
206
- 'rgb(66, 66, 66)',
207
- 'rgb(33, 33, 33)',
208
- 'rgb(255, 255, 255)',
209
- 'rgb(207, 216, 220)',
210
- 'rgb(176, 190, 197)',
211
- 'rgb(144, 164, 174)',
212
- 'rgb(120, 144, 156)',
213
- 'rgb(96, 125, 139)',
214
- 'rgb(84, 110, 122)',
215
- 'rgb(69, 90, 100)',
216
- 'rgb(55, 71, 79)',
217
- 'rgb(0, 0, 0)',
218
- ];
219
-
220
28
  const Container = styled.div`
221
- display: flex;
222
- flex-direction: column;
223
- width: 500px;
224
- background-color: white;
225
- position: relative;
226
- `;
227
-
228
- const PickerContainer = styled.div`
229
- position: absolute;
230
- top: 65px;
231
- display: flex;
232
- flex-direction: column;
233
- flex-wrap: wrap;
234
- width: 400px;
235
- height: 213px;
236
- background-color: white;
237
- z-index: 1;
238
- padding: 8px;
239
- border-radius: 8px;
240
- box-shadow: 0 0 2px ${(props) => props.theme.color.grey2};
241
- `;
242
-
243
- const SelectColor = styled.div`
244
- display: flex;
245
- flex: 8%;
246
- cursor: pointer;
247
- margin: 2px;
248
- border-radius: 0px;
249
- &:hover {
250
- box-shadow: inset 0 0 4px #9e9e9e;
251
- }
252
- `;
253
-
254
- const EditPicker = styled.div`
255
29
  display: flex;
256
30
  flex: 1;
257
31
  flex-direction: row;
258
- justify-content: space-between;
32
+ justify-content: flex-start;
259
33
  align-items: center;
260
34
  margin: 0px;
261
35
  padding: 5px;
262
36
  border-radius: 4px;
263
37
  `;
264
38
 
265
- const Palette = styled.div`
266
- display: flex;
267
- flexdirection: row;
268
- justify-content: center;
269
- align-items: center;
270
- cursor: pointer;
271
- `;
272
-
273
- const ColorHex = styled.input`
274
- &&& {
275
- width: 100px;
276
- height: 40px;
277
- margin: 0px;
278
- margin-left: 8px;
279
- text-align: center;
280
- border-radius: 4px;
281
- }
282
- `;
283
-
284
- const Text = styled.span`
285
- font-size: 15px;
286
- font-weight: 400;
287
- margin-left: 5px;
288
- `;
289
-
290
- const RGBToHex = (color: string): string => {
291
- if (!color.includes('rgb')) {
292
- return color;
293
- }
294
-
295
- const rgb: number[] = color
296
- .substring(4, color.length - 1)
297
- .replace(/ /g, '')
298
- .split(',')
299
- .map((i) => Number(i));
300
- let r = rgb[0].toString(16);
301
- let g = rgb[1].toString(16);
302
- let b = rgb[2].toString(16);
303
-
304
- if (r.length == 1) r = '0' + r;
305
- if (g.length == 1) g = '0' + g;
306
- if (b.length == 1) b = '0' + b;
307
-
308
- return '#' + r + g + b;
309
- };
310
-
311
39
  const JRCFormColorFieldRender = (input: WrappedFieldInputProps, props: JRCWritableFormInputProps) => {
312
- const [open, setOpen] = React.useState(false);
40
+ const [, setOpen] = React.useState(false);
313
41
 
314
42
  React.useEffect(() => {
315
43
  if (input.value == '') input.onChange('#000000');
316
44
  }, []);
317
45
 
318
46
  const handleClickAway = () => setOpen(false);
319
- const handleOpen = () => setOpen(!open);
320
47
 
321
48
  return (
322
49
  <ClickAwayListener onClickAway={handleClickAway}>
323
50
  <Container>
324
- <EditPicker>
325
- {/* dirty fix to go over a css legacy rule, will be refactored when component is designed */}
326
- <StyledInputColor
327
- id={props.name}
328
- {...input}
329
- style={{ textAlign: 'center', boxSizing: 'border-box' }}
330
- />
331
- <ColorHex
332
- type="text"
333
- onChange={({ target }) => input.onChange(RGBToHex(target.value))}
334
- value={RGBToHex(input.value)}
335
- style={{ boxSizing: 'border-box' }}
336
- />
337
- <Palette onClick={handleOpen}>
338
- <svg
339
- id="Capa_2"
340
- enableBackground="new 0 0 512 512"
341
- height="20"
342
- width="20"
343
- viewBox="0 0 512 512"
344
- xmlns="http://www.w3.org/2000/svg">
345
- <g>
346
- <g>
347
- <path
348
- d="M106,361c-24.813,0-45,20.187-45,45s20.187,45,45,45s45-20.187,45-45S130.813,361,106,361z M106,421
349
- c-8.271,0-15-6.729-15-15s6.729-15,15-15s15,6.729,15,15S114.271,421,106,421z"
350
- />
351
- </g>
352
- </g>
353
- <g>
354
- <g>
355
- <path
356
- d="M484.927,304.736c10.233-13.848,12.118-33.159,2.813-49.274l-59.969-104.87c-10.374-17.968-32.25-26.167-51.764-20.951
357
- c4.155-18.677-3.997-38.714-21.423-48.775L250.667,20.87c-14.841-8.57-32.586-7.692-46.233,0.749C196.525,8.666,182.256,0,166,0
358
- H45C20.187,0,0,20.187,0,45c0,10.405,0,410.022,0,422c0,24.813,20.187,45,45,45c11.653,0,364.968,0,422,0
359
- c24.813,0,45-20.187,45-45V346C512,327.557,500.843,311.677,484.927,304.736z M181,467c0,8.271-6.729,15-15,15H45
360
- c-8.271,0-15-6.729-15-15c0-6.853,0-129.418,0-136h151V467z M181,301H30V180h151V301z M181,150H30V45c0-8.271,6.729-15,15-15h121
361
- c8.271,0,15,6.729,15,15V150z M211,59.568l4.171-7.225c4.138-7.165,13.332-9.629,20.496-5.492l103.917,59.996
362
- c7.165,4.137,9.628,13.331,5.48,20.516l-17.332,30.127c-0.434,0.641-0.824,1.307-1.152,2.002L211,360.395V59.568z M211,420.555
363
- l140.222-243.737l28.993-16.739c7.35-4.243,17.431-1.666,21.545,5.459l59.969,104.87c4.148,7.184,1.729,16.394-5.529,20.584
364
- c-10.712,6.201-234.651,135.846-245.2,141.953V420.555z M482,467c0,8.271-6.729,15-15,15H208.42
365
- c1.599-4.51,2.496-9.346,2.565-14.381L446.97,331H467c8.271,0,15,6.729,15,15V467z"
366
- />
367
- </g>
368
- </g>
369
- </svg>
370
- <Text>Afficher la palette</Text>
371
- <div>
372
- <JRCIcon name={open ? 'icon-angle-down' : 'icon-angle-up'} key={'icon-angle'} size={24} />
373
- </div>
374
- </Palette>
375
- </EditPicker>
376
51
  {/* dirty fix to go over a css legacy rule, will be refactored when component is designed */}
377
- <PickerContainer
378
- style={
379
- open
380
- ? { display: 'flex', boxSizing: 'content-box' }
381
- : { display: 'none', boxSizing: 'content-box' }
382
- }>
383
- {colors.map((color, index) => (
384
- <SelectColor
385
- key={index}
386
- onClick={() => {
387
- input.onChange(RGBToHex(color));
388
- }}
389
- style={{ backgroundColor: color }}
390
- />
391
- ))}
392
- </PickerContainer>
52
+ <StyledInputColor id={props.name} {...input} />
393
53
  </Container>
394
54
  </ClickAwayListener>
395
55
  );
@@ -4,8 +4,7 @@ import { JRCIconButton } from '../JRCIconButton/JRCIconButton';
4
4
  import JRCButton, { JRCButtonProps } from 'components/JRCButton/JRCButton';
5
5
  import { JRCTypography } from '../JRCTypography/JRCTypography';
6
6
  import JRCIcon from '../JRCIcon/JRCIcon';
7
-
8
- export type AlertType = 'success' | 'error' | 'warning';
7
+ import { getColor, MessageType } from 'components/Common/util/getColor.util';
9
8
 
10
9
  export interface JRCAlertProps extends React.ComponentPropsWithoutRef<'div'> {
11
10
  /** Alert title */
@@ -13,7 +12,7 @@ export interface JRCAlertProps extends React.ComponentPropsWithoutRef<'div'> {
13
12
  /** Main content of the alert */
14
13
  description?: string;
15
14
  /** Define the type of alert */
16
- type?: AlertType;
15
+ type?: MessageType;
17
16
  /** Add a loader which will make the alert disappear after the timeout */
18
17
  hasLoader?: boolean;
19
18
  /** Timeout */
@@ -22,7 +21,7 @@ export interface JRCAlertProps extends React.ComponentPropsWithoutRef<'div'> {
22
21
  buttons?: JRCButtonProps[];
23
22
  }
24
23
 
25
- const Alert = styled.div<{ description?: string; type: AlertType }>`
24
+ const Alert = styled.div<{ description?: string; type: MessageType }>`
26
25
  width: 320px;
27
26
  border-radius: 8px;
28
27
  background: ${(props) => (props.description ? 'white' : props.theme.color[getColor(props.type)])};
@@ -46,17 +45,6 @@ const Header = styled.div`
46
45
  align-items: center;
47
46
  `;
48
47
 
49
- const getColor = (type: AlertType) => {
50
- switch (type) {
51
- case 'error':
52
- return 'orange';
53
- case 'warning':
54
- return 'yellow';
55
- default:
56
- return 'green';
57
- }
58
- };
59
-
60
48
  const icons = {
61
49
  success: 'icon-check-circle',
62
50
  error: 'icon-times-circle',
@@ -1,3 +1,4 @@
1
+ import { getColor, MessageType } from 'components/Common/util/getColor.util';
1
2
  import * as React from 'react';
2
3
  import styled from 'styled-components';
3
4
 
@@ -7,20 +8,21 @@ export type JRCCardProps = {
7
8
  className?: string;
8
9
  children: React.ReactNode;
9
10
  variant?: TVariants;
11
+ type?: MessageType;
10
12
  };
11
13
 
12
- export const Card = styled.div`
14
+ export const Card = styled.div<{ type?: MessageType }>`
13
15
  border-radius: 8px;
14
- background-color: ${(props) => props.theme.color.white};
16
+ background: ${(props) => (props.type ? props.theme.color[getColor(props.type)] : 'white')};
15
17
  padding: 8px;
16
18
  margin: 0 8px 16px;
17
19
  `;
18
20
 
19
21
  export const JRCCard = (props: JRCCardProps) => {
20
- const { className, children, variant } = props;
22
+ const { className, children, variant, type } = props;
21
23
 
22
24
  return (
23
- <Card as={variant} className={className}>
25
+ <Card as={variant} className={className} type={type}>
24
26
  {children}
25
27
  </Card>
26
28
  );
@@ -9,4 +9,9 @@ export default {
9
9
 
10
10
  const Template: Story<JRCLoaderProps> = (args: JRCLoaderProps) => <JRCLoader {...args} />;
11
11
 
12
- export const Primary = Template.bind({});
12
+ export const Spinner = Template.bind({});
13
+
14
+ export const Skeleton = Template.bind({});
15
+ Skeleton.args = {
16
+ variant: 'skeleton',
17
+ };
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { Colors } from '../../styles/theme';
4
+ import { Skeleton } from './JRCSkeleton';
4
5
 
5
6
  /**
6
7
  * Props type for JRCLoader
@@ -8,10 +9,14 @@ import { Colors } from '../../styles/theme';
8
9
  * @member size size of the loader, default is s, 20px width
9
10
  */
10
11
 
11
- export interface JRCLoaderProps {
12
+ interface JRCSpinnerProps {
12
13
  color?: Colors;
13
14
  size?: 's' | 'm' | 'l';
14
15
  }
16
+ interface JRCLoaderVariantProps {
17
+ variant?: 'spinner' | 'skeleton';
18
+ }
19
+ export type JRCLoaderProps = JRCLoaderVariantProps & JRCSpinnerProps;
15
20
 
16
21
  const sizeMap = {
17
22
  s: 20,
@@ -19,7 +24,7 @@ const sizeMap = {
19
24
  l: 60,
20
25
  };
21
26
 
22
- const Loader = styled.div<Required<JRCLoaderProps>>`
27
+ const Loader = styled.div<Required<JRCSpinnerProps>>`
23
28
  border: ${(props) => `${sizeMap[props.size] / 10}px solid transparent`};
24
29
  border-top: ${(props) => `${sizeMap[props.size] / 10}px solid ${props.theme.color[props.color]}`};
25
30
  border-radius: 50%;
@@ -38,6 +43,11 @@ const Loader = styled.div<Required<JRCLoaderProps>>`
38
43
  }
39
44
  `;
40
45
 
41
- const JRCLoader = ({ color = 'primary', size = 's' }: JRCLoaderProps) => <Loader color={color} size={size} />;
46
+ const JRCLoader = ({ color = 'primary', size = 's', variant = 'spinner' }: JRCLoaderProps) => {
47
+ if (variant === 'skeleton') {
48
+ return <Skeleton />;
49
+ }
50
+ return <Loader color={color} size={size} />;
51
+ };
42
52
 
43
53
  export default JRCLoader;
@@ -0,0 +1,77 @@
1
+ import * as React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ type SSkeletonLineProps = {
5
+ width?: string;
6
+ height?: string;
7
+ translucent?: boolean;
8
+ };
9
+
10
+ const SSkeletonLine = styled.div<SSkeletonLineProps>`
11
+ display: inline-block;
12
+ width: ${(props) => props.width || `20em`};
13
+ height: ${(props) => props.height || `0.5em`};
14
+ border-radius: 5px;
15
+ margin: 5px;
16
+ background: linear-gradient(-90deg, #f0f0f0 0%, #f8f8f8 50%, #f0f0f0 100%);
17
+ background-size: 400% 400%;
18
+ animation: pulse 1.2s ease-in-out infinite;
19
+ @keyframes pulse {
20
+ 0% {
21
+ background-position: 0% 0%;
22
+ }
23
+ 100% {
24
+ background-position: -135% 0%;
25
+ }
26
+ }
27
+ `;
28
+ const SkeletonRowContainer = styled.div`
29
+ display: flex;
30
+ flex-direction: row;
31
+ flex-wrap: nowrap;
32
+ justify-content: flex-start;
33
+ align-items: flex-start;
34
+ flex: 1 100%;
35
+ overflow: hidden;
36
+ border-radius: 6px;
37
+ border: 1px solid ${(props) => props.theme.color.grey1};
38
+ margin: 8px 32px;
39
+ padding: 22px;
40
+ cursor: pointer;
41
+ &:hover {
42
+ border: 1px solid ${(props) => props.theme.color.lavender};
43
+ background: ${(props) => props.theme.color.grey0};
44
+ }
45
+ `;
46
+
47
+ const SkeletonLines = styled.div`
48
+ display: flex;
49
+ flex: 4;
50
+ flex-direction: column;
51
+ flex-wrap: wrap;
52
+ justify-content: flex-start;
53
+ align-items: flex-start;
54
+ margin: 2px 8px;
55
+ `;
56
+
57
+ const SkeletonPart = () => (
58
+ <SkeletonRowContainer data-theme="skeleton">
59
+ <SkeletonLines>
60
+ <SSkeletonLine width="50%" />
61
+ <SSkeletonLine width="30%" />
62
+ <br />
63
+ <SSkeletonLine width="50%" />
64
+ <SSkeletonLine width="30%" />
65
+ <SSkeletonLine width="10%" />
66
+ </SkeletonLines>
67
+ </SkeletonRowContainer>
68
+ );
69
+
70
+ export const Skeleton = () => (
71
+ <>
72
+ <SkeletonPart />
73
+ <SkeletonPart />
74
+ <SkeletonPart />
75
+ <SkeletonPart />
76
+ </>
77
+ );