dce-reactkit 3.0.0 → 3.0.3

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 (166) hide show
  1. package/README.md +1 -546
  2. package/dist/cjs/index.js +1826 -0
  3. package/dist/cjs/index.js.map +1 -0
  4. package/{lib/esm → dist/cjs}/types/components/AppWrapper.d.ts +29 -4
  5. package/dist/cjs/types/components/ButtonInputGroup.d.ts +12 -0
  6. package/dist/cjs/types/components/CheckboxButton.d.ts +20 -0
  7. package/dist/cjs/types/components/Drawer.d.ts +10 -0
  8. package/{lib/cjs/lib → dist/cjs/types}/components/ErrorBox.d.ts +0 -0
  9. package/{lib/cjs/lib → dist/cjs/types}/components/LoadingSpinner.d.ts +0 -0
  10. package/{lib/cjs/lib → dist/cjs/types}/components/Modal.d.ts +0 -0
  11. package/dist/cjs/types/components/RadioButton.d.ts +20 -0
  12. package/dist/cjs/types/components/SimpleDateChooser.d.ts +22 -0
  13. package/{lib/esm/lib → dist/cjs/types}/components/TabBox.d.ts +1 -0
  14. package/{lib/cjs/lib → dist/cjs/types}/errors/ErrorWithCode.d.ts +0 -0
  15. package/{lib/cjs/lib → dist/cjs/types}/helpers/abbreviate.d.ts +0 -0
  16. package/{lib/cjs/lib → dist/cjs/types}/helpers/avg.d.ts +0 -0
  17. package/{lib/cjs/lib → dist/cjs/types}/helpers/ceilToNumDecimals.d.ts +0 -0
  18. package/{lib/cjs/lib → dist/cjs/types}/helpers/floorToNumDecimals.d.ts +0 -0
  19. package/{lib/cjs/lib → dist/cjs/types}/helpers/forceNumIntoBounds.d.ts +0 -0
  20. package/dist/cjs/types/helpers/genRouteHandler.d.ts +32 -0
  21. package/dist/cjs/types/helpers/getOrdinal.d.ts +8 -0
  22. package/dist/cjs/types/helpers/getTimeInfoInET.d.ts +17 -0
  23. package/{lib/cjs/lib → dist/cjs/types}/helpers/handleError.d.ts +5 -1
  24. package/{lib/cjs/lib → dist/cjs/types}/helpers/handleSuccess.d.ts +0 -0
  25. package/{lib/cjs/lib → dist/cjs/types}/helpers/padDecimalZeros.d.ts +0 -0
  26. package/{lib/cjs/lib → dist/cjs/types}/helpers/padZerosLeft.d.ts +0 -0
  27. package/{lib/cjs/lib → dist/cjs/types}/helpers/roundToNumDecimals.d.ts +0 -0
  28. package/{lib/cjs/lib → dist/cjs/types}/helpers/sum.d.ts +0 -0
  29. package/{lib/cjs/lib → dist/cjs/types}/helpers/visitServerEndpoint.d.ts +0 -0
  30. package/{lib/cjs/lib → dist/cjs/types}/helpers/waitMs.d.ts +0 -0
  31. package/{lib/cjs/lib → dist/cjs/types}/index.d.ts +14 -6
  32. package/dist/cjs/types/server/initServer.d.ts +21 -0
  33. package/{lib/cjs/lib → dist/cjs/types}/types/ModalButtonType.d.ts +0 -0
  34. package/{lib/cjs/lib → dist/cjs/types}/types/ModalSize.d.ts +0 -0
  35. package/{lib/cjs/lib → dist/cjs/types}/types/ModalType.d.ts +0 -0
  36. package/{lib → dist}/cjs/types/types/ParamType.d.ts +1 -1
  37. package/{lib → dist}/cjs/types/types/ReactKitErrorCode.d.ts +3 -1
  38. package/{lib/cjs/lib → dist/cjs/types}/types/Variant.d.ts +0 -0
  39. package/dist/esm/index.js +1782 -0
  40. package/dist/esm/index.js.map +1 -0
  41. package/{lib/cjs → dist/esm}/types/components/AppWrapper.d.ts +29 -4
  42. package/dist/esm/types/components/ButtonInputGroup.d.ts +12 -0
  43. package/dist/esm/types/components/CheckboxButton.d.ts +20 -0
  44. package/dist/esm/types/components/Drawer.d.ts +10 -0
  45. package/{lib/cjs → dist/esm}/types/components/ErrorBox.d.ts +0 -0
  46. package/{lib/cjs → dist/esm}/types/components/LoadingSpinner.d.ts +0 -0
  47. package/{lib/cjs → dist/esm}/types/components/Modal.d.ts +0 -0
  48. package/dist/esm/types/components/RadioButton.d.ts +20 -0
  49. package/dist/esm/types/components/SimpleDateChooser.d.ts +22 -0
  50. package/{lib/cjs/lib → dist/esm/types}/components/TabBox.d.ts +1 -0
  51. package/{lib/cjs → dist/esm}/types/errors/ErrorWithCode.d.ts +0 -0
  52. package/{lib/cjs → dist/esm}/types/helpers/abbreviate.d.ts +0 -0
  53. package/{lib/cjs → dist/esm}/types/helpers/avg.d.ts +0 -0
  54. package/{lib/cjs → dist/esm}/types/helpers/ceilToNumDecimals.d.ts +0 -0
  55. package/{lib/cjs → dist/esm}/types/helpers/floorToNumDecimals.d.ts +0 -0
  56. package/{lib/cjs → dist/esm}/types/helpers/forceNumIntoBounds.d.ts +0 -0
  57. package/dist/esm/types/helpers/genRouteHandler.d.ts +32 -0
  58. package/dist/esm/types/helpers/getOrdinal.d.ts +8 -0
  59. package/dist/esm/types/helpers/getTimeInfoInET.d.ts +17 -0
  60. package/{lib/cjs → dist/esm}/types/helpers/handleError.d.ts +5 -1
  61. package/{lib/cjs → dist/esm}/types/helpers/handleSuccess.d.ts +0 -0
  62. package/{lib/cjs → dist/esm}/types/helpers/padDecimalZeros.d.ts +0 -0
  63. package/{lib/cjs → dist/esm}/types/helpers/padZerosLeft.d.ts +0 -0
  64. package/{lib/cjs → dist/esm}/types/helpers/roundToNumDecimals.d.ts +0 -0
  65. package/{lib/cjs → dist/esm}/types/helpers/sum.d.ts +0 -0
  66. package/{lib/cjs → dist/esm}/types/helpers/visitServerEndpoint.d.ts +0 -0
  67. package/{lib/cjs → dist/esm}/types/helpers/waitMs.d.ts +0 -0
  68. package/{lib/esm/lib → dist/esm/types}/index.d.ts +14 -6
  69. package/dist/esm/types/server/initServer.d.ts +21 -0
  70. package/{lib/cjs → dist/esm}/types/types/ModalButtonType.d.ts +0 -0
  71. package/{lib/cjs → dist/esm}/types/types/ModalSize.d.ts +0 -0
  72. package/{lib/cjs → dist/esm}/types/types/ModalType.d.ts +0 -0
  73. package/{lib/esm/lib → dist/esm/types}/types/ParamType.d.ts +1 -1
  74. package/{lib/esm/lib → dist/esm/types}/types/ReactKitErrorCode.d.ts +3 -1
  75. package/{lib/cjs → dist/esm}/types/types/Variant.d.ts +0 -0
  76. package/dist/index.d.ts +505 -0
  77. package/package.json +18 -29
  78. package/rollup.config.js +14 -13
  79. package/src/components/AppWrapper.tsx +85 -18
  80. package/src/components/ButtonInputGroup.tsx +89 -0
  81. package/src/components/CheckboxButton.tsx +100 -0
  82. package/src/components/Drawer.tsx +76 -0
  83. package/src/components/ErrorBox.tsx +4 -4
  84. package/src/components/LoadingSpinner.tsx +3 -3
  85. package/src/components/Modal.tsx +214 -97
  86. package/src/components/RadioButton.tsx +102 -0
  87. package/src/components/SimpleDateChooser.tsx +222 -0
  88. package/src/components/TabBox.tsx +65 -58
  89. package/src/helpers/genRouteHandler.ts +329 -0
  90. package/src/helpers/getOrdinal.tsx +13 -0
  91. package/src/helpers/getTimeInfoInET.tsx +56 -0
  92. package/src/helpers/handleError.ts +65 -0
  93. package/src/helpers/handleSuccess.ts +18 -0
  94. package/src/helpers/visitServerEndpoint.tsx +110 -0
  95. package/src/index.ts +29 -0
  96. package/src/server/initServer.ts +53 -0
  97. package/src/types/ParamType.ts +18 -0
  98. package/src/types/ReactKitErrorCode.tsx +3 -1
  99. package/tsconfig.json +9 -7
  100. package/lib/cjs/index.js +0 -2
  101. package/lib/cjs/index.js.map +0 -1
  102. package/lib/cjs/lib/components/AppWrapper.d.ts +0 -35
  103. package/lib/cjs/lib/helpers/parseRequest.d.ts +0 -21
  104. package/lib/cjs/lib/types/ParamType.d.ts +0 -17
  105. package/lib/cjs/lib/types/ReactKitErrorCode.d.ts +0 -13
  106. package/lib/cjs/types/components/TabBox.d.ts +0 -11
  107. package/lib/cjs/types/helpers/alert.d.ts +0 -2
  108. package/lib/cjs/types/helpers/confirm.d.ts +0 -2
  109. package/lib/cjs/types/helpers/parseRequest.d.ts +0 -21
  110. package/lib/cjs/types/helpers/showFatalError.d.ts +0 -2
  111. package/lib/cjs/types/index.d.ts +0 -22
  112. package/lib/esm/index.js +0 -16
  113. package/lib/esm/index.js.map +0 -1
  114. package/lib/esm/lib/components/AppWrapper.d.ts +0 -35
  115. package/lib/esm/lib/components/ErrorBox.d.ts +0 -12
  116. package/lib/esm/lib/components/LoadingSpinner.d.ts +0 -7
  117. package/lib/esm/lib/components/Modal.d.ts +0 -40
  118. package/lib/esm/lib/errors/ErrorWithCode.d.ts +0 -9
  119. package/lib/esm/lib/helpers/abbreviate.d.ts +0 -10
  120. package/lib/esm/lib/helpers/avg.d.ts +0 -8
  121. package/lib/esm/lib/helpers/ceilToNumDecimals.d.ts +0 -9
  122. package/lib/esm/lib/helpers/floorToNumDecimals.d.ts +0 -9
  123. package/lib/esm/lib/helpers/forceNumIntoBounds.d.ts +0 -10
  124. package/lib/esm/lib/helpers/handleError.d.ts +0 -14
  125. package/lib/esm/lib/helpers/handleSuccess.d.ts +0 -8
  126. package/lib/esm/lib/helpers/padDecimalZeros.d.ts +0 -10
  127. package/lib/esm/lib/helpers/padZerosLeft.d.ts +0 -9
  128. package/lib/esm/lib/helpers/parseRequest.d.ts +0 -21
  129. package/lib/esm/lib/helpers/roundToNumDecimals.d.ts +0 -9
  130. package/lib/esm/lib/helpers/sum.d.ts +0 -8
  131. package/lib/esm/lib/helpers/visitServerEndpoint.d.ts +0 -23
  132. package/lib/esm/lib/helpers/waitMs.d.ts +0 -7
  133. package/lib/esm/lib/types/ModalButtonType.d.ts +0 -17
  134. package/lib/esm/lib/types/ModalSize.d.ts +0 -11
  135. package/lib/esm/lib/types/ModalType.d.ts +0 -16
  136. package/lib/esm/lib/types/Variant.d.ts +0 -15
  137. package/lib/esm/types/components/ErrorBox.d.ts +0 -12
  138. package/lib/esm/types/components/LoadingSpinner.d.ts +0 -7
  139. package/lib/esm/types/components/Modal.d.ts +0 -40
  140. package/lib/esm/types/components/TabBox.d.ts +0 -11
  141. package/lib/esm/types/errors/ErrorWithCode.d.ts +0 -9
  142. package/lib/esm/types/helpers/abbreviate.d.ts +0 -10
  143. package/lib/esm/types/helpers/alert.d.ts +0 -2
  144. package/lib/esm/types/helpers/avg.d.ts +0 -8
  145. package/lib/esm/types/helpers/ceilToNumDecimals.d.ts +0 -9
  146. package/lib/esm/types/helpers/confirm.d.ts +0 -2
  147. package/lib/esm/types/helpers/floorToNumDecimals.d.ts +0 -9
  148. package/lib/esm/types/helpers/forceNumIntoBounds.d.ts +0 -10
  149. package/lib/esm/types/helpers/handleError.d.ts +0 -14
  150. package/lib/esm/types/helpers/handleSuccess.d.ts +0 -8
  151. package/lib/esm/types/helpers/padDecimalZeros.d.ts +0 -10
  152. package/lib/esm/types/helpers/padZerosLeft.d.ts +0 -9
  153. package/lib/esm/types/helpers/parseRequest.d.ts +0 -21
  154. package/lib/esm/types/helpers/roundToNumDecimals.d.ts +0 -9
  155. package/lib/esm/types/helpers/showFatalError.d.ts +0 -2
  156. package/lib/esm/types/helpers/sum.d.ts +0 -8
  157. package/lib/esm/types/helpers/visitServerEndpoint.d.ts +0 -23
  158. package/lib/esm/types/helpers/waitMs.d.ts +0 -7
  159. package/lib/esm/types/index.d.ts +0 -22
  160. package/lib/esm/types/types/ModalButtonType.d.ts +0 -17
  161. package/lib/esm/types/types/ModalSize.d.ts +0 -11
  162. package/lib/esm/types/types/ModalType.d.ts +0 -16
  163. package/lib/esm/types/types/ParamType.d.ts +0 -17
  164. package/lib/esm/types/types/ReactKitErrorCode.d.ts +0 -13
  165. package/lib/esm/types/types/Variant.d.ts +0 -15
  166. package/lib/index.d.ts +0 -274
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * A wrapper for the entire React app that adds global functionality like
3
- * handling for fatal error messages
3
+ * handling for fatal error messages, adds bootstrap support
4
4
  * @author Gabe Abrams
