@digigov/react-icons 1.0.0-rc → 1.0.0-rc.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 (110) hide show
  1. package/AccessibilityIcon/__snapshots__/index.test.tsx.snap +0 -315
  2. package/AccessibilityIcon/index.d.ts +1 -1
  3. package/AccessibilityIcon/index.js +1 -1
  4. package/AccessibilityIcon/index.test.js +13 -69
  5. package/ArrowIcon/__snapshots__/index.test.tsx.snap +1 -1
  6. package/ArrowIcon/config.d.ts +7 -0
  7. package/ArrowIcon/index.d.ts +1 -1
  8. package/ArrowIcon/index.js +1 -1
  9. package/BurgerIcon/index.d.ts +1 -1
  10. package/BurgerIcon/index.js +1 -1
  11. package/CaretIcon/config.d.ts +7 -0
  12. package/CaretIcon/index.d.ts +1 -1
  13. package/CaretIcon/index.js +1 -1
  14. package/CheckIcon/__snapshots__/index.test.tsx.snap +0 -259
  15. package/CheckIcon/index.d.ts +1 -1
  16. package/CheckIcon/index.js +1 -1
  17. package/CheckIcon/index.test.js +13 -69
  18. package/CloseIcon/index.d.ts +1 -1
  19. package/CloseIcon/index.js +1 -1
  20. package/GlobeIcon/index.d.ts +1 -1
  21. package/GlobeIcon/index.js +1 -1
  22. package/Icon/__snapshots__/index.test.tsx.snap +343 -0
  23. package/Icon/index.d.ts +25 -0
  24. package/Icon/index.js +58 -0
  25. package/Icon/index.test.d.ts +1 -0
  26. package/Icon/index.test.js +88 -0
  27. package/MoreVertIcon/__snapshots__/index.test.tsx.snap +0 -294
  28. package/MoreVertIcon/index.d.ts +1 -1
  29. package/MoreVertIcon/index.js +1 -1
  30. package/MoreVertIcon/index.test.js +13 -61
  31. package/SearchIcon/index.d.ts +1 -1
  32. package/SearchIcon/index.js +1 -1
  33. package/UncheckIcon/__snapshots__/index.test.tsx.snap +0 -222
  34. package/UncheckIcon/index.d.ts +1 -1
  35. package/UncheckIcon/index.js +1 -1
  36. package/UncheckIcon/index.test.js +15 -63
  37. package/es/AccessibilityIcon/__snapshots__/index.test.tsx.snap +0 -315
  38. package/es/AccessibilityIcon/index.js +1 -1
  39. package/es/AccessibilityIcon/index.test.js +13 -69
  40. package/es/ArrowIcon/__snapshots__/index.test.tsx.snap +1 -1
  41. package/es/ArrowIcon/index.js +1 -1
  42. package/es/BurgerIcon/index.js +1 -1
  43. package/es/CaretIcon/index.js +1 -1
  44. package/es/CheckIcon/__snapshots__/index.test.tsx.snap +0 -259
  45. package/es/CheckIcon/index.js +1 -1
  46. package/es/CheckIcon/index.test.js +13 -69
  47. package/es/CloseIcon/index.js +1 -1
  48. package/es/GlobeIcon/index.js +1 -1
  49. package/es/Icon/__snapshots__/index.test.tsx.snap +343 -0
  50. package/es/Icon/index.js +34 -0
  51. package/es/Icon/index.test.js +82 -0
  52. package/es/MoreVertIcon/__snapshots__/index.test.tsx.snap +0 -294
  53. package/es/MoreVertIcon/index.js +1 -1
  54. package/es/MoreVertIcon/index.test.js +13 -61
  55. package/es/SearchIcon/index.js +1 -1
  56. package/es/UncheckIcon/__snapshots__/index.test.tsx.snap +0 -222
  57. package/es/UncheckIcon/index.js +1 -1
  58. package/es/UncheckIcon/index.test.js +15 -63
  59. package/es/registry.js +2 -0
  60. package/esm/AccessibilityIcon/__snapshots__/index.test.tsx.snap +0 -315
  61. package/esm/AccessibilityIcon/index.js +1 -1
  62. package/esm/AccessibilityIcon/index.test.js +13 -69
  63. package/esm/ArrowIcon/__snapshots__/index.test.tsx.snap +1 -1
  64. package/esm/ArrowIcon/index.js +1 -1
  65. package/esm/BurgerIcon/index.js +1 -1
  66. package/esm/CaretIcon/index.js +1 -1
  67. package/esm/CheckIcon/__snapshots__/index.test.tsx.snap +0 -259
  68. package/esm/CheckIcon/index.js +1 -1
  69. package/esm/CheckIcon/index.test.js +13 -69
  70. package/esm/CloseIcon/index.js +1 -1
  71. package/esm/GlobeIcon/index.js +1 -1
  72. package/esm/Icon/__snapshots__/index.test.tsx.snap +343 -0
  73. package/esm/Icon/index.js +34 -0
  74. package/esm/Icon/index.test.js +82 -0
  75. package/esm/MoreVertIcon/__snapshots__/index.test.tsx.snap +0 -294
  76. package/esm/MoreVertIcon/index.js +1 -1
  77. package/esm/MoreVertIcon/index.test.js +13 -61
  78. package/esm/SearchIcon/index.js +1 -1
  79. package/esm/UncheckIcon/__snapshots__/index.test.tsx.snap +0 -222
  80. package/esm/UncheckIcon/index.js +1 -1
  81. package/esm/UncheckIcon/index.test.js +15 -63
  82. package/esm/registry.js +2 -0
  83. package/package.json +2 -3
  84. package/registry.d.ts +1 -0
  85. package/registry.js +3 -0
  86. package/src/AccessibilityIcon/__snapshots__/index.test.tsx.snap +0 -315
  87. package/src/AccessibilityIcon/index.test.tsx +0 -21
  88. package/src/AccessibilityIcon/index.tsx +1 -1
  89. package/src/ArrowIcon/__snapshots__/index.test.tsx.snap +1 -1
  90. package/src/ArrowIcon/config.tsx +8 -1
  91. package/src/ArrowIcon/index.tsx +1 -1
  92. package/src/BurgerIcon/index.tsx +1 -1
  93. package/src/CaretIcon/config.tsx +8 -1
  94. package/src/CaretIcon/index.tsx +1 -1
  95. package/src/CheckIcon/__snapshots__/index.test.tsx.snap +0 -259
  96. package/src/CheckIcon/index.test.tsx +0 -21
  97. package/src/CheckIcon/index.tsx +1 -1
  98. package/src/CloseIcon/index.tsx +1 -1
  99. package/src/GlobeIcon/index.tsx +1 -1
  100. package/src/Icon/__snapshots__/index.test.tsx.snap +343 -0
  101. package/src/Icon/index.test.tsx +36 -0
  102. package/src/Icon/index.tsx +63 -0
  103. package/src/MoreVertIcon/__snapshots__/index.test.tsx.snap +0 -294
  104. package/src/MoreVertIcon/index.test.tsx +0 -18
  105. package/src/MoreVertIcon/index.tsx +1 -1
  106. package/src/SearchIcon/index.tsx +1 -1
  107. package/src/UncheckIcon/__snapshots__/index.test.tsx.snap +0 -222
  108. package/src/UncheckIcon/index.test.tsx +0 -18
  109. package/src/UncheckIcon/index.tsx +1 -1
  110. package/src/registry.js +2 -0
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+
4
+ import Icon from '@digigov/react-icons/Icon';
5
+
6
+ it('renders the Icon with no props', () => {
7
+ expect(mount(<Icon />)).toMatchSnapshot();
8
+ });
9
+
10
+ it('renders the Icon with prop icon=arrow and direction=up', () => {
11
+ expect(mount(<Icon direction="up" />)).toMatchSnapshot();
12
+ });
13
+ it('renders the Icon with prop prop icon=burger', () => {
14
+ expect(mount(<Icon icon="burger" />)).toMatchSnapshot();
15
+ });
16
+ it('renders the Icon prop icon= "caret"', () => {
17
+ expect(mount(<Icon icon="caret" />)).toMatchSnapshot();
18
+ });
19
+ it('renders the Icon prop icon= "caret" and direction=left', () => {
20
+ expect(mount(<Icon icon="caret" direction="left" />)).toMatchSnapshot();
21
+ });
22
+ it('renders the Icon prop icon= "check"', () => {
23
+ expect(mount(<Icon icon="check" />)).toMatchSnapshot();
24
+ });
25
+ it('renders the Icon prop icon= "close"', () => {
26
+ expect(mount(<Icon icon="close" />)).toMatchSnapshot();
27
+ });
28
+ it('renders the Icon with prop prop icon=globe', () => {
29
+ expect(mount(<Icon icon="globe" />)).toMatchSnapshot();
30
+ });
31
+ it('renders the Icon props icon= "moreVert"', () => {
32
+ expect(mount(<Icon icon="moreVert" />)).toMatchSnapshot();
33
+ });
34
+ it('renders the Icon prop icon= "uncheck"', () => {
35
+ expect(mount(<Icon icon="uncheck" />)).toMatchSnapshot();
36
+ });
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import SvgIcon, { SvgIconProps } from '@digigov/react-core/SvgIcon';
4
+ import * as icons from '@digigov/react-icons/icons';
5
+ import type { IconTypes } from '@digigov/react-icons/icons';
6
+
7
+ export type IconProps<N extends keyof IconTypes> = SvgIconProps &
8
+ IconTypes[N] & {
9
+ /**
10
+ * ref is optional.
11
+ * ref prop declares the reference of the svg icon component.
12
+ * It can be used to to access the DOM element and the React element.
13
+ */
14
+ ref?: React.Ref<SVGSVGElement>;
15
+ /**
16
+ * icon is optional, but strongly recommended.
17
+ * Default value is 'arrow'.
18
+ * Use this prop to display the icon you want.
19
+ */
20
+ icon?: N;
21
+ };
22
+
23
+ type IconComponent = <C extends keyof IconTypes>(
24
+ props: IconProps<C>
25
+ ) => React.ReactElement | null;
26
+ export type IconNames = keyof IconTypes;
27
+ /**
28
+ * Icon is used whenever we need a GOV.GR icon.
29
+ * Choose the icon from the list in icon prop.
30
+ */
31
+ export const Icon: IconComponent = React.forwardRef<
32
+ SVGSVGElement,
33
+ IconProps<IconNames>
34
+ >(function Icon(
35
+ { icon = 'arrow', className, ...props }: IconProps<IconNames>,
36
+ ref
37
+ ) {
38
+ const IconComponent = icons[icon];
39
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
+ // @ts-ignore
41
+ const iconProps = IconComponent?.props.reduce((compProps, propName) => {
42
+ const value = props[propName];
43
+ delete props[propName];
44
+ return {
45
+ ...compProps,
46
+ [propName]: value,
47
+ };
48
+ }, {});
49
+
50
+ return (
51
+ <SvgIcon
52
+ ref={ref}
53
+ {...props}
54
+ className={clsx(className, {
55
+ [`govgr-svg-icon--${icon}`]: true,
56
+ })}
57
+ >
58
+ <IconComponent {...iconProps} />
59
+ </SvgIcon>
60
+ );
61
+ });
62
+
63
+ export default Icon;
@@ -94,55 +94,6 @@ exports[`renders the MoreVertIcon with prop size=l 1`] = `
94
94
  </MoreVertIcon>
95
95
  `;
