File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
src/lib/components/shared Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { cn } from ' @/utils' ;
3+ import { IconChevronDown , IconChevronRight } from ' @tabler/icons-svelte' ;
4+ import type { Snippet } from ' svelte' ;
5+
6+ let {
7+ title,
8+ children,
9+ class : className,
10+ ... restProps
11+ }: {
12+ title: string ;
13+ children: Snippet ;
14+ class? : string ;
15+ } = $props ();
16+
17+ let collapsed = $state (true );
18+
19+ function onClick() {
20+ collapsed = ! collapsed ;
21+ }
22+ </script >
23+
24+ <div >
25+ <button
26+ class ={cn (
27+ ' bg-muted flex w-full items-center space-x-1 px-2 py-1 hover:cursor-pointer' ,
28+ className
29+ )}
30+ type =" button"
31+ onclick ={onClick }
32+ >
33+ {#if collapsed }
34+ <IconChevronRight size ={16 } />
35+ {:else }
36+ <IconChevronDown size ={16 } />
37+ {/if }
38+ <span >
39+ {title }
40+ </span >
41+ </button >
42+ <div
43+ class ="mt-2 ml-2 grid {collapsed
44+ ? ' grid-rows-[0fr]'
45+ : ' grid-rows-[1fr]' } transition-[grid-template-rows]"
46+ >
47+ <div class =" overflow-hidden" >
48+ {@render children ()}
49+ </div >
50+ </div >
51+ </div >
You can’t perform that action at this time.
0 commit comments