-
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.
Feature: Footer prefetch 최적화, 채팅 기능 퍼블리싱 80% (#686)
* refactor: 일부 이미지 최적화 * feat: ChatList 퍼블리싱, formatDate 함수 모듈화 * refactor: 이미지 최적화, Footer의 페이지들 prefetch * refactor: 최적화 사항 베포를 위한 chat 퍼블리싱 주석
- Loading branch information
1 parent
7043a6e
commit df29fb3
Showing
24 changed files
with
977 additions
and
668 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
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
23 changes: 23 additions & 0 deletions
23
packages/web/src/app/[lng]/(main)/grouping/chatList/components/ChatCardList.tsx
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,23 @@ | ||
'use client'; | ||
|
||
import ChatCard from './ChatItem'; | ||
import { chatList } from './dummy'; | ||
|
||
import { useTranslation } from '@/app/i18n/client'; | ||
import { Empty } from '@/components/Empty'; | ||
import { ItemList } from '@/components/List'; | ||
|
||
export default function ChatCardList() { | ||
const { t } = useTranslation('grouping'); | ||
|
||
return ( | ||
<> | ||
<ItemList | ||
data={chatList} | ||
renderItem={(chat) => <ChatCard chatData={chat} />} | ||
renderEmpty={() => <Empty message={t('noGroup')} />} | ||
/> | ||
<div /> | ||
</> | ||
); | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/web/src/app/[lng]/(main)/grouping/chatList/components/ChatItem.tsx
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,64 @@ | ||
import { ko } from 'date-fns/locale'; | ||
import Image from 'next/image'; | ||
|
||
import { Chat } from './dummy'; | ||
|
||
import type { HTMLAttributes, PropsWithChildren } from 'react'; | ||
|
||
import ImageSample from '@/components/Image/ImageSample'; | ||
import { Flex } from '@/components/Layout'; | ||
import { NavLink } from '@/components/NavLink'; | ||
import { Spacing } from '@/components/Spacing'; | ||
import cn from '@/utils/cn'; | ||
import { formatDate } from '@/utils/formatDate'; | ||
|
||
interface ChatCardProps extends HTMLAttributes<HTMLDivElement> { | ||
chatData: Chat; | ||
} | ||
|
||
export default function ChatCard({ chatData, children }: PropsWithChildren<ChatCardProps>) { | ||
const { title, content, imageUrl, newMessag, groupId, latestMessageTiem } = chatData; | ||
|
||
return ( | ||
<Flex className="bg-white px-20 py-12" direction="column"> | ||
<NavLink href={`/grouping/detail/${groupId}?tab=detail`} className="flex items-center"> | ||
<section className="relative h-60 w-60 shrink-0"> | ||
{imageUrl ? ( | ||
<Image | ||
fill | ||
src={imageUrl} | ||
alt="group" | ||
className="rounded-8 object-cover" | ||
loading="lazy" | ||
sizes="32px" | ||
/> | ||
) : ( | ||
<ImageSample width={96} height={96} /> | ||
)} | ||
</section> | ||
|
||
<Spacing size={12} direction="horizontal" /> | ||
|
||
<section className="relative grow overflow-hidden "> | ||
<Flex justify="between" direction="row"> | ||
<Flex align="start" direction="column"> | ||
<p className="text-subtitle-2 grow truncate">{title}</p> | ||
<p className="text-paragraph-2 text-sign-tertiary truncate">{content}</p> | ||
</Flex> | ||
<Flex align="end" justify="between" direction="column"> | ||
<p className="text-paragraph-2 text-sign-caption truncate"> | ||
{formatDate(latestMessageTiem, ko)} | ||
</p> | ||
{newMessag && ( | ||
<div className="text-paragraph-2 text-sign-white flex h-20 w-20 items-center justify-center rounded-full bg-red-400"> | ||
{newMessag} | ||
</div> | ||
)} | ||
</Flex> | ||
</Flex> | ||
</section> | ||
</NavLink> | ||
{children} | ||
</Flex> | ||
); | ||
} |
11 changes: 6 additions & 5 deletions
11
packages/web/src/app/[lng]/(main)/grouping/chatList/components/ChatListHeader.tsx
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
44 changes: 44 additions & 0 deletions
44
packages/web/src/app/[lng]/(main)/grouping/chatList/components/dummy.ts
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,44 @@ | ||
export interface Chat { | ||
title: string; | ||
content: string; | ||
imageUrl: string; | ||
newMessag?: number; | ||
groupId: number; | ||
latestMessageTiem: string; | ||
} | ||
|
||
export const chatList: Chat[] = [ | ||
{ | ||
title: '응가 뿌직', | ||
content: '응가좀 치는사람 모이셈', | ||
newMessag: 2, | ||
imageUrl: '/images/approve_character.png', | ||
groupId: 10, | ||
latestMessageTiem: '2024-04-06T20:32', | ||
}, | ||
{ | ||
title: '응가 뿌직', | ||
content: '응가좀 치는사람 모이셈', | ||
newMessag: 1, | ||
imageUrl: '/images/approve_character.png', | ||
groupId: 10, | ||
latestMessageTiem: '2024-04-10T18:44', | ||
}, | ||
{ | ||
title: '응가 뿌직', | ||
content: '응가좀 치는사람 모이셈', | ||
|
||
imageUrl: '/images/approve_character.png', | ||
groupId: 10, | ||
latestMessageTiem: '2024-04-06T20:32', | ||
}, | ||
{ | ||
title: '응가 뿌직', | ||
content: '응가좀 치는사람 모이셈', | ||
newMessag: 3, | ||
|
||
imageUrl: '/images/approve_character.png', | ||
groupId: 10, | ||
latestMessageTiem: '2024-04-06T20:32', | ||
}, | ||
]; |
17 changes: 14 additions & 3 deletions
17
packages/web/src/app/[lng]/(main)/grouping/chatList/page.tsx
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,10 +1,21 @@ | ||
import ChatCardList from './components/ChatCardList'; | ||
import ChatListHeader from './components/ChatListHeader'; | ||
|
||
export default function ChatListPage() { | ||
import { serverTranslation } from '@/app/i18n'; | ||
|
||
interface ChatListPageProps { | ||
params: { | ||
lng: string; | ||
}; | ||
} | ||
|
||
export default async function ChatListPage({ params: { lng } }: ChatListPageProps) { | ||
const { t } = await serverTranslation(lng, 'grouping'); | ||
|
||
return ( | ||
<> | ||
<ChatListHeader /> | ||
<div className={'flex flex-col'}></div> | ||
<ChatListHeader title={t('chat.listHeader')} /> | ||
<ChatCardList /> | ||
</> | ||
); | ||
} |
3 changes: 0 additions & 3 deletions
3
packages/web/src/app/[lng]/(main)/grouping/detail/[groupId]/chat/page.tsx
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
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
29 changes: 29 additions & 0 deletions
29
packages/web/src/app/[lng]/(main)/grouping/detail/[groupId]/components/chat/ChatContent.tsx
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 { usePathname } from 'next/navigation'; | ||
|
||
import MessageForm from '@/components/Form/MessageForm'; | ||
import { Spacing } from '@/components/Spacing'; | ||
import { useNumberParams } from '@/hooks/useNumberParams'; | ||
|
||
export default function ChatContent() { | ||
const pathname = usePathname(); | ||
const { groupId } = useNumberParams<['groupId']>(); | ||
|
||
return ( | ||
<section className="bg-brand-color h-full overflow-auto"> | ||
<Spacing size={48} /> | ||
|
||
<div className="flex flex-col gap-10"> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
<div className="h-300 bg-primary"></div> | ||
</div> | ||
|
||
<MessageForm /> | ||
</section> | ||
); | ||
} |
Oops, something went wrong.