mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-17 23:12:23 +00:00
refactor(components): simplify BackButton by using TooltipButton
This commit is contained in:
parent
2e74ffbac3
commit
9003e4b5a4
@ -1,14 +1,8 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {
|
|
||||||
Tooltip,
|
|
||||||
TooltipContent,
|
|
||||||
TooltipProvider,
|
|
||||||
TooltipTrigger,
|
|
||||||
} from "@/components/ui/tooltip";
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { ArrowLeftIcon } from "lucide-react";
|
import { ArrowLeftIcon } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { TooltipButton } from "@/components/tooltip-button";
|
||||||
|
|
||||||
interface BackButtonProps {
|
interface BackButtonProps {
|
||||||
href: string;
|
href: string;
|
||||||
@ -19,23 +13,14 @@ export const BackButton = ({ href, className }: BackButtonProps) => {
|
|||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipProvider delayDuration={0}>
|
<TooltipButton
|
||||||
<Tooltip>
|
tooltipContent={t("BackButton")}
|
||||||
<TooltipTrigger asChild>
|
className={cn("h-8 w-auto p-2", className)}
|
||||||
<Button
|
asChild
|
||||||
variant="ghost"
|
>
|
||||||
className={cn("h-8 w-auto p-2", className)}
|
<Link href={href}>
|
||||||
asChild
|
<ArrowLeftIcon size={16} aria-hidden="true" />
|
||||||
>
|
</Link>
|
||||||
<Link href={href}>
|
</TooltipButton>
|
||||||
<ArrowLeftIcon size={16} aria-hidden="true" />
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent className="px-2 py-1 text-xs">
|
|
||||||
{t("BackButton")}
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@ interface TooltipButtonProps extends ButtonProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TooltipButton = ({
|
export const TooltipButton = ({
|
||||||
children,
|
children,
|
||||||
delayDuration = 0,
|
delayDuration = 0,
|
||||||
tooltipContent,
|
tooltipContent,
|
||||||
@ -43,5 +43,3 @@ const TooltipButton = ({
|
|||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { TooltipButton };
|
|
||||||
|
Loading…
Reference in New Issue
Block a user