Add style for mentioning (#137)

This commit is contained in:
Maria Rushkova 2021-11-29 09:04:18 +01:00 committed by GitHub
parent 30984cdc05
commit 0742fa3635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 12 deletions

View File

@ -20,6 +20,7 @@ import { StickerIcon } from "../Icons/StickerIcon";
import "emoji-mart/css/emoji-mart.css"; import "emoji-mart/css/emoji-mart.css";
import { SizeLimitModal, SizeLimitModalName } from "../Modals/SizeLimitModal"; import { SizeLimitModal, SizeLimitModalName } from "../Modals/SizeLimitModal";
import { SearchBlock } from "../SearchBlock"; import { SearchBlock } from "../SearchBlock";
import { textMediumStyles } from "../Text";
export function ChatInput() { export function ChatInput() {
const { sendMessage } = useMessengerContext(); const { sendMessage } = useMessengerContext();
@ -158,7 +159,7 @@ export function ChatInput() {
const secondSlice = text.slice(end > -1 ? end : content.length); const secondSlice = text.slice(end > -1 ? end : content.length);
const replaceContent = `${firstSlice} @${contact}${secondSlice}`; const replaceContent = `${firstSlice} @${contact}${secondSlice}`;
const spaceElement = document.createTextNode(" "); const spaceElement = document.createTextNode(" ");
const contactElement = document.createElement("b"); const contactElement = document.createElement("span");
contactElement.innerText = `@${contact}`; contactElement.innerText = `@${contact}`;
if (contactElement && element.rangeCount > 0) { if (contactElement && element.rangeCount > 0) {
@ -338,11 +339,11 @@ const Input = styled.div`
color: ${({ theme }) => theme.primary}; color: ${({ theme }) => theme.primary};
border-radius: 16px 16px 4px 16px; border-radius: 16px 16px 4px 16px;
outline: none; outline: none;
font-family: Inter; font-family: "Inter";
font-style: normal; font-style: normal;
font-weight: normal; font-weight: normal;
font-size: 15px;
line-height: 22px; ${textMediumStyles};
&:focus { &:focus {
outline: none; outline: none;
@ -352,6 +353,21 @@ const Input = styled.div`
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 0; width: 0;
} }
& > span {
display: inline-block;
color: ${({ theme }) => theme.mentionColor};
background: ${({ theme }) => theme.mentionBg};
border-radius: 4px;
font-weight: 500;
position: relative;
padding: 0 2px;
cursor: pointer;
&:hover {
background: ${({ theme }) => theme.mentionBgHover};
}
}
`; `;
const AddPictureInputWrapper = styled.div` const AddPictureInputWrapper = styled.div`

View File

@ -8,6 +8,7 @@ import { ChatMessage } from "../../models/ChatMessage";
import { Metadata } from "../../models/Metadata"; import { Metadata } from "../../models/Metadata";
import { ContactMenu } from "../Form/ContactMenu"; import { ContactMenu } from "../Form/ContactMenu";
import { ImageMenu } from "../Form/ImageMenu"; import { ImageMenu } from "../Form/ImageMenu";
import { textMediumStyles, textSmallStyles } from "../Text";
interface MentionProps { interface MentionProps {
id: string; id: string;
@ -19,10 +20,10 @@ function Mention({ id }: MentionProps) {
const [showMenu, setShowMenu] = useState(false); const [showMenu, setShowMenu] = useState(false);
if (!contact) return <>{id}</>; if (!contact) return <>{id}</>;
return ( return (
<MentionSpan onClick={() => setShowMenu(!showMenu)}> <MentionBLock onClick={() => setShowMenu(!showMenu)}>
{`@${contact.customName ?? contact.id}`} {`@${contact.customName ?? contact.id}`}
{showMenu && <ContactMenu id={id.slice(1)} setShowMenu={setShowMenu} />} {showMenu && <ContactMenu id={id.slice(1)} setShowMenu={setShowMenu} />}
</MentionSpan> </MentionBLock>
); );
} }
@ -147,10 +148,10 @@ const PreviewTitleWrapper = styled.div`
font-family: Inter; font-family: Inter;
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
font-size: 13px;
width: 290px; width: 290px;
line-height: 18px;
margin-left: 12px; margin-left: 12px;
${textSmallStyles}
`; `;
const PreviewImage = styled.img` const PreviewImage = styled.img`
@ -177,10 +178,21 @@ const ContentWrapper = styled.div`
flex-direction: column; flex-direction: column;
`; `;
const MentionSpan = styled.span` const MentionBLock = styled.div`
color: blue; display: inline-block;
color: ${({ theme }) => theme.mentionColor};
background: ${({ theme }) => theme.mentionBg};
border-radius: 4px;
font-weight: 500; font-weight: 500;
position: relative; position: relative;
padding: 0 2px;
cursor: pointer;
&:hover {
background: ${({ theme }) => theme.mentionBgHover};
}
${textMediumStyles}
`; `;
const Link = styled.a` const Link = styled.a`

View File

@ -178,7 +178,7 @@ const DateSeparator = styled.div`
text-align: center; text-align: center;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-family: Inter; font-family: "Inter";
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
color: #939ba1; color: #939ba1;

View File

@ -107,7 +107,6 @@ const Input = styled.input`
const Button = styled.button` const Button = styled.button`
padding: 5px; padding: 5px;
margin: 5px; margin: 5px;
box-shadow: 5px 5px 10px -4px rgba(197, 197, 255, 1); box-shadow: 5px 5px 10px -4px rgba(197, 197, 255, 1);
border-radius: 5px; border-radius: 5px;
background-color: ${({ theme }) => theme.buttonBg}; background-color: ${({ theme }) => theme.buttonBg};

View File

@ -19,6 +19,9 @@ export type Theme = {
skeletonLight: string; skeletonLight: string;
skeletonDark: string; skeletonDark: string;
redColor: string; redColor: string;
mentionColor: string;
mentionBg: string;
mentionBgHover: string;
}; };
export const lightTheme: Theme = { export const lightTheme: Theme = {
@ -42,6 +45,9 @@ export const lightTheme: Theme = {
skeletonLight: "#F6F8FA", skeletonLight: "#F6F8FA",
skeletonDark: "#E9EDF1", skeletonDark: "#E9EDF1",
redColor: "#FF2D55", redColor: "#FF2D55",
mentionColor: "#0DA4C9",
mentionBg: "#E5F8FD",
mentionBgHover: "#BDE7F2",
}; };
export const darkTheme: Theme = { export const darkTheme: Theme = {
@ -65,6 +71,9 @@ export const darkTheme: Theme = {
skeletonLight: "#2E2F31", skeletonLight: "#2E2F31",
skeletonDark: "#141414", skeletonDark: "#141414",
redColor: "#FF5C7B", redColor: "#FF5C7B",
mentionColor: "#0DA4C9",
mentionBg: "#E5F8FD",
mentionBgHover: "#BDE7F2",
}; };
export default { lightTheme, darkTheme }; export default { lightTheme, darkTheme };