96
96
 
97
- exports[`renders the MoreVertIcon with prop size=m 1`] = `
98
- <MoreVertIcon
99
- size="md"
100
- >
101
- <ForwardRef(Icon)
102
- icon="moreVert"
103
- size="md"
104
- >
105
- <ForwardRef(SvgIcon)
106
- className="govgr-svg-icon--moreVert"
107
- size="md"
108
- >
109
- <ForwardRef(Base)
110
- aria-hidden="true"
111
- as="svg"
112
- className="govgr-svg-icon--moreVert govgr-svg-icon--md govgr-svg-icon"
113
- focusable="false"
114
- viewBox="0 0 24 24"
115
- >
116
- <svg
117
- aria-hidden="true"
118
- className="govgr-svg-icon--moreVert govgr-svg-icon--md govgr-svg-icon"
119
- focusable="false"
120
- viewBox="0 0 24 24"
121
- >
122
- <moreVert>
123
- <circle
124
- cx="12"
125
- cy="5"
126
- r="2"
127
- />
128
- <circle
129
- cx="12"
130
- cy="12"
131
- r="2"
132
- />
133
- <circle
134
- cx="12"
135
- cy="19"
136
- r="2"
137
- />
138
- </moreVert>
139
- </svg>
140
- </ForwardRef(Base)>
141
- </ForwardRef(SvgIcon)>
142
- </ForwardRef(Icon)>
143
- </MoreVertIcon>
144
- `;
145
-
146
97
  exports[`renders the MoreVertIcon with prop size=s 1`] = `
147
98
  <MoreVertIcon
148
99
  size="sm"
@@ -192,55 +143,6 @@ exports[`renders the MoreVertIcon with prop size=s 1`] = `
192
143
  </MoreVertIcon>
