@imposium-hub/components 1.36.4 → 1.38.0

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.
package/Entry.ts CHANGED
@@ -22,6 +22,7 @@ import NumberField from './components/number-field/NumberField';
22
22
  import SelectField from './components/select-field/SelectField';
23
23
  import TextField from './components/text-field/TextField';
24
24
  import TextAreaField from './components/text-area-field/TextAreaField';
25
+ import ToastService from './components/toast-service/ToastService';
25
26
  import SliderField from './components/slider-field/SliderField';
26
27
  import ColorField from './components/color-field/ColorField';
27
28
  import Tag from './components/tag/Tag';
@@ -139,6 +140,7 @@ export {
139
140
  Tag,
140
141
  TextField,
141
142
  TextAreaField,
143
+ ToastService,
142
144
  SliderField,
143
145
  Section,
144
146
  DeterminateLoader,
File without changes
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ import cogoToast from 'cogo-toast';
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
+ import { faInfoCircle } from '@fortawesome/free-solid-svg-icons/faInfoCircle';
5
+ import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons/faExclamationTriangle';
6
+
7
+ export default class ToastService {
8
+ private static readonly DEFAULT_TOAST_CONFIG : any = {
9
+ hideAfter: 3,
10
+ position: 'bottom-right'
11
+ };
12
+
13
+ private static INFO_STYLE : any = {
14
+ bar: {
15
+ size: '2px',
16
+ style: 'solid',
17
+ color: '#56B05E'
18
+ },
19
+ renderIcon: () => (<FontAwesomeIcon icon = {faInfoCircle} color = '#56B05E' />)
20
+ };
21
+
22
+ private static ERROR_STYLE : any = {
23
+ bar: {
24
+ size: '2px',
25
+ style: 'solid',
26
+ color: '#AF1126'
27
+ },
28
+ renderIcon: () => (<FontAwesomeIcon icon = {faExclamationTriangle} color = '#AF1126' />)
29
+ };
30
+
31
+ public static emit = (type : string, copy : string) : void => {
32
+ switch (type) {
33
+ case 'info':
34
+ cogoToast.info(
35
+ copy,
36
+ {
37
+ ...ToastService.DEFAULT_TOAST_CONFIG,
38
+ ...ToastService.INFO_STYLE
39
+ }
40
+ );
41
+ return;
42
+ case 'error':
43
+ cogoToast.error(
44
+ copy,
45
+ {
46
+ ...ToastService.DEFAULT_TOAST_CONFIG,
47
+ ...ToastService.ERROR_STYLE
48
+ }
49
+ );
50
+ return;
51
+ default:
52
+ return;
53
+ }
54
+ }
55
+ }