Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: shoutbox autoscroll to bottom. #66

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions components/ShoutBox/nameformatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@ const NameFormatter = ({ name, timestamp, telegram }: NameFormatterProps) => {
className={`flex items-center pr-2 text-sm font-bold ${findStyle(name)}`}
>
{name}
{telegram ? <div className="relative ml-2 w-3.5 h-3.5"><a target="_blank" rel="noreferrer" href="https://t.me/turunwappuradio"><Image layout="fill"
unoptimized={true} alt="Telegram" src="/telegram.svg"></Image></a></div> : null}
{
time ? (
<span className="pl-2 text-xs font-normal opacity-70" > {time}</span>
) : null
}
</div >
{telegram ? (
<div className="relative ml-2 h-3.5 w-3.5">
<a
target="_blank"
rel="noreferrer"
href="https://t.me/turunwappuradio"
>
<Image
layout="fill"
unoptimized={true}
alt="Telegram"
src="/telegram.svg"
></Image>
</a>
</div>
) : null}
{time ? (
<span className="pl-2 text-xs font-normal opacity-70"> {time}</span>
) : null}
</div>
);
};

Expand Down
6 changes: 3 additions & 3 deletions components/ShoutBox/shoutbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ChatWrapper = () => {
<button
onClick={handleClose}
title="chat"
className="bg-orange mr-5 mt-5 h-10 w-10 rounded-full"
className="mr-5 mt-5 h-10 w-10 rounded-full bg-orange"
>
<GrFormClose size="1.7rem" className="mx-auto" />
</button>
Expand Down Expand Up @@ -106,7 +106,7 @@ const Chat = ({ limit, isOpen }: ShoutBoxProps) => {
}, []);

function addMessage(message: any) {
setMessages((messages) => [...messages, message].slice(-limit));
setMessages((messages) => [message, ...messages].slice(0, limit));
}

function submitMessage(messageString: string) {
Expand Down Expand Up @@ -146,7 +146,7 @@ const Chat = ({ limit, isOpen }: ShoutBoxProps) => {
<div className="mx-auto flex h-96 w-full max-w-6xl px-[25px] py-6 md:h-[38rem]">
<div className="mx-auto my-0 h-auto w-full flex-wrap overflow-auto overflow-x-hidden shadow-md">
<div
className="h-[81%] flex-col-reverse overflow-auto overflow-x-hidden px-0 py-2 text-white md:h-[85%]"
className="flex h-[81%] flex-col-reverse overflow-y-auto overflow-x-hidden px-0 py-2 text-white md:h-[85%]"
ref={messagesViewport}
>
{messages.map((message, index) => (
Expand Down
Loading