|
1 | | -import { Button, Tooltip, DiffChanges, IconButton } from "@opencode-ai/ui" |
2 | | -import { createMemo, For, ParentProps, Show } from "solid-js" |
| 1 | +import { Button, Tooltip, DiffChanges, IconButton, Mark, Icon } from "@opencode-ai/ui" |
| 2 | +import { createMemo, For, Match, ParentProps, Show, Switch } from "solid-js" |
3 | 3 | import { DateTime } from "luxon" |
4 | 4 | import { useSync } from "@/context/sync" |
5 | 5 | import { A, useParams } from "@solidjs/router" |
6 | | -import { useLocal } from "@/context/local" |
| 6 | +import { useLayout } from "@/context/layout" |
7 | 7 |
|
8 | 8 | export default function Layout(props: ParentProps) { |
9 | 9 | const params = useParams() |
10 | 10 | const sync = useSync() |
11 | | - const local = useLocal() |
| 11 | + const layout = useLayout() |
12 | 12 |
|
13 | 13 | return ( |
14 | 14 | <div class="relative h-screen flex flex-col"> |
15 | | - <header class="hidden h-12 shrink-0 bg-background-strong border-b border-border-weak-base"></header> |
16 | | - <div class="h-[calc(100vh-0rem)] flex"> |
| 15 | + <header class="h-12 shrink-0 bg-background-base border-b border-border-weak-base"> |
17 | 16 | <div |
18 | 17 | classList={{ |
19 | | - "@container w-14 pb-4 shrink-0 bg-background-weak": true, |
20 | | - "flex flex-col items-start self-stretch justify-between": true, |
| 18 | + "w-12 shrink-0 px-4 py-3.5": true, |
| 19 | + "flex items-center justify-start self-stretch": true, |
21 | 20 | "border-r border-border-weak-base": true, |
22 | | - "w-70": local.layout.sidebar.opened(), |
23 | 21 | }} |
| 22 | + style={{ width: layout.sidebar.opened() ? `${layout.sidebar.width()}px` : undefined }} |
24 | 23 | > |
25 | | - <div class="flex flex-col justify-center items-start gap-4 self-stretch py-2 overflow-hidden mx-auto @[4rem]:mx-0"> |
26 | | - <div class="h-8 shrink-0 flex items-center self-stretch px-3"> |
27 | | - <Tooltip placement="right" value="Collapse sidebar"> |
28 | | - <IconButton icon="layout-left" variant="ghost" size="large" onClick={local.layout.sidebar.toggle} /> |
29 | | - </Tooltip> |
30 | | - </div> |
| 24 | + <Mark class="shrink-0" /> |
| 25 | + </div> |
| 26 | + </header> |
| 27 | + <div class="h-[calc(100vh-3rem)] flex"> |
| 28 | + <div |
| 29 | + classList={{ |
| 30 | + "@container w-12 pb-5 shrink-0 bg-background-base": true, |
| 31 | + "flex flex-col gap-5.5 items-start self-stretch justify-between": true, |
| 32 | + "border-r border-border-weak-base": true, |
| 33 | + }} |
| 34 | + style={{ width: layout.sidebar.opened() ? `${layout.sidebar.width()}px` : undefined }} |
| 35 | + > |
| 36 | + <div class="flex flex-col justify-center items-start gap-4 self-stretch p-2 overflow-hidden mx-auto @[4rem]:mx-0"> |
| 37 | + <Switch> |
| 38 | + <Match when={layout.sidebar.opened()}> |
| 39 | + <Button |
| 40 | + variant="ghost" |
| 41 | + size="large" |
| 42 | + class="group/sidebar-toggle w-full text-left justify-start" |
| 43 | + onClick={layout.sidebar.toggle} |
| 44 | + > |
| 45 | + <div class="relative -ml-px flex items-center justify-center size-4 [&>*]:absolute [&>*]:inset-0"> |
| 46 | + <Icon name="layout-left" size="small" class="group-hover/sidebar-toggle:hidden" /> |
| 47 | + <Icon |
| 48 | + name="layout-left-partial" |
| 49 | + size="small" |
| 50 | + class="hidden group-hover/sidebar-toggle:inline-block" |
| 51 | + /> |
| 52 | + <Icon |
| 53 | + name="layout-left-full" |
| 54 | + size="small" |
| 55 | + class="hidden group-active/sidebar-toggle:inline-block" |
| 56 | + /> |
| 57 | + </div> |
| 58 | + <div class="hidden group-hover/sidebar-toggle:block group-active/sidebar-toggle:block text-text-base"> |
| 59 | + Toggle sidebar |
| 60 | + </div> |
| 61 | + </Button> |
| 62 | + </Match> |
| 63 | + <Match when={!layout.sidebar.opened()}> |
| 64 | + <Tooltip placement="right" value="Toggle sidebar"> |
| 65 | + <Button variant="ghost" size="large" class="group/sidebar-toggle" onClick={layout.sidebar.toggle}> |
| 66 | + <div class="relative -ml-px flex items-center justify-center size-4 [&>*]:absolute [&>*]:inset-0"> |
| 67 | + <Icon name="layout-right" size="small" class="group-hover/sidebar-toggle:hidden" /> |
| 68 | + <Icon |
| 69 | + name="layout-right-partial" |
| 70 | + size="small" |
| 71 | + class="hidden group-hover/sidebar-toggle:inline-block" |
| 72 | + /> |
| 73 | + <Icon |
| 74 | + name="layout-right-full" |
| 75 | + size="small" |
| 76 | + class="hidden group-active/sidebar-toggle:inline-block" |
| 77 | + /> |
| 78 | + </div> |
| 79 | + </Button> |
| 80 | + </Tooltip> |
| 81 | + </Match> |
| 82 | + </Switch> |
31 | 83 | <div class="w-full px-3"> |
32 | 84 | <Button as={A} href="/session" class="hidden @[4rem]:flex w-full" size="large" icon="edit-small-2"> |
33 | 85 | New Session |
|
0 commit comments