File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
src/lib/components/shared Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { cn } from ' @/utils' ;
3+ import type { Snippet } from ' svelte' ;
4+ import { Button } from ' $lib/components/ui/button' ;
5+ import { IconHash } from ' @tabler/icons-svelte' ;
6+
7+ let {
8+ id,
9+ children,
10+ class : className,
11+ ... restProps
12+ }: {
13+ id: string ;
14+ children: Snippet ;
15+ class? : string ;
16+ } = $props ();
17+
18+ let buttonVisible = $state (false );
19+
20+ function onMouseEnter() {
21+ buttonVisible = true ;
22+ }
23+
24+ function onMouseLeave() {
25+ buttonVisible = false ;
26+ }
27+
28+ function gotoLink() {
29+ window .location .hash = id ;
30+ }
31+ </script >
32+
33+ <div
34+ class ={cn (' relative flex scroll-mt-24 items-center' , className )}
35+ {...restProps }
36+ {id }
37+ onmouseenter ={onMouseEnter }
38+ onmouseleave ={onMouseLeave }
39+ >
40+ {@render children ()}
41+ <div class =" relative flex items-center" >
42+ <div class =" absolute h-12 w-12" ></div >
43+ <Button
44+ class =" hover:text-foreground absolute left-2 h-8 w-8 text-blue-500 transition-all
45+ hover:cursor-pointer {buttonVisible ? 'opacity-100' : 'opacity-0'}"
46+ variant =" outline"
47+ size =" icon"
48+ onclick ={gotoLink }
49+ >
50+ <IconHash />
51+ </Button >
52+ </div >
53+ </div >
You can’t perform that action at this time.
0 commit comments