chore: updates

This commit is contained in:
zerosoul
2022-02-21 22:29:52 +08:00
parent 656df7c670
commit d712d6b042
9 changed files with 128 additions and 41 deletions
+41 -13
View File
@@ -1,12 +1,10 @@
import { useEffect } from "react";
import styled from "styled-components";
import { AiOutlineCaretDown, AiOutlineSound } from "react-icons/ai";
import { MdOutlineKeyboardVoice } from "react-icons/md";
import { useSelector, useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import { clearAuthData } from "../../app/slices/auth.data";
import BASE_URL from "../../app/config";
// import BASE_URL from "../../app/config";
import { useLazyLogoutQuery } from "../../app/services/auth";
import Avatar from "./Avatar";
const StyledWrapper = styled.div`
@@ -14,8 +12,10 @@ const StyledWrapper = styled.div`
position: absolute;
bottom: 0;
left: 0;
padding: 16px 12px;
width: 100%;
margin: 8px;
width: -webkit-fill-available;
border-radius: 25px;
padding: 7px 8px 7px 4px;
display: flex;
align-items: center;
justify-content: space-between;
@@ -26,12 +26,28 @@ const StyledWrapper = styled.div`
justify-content: space-between;
gap: 5px;
.avatar {
width: 24px;
height: 24px;
width: 32px;
height: 32px;
border-radius: 50%;
}
.toggle {
}
.info {
display: flex;
flex-direction: column;
.name {
font-weight: bold;
font-size: 14px;
line-height: 20px;
color: #27272a;
}
.id {
padding: 0 2px;
font-size: 12px;
line-height: 18px;
color: #52525b;
}
}
}
.settings {
gap: 20px;
@@ -40,6 +56,8 @@ const StyledWrapper = styled.div`
justify-content: space-between;
.icon {
cursor: pointer;
width: 24px;
height: 24px;
}
}
`;
@@ -59,24 +77,34 @@ export default function CurrentUser({ expand = true }) {
}, [isSuccess]);
if (!user) return null;
const { name, avatar } = user;
const { uid, name, avatar } = user;
return (
<StyledWrapper>
<div className="profile" title={name}>
<div className="profile">
<Avatar
onDoubleClick={handleLogout}
title={name}
url={avatar}
name={name}
alt="user avatar"
className="avatar"
/>
<AiOutlineCaretDown className="toggle" width={20} color="#C4C4C4" />
<div className="info">
<span className="name">{name}</span>
<span className="id">#{uid}</span>
</div>
</div>
{expand && (
<div className="settings">
<AiOutlineSound className="icon" size={15} color="#1C1C1E" />
<MdOutlineKeyboardVoice className="icon" size={15} color="#1C1C1E" />
<img
src="https://static.nicegoodthings.com/project/rustchat/icon.speaker.svg"
className="icon"
alt="mic icon"
/>
<img
src="https://static.nicegoodthings.com/project/rustchat/icon.mic.svg"
className="icon"
alt="sound icon"
/>
</div>
)}
</StyledWrapper>
+15 -5
View File
@@ -1,12 +1,12 @@
import { useEffect, useRef } from "react";
import dayjs from "dayjs";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { useInViewRef } from "rooks";
import Tippy from "@tippyjs/react";
import Linkify from "react-linkify";
import Profile from "../Profile";
import Avatar from "../Avatar";
import BASE_URL from "../../../app/config";
import { useGetContactsQuery } from "../../../app/services/contact";
import { setChannelMsgRead } from "../../../app/slices/message.channel";
import { setUserMsgRead } from "../../../app/slices/message.user";
import StyledWrapper from "./styled";
@@ -15,7 +15,17 @@ const renderContent = (type, content) => {
let ctn = null;
switch (type) {
case "text/plain":
ctn = content;
ctn = (
<Linkify
componentDecorator={(decoratedHref, decoratedText, key) => (
<a target="blank" href={decoratedHref} key={key}>
{decoratedText}
</a>
)}
>
{content}
</Linkify>
);
break;
case "image/jpeg":
ctn = (
@@ -45,7 +55,7 @@ export default function Message({
const [myRef, inView] = useInViewRef();
const disptach = useDispatch();
const avatarRef = useRef(null);
const { data: contacts } = useGetContactsQuery();
const contacts = useSelector((store) => store.contacts);
useEffect(() => {
if (!unread) {
avatarRef.current?.scrollIntoView();
@@ -72,7 +82,7 @@ export default function Message({
content={<Profile data={currUser} type="card" />}
>
<div className="avatar" data-uid={uid} ref={avatarRef}>
<Avatar url={currUser.avatar} id={fromUid} name={currUser.name} />
<Avatar url={currUser.avatar} name={currUser.name} />
</div>
</Tippy>
<div className="details">
+6
View File
@@ -56,6 +56,12 @@ const StyledMsg = styled.div`
.img {
max-width: 400px;
}
a {
border-radius: 2px;
background-color: #f5feff;
padding: 2px;
color: #1fe1f9;
}
}
}
`;