mirror of
https://github.com/outline/outline.git
synced 2026-11-30 00:50:41 +03:00
- Applied types-react-codemod implicit-children transform - Updated 63 components to use React.PropsWithChildren - Fixed React.FC types to be compatible with React 18 - Ensures proper typing for components that accept children props This addresses React 18's removal of implicit children from component props.
73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import { t } from "i18next";
|
|
import { MoreIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import { MenuButton } from "reakit/Menu";
|
|
import styled from "styled-components";
|
|
import { s, hover } from "@shared/styles";
|
|
import ContextMenu from "~/components/ContextMenu";
|
|
import Template from "~/components/ContextMenu/Template";
|
|
import NudeButton from "~/components/NudeButton";
|
|
import { actionToMenuItem, performAction } from "~/actions";
|
|
import { navigateToNotificationSettings } from "~/actions/definitions/navigation";
|
|
import { markNotificationsAsArchived } from "~/actions/definitions/notifications";
|
|
import useActionContext from "~/hooks/useActionContext";
|
|
import { useMenuState } from "~/hooks/useMenuState";
|
|
import useOnClickOutside from "~/hooks/useOnClickOutside";
|
|
import { MenuItem } from "~/types";
|
|
|
|
const NotificationMenu: React.FC<React.PropsWithChildren<unknown>> = () => {
|
|
const menuRef = React.useRef<HTMLDivElement>(null);
|
|
const menu = useMenuState();
|
|
const context = useActionContext();
|
|
const items: MenuItem[] = React.useMemo(
|
|
() => [
|
|
actionToMenuItem(markNotificationsAsArchived, context),
|
|
{
|
|
type: "button",
|
|
title: t("Notification settings"),
|
|
onClick: () => performAction(navigateToNotificationSettings, context),
|
|
},
|
|
],
|
|
[context]
|
|
);
|
|
|
|
useOnClickOutside(
|
|
menuRef,
|
|
(event) => {
|
|
if (menu.visible) {
|
|
event.stopPropagation();
|
|
event.preventDefault();
|
|
menu.hide();
|
|
}
|
|
},
|
|
{ capture: true }
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<MenuButton {...menu}>
|
|
{(props) => (
|
|
<Button {...props}>
|
|
<MoreIcon />
|
|
</Button>
|
|
)}
|
|
</MenuButton>
|
|
<ContextMenu {...menu} menuRef={menuRef} aria-label={t("Notification")}>
|
|
<Template {...menu} items={items} />
|
|
</ContextMenu>
|
|
</>
|
|
);
|
|
};
|
|
|
|
const Button = styled(NudeButton)`
|
|
color: ${s("textSecondary")};
|
|
|
|
&:${hover},
|
|
&:active {
|
|
color: ${s("text")};
|
|
background: ${s("sidebarControlHoverBackground")};
|
|
}
|
|
`;
|
|
|
|
export default NotificationMenu;
|