5
5
  */
6
6
 
@@ -28,22 +28,70 @@ import ErrorWithCode from '../errors/ErrorWithCode';
28
28
  type Props = {
29
29
  // The entire app
30
30
  children: React.ReactNode,
31
+ // Copy of CACCL's send request function
32
+ sendRequest: SendRequestFunction,
31
33
  // True if this app is a dark-themed app
32
34
  dark?: boolean,
33
35
  // Custom session expired message
34
36
  sessionExpiredMessage?: string,
35
37
  };
36
38
 
39
+ // Type of CACCL's send request function
40
+ type SendRequestFunction = (
41
+ opts: {
42
+ path: string;
43
+ method: ('GET' | 'POST' | 'DELETE' | 'PUT');
44
+ params?: {
45
+ [x: string]: any;
46
+ } | undefined;
47
+ headers?: {
48
+ [x: string]: any;
49
+ } | undefined;
50
+ numRetries?: number | undefined;
51
+ },
52
+ ) => Promise<{
53
+ body: any;
54
+ status: number;
55
+ headers: {
56
+ [x: string]: any;
57
+ };
58
+ }>;
59
+
37
60
  /*------------------------------------------------------------------------*/
38
61
  /* Static Helpers */
39
62
  /*------------------------------------------------------------------------*/
