excalidraw/packages/excalidraw/components/TTDDialog/TTDDialogTrigger.tsx
Marcel Mraz 21ffaf4d76
All checks were successful
Tests / test (push) Successful in 4m38s
refactor: auto ordered imports (#9163)
2025-03-12 15:23:31 +01:00

36 lines
1 KiB
TypeScript

import { trackEvent } from "../../analytics";
import { useTunnels } from "../../context/tunnels";
import { t } from "../../i18n";
import { useExcalidrawSetAppState } from "../App";
import DropdownMenu from "../dropdownMenu/DropdownMenu";
import { brainIcon } from "../icons";
import type { ReactNode } from "react";
import type { JSX } from "react";
export const TTDDialogTrigger = ({
children,
icon,
}: {
children?: ReactNode;
icon?: JSX.Element;
}) => {
const { TTDDialogTriggerTunnel } = useTunnels();
const setAppState = useExcalidrawSetAppState();
return (
<TTDDialogTriggerTunnel.In>
<DropdownMenu.Item
onSelect={() => {
trackEvent("ai", "dialog open", "ttd");
setAppState({ openDialog: { name: "ttd", tab: "text-to-diagram" } });
}}
icon={icon ?? brainIcon}
>
{children ?? t("labels.textToDiagram")}
<DropdownMenu.Item.Badge>AI</DropdownMenu.Item.Badge>
</DropdownMenu.Item>
</TTDDialogTriggerTunnel.In>
);
};
TTDDialogTrigger.displayName = "TTDDialogTrigger";