From 3db5e1400bb98e2f2e70db329fe601d0062689d9 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 18 Jul 2024 00:15:58 +0900 Subject: [PATCH] refs #4917 Implement context-menu on notification --- .../timelines/notification/Reaction.tsx | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/renderer/components/timelines/notification/Reaction.tsx b/renderer/components/timelines/notification/Reaction.tsx index 09a71bca..9a894e3a 100644 --- a/renderer/components/timelines/notification/Reaction.tsx +++ b/renderer/components/timelines/notification/Reaction.tsx @@ -6,9 +6,9 @@ import Poll from '../status/Poll' import Card from '../status/Card' import Media from '../status/Media' import { FaBarsProgress, FaHouse, FaPenToSquare, FaRetweet, FaStar } from 'react-icons/fa6' -import { useIntl } from 'react-intl' -import { useState } from 'react' -import { Avatar } from '@material-tailwind/react' +import { FormattedMessage, useIntl } from 'react-intl' +import { MouseEventHandler, useState } from 'react' +import { Avatar, List, ListItem, Card as MaterialCard } from '@material-tailwind/react' import { useRouter } from 'next/router' type Props = { @@ -37,6 +37,33 @@ export default function Reaction(props: Props) { router.push({ query: { id: router.query.id, timeline: router.query.timeline, user_id: id, detail: true } }) } + const onContextMenu: MouseEventHandler = e => { + e.preventDefault() + hideOthers() + const context = document.getElementById(`context-${status.id}`) + if (context) { + context.style.left = `${e.clientX}px` + context.style.top = `${e.clientY}px` + context.style.display = 'block' + } + } + + const onClick: MouseEventHandler = e => { + e.preventDefault() + hideOthers() + } + + const hideOthers = () => { + const menu = document.getElementsByClassName('context-menu') + for (let i = 0; i < menu.length; i++) { + ;(menu[i] as HTMLElement).style.display = 'none' + } + } + + const copyLink = () => { + navigator.clipboard.writeText(status.url) + } + return (
@@ -71,7 +98,12 @@ export default function Reaction(props: Props) { alt={formatMessage({ id: 'timeline.status.avatar' }, { user: status.account.username })} />
-
+
openUser(status.account.id)}> )} +
+ + + + + + + + + + +