193
144
  `;
194
145
 
195
- exports[`renders the MoreVertIcon with prop size=xl 1`] = `
196
- <MoreVertIcon
197
- size="xl"
198
- >
199
- <ForwardRef(Icon)
200
- icon="moreVert"
201
- size="xl"
202
- >
203
- <ForwardRef(SvgIcon)
204
- className="govgr-svg-icon--moreVert"
205
- size="xl"
206
- >
207
- <ForwardRef(Base)
208
- aria-hidden="true"
209
- as="svg"
210
- className="govgr-svg-icon--moreVert govgr-svg-icon--xl govgr-svg-icon"
211
- focusable="false"
212
- viewBox="0 0 24 24"
213
- >
214
- <svg
215
- aria-hidden="true"
216
- className="govgr-svg-icon--moreVert govgr-svg-icon--xl govgr-svg-icon"
217
- focusable="false"
218
- viewBox="0 0 24 24"
219
- >
220
- <moreVert>
221
- <circle
222
- cx="12"
223
- cy="5"
224
- r="2"
225
- />
226
- <circle
227
- cx="12"
228
- cy="12"
229
- r="2"
230
- />
231
- <circle
232
- cx="12"
233
- cy="19"
234
- r="2"
235
- />
236
- </moreVert>
237
- </svg>
238
- </ForwardRef(Base)>
239
- </ForwardRef(SvgIcon)>
240
- </ForwardRef(Icon)>
241
- </MoreVertIcon>
242
- `;
243
-
244
146
  exports[`renders the MoreVertIcon with prop variant=dark 1`] = `
