-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
채팅 추가 컴포넌트 및 페이지 구현
- Loading branch information
Showing
42 changed files
with
1,055 additions
and
179 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,12 +1,14 @@ | ||
import { Theme } from './theme.type'; | ||
import typography from './typography'; | ||
import colorPalette from './colorPalette'; | ||
import semantic from './semantic'; | ||
import coloredTypography from './coloredTypography'; | ||
import layout from './layout'; | ||
import semantic from './semantic'; | ||
import typography from './typography'; | ||
|
||
export const theme: Theme = { | ||
colorPalette, | ||
typography, | ||
semantic, | ||
layout, | ||
coloredTypography, | ||
}; |
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
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
63 changes: 63 additions & 0 deletions
63
frontend/src/components/ChatBottomMenu/ChatBottomMenu.stories.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,63 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import ChatBottomMenu from './ChatBottomMenu'; | ||
import ChatMenuItem from '@_components/ChatMenuItem/ChatMenuItem'; | ||
import { Fragment } from 'react'; | ||
import Plus from '@_common/assets/plus.svg'; | ||
import { css } from '@emotion/react'; | ||
|
||
const meta: Meta<typeof ChatBottomMenu> = { | ||
component: ChatBottomMenu, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ChatBottomMenu>; | ||
export const Two: Story = { | ||
args: { | ||
children: ( | ||
<Fragment> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
</Fragment> | ||
), | ||
}, | ||
decorators: (Story) => ( | ||
<div | ||
css={css` | ||
width: 300px; | ||
`} | ||
> | ||
<Story /> | ||
</div> | ||
), | ||
}; | ||
|
||
export const Nine: Story = { | ||
args: { | ||
children: ( | ||
<Fragment> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem | ||
icon={<Plus />} | ||
description="더하기rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" | ||
/> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
<ChatMenuItem icon={<Plus />} description="더하기" /> | ||
</Fragment> | ||
), | ||
}, | ||
decorators: (Story) => ( | ||
<div | ||
css={css` | ||
width: 300px; | ||
`} | ||
> | ||
<Story /> | ||
</div> | ||
), | ||
}; |
13 changes: 13 additions & 0 deletions
13
frontend/src/components/ChatBottomMenu/ChatBottomMenu.style.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,13 @@ | ||
import { Theme, css } from '@emotion/react'; | ||
|
||
export const menu = ({ theme }: { theme: Theme }) => css` | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 2rem; | ||
width: 100%; | ||
min-height: 40vh; | ||
padding: 2rem; | ||
background-color: ${theme.colorPalette.white[100]}; | ||
`; |
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,11 @@ | ||
import * as S from './ChatBottomMenu.style'; | ||
|
||
import { PropsWithChildren } from 'react'; | ||
import { useTheme } from '@emotion/react'; | ||
|
||
export default function ChatBottomMenu(props: PropsWithChildren) { | ||
const { children } = props; | ||
const theme = useTheme(); | ||
|
||
return <div css={S.menu({ theme })}>{children}</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,14 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import ChatBubble from './ChatBubble'; | ||
|
||
const meta: Meta<typeof ChatBubble> = { | ||
component: ChatBubble, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ChatBubble>; | ||
|
||
export const Default: Story = { | ||
args: { isMyMessage: true, children: '안녕' }, | ||
}; |
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 @@ | ||
import { Theme, css } from '@emotion/react'; | ||
|
||
export const chatBubble = ({ | ||
theme, | ||
backgroundColor, | ||
isMyMessage, | ||
}: { | ||
theme: Theme; | ||
isMyMessage: boolean; | ||
backgroundColor?: string; | ||
}) => css` | ||
${theme.typography.b4}; | ||
display: inline-block; | ||
max-width: 25rem; | ||
padding: 10px; | ||
word-break: break-all; | ||
background-color: ${backgroundColor || theme.semantic.primary}; | ||
border-radius: ${isMyMessage ? '12px' : 0} ${isMyMessage ? 0 : '12px'} 12px | ||
12px; | ||
`; |
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,20 @@ | ||
import * as S from './ChatBubble.style'; | ||
|
||
import { PropsWithChildren } from 'react'; | ||
import { useTheme } from '@emotion/react'; | ||
|
||
interface ChatBubbleProps extends PropsWithChildren { | ||
isMyMessage: boolean; | ||
backgroundColor?: string; | ||
} | ||
|
||
export default function ChatBubble(props: ChatBubbleProps) { | ||
const { isMyMessage, backgroundColor, children } = props; | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<div css={S.chatBubble({ theme, backgroundColor, isMyMessage })}> | ||
{children} | ||
</div> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
frontend/src/components/ChatBubble/ChatChildren/ChatChildren.style.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,6 @@ | ||
import { Theme, css } from '@emotion/react'; | ||
|
||
export const grey400C2 = ({ theme }: { theme: Theme }) => css` | ||
${theme.typography.c2} | ||
color:${theme.colorPalette.grey[400]} | ||
`; |
60 changes: 60 additions & 0 deletions
60
frontend/src/components/ChatBubble/ChatChildren/ChatChildren.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,60 @@ | ||
import * as S from './ChatChildren.style'; | ||
|
||
import { | ||
formatHhmmToKoreanWithPrefix, | ||
formatYyyymmddToKorean, | ||
} from '@_utils/formatters'; | ||
|
||
import { Chat } from '@_types/index'; | ||
import ChatBubble from '@_components/ChatBubble/ChatBubble'; | ||
import { useTheme } from '@emotion/react'; | ||
|
||
interface ChatChildrenProps { | ||
chat: Chat; | ||
} | ||
export const ChatChildren = (props: ChatChildrenProps) => { | ||
const { chat } = props; | ||
const theme = useTheme(); | ||
if (chat.chatType === 'PLACE') { | ||
return ( | ||
<ChatBubble | ||
isMyMessage={chat.isMyMessage} | ||
backgroundColor={theme.colorPalette.green[50]} | ||
> | ||
<div css={S.grey400C2({ theme })}>{'장소가 확정되었습니다!'}</div> | ||
<div css={theme.typography.b3}>{chat.content}</div> | ||
</ChatBubble> | ||
); | ||
} | ||
if (chat.chatType === 'DATETIME') { | ||
const [yyyymmdd, hhmm] = chat.content.split(' '); | ||
return ( | ||
<ChatBubble | ||
isMyMessage={chat.isMyMessage} | ||
backgroundColor={theme.colorPalette.green[50]} | ||
> | ||
<div css={S.grey400C2({ theme })}> | ||
{'날짜와 시간이 확정되었습니다!'} | ||
</div> | ||
<div css={theme.typography.b3}> | ||
{formatYyyymmddToKorean(yyyymmdd, '-')} | ||
</div> | ||
<div css={theme.typography.b3}> | ||
{formatHhmmToKoreanWithPrefix(hhmm, ':')} | ||
</div> | ||
</ChatBubble> | ||
); | ||
} | ||
return ( | ||
<ChatBubble | ||
isMyMessage={chat.isMyMessage} | ||
backgroundColor={ | ||
chat.isMyMessage | ||
? theme.colorPalette.yellow[200] | ||
: theme.colorPalette.orange[100] | ||
} | ||
> | ||
{chat.content} | ||
</ChatBubble> | ||
); | ||
}; |
Oops, something went wrong.