Skip to content

Commit 8cadef1

Browse files
Add collapse sidebar button
1 parent 2cb4797 commit 8cadef1

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

packages/web/src/app/(app)/browse/layoutClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function LayoutClient({
2323
const { repoName, revisionName } = useBrowseParams();
2424
return (
2525
<BrowseStateProvider>
26-
<div className="flex flex-col h-screen">
26+
<div className="flex flex-col h-full">
2727
<div className='sticky top-0 left-0 right-0 z-10'>
2828
<div className="py-1.5 px-3">
2929
<SearchBar

packages/web/src/app/(app)/components/appSidebar.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ import {
2626
SidebarMenuAction,
2727
SidebarMenuButton,
2828
SidebarMenuItem,
29+
SidebarRail,
30+
useSidebar,
2931
} from "@/components/ui/sidebar";
3032
import { UserAvatar } from "@/components/userAvatar";
3133
import { deleteChat, duplicateChat, updateChatName } from "@/features/chat/actions";
3234
import { captureEvent } from "@/hooks/useCaptureEvent";
3335
import { cn, isServiceError } from "@/lib/utils";
34-
import { BookMarkedIcon, ChevronsUpDown, EllipsisIcon, LogOut, MessageCircleIcon, MessagesSquareIcon, SearchIcon, SettingsIcon } from "lucide-react";
36+
import { ArrowLeftToLineIcon, ArrowRightToLineIcon, BookMarkedIcon, ChevronsUpDown, EllipsisIcon, LogOut, MessageCircleIcon, MessagesSquareIcon, SearchIcon, SettingsIcon } from "lucide-react";
3537
import { Session } from "next-auth";
3638
import { signOut } from "next-auth/react";
3739
import Link from "next/link";
@@ -232,16 +234,38 @@ export function AppSidebar({ session, chatHistory }: AppSidebarProps) {
232234
currentName={chatHistory.find((chat) => chat.id === chatIdToDuplicate)?.name ?? "Untitled chat"}
233235
/>
234236
</SidebarContent>
235-
<SidebarFooter>
237+
<SidebarFooter className="border-t border-sidebar-border">
238+
<CollapseSidebarButton />
236239
{session && (
237240
<MeControlDropdownMenu session={session} />
238241
)}
239242
</SidebarFooter>
243+
<SidebarRail />
240244
</Sidebar>
241245
);
242246
}
243247

244248

249+
function CollapseSidebarButton() {
250+
const { toggleSidebar, state } = useSidebar();
251+
return (
252+
<SidebarMenu>
253+
<SidebarMenuItem>
254+
<SidebarMenuButton onClick={toggleSidebar}>
255+
{state === "expanded" ? (
256+
<>
257+
<ArrowLeftToLineIcon />
258+
<span>Collapse sidebar</span>
259+
</>
260+
) : (
261+
<ArrowRightToLineIcon />
262+
)}
263+
</SidebarMenuButton>
264+
</SidebarMenuItem>
265+
</SidebarMenu>
266+
);
267+
}
268+
245269
interface MeControlDropdownMenuProps {
246270
session: Session;
247271
}

packages/web/src/app/(app)/search/components/searchResultsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const SearchResultsPage = ({
170170

171171

172172
return (
173-
<div className="flex flex-col h-screen overflow-clip">
173+
<div className="flex flex-col h-full">
174174
<div className='sticky top-0 left-0 right-0 z-10'>
175175
<div className="py-1.5 px-3">
176176
<SearchBar

packages/web/src/components/ui/sidebar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
3030
const SIDEBAR_WIDTH = "16rem"
3131
const SIDEBAR_WIDTH_MOBILE = "18rem"
3232
const SIDEBAR_WIDTH_ICON = "3rem"
33-
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
33+
const SIDEBAR_KEYBOARD_SHORTCUT = "["
3434

3535
type SidebarContextProps = {
3636
state: "expanded" | "collapsed"
@@ -106,8 +106,7 @@ const SidebarProvider = React.forwardRef<
106106
React.useEffect(() => {
107107
const handleKeyDown = (event: KeyboardEvent) => {
108108
if (
109-
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
110-
(event.metaKey || event.ctrlKey)
109+
event.key === SIDEBAR_KEYBOARD_SHORTCUT
111110
) {
112111
event.preventDefault()
113112
toggleSidebar()

0 commit comments

Comments
 (0)