Файли
openidea/src/ui/BarButton.tsx
T
l0ng-ai 90cca59462 fix(plugins): show plugin text as written instead of through the IDE catalog (#1999)
A plugin title, label or message equal to IDE text ("Pick", "Log", "Refresh") was translated by the IDE catalog. Primitives now translate given text through useGivenTx, which returns it as written below VerbatimTextContext (plugin views, service panes, status items, prompts); plugin commands, tool windows, menu labels and notifications carry a verbatim flag. Command categories and the IDE's own words stay translated.
2026-11-07 21:44:03 +08:00

35 рядки
1.2 KiB
TypeScript

import { forwardRef, type ButtonHTMLAttributes } from "react";
import clsx from "clsx";
import { useGivenTx } from "@/platform/i18n";
import { tooltipAttrs } from "./Tooltip";
import styles from "./BarButton.module.css";
export interface BarButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "title"> {
/** `status`: status bar widget; `title`: main toolbar widget. */
variant?: "status" | "title";
mono?: boolean;
/** Tooltip text (also the accessible name unless `aria-label` is set). */
tooltip?: string;
shortcut?: string;
emphasis?: boolean;
}
/** Text button for status bar / title bar widgets contributed by features. */
export const BarButton = forwardRef<HTMLButtonElement, BarButtonProps>(function BarButton(
{ variant = "status", mono, tooltip, shortcut, emphasis, className, type = "button", children, ...rest },
ref,
) {
const given = useGivenTx();
return (
<button
ref={ref}
type={type}
className={clsx(styles.button, styles[variant], mono && styles.mono, emphasis && styles.emphasis, className)}
{...tooltipAttrs(given(tooltip), shortcut, true)}
{...rest}
>
{children}
</button>
);
});