feat: add disableTooltip prop to sidebar components and streamline mobile sidebar button functionality

This commit is contained in:
Anish Sarkar 2026-02-06 18:59:52 +05:30
parent 21eec210cc
commit 6857c1d7e8
5 changed files with 51 additions and 41 deletions

View file

@ -8,20 +8,29 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip
interface SidebarCollapseButtonProps {
isCollapsed: boolean;
onToggle: () => void;
disableTooltip?: boolean;
}
export function SidebarCollapseButton({ isCollapsed, onToggle }: SidebarCollapseButtonProps) {
export function SidebarCollapseButton({ isCollapsed, onToggle, disableTooltip = false }: SidebarCollapseButtonProps) {
const t = useTranslations("sidebar");
const button = (
<Button variant="ghost" size="icon" onClick={onToggle} className="h-8 w-8 shrink-0">
{isCollapsed ? <PanelLeft className="h-4 w-4" /> : <PanelLeftClose className="h-4 w-4" />}
<span className="sr-only">
{isCollapsed ? t("expand_sidebar") : t("collapse_sidebar")}
</span>
</Button>
);
if (disableTooltip) {
return button;
}
return (
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" onClick={onToggle} className="h-8 w-8 shrink-0">
{isCollapsed ? <PanelLeft className="h-4 w-4" /> : <PanelLeftClose className="h-4 w-4" />}
<span className="sr-only">
{isCollapsed ? t("expand_sidebar") : t("collapse_sidebar")}
</span>
</Button>
{button}
</TooltipTrigger>
<TooltipContent side={isCollapsed ? "right" : "bottom"}>
{isCollapsed ? `${t("expand_sidebar")} (⌘B)` : `${t("collapse_sidebar")} (⌘B)`}