From 147d3720efd3d1c98c35c595d10e4698c8a19b7e Mon Sep 17 00:00:00 2001 From: hfdem Date: Tue, 13 Aug 2024 05:37:01 +0800 Subject: [PATCH] style: fix Copied button misalignment on mobile browsers --- .../components/LinkDisplay/Style.module.css | 80 +++++++++++-------- client/src/components/LinkDisplay/index.tsx | 25 +++--- 2 files changed, 60 insertions(+), 45 deletions(-) diff --git a/client/src/components/LinkDisplay/Style.module.css b/client/src/components/LinkDisplay/Style.module.css index dfbe6f29..247bfcc0 100644 --- a/client/src/components/LinkDisplay/Style.module.css +++ b/client/src/components/LinkDisplay/Style.module.css @@ -41,7 +41,7 @@ border-width: 1px; font-family: inherit; font-size: 18px; - width: 100px; + width: 50px; height: 40px; border-radius: 5px; cursor: pointer; @@ -64,6 +64,7 @@ .copyIcon { font-size: '15px'; + transform: translateY(2px); } .textAreaContainer { @@ -121,47 +122,17 @@ color: #aeaeae; } -@media screen and (min-width: 640px) { - .fullWidth { - display: flex; - flex-flow: wrap; - } - .fullWidth > div { - flex: 1 auto; - } - .pinDisplay { - margin: 0; - } - .pinDisplayMsg { - width: 100%; - font-size: 18px; - padding-bottom: 20px; - } - - .openLink { - width: 100%; - flex: 1 auto; - } - - .divider { - margin: 30px 0; - border-top: 1px solid #434343; - width: 100%; - } -} - .qrCodeContainer { margin-top: 20px; display: flex; justify-content: center; } - .qrButton { border-width: 1px; font-family: inherit; font-size: 18px; - width: 110px; + width: 50px; height: 40px; border-radius: 5px; cursor: pointer; @@ -170,6 +141,7 @@ background: #4bb2f9; color: white; margin-left: 5px; + transform: translateY(2px); } .qrButton:hover { @@ -185,5 +157,47 @@ .qrIcon { display: inline-block; margin-top: 0; - transform: translateY(2px); + transform: none; +} + +@media screen and (min-width: 640px) { + .fullWidth { + display: flex; + flex-flow: wrap; + } + .fullWidth > div { + flex: 1 auto; + } + .pinDisplay { + margin: 0; + } + .pinDisplayMsg { + width: 100%; + font-size: 18px; + padding-bottom: 20px; + } + + .openLink { + width: 100%; + flex: 1 auto; + } + + .divider { + margin: 30px 0; + border-top: 1px solid #434343; + width: 100%; + } + + .copyButton { + width: 100px; + } + + .qrButton { + width: 100px; + transform: none; + } + + .qrIcon { + transform: translateY(2px); + } } diff --git a/client/src/components/LinkDisplay/index.tsx b/client/src/components/LinkDisplay/index.tsx index 33fee4de..1f51d229 100644 --- a/client/src/components/LinkDisplay/index.tsx +++ b/client/src/components/LinkDisplay/index.tsx @@ -1,9 +1,11 @@ -import React, { useRef, useState, useContext } from "react"; -import { FiLink, FiCopy, FiExternalLink, FiArrowDown, FiArrowUp } from "react-icons/fi"; +import React, { useRef, useState, useContext, useEffect } from "react"; +import { FiLink, FiCopy, FiExternalLink } from "react-icons/fi"; +import { MdOutlineQrCode } from "react-icons/md"; import styles from "./Style.module.css"; import { ThemeContext } from "../../ThemeContext"; import { LinkObjType } from "@chat-e2ee/service"; import QRCode from "qrcode.react"; +import detectMobile from "../../utils/detectMobile"; const LinkDisplay: React.FC<{ content: LinkObjType }> = ({ content }) => { const chatLink = @@ -13,6 +15,11 @@ const LinkDisplay: React.FC<{ content: LinkObjType }> = ({ content }) => { const [buttonText, setButtonText] = useState("Copy"); const [showQR, setShowQR] = useState(false); const [darkMode] = useContext(ThemeContext); + const [isMobile, setIsMobile] = useState(false); + + useEffect(() => { + setIsMobile(detectMobile()); + }, []); const copyCodeToClipboard = () => { if (textAreaRef.current !== null) textAreaRef.current.select(); @@ -50,22 +57,16 @@ const LinkDisplay: React.FC<{ content: LinkObjType }> = ({ content }) => { ${!darkMode && styles.lightModeButton}`} onClick={copyCodeToClipboard} > - {buttonText} + {!isMobile && buttonText}