245
147
  <MoreVertIcon
246
148
  variant="dark"
@@ -290,55 +192,6 @@ exports[`renders the MoreVertIcon with prop variant=dark 1`] = `
290
192
  </MoreVertIcon>
291
193
  `;
292
194
 
293
- exports[`renders the MoreVertIcon with prop variant=error 1`] = `
294
- <MoreVertIcon
295
- variant="error"
296
- >
297
- <ForwardRef(Icon)
298
- icon="moreVert"
299
- variant="error"
300
- >
301
- <ForwardRef(SvgIcon)
302
- className="govgr-svg-icon--moreVert"
303
- variant="error"
304
- >
305
- <ForwardRef(Base)
306
- aria-hidden="true"
307
- as="svg"
308
- className="govgr-svg-icon--moreVert govgr-svg-icon--error govgr-svg-icon"
309
- focusable="false"
310
- viewBox="0 0 24 24"
311
- >
312
- <svg
313
- aria-hidden="true"
314
- className="govgr-svg-icon--moreVert govgr-svg-icon--error govgr-svg-icon"
315
- focusable="false"
316
- viewBox="0 0 24 24"
317
- >
318
- <moreVert>
319
- <circle
320
- cx="12"
321
- cy="5"
322
- r="2"
323
- />
324
- <circle
325
- cx="12"
326
- cy="12"
327
- r="2"
328
- />
329
- <circle
330
- cx="12"
331
- cy="19"
332
- r="2"
333
- />
334
- </moreVert>
335
- </svg>
336
- </ForwardRef(Base)>
337
- </ForwardRef(SvgIcon)>
338
- </ForwardRef(Icon)>
339
- </MoreVertIcon>
340
- `;
341
-
342
195
  exports[`renders the MoreVertIcon with prop variant=error and size= xl 1`] = `
343
196
  <MoreVertIcon
344
197
  size="xl"
@@ -440,104 +293,6 @@ exports[`renders the MoreVertIcon with prop variant=focus 1`] = `
440
293
  </MoreVertIcon>
441
294
  `;
442
295
 
443
- exports[`renders the MoreVertIcon with prop variant=gray 1`] = `
444
- <MoreVertIcon
445
- variant="gray"
446
- >
447
- <ForwardRef(Icon)
448
- icon="moreVert"
449
- variant="gray"
450
- >
451
- <ForwardRef(SvgIcon)
452
- className="govgr-svg-icon--moreVert"
453
- variant="gray"
454
- >
455
- <ForwardRef(Base)
456
- aria-hidden="true"
457
- as="svg"
458
- className="govgr-svg-icon--moreVert govgr-svg-icon--gray govgr-svg-icon"
459
- focusable="false"
460
- viewBox="0 0 24 24"
461
- >
462
- <svg
463
- aria-hidden="true"
464
- className="govgr-svg-icon--moreVert govgr-svg-icon--gray govgr-svg-icon"
465
- focusable="false"
466
- viewBox="0 0 24 24"
467
- >
468
- <moreVert>
469
- <circle
470
- cx="12"
471
- cy="5"
472
- r="2"
473
- />
474
- <circle
475
- cx="12"
476
- cy="12"
477
- r="2"
478
- />
479
- <circle
480
- cx="12"
481
- cy="19"
482
- r="2"
483
- />
484
- </moreVert>
485
- </svg>
486
- </ForwardRef(Base)>
487
- </ForwardRef(SvgIcon)>
488
- </ForwardRef(Icon)>
489
- </MoreVertIcon>
490
- `;
491
-
492
- exports[`renders the MoreVertIcon with prop variant=light 1`] = `
493
- <MoreVertIcon
494
- variant="light"
495
- >
496
- <ForwardRef(Icon)
497
- icon="moreVert"
498
- variant="light"
499
- >
500
- <ForwardRef(SvgIcon)
501
- className="govgr-svg-icon--moreVert"
502
- variant="light"
503
- >
504
- <ForwardRef(Base)
505
- aria-hidden="true"
506
- as="svg"
507
- className="govgr-svg-icon--moreVert govgr-svg-icon--light govgr-svg-icon"
508
- focusable="false"
509
- viewBox="0 0 24 24"
510
- >
511
- <svg
512
- aria-hidden="true"
513
- className="govgr-svg-icon--moreVert govgr-svg-icon--light govgr-svg-icon"
514
- focusable="false"
515
- viewBox="0 0 24 24"
516
- >
517
- <moreVert>
518
- <circle
519
- cx="12"
520
- cy="5"
521
- r="2"
522
- />
523
- <circle
524
- cx="12"
525
- cy="12"
526
- r="2"
527
- />
528
- <circle
529
- cx="12"
530
- cy="19"
531
- r="2"
532
- />
533
- </moreVert>
534
- </svg>
535
- </ForwardRef(Base)>
536
- </ForwardRef(SvgIcon)>
537
- </ForwardRef(Icon)>
538
- </MoreVertIcon>
539
- `;
540
-
541
296
  exports[`renders the MoreVertIcon with prop variant=primary 1`] = `
542
297
  <MoreVertIcon
543
298
  variant="primary"
@@ -636,55 +391,6 @@ exports[`renders the MoreVertIcon with prop variant=success 1`] = `
636
391
  </MoreVertIcon>
637
392
  `;
638
393
 
