-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ramin Rezaei
committed
May 28, 2024
1 parent
24899dc
commit 9f9876e
Showing
4 changed files
with
70 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { animator } from "shared/utils/animator"; | ||
import { classnames } from "shared/utils/classnames"; | ||
|
||
interface CounterChatItemProps { | ||
text: string; | ||
created: string; | ||
isLeft: boolean; | ||
} | ||
|
||
export function CounterChatItem({ text, created, isLeft }: CounterChatItemProps) { | ||
return ( | ||
<div className={classnames( | ||
'w-full flex items-center', | ||
{ | ||
'justify-end': isLeft, | ||
'justify-start': !isLeft | ||
} | ||
)}> | ||
<div className={classnames( | ||
'relative max-w-full py-2 px-3 text-sm overflow-hidden', | ||
{ | ||
'dark:bg-slate-700 bg-slate-200 rounded-r-xl rounded-tl-xl': isLeft, | ||
'dark:bg-slate-500 bg-slate-300 rounded-l-xl rounded-tr-xl': !isLeft | ||
}, | ||
animator({ name: isLeft ? "bounceInLeft" : "bounceInRight" }) | ||
)} | ||
> | ||
<p className="whitespace-pre-line text-right leading-6">{text}</p> | ||
<span dir="ltr" className="text-xs mt-1 opacity-40">{created}</span> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useSelector } from "react-redux"; | ||
import { useEffect, useState } from "react"; | ||
import { animator } from "../../shared/utils/animator"; | ||
import { classnames } from "../../shared/utils/classnames"; | ||
import { appSelectors } from "../../shared/redux/app/app-selectors"; | ||
import { calculateTimeDifference } from "../../shared/utils/calculate-time-difference"; | ||
|
||
export function CounterHeader({ length = 0 }) { | ||
const [time, setTime] = useState<string>('Loading ...'); | ||
const { startDate, startTime } = useSelector(appSelectors.appData); | ||
|
||
useEffect(() => { | ||
const intervalId = (startDate && startTime) ? setInterval(() => { | ||
setTime(calculateTimeDifference(startDate, startTime)); | ||
}, 1000) : undefined; | ||
return () => clearInterval(intervalId); | ||
}, [startDate, startTime]); | ||
|
||
return ( | ||
<header className={classnames( | ||
"top-0 z-20 fixed w-full flex flex-col items-center justify-center shadow-md p-5 bg-white/20 dark:bg-black/20 backdrop-blur-sm", | ||
animator({ name: 'fadeInDown' }) | ||
)}> | ||
<h1 className="tas-font text-2xl mt-4">The Memories 🩵</h1> | ||
<h3 className="text-s mt-1">{`You have ${length} memories now.`}</h3> | ||
<h3 className="text-app-color text-sm leading-8 mt-1">{time}</h3> | ||
</header> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters