dce-reactkit 3.6.4 → 3.6.6

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.
@@ -3,10 +3,14 @@
3
3
  * @author Gabe Abrams
4
4
  */
5
5
  import React from 'react';
6
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
7
+ import Variant from '../types/Variant';
6
8
  type Props = {
7
9
  error: any;
8
10
  title?: string;
9
11
  onClose?: () => void;
12
+ variant?: Variant;
13
+ icon?: IconProp;
10
14
  };
11
15
  declare const ErrorBox: React.FC<Props>;
12
16
  export default ErrorBox;
package/dist/index.d.ts CHANGED
@@ -92,6 +92,8 @@ type Props$j = {
92
92
  error: any;
93
93
  title?: string;
94
94
  onClose?: () => void;
95
+ variant?: Variant;
96
+ icon?: IconProp;
95
97
  };
96
98
  declare const ErrorBox: React.FC<Props$j>;
97
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.6.4",
3
+ "version": "3.6.6",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -7,6 +7,9 @@
7
7
  // Import React
8
8
  import React, { useState } from 'react';
9
9
 
10
+ // Import FontAwesome
11
+ import { faHourglassEnd } from '@fortawesome/free-solid-svg-icons';
12
+
10
13
  // Import shared components
11
14
  import ErrorBox from './ErrorBox';
12
15
 
@@ -571,6 +574,16 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
571
574
  )
572
575
  );
573
576
 
577
+ // Choose error box variant
578
+ let errorBoxVariant = Variant.Danger;
579
+ if (sessionHasExpired) {
580
+ errorBoxVariant = (
581
+ isDarkModeOn()
582
+ ? Variant.Light
583
+ : Variant.Secondary
584
+ );
585
+ }
586
+
574
587
  // Build error screen
575
588
  body = (
576
589
  <div
@@ -593,6 +606,8 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
593
606
  : fatalErrorTitle
594
607
  )}
595
608
  error={error}
609
+ variant={errorBoxVariant}
610
+ icon={faHourglassEnd}
596
611
  />
597
612
  </div>
598
613
  );
@@ -9,9 +9,11 @@ import React from 'react';
9
9
  // Import FontAwesome Icons
10
10
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
11
11
  import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
12
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
12
13
 
13
14
  // Import shared types
14
15
  import ReactKitErrorCode from '../types/ReactKitErrorCode';
16
+ import Variant from '../types/Variant';
15
17
 
16
18
  /*------------------------------------------------------------------------*/
17
19
  /* -------------------------------- Types ------------------------------- */
@@ -24,6 +26,10 @@ type Props = {
24
26
  title?: string,
25
27
  // Handler for close,
26
28
  onClose?: () => void,
29
+ // Variant for notice (defaults to danger)
30
+ variant?: Variant,
31
+ // Custom icon before error message (defaults to exclamation triangle)
32
+ icon?: IconProp,
27
33
  };
28
34
 
29
35
  /*------------------------------------------------------------------------*/
@@ -41,6 +47,8 @@ const ErrorBox: React.FC<Props> = (props) => {
41
47
  error,
42
48
  title = 'An Error Occurred',
43
49
  onClose,
50
+ variant = Variant.Danger,
51
+ icon = faExclamationTriangle,
44
52
  } = props;
45
53
 
46
54
  /*------------------------------------------------------------------------*/
@@ -83,7 +91,7 @@ const ErrorBox: React.FC<Props> = (props) => {
83
91
  // Main UI
84
92
  return (
85
93
  <div
86
- className="alert alert-danger text-center"
94
+ className={`alert alert-${variant} text-center`}
87
95
  style={{
88
96
  maxWidth: '40rem',
89
97
  margin: 'auto',
@@ -91,7 +99,7 @@ const ErrorBox: React.FC<Props> = (props) => {
91
99
  >
92
100
  <h4 className="mb-1">
93
101
  <FontAwesomeIcon
94
- icon={faExclamationTriangle}
102
+ icon={icon}
95
103
  className="me-2"
96
104
  />
97
105
  {title}