40
63
 
64
+ /*----------------------------------------*/
65
+ /* Send Request */
66
+ /*----------------------------------------*/
67
+
68
+ // Store copy of caccl send request
69
+ let _cacclSendRequest: SendRequestFunction;
70
+
71
+ /**
72
+ * Send a request using caccl's send request feature
73
+ * @author Gabe Abrams
74
+ * @param opts send request options
75
+ * @returns send request response
76
+ */
77
+ export const cacclSendRequest: SendRequestFunction = async (opts) => {
78
+ // Make sure send request has been passed in
79
+ if (!_cacclSendRequest) {
80
+ throw new ErrorWithCode(
81
+ 'The request could not be sent because the AppWrapper component does not have a copy of sendRequest from CACCL.',
82
+ ReactKitErrorCode.NoCACCLSendRequestFunction,
83
+ );
84
+ }
85
+
86
+ return _cacclSendRequest(opts);
87
+ };
88
+
41
89
  /*----------------------------------------*/
42
90
  /* Alert */
43
91
  /*----------------------------------------*/
44
92
 
45
93
  // Stored copies of setters
46
- let setAlertInfo: (info: { title: string, text: string }) => void;
94
+ let setAlertInfo: (info: undefined | { title: string, text: string }) => void;
47
95
  let onAlertClosed: () => void;
