File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ import { UseGetIcon } from '../../types' ;
2+
3+ const defaultIcons = {
4+ fa : {
5+ clear : 'fa-circle-xmark' ,
6+ false : 'fa-xmark' ,
7+ loading : 'fa-circle-notch' ,
8+ save : 'fa-floppy-disk' ,
9+ true : 'fa-check' ,
10+ } ,
11+ mdi : {
12+ clear : 'mdi-close-circle-outline' ,
13+ false : 'mdi-close' ,
14+ loading : 'mdi-loading' ,
15+ save : 'mdi-content-save' ,
16+ true : 'mdi-check' ,
17+ } ,
18+ } ;
19+
20+ export const useGetIcon : UseGetIcon = ( options ) => {
21+ const { icon, iconOptions, name } = options ;
22+
23+ if ( icon ) {
24+ return icon ;
25+ }
26+
27+ const iconSet = defaultIcons [ iconOptions ?. defaultSet as string ] ;
28+
29+ if ( ! iconSet ) {
30+ throw new Error ( `VInlineFields: No VInlineFields default ${ iconOptions ?. defaultSet } icon set found for ${ name } . Please set the icon prop.` ) ;
31+ }
32+
33+ const newIcon = iconSet [ name ] ;
34+
35+ if ( ! newIcon ) {
36+ throw new Error ( `VInlineFields: No ${ name } icon found. Please set the icon prop, or set the default icon set to 'mdi' or 'fa'` ) ;
37+ }
38+
39+ return newIcon ;
40+ } ;
You can’t perform that action at this time.
0 commit comments