@digigov/react-core 2.0.0-aefd0709 → 2.0.0-b15d5d44

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.
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { BaseProps } from '@digigov/react-core/Base';
3
3
  import NotificationBannerContainer from '@digigov/react-core/NotificationBannerContainer';
4
4
  import NotificationBannerContent from '@digigov/react-core/NotificationBannerContent';
5
-
6
5
  export interface ErrorSummaryProps extends BaseProps<'div'> {
7
6
  /**
8
7
  * dense is optional.
@@ -11,21 +10,35 @@ export interface ErrorSummaryProps extends BaseProps<'div'> {
11
10
  * @default false
12
11
  * */
13
12
  dense?: boolean;
13
+ /**
14
+ * variant is optional.
15
+ * variant error is used to change the color of the NotificationBannerContainer.
16
+ * variant error-group is used to display red line on the left side of the component and exclamation mark icon with light red as background.
17
+ * @value 'error'
18
+ * @value 'error-group'
19
+ * @default 'error'.
20
+ */
21
+ variant?: 'error' | 'error-group';
14
22
  }
15
23
  /**
16
24
  * Use this component at the top of a page to summarize any errors a user has made.
17
25
  */
18
26
  export const ErrorSummary = React.forwardRef<HTMLDivElement, ErrorSummaryProps>(
19
- function ErrorSummary({ className, dense, children, ...props }, ref) {
27
+ function ErrorSummary(
28
+ { className, dense, children, variant = 'error', ...props },
29
+ ref
30
+ ) {
20
31
  return (
21
32
  <NotificationBannerContainer
22
- variant={'error'}
33
+ variant={variant}
23
34
  className={className}
24
35
  ref={ref}
25
36
  dense={dense}
26
37
  {...props}
27
38
  >
28
- <NotificationBannerContent>{children}</NotificationBannerContent>
39
+ <NotificationBannerContent variant={variant}>
40
+ {children}
41
+ </NotificationBannerContent>
29
42
  </NotificationBannerContainer>
30
43
  );
31
44
  }
@@ -9,9 +9,10 @@ export interface NotificationBannerContainerProps extends BaseProps<'div'> {
9
9
  * @value 'info'
10
10
  * @value 'success'
11
11
  * @value 'error'
12
+ * @value 'error-group'
12
13
  * @default 'info'.
13
14
  */
14
- variant?: 'info' | 'success' | 'error';
15
+ variant?: 'info' | 'success' | 'error' | 'error-group';
15
16
  /**
16
17
  * dense is optional.
17
18
  * @value true NotificationBannerContainer will be dense.
@@ -1,8 +1,32 @@
1
1
  import React from 'react';
2
2
  import clsx from 'clsx';
3
3
  import Base, { BaseProps } from '@digigov/react-core/Base';
4
+ import { WarningTextAssistive } from '@digigov/react-core/WarningTextAssistive';
4
5
 
5
- export interface NotificationBannerContentProps extends BaseProps<'div'> {}
6
+ export interface NotificationBannerContentProps extends BaseProps<'div'> {
7
+ /**
8
+ * assistiveText is optional.
9
+ * Default value is "Προσοχή".
10
+ * assistiveText is used to provide a textual warning for assistive technologies like screen readers.
11
+ */
12
+ assistiveText?: string;
13
+ /**
14
+ * variant is optional.
15
+ * variant is used to display red line on the left side of the component and exclamation mark icon with light red as background.
16
+ * @value 'error'
17
+ * @value 'error-group'
18
+ * @default 'error'.
19
+ */
20
+ /**
21
+ * variant is optional.
22
+ * variant error is used to change the color of the NotificationBannerContainer.
23
+ * variant error-group is used to display red line on the left side of the component and exclamation mark icon with light red as background.
24
+ * @value 'error'
25
+ * @value 'error-group'
26
+ * @default 'error'.
27
+ */
28
+ variant?: 'error' | 'error-group';
29
+ }
6
30
  /**
7
31
  * Details for the NotificationBannerContent.
8
32
  * NotificationBannerContent component is used as a content for
@@ -12,17 +36,39 @@ export interface NotificationBannerContentProps extends BaseProps<'div'> {}
12
36
  export const NotificationBannerContent = React.forwardRef<
13
37
  HTMLDivElement,
14
38
  NotificationBannerContentProps
15
- >(function NotificationBannerContent({ className, children, ...props }, ref) {
39
+ >(function NotificationBannerContent(
40
+ { className, assistiveText, variant, children, ...props },
41
+ ref
42
+ ) {
16
43
  return (
17
44
  <Base
18
45
  as="div"
19
46
  ref={ref}
20
47
  className={clsx(className, {
21
- 'ds-notification-banner__content': true,
48
+ 'ds-notification-banner__content': variant !== 'error-group',
49
+ 'ds-notification-error-group-banner__content':
50
+ variant === 'error-group',
22
51
  })}
23
52
  {...props}
24
53
  >
25
- {children}
54
+ {variant === 'error-group' ? (
55
+ <>
56
+ <Base
57
+ as="div"
58
+ className={clsx({
59
+ 'ds-notification-banner__icon--error-group': true,
60
+ })}
61
+ >
62
+ !
63
+ </Base>
64
+ <WarningTextAssistive>{assistiveText}</WarningTextAssistive>
65
+ <Base as="div" className="ds-notification-banner__text-error-group">
66
+ {children}
67
+ </Base>
68
+ </>
69
+ ) : (
70
+ <>{children}</>
71
+ )}
26
72
  </Base>
27
73
  );
28
74
  });
@@ -90,13 +90,14 @@ export const Skeleton = React.forwardRef<HTMLSpanElement, SkeletonProps>(
90
90
  }}
91
91
  >
92
92
  {variant === 'button' && (
93
- <span
93
+ <Base
94
+ as="span"
94
95
  className={clsx({
95
96
  'ds-skeleton__line': true,
96
97
  'ds-skeleton__line--size-default':
97
98
  width === undefined && height === undefined,
98
99
  })}
99
- ></span>
100
+ ></Base>
100
101
  )}
101
102
  {typeof children != 'string' && children}
102
103
  </Base>
@@ -16,7 +16,7 @@ exports[`renders the TimelineHeading with size = "md" prop 1`] = `
16
16
  <body>
17
17
  <div>
18
18
  <h3
19
- class="ds-timeline__heading ds-timeline__heading--md"
19
+ class="ds-timeline__heading ds-timeline__heading-md"
20
20
  >
21
21
  hello
22
22
  </h3>
@@ -28,7 +28,7 @@ exports[`renders the TimelineHeading with size = "sm" prop 1`] = `
28
28
  <body>
29
29
  <div>
30
30
  <h4
31
- class="ds-timeline__heading ds-timeline__heading--sm"
31
+ class="ds-timeline__heading ds-timeline__heading-sm"
32
32
  >
33
33
  hello
34
34
  </h4>