Skip to content

Commit

Permalink
Merge pull request #66 from TurunWappuradio/fix/shoutbox-autoscroll
Browse files Browse the repository at this point in the history
fix: shoutbox autoscroll to bottom.
  • Loading branch information
kovipu authored Oct 25, 2023
2 parents d822137 + 038ef4a commit 2b93a3f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
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

0 comments on commit 2b93a3f

Please sign in to comment.