Skip to content

Commit 61579bb

Browse files
committed
ui: sidebar should always be visible on large screens
1 parent 245d4b5 commit 61579bb

File tree

3 files changed

+58
-41
lines changed

3 files changed

+58
-41
lines changed

src/components/FunTitle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const xWords = [
2525
'X',
2626
]
2727

28-
const FunTitle = ({ className }: { className?: string }) => {
29-
const funTitle = settingStore.funTitle ?? 'X'
28+
const FunTitle = ({ className, allowFun = true }: { className?: string; allowFun?: boolean }) => {
29+
const funTitle = allowFun ? settingStore.funTitle ?? 'X' : 'X'
3030

3131
const titleSections = useMemo<[string, string, string]>(() => {
3232
return funTitle?.split(/([xX])/g) as [string, string, string]

src/components/Navbar.tsx

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PersonaSelector from '~/components/PersonaSelector'
55
import ModelRefreshButton from '~/components/ModelRefreshButton'
66
import FunTitle from '~/components/FunTitle'
77
import KeyboardTooltip from '~/components/KeyboardToolTip'
8+
import { twMerge } from 'tailwind-merge'
89

910
import Bars3 from '~/icons/Bars3'
1011
import Search from '~/icons/Search'
@@ -14,37 +15,55 @@ import Create from '~/icons/Create'
1415

1516
import { settingStore } from '~/core/setting/SettingStore'
1617
import { chatStore } from '~/core/chat/ChatStore'
18+
import { Divider } from '@heroui/react'
1719

1820
const Navbar = () => {
21+
const isSidebarOpen = settingStore.setting.isSidebarOpen
22+
1923
return (
20-
<div className="navbar mb-2 flex h-auto min-h-0 flex-row justify-between gap-3 bg-base-300 p-1 md:mb-0 md:flex-col md:p-0">
21-
<div className="ml-2 hidden items-center pr-2 md:flex md:text-xl">
22-
<KeyboardTooltip
23-
command="$mod+B"
24-
placement="bottom"
25-
showArrow={false}
26-
className="-mt-2"
27-
title="Toggle Sidebar"
28-
>
29-
<button
30-
className="absolute left-2 text-base-content/30 transition-colors duration-100 ease-in-out hover:text-base-content/80"
31-
onClick={() => settingStore.toggleSideBar()}
24+
<div className="mb-2 flex h-auto min-h-0 flex-row justify-between gap-3 p-1 md:mb-0 md:flex-col md:p-0">
25+
<div className=" hidden items-center md:flex md:text-xl">
26+
{isSidebarOpen && (
27+
<KeyboardTooltip
28+
command="$mod+B"
29+
placement="bottom"
30+
showArrow={false}
31+
className="-mt-2"
32+
title="Toggle Sidebar"
3233
>
33-
<ShrinkHorizontal />
34-
</button>
35-
</KeyboardTooltip>
34+
<button
35+
className="absolute left-2 text-base-content/30 transition-colors duration-100 ease-in-out hover:text-base-content/80"
36+
onClick={() => settingStore.toggleSideBar()}
37+
>
38+
<ShrinkHorizontal />
39+
</button>
40+
</KeyboardTooltip>
41+
)}
3642

37-
<FunTitle className="md:text-xl" />
43+
<FunTitle className="w-full text-balance text-center md:text-xl" allowFun={isSidebarOpen} />
3844
</div>
3945

40-
<div className="w-full max-w-[600px] flex-row gap-2 md:flex md:flex-1">
41-
<ModelSelector />
42-
<ModelRefreshButton />
43-
</div>
46+
{isSidebarOpen ? (
47+
<>
48+
<div className="w-full max-w-[600px] flex-row gap-2 md:flex md:flex-1">
49+
<ModelSelector />
50+
<ModelRefreshButton />
51+
</div>
4452

45-
<PersonaSelector />
53+
<PersonaSelector />
54+
</>
55+
) : (
56+
<Divider className="bg-base-content/15" />
57+
)}
4658

47-
<div className="flex w-fit flex-row gap-2 md:w-full md:justify-evenly">
59+
<div
60+
className={twMerge(
61+
'flex w-fit gap-2 md:w-full ',
62+
settingStore.setting.isSidebarOpen
63+
? 'flex-row md:justify-evenly'
64+
: 'flex-col items-center',
65+
)}
66+
>
4867
<KeyboardTooltip
4968
command="$mod+Shift+O"
5069
placement="bottom"
@@ -79,7 +98,7 @@ const Navbar = () => {
7998
command="$mod+/"
8099
placement="bottom"
81100
showArrow={false}
82-
className="-mt-2"
101+
className="mt-auto"
83102
title="Settings"
84103
>
85104
<NavLink

src/containers/SideBar.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import { Divider } from '@heroui/react'
1313

1414
import KeyboardTooltip from '~/components/KeyboardToolTip'
1515

16-
export type AccordionSectionProps = {
17-
isOpen: boolean
18-
onSectionClicked: () => void
19-
}
16+
export type AccordionSectionProps = { isOpen: boolean; onSectionClicked: () => void }
2017

2118
export const SideBar = () => {
2219
const [openSectionType, setOpenSectionType] = useState<'chatList' | 'chat'>('chatList')
@@ -32,7 +29,9 @@ export const SideBar = () => {
3229
return 'w-full'
3330
}
3431

35-
return 'transition-[width] duration-300 ease-in-out ' + (isSidebarOpen ? ' w-[260px]' : ' w-0')
32+
return (
33+
'transition-[width] duration-300 ease-in-out ' + (isSidebarOpen ? ' w-[260px]' : ' w-[66px]')
34+
)
3635
}, [isMobile, isSidebarOpen])
3736

3837
const goToChat = () => {
@@ -51,22 +50,21 @@ export const SideBar = () => {
5150

5251
return (
5352
<nav className={twMerge('group/sidebar relative h-full', width)}>
54-
<div
55-
className={twMerge(
56-
'flex h-full flex-1 flex-col flex-nowrap gap-2 self-stretch bg-base-300 p-2 transition-opacity duration-150 ease-in-out',
57-
isSidebarOpen || isMobile ? 'opacity-100' : 'pointer-events-none -z-10 opacity-0',
58-
)}
59-
>
53+
<div className="flex h-full flex-1 flex-col flex-nowrap gap-2 self-stretch bg-base-300 p-2">
6054
<div className="hidden md:block">
6155
<Navbar />
6256
</div>
6357

64-
<Divider className="bg-base-content/15" />
58+
{isSidebarOpen && (
59+
<>
60+
<Divider className="bg-base-content/15" />
6561

66-
{openSectionType === 'chat' && setting.selectedChatId ? (
67-
<ChatSettingsSection onBackClicked={goToChatList} />
68-
) : (
69-
<ChatListSection onChatSelected={goToChat} />
62+
{openSectionType === 'chat' && setting.selectedChatId ? (
63+
<ChatSettingsSection onBackClicked={goToChatList} />
64+
) : (
65+
<ChatListSection onChatSelected={goToChat} />
66+
)}
67+
</>
7068
)}
7169
</div>
7270

0 commit comments

Comments
 (0)