Skip to content

Commit 6a26b98

Browse files
author
pengyu
committed
fix side bar
1 parent 76e5687 commit 6a26b98

File tree

2 files changed

+69
-55
lines changed

2 files changed

+69
-55
lines changed

frontend/src/components/sidebar-item.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function SideBarItem({
108108
)}
109109
onClick={handleChatClick}
110110
>
111-
<div className="flex-1 flex items-center truncate ml-2 mr-12">
111+
<div className="flex-1 flex items-center truncate ml-2 mr-12 min-w-0">
112112
<div className="flex flex-col">
113113
<span className="text-xs font-normal">{title || 'New Chat'}</span>
114114
</div>

frontend/src/components/sidebar.tsx

+68-54
Original file line numberDiff line numberDiff line change
@@ -74,78 +74,90 @@ export function ChatSideBar({
7474
<Sidebar collapsible="icon" side="left">
7575
{/* Header Row: Fox Logo (clickable) on the left, SidebarTrigger on the right */}
7676
<div
77-
className={`flex items-center ${
78-
isCollapsed ? 'justify-center w-full' : 'justify-between'
79-
} px-3 pt-3`}
77+
className={`flex items-center ${isCollapsed ? 'justify-center w-full px-0' : 'justify-between px-3'} pt-3`}
8078
>
81-
{/* 只包裹图标与文字,让点击区域正好等于这两个元素 */}
82-
<Button
83-
onClick={() => router.push('/')}
84-
variant="ghost"
85-
className="inline-flex items-center justify-start gap-2 pl-0 hover:bg-yellow-50 rounded-md transition-all duration-200 ease-in-out"
86-
>
87-
<Image
88-
src="/codefox.svg"
89-
alt="CodeFox Logo"
90-
width={28}
91-
height={28}
92-
className="dark:invert"
93-
/>
94-
{!isCollapsed && (
95-
<span className="text-primary-500 font-semibold text-base">
96-
CodeFox
97-
</span>
98-
)}
99-
</Button>
79+
{!isCollapsed && (
80+
<div className="flex flex-1 items-center justify-between">
81+
<Button
82+
onClick={() => router.push('/')}
83+
variant="ghost"
84+
className="inline-flex items-center gap-2 pl-0
85+
rounded-md ease-in-out"
86+
>
87+
<Image
88+
src="/codefox.svg"
89+
alt="CodeFox Logo"
90+
width={40}
91+
height={40}
92+
className="dark:invert"
93+
/>
94+
<span className="text-primary-500 font-semibold text-base">
95+
CodeFox
96+
</span>
97+
</Button>
10098

101-
{/* 折叠/展开图标放右侧 */}
102-
<SidebarTrigger
103-
className="flex items-center justify-center cursor-pointer p-2"
104-
onClick={() => setIsCollapsed(!isCollapsed)}
105-
/>
99+
{/* SidebarTrigger 保证在 CodeFox 按钮的中间 */}
100+
<SidebarTrigger
101+
className="flex items-center justify-center w-12 h-12 "
102+
onClick={() => setIsCollapsed(!isCollapsed)}
103+
/>
104+
</div>
105+
)}
106+
107+
{isCollapsed && (
108+
<SidebarTrigger
109+
className="flex items-center justify-center w-full p-2 mt"
110+
onClick={() => setIsCollapsed(!isCollapsed)}
111+
/>
112+
)}
106113
</div>
107114

108115
{/* Divider Line */}
109116
<div className="border-t border-dotted border-gray-300 my-2 w-full mx-auto" />
110117

111118
{/* New Project 按钮 - 依然占据整行 */}
112-
<Button
113-
onClick={() => setIsModalOpen(true)}
114-
variant="ghost"
115-
className="
116-
flex items-center
117-
w-full
118-
h-14
119-
gap-2
120-
pl-4
121-
rounded-md
122-
hover:bg-yellow-50
123-
transition-all
124-
duration-200
125-
ease-in-out
126-
justify-start
127-
"
119+
<div
120+
className={`flex ${isCollapsed ? 'justify-center items-center w-full px-0' : ''} w-full mt-4`}
128121
>
129-
{
122+
<Button
123+
onClick={() => {
124+
if (isCollapsed) {
125+
router.push('/');
126+
} else {
127+
setIsModalOpen(true);
128+
}
129+
}}
130+
variant="ghost"
131+
className={`h-7 w-7 flex items-center justify-center rounded-md ease-in-out ${
132+
!isCollapsed && 'w-full gap-2 pl-4 justify-start'
133+
}`}
134+
>
130135
<svg
131136
data-name="Layer 1"
132-
viewBox="0 0 24 24"
137+
viewBox="0 0 32 32"
138+
preserveAspectRatio="xMidYMid meet"
133139
xmlns="http://www.w3.org/2000/svg"
140+
className={
141+
isCollapsed
142+
? 'w-8 h-8 min-w-[32px] min-h-[32px] ml-[-5px] mt-[-10px]'
143+
: 'w-10 h-10 min-w-[32px] min-h-[32px] mr-1'
144+
}
145+
strokeWidth="0.1"
134146
>
135-
<g transform="scale(-1,1) translate(-24,0)">
147+
<g transform="scale(-1,1) translate(-32,0)">
136148
<path
137149
d="M5,8A1,1,0,0,0,7,8V7H8A1,1,0,0,0,8,5H7V4A1,1,0,0,0,5,4V5H4A1,1,0,0,0,4,7H5ZM18,5H12a1,1,0,0,0,0,2h6a1,1,0,0,1,1,1v9.72l-1.57-1.45a1,1,0,0,0-.68-.27H8a1,1,0,0,1-1-1V12a1,1,0,0,0-2,0v3a3,3,0,0,0,3,3h8.36l3,2.73A1,1,0,0,0,20,21a1.1,1.1,0,0,0,.4-.08A1,1,0,0,0,21,20V8A3,3,0,0,0,18,5Z"
138150
fill="#808080"
139151
/>
140152
</g>
141153
</svg>
142-
}
143-
{!isCollapsed && (
144-
<span className="text-gray-600 hover:text-gray-800 font-semibold text-sm">
145-
New Project
146-
</span>
147-
)}
148-
</Button>
154+
{!isCollapsed && (
155+
<span className="text-gray-600 hover:text-gray-800 font-semibold text-sm relative -top-0.5">
156+
New Project
157+
</span>
158+
)}
159+
</Button>
160+
</div>
149161

150162
{/* 聊天列表 */}
151163
<SidebarContent>
@@ -178,7 +190,9 @@ export function ChatSideBar({
178190
</SidebarContent>
179191

180192
{/* 底部设置 */}
181-
<SidebarFooter>
193+
<SidebarFooter
194+
className={`mt-auto ${isCollapsed ? 'flex justify-center px-0' : ''}`}
195+
>
182196
<UserSettings isSimple={false} />
183197
</SidebarFooter>
184198

0 commit comments

Comments
 (0)