personal web client for Bluesky
typescript
solidjs
bluesky
atcute
1import type { Component, ParentProps } from 'solid-js';
2
3import { useModalContext } from '~/globals/modals';
4
5import { useModalClose } from '~/lib/hooks/modal-close';
6
7export { Backdrop } from './dialog';
8
9export interface SidebarContainerProps extends ParentProps {}
10
11const SidebarContainer = (props: SidebarContainerProps) => {
12 const { close, isActive } = useModalContext();
13
14 const containerRef = (node: HTMLElement) => {
15 useModalClose(node, close, isActive);
16 };
17
18 return (
19 <div
20 ref={containerRef}
21 role="menu"
22 class="z-1 flex w-72 grow flex-col self-start overflow-auto bg-background"
23 >
24 {props.children}
25 </div>
26 );
27};
28
29export { SidebarContainer as Container };
30
31export interface SidebarItemProps {
32 icon: Component;
33 label: string;
34 onClick?: () => void;
35}
36
37const SidebarItem = (props: SidebarItemProps) => {
38 return (
39 <button
40 role="menuitem"
41 onClick={props.onClick}
42 class="flex gap-4 px-4 py-3 text-contrast hover:bg-contrast/md active:bg-contrast/sm-pressed"
43 >
44 <div class="mt-0.5 text-xl">
45 {(() => {
46 const Icon = props.icon;
47 return <Icon />;
48 })()}
49 </div>
50
51 <span class="text-base font-bold">{props.label}</span>
52 </button>
53 );
54};
55
56export { SidebarItem as Item };
57
58export interface SidebarNavItemProps {
59 icon: Component;
60 label: string;
61 href: string;
62}
63
64const SidebarNavItem = (props: SidebarNavItemProps) => {
65 const { close } = useModalContext();
66
67 return (
68 <a
69 role="menuitem"
70 href={props.href}
71 onClick={close}
72 class="flex gap-4 px-4 py-3 text-contrast hover:bg-contrast/md active:bg-contrast/sm-pressed"
73 >
74 <div class="mt-0.5 text-xl">
75 {(() => {
76 const Icon = props.icon;
77 return <Icon />;
78 })()}
79 </div>
80
81 <span class="text-base font-bold">{props.label}</span>
82 </a>
83 );
84};
85
86export { SidebarNavItem as NavItem };