Open History to see the last commit
1import { Splitter } from '@ark-ui/solid'
2import { splitProps } from 'solid-js'
3import type { ParentProps } from 'solid-js'
4import type { SplitterResizeTriggerProps } from '@ark-ui/solid'
5import { cn } from '@/utils'
6β
7function SidebarRail(props: SplitterResizeTriggerProps) {
8 const [local, others] = splitProps(props, ['class'])
9β
10 return (
11 <Splitter.ResizeTrigger
12 class={cn(
13 'ring-offset-background focus-visible:ring-1 focus-visible:ring-border relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-hidden data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:after:left-0 data-[orientation=vertical]:after:h-1 data-[orientation=vertical]:after:w-full data-[orientation=vertical]:after:translate-x-0 data-[orientation=vertical]:after:-translate-y-1/2 [&[data-orientation=vertical]>div]:rotate-90',
14 local.class,
15 )}
16 {...others}
17 >
18 <Splitter.ResizeTriggerIndicator class="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border" />
19 </Splitter.ResizeTrigger>
20 )
21}
22β
23interface ResizableSidebarProps extends ParentProps {
24 sidebarPanelId: string
25 mainPanelId: string
26 class?: string
27}
28β
29export function ResizableSidebar(props: ResizableSidebarProps) {
30 return (
31 <>
32 <Splitter.Panel
33 id={props.sidebarPanelId}
34 class={cn('size-full', props.class)}
35 >
36 {props.children}
37 </Splitter.Panel>
38 <SidebarRail
39 id={`${props.sidebarPanelId}:${props.mainPanelId}`}
40 aria-label="Resize"
41 />
42 </>
43 )
44}