Add reply transition (#154)

This commit is contained in:
Szymon Szlachtowicz 2021-12-10 13:44:06 +01:00 committed by GitHub
parent 727197570b
commit c06c0253bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 4 deletions

View File

@ -1,4 +1,10 @@
import React, { useEffect, useMemo, useRef, useState } from "react";
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { utils } from "status-communities/dist/cjs";
import styled from "styled-components";
@ -44,9 +50,30 @@ type MessageQuoteProps = {
};
function MessageQuote({ quote }: MessageQuoteProps) {
const quoteClick = useCallback(() => {
if (quote) {
const quoteDiv = document.getElementById(quote.id);
if (quoteDiv) {
quoteDiv.scrollIntoView({
behavior: "smooth",
block: "center",
inline: "center",
});
quoteDiv.style.background = "lightblue";
quoteDiv.style.transition = "background-color 1000ms linear";
window.setTimeout(() => {
quoteDiv.style.background = "";
window.setTimeout(() => {
quoteDiv.style.transition = "";
}, 1000);
}, 1000);
}
}
}, [quote]);
if (quote) {
return (
<QuoteWrapper>
<QuoteWrapper onClick={quoteClick}>
<QuoteSvg width={22} height={calcHeight(quote)} />
<QuoteSender>
{" "}
@ -129,7 +156,7 @@ function ChatUiMessage({
: message.date.toLocaleDateString()}
</DateSeparator>
)}
<MessageWrapper className={`${mentioned && "mention"}`}>
<MessageWrapper className={`${mentioned && "mention"}`} id={message.id}>
<MessageQuote quote={quote} />
<UserMessageWrapper>
<Icon
@ -142,7 +169,6 @@ function ChatUiMessage({
)}
<UserIcon />
</Icon>
<ContentWrapper>
<MessageHeaderWrapper>
<UserNameWrapper>