feat(webui): add central icon button
This commit is contained in:
31
webui/src/components/IconButton.tsx
Normal file
31
webui/src/components/IconButton.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { usePlatformLanguage } from "../i18n/LanguageContext";
|
||||
import Button, { type ButtonProps } from "./Button";
|
||||
|
||||
export type IconButtonProps = Omit<ButtonProps, "aria-label" | "children" | "title"> & {
|
||||
label: string;
|
||||
icon: ReactNode;
|
||||
};
|
||||
|
||||
export default function IconButton({
|
||||
label,
|
||||
icon,
|
||||
className = "",
|
||||
type = "button",
|
||||
...buttonProps
|
||||
}: IconButtonProps) {
|
||||
const { translateText } = usePlatformLanguage();
|
||||
const translatedLabel = translateText(label);
|
||||
|
||||
return (
|
||||
<Button
|
||||
{...buttonProps}
|
||||
type={type}
|
||||
className={["icon-button", className].filter(Boolean).join(" ")}
|
||||
aria-label={translatedLabel}
|
||||
title={translatedLabel}
|
||||
>
|
||||
<span className="icon-button-icon" aria-hidden="true">{icon}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user