From d6179d0fdca562a376cf0fd8bb18f1fa9cc7144c Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 29 Apr 2024 13:28:04 +0200 Subject: [PATCH 1/7] feat(reply modal): disable draggable on mobile and calculate absolute top position --- .../reply-modal/reply-modal.module.css | 10 +++ src/components/reply-modal/reply-modal.tsx | 81 +++++++++++++------ 2 files changed, 67 insertions(+), 24 deletions(-) diff --git a/src/components/reply-modal/reply-modal.module.css b/src/components/reply-modal/reply-modal.module.css index 5acd55f6..e0ab7519 100644 --- a/src/components/reply-modal/reply-modal.module.css +++ b/src/components/reply-modal/reply-modal.module.css @@ -57,4 +57,14 @@ text-transform: capitalize; float: right; cursor: pointer; +} + +@media (max-width: 640px) { + .container { + position: absolute; + } + + .title { + cursor: default; + } } \ No newline at end of file diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx index eda69f8d..c914fdec 100644 --- a/src/components/reply-modal/reply-modal.tsx +++ b/src/components/reply-modal/reply-modal.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from 'react'; +import React, { useEffect, useRef } from 'react'; import { useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import Draggable from 'react-draggable'; @@ -6,6 +6,7 @@ import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js'; import { useAccount } from '@plebbit/plebbit-react-hooks'; import { isValidURL } from '../../lib/utils/url-utils'; import useReply from '../../hooks/use-reply'; +import useWindowWidth from '../../hooks/use-window-width'; import styles from './reply-modal.module.css'; import _ from 'lodash'; @@ -48,31 +49,63 @@ const ReplyModal = ({ closeModal, parentCid }: ReplyModalProps) => { } }, [replyIndex, resetContent, closeModal]); - // react-draggable requires a ref to the modal node - const nodeRef = useRef(null); + const nodeRef = useRef(null); + const isMobile = useWindowWidth() < 640; - return ( - -
-
- Reply to c/{parentCid && Plebbit.getShortCid(parentCid)} -
-
-
- -
-
- setContent.link(e.target.value)} /> -
-
-