From 85bdaace589fc49dcf3dc14fe89307c8a2e41e34 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 18 Nov 2023 21:11:07 +0800 Subject: [PATCH] Replace all Menu to Menu2 Need the default unmountOnClose so don't need the :has() hack --- src/app.css | 2 +- src/components/account-info.jsx | 13 +++---------- src/components/media-alt-modal.jsx | 5 +++-- src/components/media-modal.jsx | 6 +++--- src/components/menu2.jsx | 6 ++++-- src/components/shortcuts.jsx | 6 +++--- src/components/status.jsx | 6 +++--- src/pages/accounts.jsx | 5 +++-- src/pages/status.jsx | 5 +++-- 9 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/app.css b/src/app.css index ee127f6a..7834b5e2 100644 --- a/src/app.css +++ b/src/app.css @@ -1577,7 +1577,7 @@ body > .szh-menu-container { position: fixed !important; z-index: 10; } -.szh-menu-container:has(.szh-menu--state-open) { +.szh-menu-container:not(:empty) { inset: 0; inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); diff --git a/src/components/account-info.jsx b/src/components/account-info.jsx index f3b2ecaa..142bc998 100644 --- a/src/components/account-info.jsx +++ b/src/components/account-info.jsx @@ -29,6 +29,7 @@ import Icon from './icon'; import Link from './link'; import ListAddEdit from './list-add-edit'; import Loader from './loader'; +import Menu2 from './menu2'; import MenuConfirm from './menu-confirm'; import Modal from './modal'; import TranslationBlock from './translation-block'; @@ -906,7 +907,6 @@ function RelatedActions({ }, [info, isSelf]); const loading = relationshipUIState === 'loading'; - const menuInstanceRef = useRef(null); const [showTranslatedBio, setShowTranslatedBio] = useState(false); const [showAddRemoveLists, setShowAddRemoveLists] = useState(false); @@ -947,8 +947,7 @@ function RelatedActions({ {privateNote} )} - { - if (e.target === e.currentTarget) { - menuInstanceRef.current?.closeMenu?.(); - } - }, }} align="center" position="anchor" overflow="auto" - boundingBoxPadding="8 8 8 8" menuButton={ + {!relationship && relationshipUIState === 'loading' && ( )} diff --git a/src/components/media-alt-modal.jsx b/src/components/media-alt-modal.jsx index 58908013..5c99d925 100644 --- a/src/components/media-alt-modal.jsx +++ b/src/components/media-alt-modal.jsx @@ -7,6 +7,7 @@ import localeMatch from '../utils/locale-match'; import states from '../utils/states'; import Icon from './icon'; +import Menu2 from './menu2'; import TranslationBlock from './translation-block'; export default function MediaAltModal({ alt, lang, onClose }) { @@ -33,7 +34,7 @@ export default function MediaAltModal({ alt, lang, onClose }) {

Media description

- @@ -50,7 +51,7 @@ export default function MediaAltModal({ alt, lang, onClose }) { Translate - +
diff --git a/src/components/media-modal.jsx b/src/components/media-modal.jsx index 46ea7661..3b80630b 100644 --- a/src/components/media-modal.jsx +++ b/src/components/media-modal.jsx @@ -15,6 +15,7 @@ import states from '../utils/states'; import Icon from './icon'; import Link from './link'; import Media from './media'; +import Menu2 from './menu2'; import MenuLink from './menu-link'; function MediaModal({ @@ -259,11 +260,10 @@ function MediaModal({ )} - Open original media - {' '} + {' '} ) : ( - ); })} - + )} ); diff --git a/src/components/status.jsx b/src/components/status.jsx index 9e0f2dfb..202ba726 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -28,6 +28,7 @@ import { snapshot } from 'valtio/vanilla'; import AccountBlock from '../components/account-block'; import EmojiText from '../components/emoji-text'; import Loader from '../components/loader'; +import Menu2 from '../components/menu2'; import MenuConfirm from '../components/menu-confirm'; import Modal from '../components/modal'; import NameText from '../components/name-text'; @@ -1629,7 +1630,7 @@ function Status({ onClick={bookmarkStatus} /> - + )} diff --git a/src/pages/accounts.jsx b/src/pages/accounts.jsx index 59d43719..5d57ba21 100644 --- a/src/pages/accounts.jsx +++ b/src/pages/accounts.jsx @@ -7,6 +7,7 @@ import { useReducer } from 'preact/hooks'; import Avatar from '../components/avatar'; import Icon from '../components/icon'; import Link from '../components/link'; +import Menu2 from '../components/menu2'; import MenuConfirm from '../components/menu-confirm'; import NameText from '../components/name-text'; import { api } from '../utils/api'; @@ -92,7 +93,7 @@ function Accounts({ onClose }) { Default{' '} )} - Log out… - + ); diff --git a/src/pages/status.jsx b/src/pages/status.jsx index e8de6597..22ffdb83 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -23,6 +23,7 @@ import Icon from '../components/icon'; import Link from '../components/link'; import Loader from '../components/loader'; import MediaModal from '../components/media-modal'; +import Menu2 from '../components/menu2'; import NameText from '../components/name-text'; import RelativeTime from '../components/relative-time'; import Status from '../components/status'; @@ -1034,7 +1035,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { > - {postInstance}) - +