File size: 1,004 Bytes
3201ca6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { useTranslation } from "react-i18next";
import {
  ComboboxCaretIcon,
  comboboxCaretButtonClassName,
} from "#/ui/combobox-caret";
import { cn } from "#/utils/utils";
import { I18nKey } from "#/i18n/declaration";

interface ToggleButtonProps {
  isOpen: boolean;
  disabled: boolean;
  getToggleButtonProps: (
    props?: Record<string, unknown>,
  ) => Record<string, unknown>;
  iconClassName?: string;
}

export function ToggleButton({
  isOpen,
  disabled,
  getToggleButtonProps,
  iconClassName,
}: ToggleButtonProps) {
  const { t } = useTranslation("openhands");

  return (
    <button
      {...getToggleButtonProps({
        disabled,
        className: cn(
          comboboxCaretButtonClassName,
          "text-current",
          isOpen && "rotate-180",
          disabled && "cursor-not-allowed opacity-60",
        ),
      })}
      type="button"
      aria-label={t(I18nKey.COMMON$TOGGLE_MENU)}
    >
      <ComboboxCaretIcon className={iconClassName} />
    </button>
  );
}