feat(admin): 完善玩家管理与角色配置
This commit is contained in:
67
src/components/admin/admin-field-label.tsx
Normal file
67
src/components/admin/admin-field-label.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import { CircleHelp } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
|
||||
type AdminFieldLabelProps = {
|
||||
htmlFor: string;
|
||||
children: ReactNode;
|
||||
helpText?: string;
|
||||
helpAriaLabel?: string;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function AdminFieldLabel({
|
||||
htmlFor,
|
||||
children,
|
||||
helpText,
|
||||
helpAriaLabel,
|
||||
className,
|
||||
}: AdminFieldLabelProps): React.ReactElement {
|
||||
if (!helpText) {
|
||||
return (
|
||||
<Label htmlFor={htmlFor} className={className}>
|
||||
{children}
|
||||
</Label>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<Label htmlFor={htmlFor} className={className}>
|
||||
{children}
|
||||
</Label>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className="text-muted-foreground"
|
||||
aria-label={helpAriaLabel}
|
||||
data-field-help={htmlFor}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<CircleHelp aria-hidden="true" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent
|
||||
side="top"
|
||||
align="start"
|
||||
className="max-w-80 whitespace-normal text-left leading-relaxed"
|
||||
>
|
||||
<p>{helpText}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user