fix(challenge modal): disable draggable on mobile

This commit is contained in:
plebeius.eth
2024-04-29 15:30:40 +02:00
parent 5a45e27841
commit 9c2036a6a1
2 changed files with 68 additions and 54 deletions
@@ -78,3 +78,9 @@
filter: var(--filter80); filter: var(--filter80);
text-transform: capitalize; text-transform: capitalize;
} }
@media (max-width: 640px) {
.title {
cursor: default;
}
}
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Challenge as ChallengeType } from '@plebbit/plebbit-react-hooks'; import { Challenge as ChallengeType } from '@plebbit/plebbit-react-hooks';
import { getPublicationType } from '../../lib/utils/challenge-utils'; import { getPublicationType } from '../../lib/utils/challenge-utils';
import useChallenges from '../../hooks/use-challenges'; import useChallenges from '../../hooks/use-challenges';
import useWindowWidth from '../../hooks/use-window-width';
import styles from './challenge-modal.module.css'; import styles from './challenge-modal.module.css';
import _ from 'lodash'; import _ from 'lodash';
@@ -53,9 +54,9 @@ const Challenge = ({ challenge, closeModal }: ChallengeProps) => {
// react-draggable requires a ref to the modal node // react-draggable requires a ref to the modal node
const nodeRef = useRef(null); const nodeRef = useRef(null);
const isMobile = useWindowWidth() < 640;
return ( const modalContent = (
<Draggable handle='.challengeHandle' nodeRef={nodeRef}>
<div className={styles.container} ref={nodeRef}> <div className={styles.container} ref={nodeRef}>
<div className={`challengeHandle ${styles.title}`}> <div className={`challengeHandle ${styles.title}`}>
Challenge for {publicationType} Challenge for {publicationType}
@@ -114,6 +115,13 @@ const Challenge = ({ challenge, closeModal }: ChallengeProps) => {
</div> </div>
</div> </div>
</div> </div>
);
return isMobile ? (
modalContent
) : (
<Draggable handle='.challengeHandle' nodeRef={nodeRef}>
{modalContent}
</Draggable> </Draggable>
); );
}; };