File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 import { flip } from ' svelte/animate' ;
66 import { fade } from ' svelte/transition' ;
77 import ActionButtons from ' ./actionButtons.svelte' ;
8- import { getIds , hasField } from ' $lib/helpers' ;
8+ import { getIds , hasField , isUrlString } from ' $lib/helpers' ;
99 import EmptyItem from ' ./emptyItem.svelte' ;
1010 import EmptyGroup from ' ./emptyGroup.svelte' ;
1111 import { newGroup , newItem } from ' $lib/factory' ;
200200 <div class =" flex items-center gap-2" >
201201 {#if item .icon }
202202 <div class =" h-14 w-14" >
203- <Icon color ="gray" icon ={item .icon } height ={56 } />
203+ {#if isUrlString (item .icon )}
204+ <img
205+ src ={item .icon }
206+ alt ={item .title }
207+ class =" h-full w-full rounded-full object-cover"
208+ />
209+ {:else }
210+ <Icon color ="gray" icon ={item .icon } height ={56 } />
211+ {/if }
204212 </div >
205213 {/if }
206214 <div >
Original file line number Diff line number Diff line change 3535 </Label >
3636 <Label class =" space-y-2" >
3737 <span >Icon</span >
38- <Input bind:value ={form .icon } type =" text" name =" icon" placeholder =" Icon name" />
38+ <Input bind:value ={form .icon } type =" text" name =" icon" placeholder =" URL or Icon name" />
3939 <Helper class =" text-sm" >
40- Icon name from <a
40+ URL or Icon name from <a
4141 target =" _blank"
4242 href =" https://icon-sets.iconify.design/"
4343 class =" text-primary-600 dark:text-primary-500 font-medium hover:underline" >iconify</a
Original file line number Diff line number Diff line change @@ -28,3 +28,11 @@ export const generateRandomString = (length: number) => {
2828 . toString ( 36 )
2929 . substring ( 2 , 2 + length ) ;
3030} ;
31+
32+ export const isUrlString = ( str : string ) : boolean => {
33+ if ( ! str ) {
34+ return false ;
35+ }
36+ const urlRegex = / ^ ( f t p | h t t p | h t t p s ) : \/ \/ [ ^ " ] + $ / ;
37+ return urlRegex . test ( str ) ;
38+ } ;
You can’t perform that action at this time.
0 commit comments