-
Notifications
You must be signed in to change notification settings - Fork 21
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
Guillermo Alejandro Gallardo Diez
authored and
Guillermo Alejandro Gallardo Diez
committed
Jan 4, 2025
1 parent
7d5e9b3
commit 41f2523
Showing
5 changed files
with
49 additions
and
38 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
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 |
---|---|---|
@@ -1,23 +1,33 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
function Message({ sender, premium, text }) { | ||
|
||
const [show, setShow] = useState(''); | ||
|
||
useEffect(() => { | ||
setTimeout(() => setShow('show'), 100); | ||
}, []); | ||
|
||
return ( | ||
<div className={`card ${show} mb-3 ${premium ? "border-primary" : ""}`}> | ||
<div className="card-body"> | ||
<h5 className="card-title"> | ||
<strong>{sender}</strong> | ||
{premium && ( | ||
<span className="badge bg-primary ms-2">Premium</span> | ||
)} | ||
</h5> | ||
<p className="card-text">{text}</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function Messages({ messages }) { | ||
return ( | ||
<div className="container"> | ||
<div className="container fade-animation"> | ||
<h2 className="my-4">Messages</h2> | ||
{messages.map((message, i) => ( | ||
<div | ||
key={i} | ||
className={`card mb-3 ${message.premium ? "border-primary" : ""}`} | ||
> | ||
<div className="card-body"> | ||
<h5 className="card-title"> | ||
<strong>{message.sender}</strong> | ||
{message.premium && ( | ||
<span className="badge bg-primary ms-2">Premium</span> | ||
)} | ||
</h5> | ||
<p className="card-text">{message.text}</p> | ||
</div> | ||
</div> | ||
))} | ||
{messages.map((message, i) => <Message key={`${message.sender}-${message.text}`} {...message} />)} | ||
</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
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