File tree Expand file tree Collapse file tree
features/awesome-privacy/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6666 social: UsersRound ,
6767 media: Film ,
6868 creativity: Paintbrush ,
69- categoryFallback: Circle
69+ fallback: Box
7070 } as const ;
7171 </script >
Original file line number Diff line number Diff line change 2929 const slug = $derived (awesomePrivacy .slugify (category ));
3030
3131 const IconComponent = $derived (
32- (categoryIcons as Record <string , typeof Icons .categoryFallback >)[slug ] ?? Icons .categoryFallback
32+ (categoryIcons as Record <string , typeof Icons .fallback >)[slug ] ?? Icons .fallback
3333 );
3434 </script >
3535
Original file line number Diff line number Diff line change 33
44 import type { Service } from ' ../types' ;
55
6+ import { Icons } from ' $lib/components/icons/icons.svelte' ;
67 import { cn } from ' $lib/utils/cn' ;
78
89 type ServiceLogoProps = HTMLAttributes <HTMLImageElement > & {
1112
1213 let { service, class : klass, ... props }: ServiceLogoProps = $props ();
1314
15+ let error = $state (false );
16+
1417 const fallback = $derived (` https://icon.horse/icon/${service .url } ` );
1518 </script >
1619
17- <img
18- referrerpolicy =" no-referrer"
19- src ={service .icon ?? fallback }
20- onerror ={(e ) => {
21- const target = e .target as HTMLImageElement ;
22- if (target .src !== fallback ) target .src = fallback ;
23- }}
24- alt ={service .name }
25- class ={cn (' shrink-0 object-contain' , klass )}
26- {...props }
27- />
20+ {#if error }
21+ <Icons .fallback class ={cn (' shrink-0' , klass )} />
22+ {:else }
23+ <img
24+ referrerpolicy =" no-referrer"
25+ src ={service .icon ?? fallback }
26+ onerror ={(e ) => {
27+ const target = e .target as HTMLImageElement ;
28+
29+ if (target .src !== fallback ) {
30+ target .src = fallback ;
31+ } else if (target .src === fallback ) {
32+ error = true ;
33+ }
34+ }}
35+ alt ={service .name }
36+ class ={cn (' shrink-0 object-contain' , klass )}
37+ {...props }
38+ />
39+ {/if }
You can’t perform that action at this time.
0 commit comments