mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
* base menu works * action internal link & group * action external link * simplify NewTemplatesMenu * animation * tiny cleanup * simplify group api * icon spacer * root action * mobile menu * decrease drawer animation speed * format * animation, const separator * memo.. * TemplatesMenu + Scrollable dropdown * delete file-ops * cap height
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { ShapesIcon } from "outline-icons";
|
|
import { useTranslation } from "react-i18next";
|
|
import Document from "~/models/Document";
|
|
import Button from "~/components/Button";
|
|
import { DropdownMenu } from "~/components/Menu/DropdownMenu";
|
|
import { useMenuAction } from "~/hooks/useMenuAction";
|
|
import { useTemplateMenuActions } from "~/hooks/useTemplateMenuActions";
|
|
|
|
type Props = {
|
|
/** The document to which the templates will be applied */
|
|
document: Document;
|
|
/** Whether to render the button as a compact icon */
|
|
isCompact?: boolean;
|
|
/** Callback to handle when a template is selected */
|
|
onSelectTemplate: (template: Document) => void;
|
|
};
|
|
|
|
function TemplatesMenu({ isCompact, onSelectTemplate, document }: Props) {
|
|
const { t } = useTranslation();
|
|
const allActions = useTemplateMenuActions({ onSelectTemplate, document });
|
|
const rootAction = useMenuAction(allActions);
|
|
|
|
if (!allActions.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<DropdownMenu action={rootAction} align="start" ariaLabel={t("Templates")}>
|
|
<Button
|
|
icon={isCompact ? <ShapesIcon /> : undefined}
|
|
disclosure={!isCompact}
|
|
neutral
|
|
>
|
|
{isCompact ? undefined : t("Templates")}
|
|
</Button>
|
|
</DropdownMenu>
|
|
);
|
|
}
|
|
|
|
export default observer(TemplatesMenu);
|