-
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.
Showing
8 changed files
with
72 additions
and
9 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"react/no-unescaped-entities": "off" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
'use client' | ||
|
||
import Message from '@/components/message' | ||
|
||
const now = Date.now() | ||
const MOCK_MESSAGES = [ | ||
{ sentAt: now - 1000 * 60 * 30, content: `...` }, | ||
{ sentAt: now - 1000 * 60 * 10, content: `Hello, i\'m a message! 😎` }, | ||
{ | ||
sentAt: now, | ||
content: | ||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Id, porro', | ||
}, | ||
] | ||
|
||
export default function Home() { | ||
return ( | ||
<main className="flex flex-col gap-3 p-3"> | ||
{MOCK_MESSAGES.map(({ sentAt, content }, i) => ( | ||
<Message key={i} sentAt={sentAt}> | ||
{content} | ||
</Message> | ||
))} | ||
</main> | ||
) | ||
} |
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,25 @@ | ||
import { timeFormatter } from '@/utils/getFormattedDate' | ||
import Image from 'next/image' | ||
import Link from 'next/link' | ||
|
||
export default function Message({ sentAt, children }) { | ||
const { format: formatTime } = timeFormatter() | ||
|
||
return ( | ||
<div className="flex items-end gap-2"> | ||
<Link className="rounded-full overflow-hidden" href="/"> | ||
<Image | ||
className="object-center object-cover" | ||
src="/icons/avatar.svg" | ||
width={38} | ||
height={38} | ||
alt="Picture of the author" | ||
/> | ||
</Link> | ||
<div className="flex justify-between gap-2 rounded-lg rounded-bl-none w-fit max-w-md py-2 px-3 bg-orange-100"> | ||
<p className="break-words">{children}</p> | ||
<span className="text-xs self-end">{formatTime(sentAt)}</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,7 @@ | ||
export const timeFormatter = (options) => | ||
new Intl.DateTimeFormat('en', { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
hour12: false, | ||
...options, | ||
}) |