lots of work
This commit is contained in:
parent
552ba7f3c9
commit
75bd06cac3
19 changed files with 523 additions and 314 deletions
29
src/components/sidebar.tsx
Normal file
29
src/components/sidebar.tsx
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { TbLayoutSidebarLeftCollapse, TbLayoutSidebarLeftExpand } from "solid-icons/tb";
|
||||
import { createMemo, createSignal, onMount, ParentComponent, Show } from "solid-js";
|
||||
import { Dynamic, Portal, render } from "solid-js/web";
|
||||
import css from "./sidebar.module.css";
|
||||
|
||||
export const Sidebar: ParentComponent<{ as?: string, open?: boolean, name?: string }> = (props) => {
|
||||
const [open, setOpen] = createSignal(props.open ?? true)
|
||||
const cssClass = createMemo(() => open() ? css.open : css.closed);
|
||||
const name = createMemo(() => props.name ?? 'sidebar');
|
||||
|
||||
const toggle = () => setOpen(o => !o);
|
||||
|
||||
let ref: Element;
|
||||
return <Dynamic component={props.as ?? 'div'} class={`${css.root} ${cssClass()}`} ref={ref}>
|
||||
<Portal mount={ref!} useShadow={true}>
|
||||
<button onclick={() => toggle()} role="button" title={`${open() ? 'close' : 'open'} ${name()}`}>
|
||||
<Show when={open()} fallback={<TbLayoutSidebarLeftExpand />}>
|
||||
<TbLayoutSidebarLeftCollapse />
|
||||
</Show>
|
||||
</button>
|
||||
|
||||
<div class={css.content}>
|
||||
<slot />
|
||||
</div>
|
||||
</Portal>
|
||||
|
||||
{props.children}
|
||||
</Dynamic>
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue