From 8160c31b392cb1da4a13f3c1bc9ebc4fe78cad5d Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Tue, 31 Jan 2023 07:55:37 +0800 Subject: [PATCH] feat: session list responsive --- src/assets/icons/list.svg | 3 ++ src/common/component/Message/styled.tsx | 1 + src/common/component/MixedInput/index.tsx | 51 ++++++++++----------- src/common/component/MixedInput/styled.ts | 20 -------- src/common/component/Send/Toolbar.tsx | 56 +++++------------------ src/routes/404/index.tsx | 3 +- src/routes/404/styled.tsx | 7 --- src/routes/callback/index.tsx | 9 +++- src/routes/callback/styled.tsx | 10 ---- src/routes/chat/Layout/index.tsx | 4 +- src/routes/chat/index.tsx | 13 +++++- src/routes/chat/styled.tsx | 9 ++-- src/routes/chat/utils.tsx | 41 ++--------------- 13 files changed, 70 insertions(+), 157 deletions(-) create mode 100644 src/assets/icons/list.svg delete mode 100644 src/common/component/MixedInput/styled.ts delete mode 100644 src/routes/404/styled.tsx delete mode 100644 src/routes/callback/styled.tsx diff --git a/src/assets/icons/list.svg b/src/assets/icons/list.svg new file mode 100644 index 00000000..e08df59b --- /dev/null +++ b/src/assets/icons/list.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/common/component/Message/styled.tsx b/src/common/component/Message/styled.tsx index f053d1e4..30e09e31 100644 --- a/src/common/component/Message/styled.tsx +++ b/src/common/component/Message/styled.tsx @@ -1,6 +1,7 @@ import styled from "styled-components"; const StyledMsg = styled.div` +width: 100%; position: relative; display: flex; align-items: flex-start; diff --git a/src/common/component/MixedInput/index.tsx b/src/common/component/MixedInput/index.tsx index c33c3c98..d8305622 100644 --- a/src/common/component/MixedInput/index.tsx +++ b/src/common/component/MixedInput/index.tsx @@ -19,7 +19,6 @@ import { import { createComboboxPlugin } from "@udecode/plate-combobox"; import { ReactEditor } from "slate-react"; import useUploadFile from "../../hook/useUploadFile"; -import Styled from "./styled"; import { CONFIG } from "./config"; import User from "../User"; import { useAppSelector } from "../../../app/store"; @@ -56,12 +55,12 @@ const Plugins: FC = ({ const editableRef = useRef(null); const initialProps = { ...CONFIG.editableProps, - className: "box", + className: "flex flex-col gap-2", placeholder }; const plateEditor = getPlateEditorRef(`${TEXT_EDITOR_PREFIX}_${id}`); useEffect(() => { - const handlePasteEvent = (evt: ClipboardEvent) => { + const handlePasteEvent = (evt: ClipboardEvent) => { const files = [...evt.clipboardData.files]; if (files.length) { const filesData = files.map((file) => { @@ -80,7 +79,6 @@ const Plugins: FC = ({ // updateDraft(plateEditor.children); // } }; - // window.addEventListener("paste") }, [id, updateDraft]); useKey( @@ -117,21 +115,21 @@ const Plugins: FC = ({ const plugins = createPlugins( enableMentions ? pluginArr.concat([ - createComboboxPlugin(), - createMentionPlugin({ - options: { - createMentionNode: (item) => { - // console.log("mention", item); - const { - text, - data: { uid } - } = item; - return { value: `@${text}`, uid }; - }, - insertSpaceAfterMention: true - } - }) - ]) + createComboboxPlugin(), + createMentionPlugin({ + options: { + createMentionNode: (item) => { + // console.log("mention", item); + const { + text, + data: { uid } + } = item; + return { value: `@${text}`, uid }; + }, + insertSpaceAfterMention: true + } + }) + ]) : pluginArr, { components @@ -174,12 +172,12 @@ const Plugins: FC = ({ const arr = tmps.map((tmp) => { return Array.isArray(tmp) ? { - type: "text", - content: tmp.map((t) => t.content).join("\n"), - properties: { - mentions: tmp.map((t) => t.properties?.mentions || []).flat() - } + type: "text", + content: tmp.map((t) => t.content).join("\n"), + properties: { + mentions: tmp.map((t) => t.properties?.mentions || []).flat() } + } : tmp; }); const msgs = arr.filter(({ content }) => !!content); @@ -188,8 +186,9 @@ const Plugins: FC = ({ [msgs] ); + return ( - +
= ({ /> ) : null} - +
); }; diff --git a/src/common/component/MixedInput/styled.ts b/src/common/component/MixedInput/styled.ts deleted file mode 100644 index 2ec298b7..00000000 --- a/src/common/component/MixedInput/styled.ts +++ /dev/null @@ -1,20 +0,0 @@ -import styled from "styled-components"; - -const Styled = styled.div` - max-height: 50vh; - overflow: auto; - font-weight: 400; - font-size: 14px; - line-height: 22px; - color: #475467; - > .box { - display: flex; - flex-direction: column; - gap: 16px; - p { - padding: 0; - } - } -`; - -export default Styled; diff --git a/src/common/component/Send/Toolbar.tsx b/src/common/component/Send/Toolbar.tsx index f958eff6..68292582 100644 --- a/src/common/component/Send/Toolbar.tsx +++ b/src/common/component/Send/Toolbar.tsx @@ -1,5 +1,4 @@ import { ChangeEvent, useRef, FC } from "react"; -import styled from "styled-components"; import Tooltip from "../Tooltip"; import AddIcon from "../../../assets/icons/add.solid.svg"; import MarkdownIcon from "../../../assets/icons/markdown.svg"; @@ -8,41 +7,6 @@ import ExitFullscreenIcon from "../../../assets/icons/fullscreen.exit.svg"; import useUploadFile from "../../hook/useUploadFile"; import { useTranslation } from "react-i18next"; -const Styled = styled.div` - display: flex; - align-items: center; - justify-content: flex-end; - gap: 10px; - &.markdown .add { - display: none; - } - .md { - cursor: pointer; - display: flex; - gap: 14px; - .markdown path { - fill: #22ccee; - } - } - .add { - cursor: pointer; - position: relative; - width: 24px; - height: 24px; - label { - opacity: 0; - cursor: pointer; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - input { - display: none; - } - } - } -`; type Props = { toggleMarkdownFullscreen: () => void; fullscreen: boolean; @@ -79,13 +43,14 @@ const Toolbar: FC = ({ // setFiles([...evt.target.files]); }; + const isMarkdown = mode == 'markdown'; return ( - -
+
+
- + - {mode == "markdown" && + {isMarkdown && (fullscreen ? ( @@ -96,11 +61,12 @@ const Toolbar: FC = ({ ))}
- -
+ {!isMarkdown && +
-
-
- + } +
); }; export default Toolbar; diff --git a/src/routes/404/index.tsx b/src/routes/404/index.tsx index d409e09a..a8711bab 100644 --- a/src/routes/404/index.tsx +++ b/src/routes/404/index.tsx @@ -1,5 +1,4 @@ -import StyledWrapper from "./styled"; export default function NotFoundPage() { - return 404 page; + return
404 page
; } diff --git a/src/routes/404/styled.tsx b/src/routes/404/styled.tsx deleted file mode 100644 index 36b3ee08..00000000 --- a/src/routes/404/styled.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import styled from "styled-components"; - -const StyledWrapper = styled.div` - display: flex; -`; - -export default StyledWrapper; diff --git a/src/routes/callback/index.tsx b/src/routes/callback/index.tsx index 855ff383..bffa95af 100644 --- a/src/routes/callback/index.tsx +++ b/src/routes/callback/index.tsx @@ -1,7 +1,14 @@ +import { DOMAttributes, ReactNode } from "react"; import { useParams } from "react-router-dom"; import PaymentSuccess from "./PaymentSuccess"; import GithubCallback, { GithubLoginSource } from "./GithubCallback"; -import StyledWrapper from "./styled"; + +const StyledWrapper = ({ children }: DOMAttributes & { children?: ReactNode }) => { + + return
+ {children} +
; +}; // type Props = { // type: "payment_success"; // }; diff --git a/src/routes/callback/styled.tsx b/src/routes/callback/styled.tsx deleted file mode 100644 index 0faea57e..00000000 --- a/src/routes/callback/styled.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { DOMAttributes, ReactNode } from "react"; - -const StyledWrapper = ({ children }: DOMAttributes & { children?: ReactNode }) => { - - return
- {children} -
; -}; - -export default StyledWrapper; diff --git a/src/routes/chat/Layout/index.tsx b/src/routes/chat/Layout/index.tsx index 3c028c27..32f6cbd3 100644 --- a/src/routes/chat/Layout/index.tsx +++ b/src/routes/chat/Layout/index.tsx @@ -123,8 +123,8 @@ const Layout: FC = ({ {selects && }
- {users &&
{users}
} - {aside &&
{aside}
} + {users &&
{users}
} + {aside &&
{aside}
} {!readonly && isActive && ( diff --git a/src/routes/chat/index.tsx b/src/routes/chat/index.tsx index bedb53b3..77ffe49d 100644 --- a/src/routes/chat/index.tsx +++ b/src/routes/chat/index.tsx @@ -1,5 +1,6 @@ import { memo, useState } from "react"; import { useParams } from "react-router-dom"; +import clsx from "clsx"; import StyledWrapper from "./styled"; import BlankPlaceholder from "../../common/component/BlankPlaceholder"; import Server from "../../common/component/Server"; @@ -12,7 +13,9 @@ import { useAppSelector } from "../../app/store"; import GuestBlankPlaceholder from "./GuestBlankPlaceholder"; import GuestChannelChat from "./GuestChannelChat"; import GuestSessionList from "./GuestSessionList"; +import IconList from '../../assets/icons/list.svg'; function ChatPage() { + const [sessionListVisible, setSessionListVisible] = useState(false); const [channelModalVisible, setChannelModalVisible] = useState(false); const [usersModalVisible, setUsersModalVisible] = useState(false); const { channel_id = 0, user_id = 0 } = useParams(); @@ -28,6 +31,9 @@ function ChatPage() { const toggleChannelModalVisible = () => { setChannelModalVisible((prev) => !prev); }; + const toggleSessionList = () => { + setSessionListVisible(prev => !prev); + }; const tmpSession = sessionUids.findIndex((i) => i == user_id) > -1 ? undefined @@ -45,10 +51,13 @@ function ChatPage() { )} {usersModalVisible && } - -
+ +
{isGuest ? : } +
{placeholderVisible && (isGuest ? : )} diff --git a/src/routes/chat/styled.tsx b/src/routes/chat/styled.tsx index 12f1511c..3d116a7f 100644 --- a/src/routes/chat/styled.tsx +++ b/src/routes/chat/styled.tsx @@ -2,10 +2,9 @@ import styled from "styled-components"; const StyledWrapper = styled.div` display: flex; height: 100%; - padding: 8px 48px 10px 0; - &.guest { - padding-right: 0; - } + padding-top: 8px; + padding-bottom: 10px; + padding-right: 4px; > .left { background-color: #fff; position: relative; @@ -14,7 +13,7 @@ const StyledWrapper = styled.div` min-width: 268px; box-shadow: inset -1px 0px 0px rgba(0, 0, 0, 0.05); height: 100%; - overflow: auto; + /* overflow: auto; */ border-radius: 16px 0 0 16px; .list { margin: 12px 8px; diff --git a/src/routes/chat/utils.tsx b/src/routes/chat/utils.tsx index f1dbd84f..f854dedf 100644 --- a/src/routes/chat/utils.tsx +++ b/src/routes/chat/utils.tsx @@ -1,6 +1,5 @@ import React from "react"; import dayjs from "dayjs"; -import styled from "styled-components"; import { useDispatch } from "react-redux"; import { isImage } from "../../common/utils"; import { ContentTypes } from "../../app/config"; @@ -86,38 +85,6 @@ export const renderPreviewMessage = (message = null) => { } return res; }; -const StyledWrapper = styled.div` - position: relative; - width: 100%; - display: flex; - align-items: flex-start; - gap: 8px; - > .overlay { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - cursor: pointer; - } - > .check { - display: none; - margin-top: 18px; - margin-left: 8px; - } - > .message { - flex: 1; - } - &.select { - &:hover { - border-radius: var(--br); - background: #f5f6f7; - } - > .check { - display: block; - } - } -`; const MessageWrapper = ({ selectMode = false, context, id, mid, children, ...rest }) => { const dispatch = useDispatch(); @@ -129,13 +96,13 @@ const MessageWrapper = ({ selectMode = false, context, id, mid, children, ...res dispatch(updateSelectMessages({ context, id, operation, data: mid })); }; return ( - - +
+ {selectMode && } {children} {selectMode && ( -
+
)} - +
); }; type Params = {