Skip to content

Commit 52e5a75

Browse files
authored
feat(web): compact sidebar footer actions (#6210)
1 parent c196f42 commit 52e5a75

2 files changed

Lines changed: 190 additions & 138 deletions

File tree

apps/web/src/components/sidebar/SidebarChrome.tsx

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
SettingsIcon,
66
} from "lucide-react";
77
import { memo, useCallback } from "react";
8-
import { Link, useCanGoBack, useLocation, useNavigate } from "@tanstack/react-router";
8+
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
99

1010
import { useEnvironmentIdentificationMode } from "../../hooks/useSettings";
1111
import { cn } from "../../lib/utils";
@@ -27,8 +27,9 @@ import {
2727
SidebarTrigger,
2828
useSidebar,
2929
} from "../ui/sidebar";
30+
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
3031
import { SidebarProviderUpdatePill } from "./SidebarProviderUpdatePill";
31-
import { SidebarUpdatePill } from "./SidebarUpdatePill";
32+
import { SidebarUpdateArchitectureWarning, SidebarUpdatePill } from "./SidebarUpdatePill";
3233

3334
export const SidebarChromeHeader = memo(function SidebarChromeHeader({
3435
isElectron,
@@ -119,7 +120,6 @@ function T3Wordmark() {
119120
export const SidebarChromeFooter = memo(function SidebarChromeFooter() {
120121
const navigate = useNavigate();
121122
const { isMobile, setOpenMobile } = useSidebar();
122-
const canGoBack = useCanGoBack();
123123
const currentFooterPage = useLocation({
124124
select: (location) =>
125125
location.pathname === "/usage"
@@ -154,54 +154,72 @@ export const SidebarChromeFooter = memo(function SidebarChromeFooter() {
154154

155155
const handleBackClick = useCallback(() => {
156156
closeMobileSidebar();
157-
if (canGoBack) {
158-
window.history.back();
159-
return;
160-
}
161157
void navigate({ to: "/" });
162-
}, [canGoBack, closeMobileSidebar, navigate]);
158+
}, [closeMobileSidebar, navigate]);
163159

164160
return (
165161
<SidebarFooter className="p-[var(--sidebar-content-inset)]">
166162
<SidebarProviderUpdatePill />
167-
<SidebarUpdatePill />
168-
<SidebarMenu>
169-
{currentFooterPage === "pull-requests" ? (
170-
<SidebarMenuItem>
171-
<SidebarMenuButton onClick={handleBackClick}>
172-
<ArrowLeftIcon />
173-
<span>Back</span>
174-
</SidebarMenuButton>
175-
</SidebarMenuItem>
176-
) : pullRequestsSupported ? (
177-
<SidebarMenuItem>
178-
<SidebarMenuButton onClick={handlePullRequestsClick}>
179-
<GitPullRequestIcon />
180-
<span>Pull Requests</span>
181-
</SidebarMenuButton>
182-
</SidebarMenuItem>
183-
) : null}
184-
{currentFooterPage === "usage" ? (
185-
<SidebarMenuItem>
163+
<SidebarUpdateArchitectureWarning />
164+
<SidebarMenu className="flex-row items-center">
165+
{currentFooterPage ? (
166+
<SidebarMenuItem className="min-w-0 flex-1">
186167
<SidebarMenuButton onClick={handleBackClick}>
187168
<ArrowLeftIcon />
188169
<span>Back</span>
189170
</SidebarMenuButton>
190171
</SidebarMenuItem>
191172
) : (
192-
<SidebarMenuItem>
193-
<SidebarMenuButton onClick={handleUsageClick}>
194-
<ChartNoAxesColumnIcon />
195-
<span>Usage</span>
196-
</SidebarMenuButton>
197-
</SidebarMenuItem>
173+
<>
174+
<SidebarMenuItem className="shrink-0">
175+
<Tooltip>
176+
<TooltipTrigger
177+
render={
178+
<SidebarMenuButton
179+
aria-label="Settings"
180+
onClick={handleSettingsClick}
181+
size="icon"
182+
>
183+
<SettingsIcon />
184+
</SidebarMenuButton>
185+
}
186+
/>
187+
<TooltipPopup side="top">Settings</TooltipPopup>
188+
</Tooltip>
189+
</SidebarMenuItem>
190+
{pullRequestsSupported ? (
191+
<SidebarMenuItem className="shrink-0">
192+
<Tooltip>
193+
<TooltipTrigger
194+
render={
195+
<SidebarMenuButton
196+
aria-label="Pull Requests"
197+
onClick={handlePullRequestsClick}
198+
size="icon"
199+
>
200+
<GitPullRequestIcon />
201+
</SidebarMenuButton>
202+
}
203+
/>
204+
<TooltipPopup side="top">Pull Requests</TooltipPopup>
205+
</Tooltip>
206+
</SidebarMenuItem>
207+
) : null}
208+
<SidebarMenuItem className="shrink-0">
209+
<Tooltip>
210+
<TooltipTrigger
211+
render={
212+
<SidebarMenuButton aria-label="Usage" onClick={handleUsageClick} size="icon">
213+
<ChartNoAxesColumnIcon />
214+
</SidebarMenuButton>
215+
}
216+
/>
217+
<TooltipPopup side="top">Usage</TooltipPopup>
218+
</Tooltip>
219+
</SidebarMenuItem>
220+
</>
198221
)}
199-
<SidebarMenuItem>
200-
<SidebarMenuButton onClick={handleSettingsClick}>
201-
<SettingsIcon />
202-
<span>Settings</span>
203-
</SidebarMenuButton>
204-
</SidebarMenuItem>
222+
<SidebarUpdatePill />
205223
</SidebarMenu>
206224
</SidebarFooter>
207225
);

0 commit comments

Comments
 (0)