48
96
 
49
97
  /**
@@ -52,17 +100,18 @@ let onAlertClosed: () => void;
52
100
  * @param title the title text to display at the top of the alert
53
101
  * @param text the text to display in the alert
54
102
  */
55
- export const alert = async (title: string, text: string) => {
103
+ export const alert = async (title: string, text: string): Promise<undefined> => {
56
104
  // Fallback if alert not available
57
105
  if (!setAlertInfo) {
58
- return window.alert(`${title}\n\n${text}`);
106
+ window.alert(`${title}\n\n${text}`);
107
+ return undefined;
59
108
  }
60
109
 
61
110
  // Return promise that resolves when alert is closed
62
111
  return new Promise((resolve) => {
63
112
  // Setup handler
64
113
  onAlertClosed = () => {
65
- resolve(null);
114
+ resolve(undefined);
66
115
  };
67
116
 
68
117
  // Show the alert
@@ -78,7 +127,7 @@ export const alert = async (title: string, text: string) => {
78
127
  /*----------------------------------------*/
79
128
 
80
129
  // Stored copies of setters
81
- let setConfirmInfo: (info: { title: string, text: string }) => void;
130
+ let setConfirmInfo: (info: undefined | { title: string, text: string }) => void;
82
131
  let onConfirmClosed: (confirmed: boolean) => void;
83
132
 
84
133
  /**
@@ -130,7 +179,7 @@ let setFatalErrorTitle: (title: string) => void;
130
179
  export const showFatalError = (
131
180
  error: any,
132
181
  errorTitle: string = 'An Error Occurred',
133
- ) => {
182
+ ): undefined => {
134
183
  // Determine message and code
135
184
  const message: string = (
136
185
  typeof error === 'string'
@@ -145,16 +194,19 @@ export const showFatalError = (
145
194
 
146
195
  // Handle case where app hasn't loaded
147
196
  if (!setFatalErrorMessage || !setFatalErrorCode) {
148
- return alert(
197
+ alert(
149
198
  errorTitle,
150
199
  `${message} (code: ${code}). Please contact support.`,
151
200
  );
201
+ return undefined;
152
202
  }
153
203
 
154
204
  // Use setters
155
205
  setFatalErrorMessage(message);
156
206
  setFatalErrorCode(code);
157
207
  setFatalErrorTitle(errorTitle);
208
+
209
+ return undefined;
158
210
  };
159
211
 
160
212
  /*----------------------------------------*/
@@ -168,8 +220,9 @@ let setSessionHasExpired: (isExpired: boolean) => void;
168
220
  * Show the "session expired" message
169
221
  * @author Gabe Abrams
170
222
  */
171
- export const showSessionExpiredMessage = () => {
223
+ export const showSessionExpiredMessage = (): undefined => {
172
224
  setSessionHasExpired(true);
225
+ return undefined;
173
226
  };
174
227
 
175
228
  /*------------------------------------------------------------------------*/
@@ -185,10 +238,14 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
185
238
 
186
239
  const {
187
240
  children,
241
+ sendRequest,
188
242
  dark,
189
243
  sessionExpiredMessage = 'Your session has expired. Please go back to Canvas and start over.',
190
244
  } = props;
191
245
 
246
+ // Store copy of send request
247
+ _cacclSendRequest = sendRequest;
248
+
192
249
  /* -------------- State ------------- */
193
250
 
194
251
  // Fatal error
@@ -212,20 +269,26 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
212
269
  const [
213
270
  alertInfo,
214
271
  setAlertInfoInner,
215
- ] = useState<{
216
- title: string,
217
- text: string
218
- }>();
272
+ ] = useState<
273
+ undefined
274
+ | {
275
+ title: string,
276
+ text: string
277
+ }
278
+ >(undefined);
219
279
  setAlertInfo = setAlertInfoInner;
220
280
 
221
281
  // Confirm
222
282
  const [
223
283
  confirmInfo,
224
284
  setConfirmInfoInner,
225
- ] = useState<{
226
- title: string,
227
- text: string
228
- }>();
285
+ ] = useState<
286
+ undefined
287
+ | {
288
+ title: string,
289
+ text: string
290
+ }
291
+ >(undefined);
229
292
  setConfirmInfo = setConfirmInfoInner;
230
293
 
231
294
  // Session expired
@@ -251,10 +314,12 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
251
314
  if (alertInfo) {
252
315
  modal = (
253
316
  <Modal
317
+ key={`alert-${alertInfo.title}-${alertInfo.text}`}
254
318
  title={alertInfo.title}
255
319
  type={ModalType.Okay}
256
320
  onClose={() => {
257
321
  // Alert closed
322
+ setAlertInfo(undefined);
258
323
  if (onAlertClosed) {
259
324
  onAlertClosed();
260
325
  }
@@ -271,16 +336,18 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
271
336
  if (confirmInfo) {
272
337
  modal = (
273
338
  <Modal
339
+ key={`confirm-${confirmInfo.title}-${confirmInfo.text}`}
274
340
  title={confirmInfo.title}
275
341
  type={ModalType.OkayCancel}
276
342
  onClose={(buttonType) => {
343
+ setConfirmInfo(undefined);
277
344
  if (onConfirmClosed) {
278
345
  onConfirmClosed(buttonType === ModalButtonType.Okay);
279
346
  }
280
347
  }}
281
348
  dontAllowBackdropExit
282
349
  >
283
-
350
+ {confirmInfo.text}
284
351
  </Modal>
285
352
  );
286
353
  }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Input group with a title and space for buttons
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ // Import React
7
+ import React from 'react';
8
+
9
+ /*------------------------------------------------------------------------*/
10
+ /* Types */
11
+ /*------------------------------------------------------------------------*/
12
+
13
+ // Props definition
14
+ type Props = {
15
+ // Label text
16
+ label: string,
17
+ // Minimum width of the label (css units)
18
+ minLabelWidth?: string,
19
+ // Buttons
20
+ children: React.ReactNode,
21
+ };
22
+
23
+ /*------------------------------------------------------------------------*/
24
+ /* Component */
25
+ /*------------------------------------------------------------------------*/
26
+
27
+ const ButtonInputGroup: React.FC<Props> = (props) => {
28
+ /*------------------------------------------------------------------------*/
29
+ /* Setup */
30
+ /*------------------------------------------------------------------------*/
31
+
32
+ /* -------------- Props ------------- */
33
+
34
+ // Destructure all props
35
+ const {
36
+ label,
37
+ minLabelWidth,
38
+ children,
39
+ } = props;
40
+
41
+ /*------------------------------------------------------------------------*/
42
+ /* Render */
43
+ /*------------------------------------------------------------------------*/
44
+
45
+ /*----------------------------------------*/
46
+ /* Main UI */
47
+ /*----------------------------------------*/
48
+
49
+ return (
50
+ <div className="input-group">
51
+ <div className="input-group-prepend d-flex w-100">
52
+ {/* Label */}
53
+ <span
54
+ className="input-group-text"
55
+ style={{
56
+ minWidth: (
57
+ minLabelWidth
58
+ ?? undefined
59
+ ),
60
+ borderTopRightRadius: 0,
61
+ borderBottomRightRadius: 0,
62
+ }}
63
+ >
64
+ {label}
65
+ </span>
66
+
67
+ {/* Contents */}
68
+ <span
69
+ className="input-group-text flex-grow-1 rounded-right"
70
+ style={{
71
+ backgroundColor: 'white',
72
+ borderTopLeftRadius: 0,
73
+ borderBottomLeftRadius: 0,
74
+ borderLeftWidth: 0,
75
+ }}
76
+ >
77
+ {children}
78
+ </span>
79
+ </div>
80
+ </div>
81
+ );
82
+ };
83
+
84
+ /*------------------------------------------------------------------------*/
85
+ /* Wrap Up */
86
+ /*------------------------------------------------------------------------*/
87
+
88
+ // Export component
89
+ export default ButtonInputGroup;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * A checkbox button
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ // Import React
7
+ import React from 'react';
8
+
9
+ // Import FontAwesome Icons
10
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
11
+ import { faCheckSquare } from '@fortawesome/free-solid-svg-icons';
12
+ import { faSquare } from '@fortawesome/free-regular-svg-icons';
13
+
14
+ // Import shared types
15
+ import Variant from '../types/Variant';
16
+
17
+ /*------------------------------------------------------------------------*/
18
+ /* Types */
19
+ /*------------------------------------------------------------------------*/
20
+
21
+ type Props = {
22
+ // Text of the button
23
+ text: string,
24
+ // Handler for when this item is toggled
25
+ onChanged: (checked: boolean) => void,
26
+ // Aria label
27
+ ariaLabel: string,
28
+ // Button title
29
+ title?: string,
30
+ // True if checked
31
+ checked?: boolean,
32
+ // The id of the button
33
+ id?: string,
34
+ // If true, no margin on right
35
+ noMarginOnRight?: boolean,
36
+ // Variant for when checkbox is checked
37
+ checkedVariant?: Variant,
38
+ // Variant for when checkbox is not checked
39
+ uncheckedVariant?: Variant,
40
+ // True if using a small button
41
+ small?: boolean,
42
+ };
43
+
44
+ /*------------------------------------------------------------------------*/
45
+ /* Component */
46
+ /*------------------------------------------------------------------------*/
47
+
48
+ const CheckboxButton: React.FC<Props> = (props) => {
49
+ /*------------------------------------------------------------------------*/
50
+ /* Setup */
51
+ /*------------------------------------------------------------------------*/
52
+
53
+ /* -------------- Props ------------- */
54
+
55
+ const {
56
+ text,
57
+ onChanged,
58
+ ariaLabel,
59
+ title,
60
+ checked,
61
+ id,
62
+ noMarginOnRight,
63
+ checkedVariant = Variant.Secondary,
64
+ uncheckedVariant = Variant.Light,
65
+ small,
66
+ } = props;
67
+
68
+ /*------------------------------------------------------------------------*/
69
+ /* Render */
70
+ /*------------------------------------------------------------------------*/
71
+
72
+ /*----------------------------------------*/
73
+ /* Main UI */
74
+ /*----------------------------------------*/
75
+
76
+ return (
77
+ <button
78
+ type="button"
79
+ id={id}
80
+ title={title}
81
+ className={`btn btn-${checked ? checkedVariant : uncheckedVariant}${checked ? ' selected' : ''}${small ? ' btn-sm' : ''} m-0${noMarginOnRight ? '' : ' me-1'}`}
82
+ aria-label={`${ariaLabel}${checked ? ': currently checked' : ''}`}
83
+ onClick={() => {
84
+ onChanged(!checked);
85
+ }}
86
+ >
87
+ <FontAwesomeIcon
88
+ icon={checked ? faCheckSquare : faSquare}
89
+ className="me-1"
90
+ />
91
+ {text}
92
+ </button>
93
+ );
94
+ };
95
+
96
+ /*------------------------------------------------------------------------*/
97
+ /* Wrap up */
98
+ /*------------------------------------------------------------------------*/
99
+
100
+ export default CheckboxButton;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Drawer container
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ // Import React
7
+ import React from 'react';
8
+
9
+ /*------------------------------------------------------------------------*/
10
+ /* Types */
11
+ /*------------------------------------------------------------------------*/
12
+
13
+ // Props definition
14
+ type Props = {
15
+ // Children to display
16
+ children: React.ReactNode,
17
+ };
18
+
19
+ /*------------------------------------------------------------------------*/
20
+ /* Style */
21
+ /*------------------------------------------------------------------------*/
22
+
23
+ const style = `
24
+ .Drawer-container {
25
+ margin-left: 1rem;
26
+ margin-right: 1rem;
27
+ margin-top: 0;
28
+ margin-bottom: 1rem;
29
+ padding: 0.75rem;
30
+ border-left: 1px solid #dee2e6;
31
+ border-bottom: 1px solid #dee2e6;
32
+ border-right: 1px solid #dee2e6;
33
+ border-bottom-left-radius: .25rem;
34
+ border-bottom-right-radius: .25rem;
35
+ box-shadow: inset 0 0 0.5rem 0 rgba(0, 0, 0, 0.05);
36
+ }
37
+ `;
38
+
39
+ /*------------------------------------------------------------------------*/
40
+ /* Component */
41
+ /*------------------------------------------------------------------------*/
42
+
43
+ const Drawer: React.FC<Props> = (props) => {
44
+ /*------------------------------------------------------------------------*/
45
+ /* Setup */
46
+ /*------------------------------------------------------------------------*/
47
+
48
+ /* -------------- Props ------------- */
49
+
50
+ // Destructure all props
51
+ const {
52
+ children,
53
+ } = props;
54
+
55
+ /*------------------------------------------------------------------------*/
56
+ /* Render */
57
+ /*------------------------------------------------------------------------*/
58
+
59
+ /*----------------------------------------*/
60
+ /* Main UI */
61
+ /*----------------------------------------*/
62
+
63
+ return (
64
+ <div className="Drawer-container">
65
+ <style>{style}</style>
66
+ {children}
67
+ </div>
68
+ );
69
+ };
70
+
71
+ /*------------------------------------------------------------------------*/
72
+ /* Wrap Up */
73
+ /*------------------------------------------------------------------------*/
74
+
75
+ // Export component
76
+ export default Drawer;
@@ -63,9 +63,9 @@ const ErrorBox: React.FC<Props> = (props) => {
63
63
  <span
64
64
  style={{
65
65
  backgroundColor: 'white',
66
- borderRadius: '5px',
67
- paddingLeft: '3px',
68
- paddingRight: '3px',
66
+ borderRadius: '0.3rem',
67
+ paddingLeft: '0.2rem',
68
+ paddingRight: '0.2rem',
69
69
  color: '#DC4150',
70
70
  fontVariant: 'small-caps',
71
71
  fontSize: '80%',
@@ -85,7 +85,7 @@ const ErrorBox: React.FC<Props> = (props) => {
85
85
  <div
86
86
  className="alert alert-danger text-center"
87
87
  style={{
88
- maxWidth: '650px',
88
+ maxWidth: '40rem',
89
89
  margin: 'auto',
90
90
  }}
91
91
  >
@@ -20,10 +20,10 @@ const style = `
20
20
  .LoadingSpinner-blip-2,
21
21
  .LoadingSpinner-blip-3,
22
22
  .LoadingSpinner-blip-4 {
23
- font-size: 25px;
23
+ font-size: 1.8rem;
24
24
  opacity: 0.6;
25
- margin-top: 20px;
26
- margin-bottom: 20px;
25
+ margin-top: 1rem;
26
+ margin-bottom: 1rem;
27
27
  }
28
28
 
29
29
  /* First Blip */