639
- exports[`renders the MoreVertIcon with prop variant=warning 1`] = `
640
- <MoreVertIcon
641
- variant="warning"
642
- >
643
- <ForwardRef(Icon)
644
- icon="moreVert"
645
- variant="warning"
646
- >
647
- <ForwardRef(SvgIcon)
648
- className="govgr-svg-icon--moreVert"
649
- variant="warning"
650
- >
651
- <ForwardRef(Base)
652
- aria-hidden="true"
653
- as="svg"
654
- className="govgr-svg-icon--moreVert govgr-svg-icon--warning govgr-svg-icon"
655
- focusable="false"
656
- viewBox="0 0 24 24"
657
- >
658
- <svg
659
- aria-hidden="true"
660
- className="govgr-svg-icon--moreVert govgr-svg-icon--warning govgr-svg-icon"
661
- focusable="false"
662
- viewBox="0 0 24 24"
663
- >
664
- <moreVert>
665
- <circle
666
- cx="12"
667
- cy="5"
668
- r="2"
669
- />
670
- <circle
671
- cx="12"
672
- cy="12"
673
- r="2"
674
- />
675
- <circle
676
- cx="12"
677
- cy="19"
678
- r="2"
679
- />
680
- </moreVert>
681
- </svg>
682
- </ForwardRef(Base)>
683
- </ForwardRef(SvgIcon)>
684
- </ForwardRef(Icon)>
685
- </MoreVertIcon>
686
- `;
687
-
688
394
  exports[`renders the MoreVertIcon with prop variant=warning and size=s 1`] = `
689
395
  <MoreVertIcon
690
396
  size="sm"
@@ -9,36 +9,18 @@ it('renders the MoreVertIcon with no props', () => {
9
9
  it('renders the MoreVertIcon with prop size=s', () => {
10
10
  expect(mount(<MoreVertIcon size="sm" />)).toMatchSnapshot();
11
11
  });
12
- it('renders the MoreVertIcon with prop size=m', () => {
13
- expect(mount(<MoreVertIcon size="md" />)).toMatchSnapshot();
14
- });
15
12
  it('renders the MoreVertIcon with prop size=l', () => {
16
13
  expect(mount(<MoreVertIcon size="lg" />)).toMatchSnapshot();
17
14
  });
18
- it('renders the MoreVertIcon with prop size=xl', () => {
19
- expect(mount(<MoreVertIcon size="xl" />)).toMatchSnapshot();
20
- });
21
15
  it('renders the MoreVertIcon with prop variant=dark', () => {
22
16
  expect(mount(<MoreVertIcon variant="dark" />)).toMatchSnapshot();
23
17
  });
24
- it('renders the MoreVertIcon with prop variant=light', () => {
25
- expect(mount(<MoreVertIcon variant="light" />)).toMatchSnapshot();
26
- });
27
- it('renders the MoreVertIcon with prop variant=gray', () => {
28
- expect(mount(<MoreVertIcon variant="gray" />)).toMatchSnapshot();
29
- });
30
18
  it('renders the MoreVertIcon with prop variant=primary', () => {
31
19
  expect(mount(<MoreVertIcon variant="primary" />)).toMatchSnapshot();
32
20
  });
33
21
  it('renders the MoreVertIcon with prop variant=success', () => {
34
22
  expect(mount(<MoreVertIcon variant="success" />)).toMatchSnapshot();
35
23
  });
36
- it('renders the MoreVertIcon with prop variant=warning', () => {
37
- expect(mount(<MoreVertIcon variant="warning" />)).toMatchSnapshot();
38
- });
39
- it('renders the MoreVertIcon with prop variant=error', () => {
40
- expect(mount(<MoreVertIcon variant="error" />)).toMatchSnapshot();
41
- });
42
24
  it('renders the MoreVertIcon with prop variant=focus', () => {
43
25
  expect(mount(<MoreVertIcon variant="focus" />)).toMatchSnapshot();
44
26
  });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import Icon, { IconProps } from '@digigov/react-core/Icon';
2
+ import Icon, { IconProps } from '@digigov/react-icons/Icon';
3
3
 
4
4
  export const MoreVertIcon: React.FC<IconProps<'moreVert'>> = (props) => {
5
5
  return <Icon {...props} icon="moreVert"></Icon>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import Icon, { IconProps } from '@digigov/react-core/Icon';
2
+ import Icon, { IconProps } from '@digigov/react-icons/Icon';
3
3
 
4
4
  export const SearchIcon: React.FC<IconProps<'search'>> = (props) => {
5
5
  return <Icon {...props} icon="search"></Icon>;