Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chat] epic: geochat 기능을 chat 패키지에 추가합니다. #3130

Merged
merged 57 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
27bca31
renderMessages에 날짜 비교를 위한 lastMessageOfPrevList arg 추가
dongoc Jan 24, 2024
79bbea4
moment를 date-fns로 교체
dongoc Jan 24, 2024
b20c3e7
time 및 profile 노출 여부 props 추가
dongoc Jan 24, 2024
2de3270
showTimeInfo, showProfile 여부 계산 추가
dongoc Jan 24, 2024
a67b94f
messages 폴더 생성 및 파일 이동
dongoc Jan 24, 2024
a136f90
type, utils 파일 분리
dongoc Jan 24, 2024
b0137cd
dateDivider 연결
dongoc Jan 24, 2024
91ef600
bubble 스타일을 지오챗에 맞게 수정
dongoc Jan 24, 2024
6b59056
스타일 수정
dongoc Jan 25, 2024
b28b2cc
time 설정을 추가한 스토리북 추가 및 로직 수정
dongoc Jan 25, 2024
18122db
주석 수정
dongoc Jan 25, 2024
e015c80
showTimeInfo 조건 수정
dongoc Jan 26, 2024
fe246d0
showTimeInfo 조건 수정
dongoc Jan 26, 2024
2f0b429
showTimeInfo 조건 수정 및 안읽음 숫자 디자인 수정
dongoc Jan 30, 2024
1e5da1e
다음 메세지가 product 타입일 때 날짜 표기
dongoc Feb 1, 2024
5992f48
bubbleInfo 영역에 답장하기 아이콘 추가
dongoc Feb 1, 2024
033b2a7
onMessageIntersecting 및 messageRef props 추가
dongoc Jan 17, 2024
5ef47d5
reply 렌더링 조건 수정
dongoc Feb 7, 2024
6c2ff2d
text bubble 관련 style 주석 제거
guswl98 Jan 18, 2024
2830902
탈퇴한 사용자일 때 프로필 내용 수정
guswl98 Jan 18, 2024
6d518ba
부모 메세지 UI 추가
guswl98 Jan 22, 2024
20dae9f
ParentMessage 스토리북 추가
guswl98 Jan 22, 2024
a7cd064
ParentMessage Type 변경 및 적용
guswl98 Jan 22, 2024
810b300
TextBubble에 ParentMessage 적용
guswl98 Jan 22, 2024
1ceb294
BaseBubble과 BubbleWithParentMessage 구분
guswl98 Jan 23, 2024
a16d619
parentMessage nullable
guswl98 Jan 23, 2024
9951b70
ParentUI sender type 변경
guswl98 Feb 1, 2024
4ab2b64
Altered Bubble 스토리북 추가
guswl98 Feb 7, 2024
04aa255
ParentMessage css prop 추가
guswl98 Feb 7, 2024
c314bf9
ParentMessage style prop으로 변경
guswl98 Feb 7, 2024
9dbadc9
backgroundColor prop 제거
guswl98 Feb 7, 2024
4df27bf
전체보기 text view 작성
dongoc Feb 1, 2024
2c8de93
전체보기 관련 Props 추가 및 스토리북 작성
dongoc Feb 1, 2024
346aa4e
전체보기뷰 hash값 수정
dongoc Feb 7, 2024
6b25119
AlteredBubble에서는 부모 메시지 노출 X
guswl98 Feb 13, 2024
7c555e0
Retry, Delete 아이콘 추가
guswl98 Feb 14, 2024
736886f
Retry, Delete 아이콘 적용
guswl98 Feb 14, 2024
9c1df7b
openMenu의 타입 오류 수정
dongoc Feb 19, 2024
1c5b25f
receiveContainer의 디자인 수정
dongoc Feb 19, 2024
0519e30
alteredTextColor 적용
guswl98 Mar 5, 2024
2f4fa1d
alteredTextColor 변수 선언 및 적용
guswl98 Mar 6, 2024
093acce
alteredTextColor 적용
guswl98 Mar 6, 2024
9810196
styled span 적용
guswl98 Mar 7, 2024
cd1dfb2
부모메세지 altered 설정
dongoc Feb 29, 2024
60f675e
imageLongPress 시에도 messageId를 받을 수 있도록 수정
dongoc Feb 29, 2024
bf4c577
이미지 버블에 id 추가
dongoc Feb 29, 2024
c082dda
parentUi props 연결
dongoc Mar 6, 2024
450a94d
부모 메세지 클릭 이벤트 추가
dongoc Aug 1, 2024
e9f1110
intersection observer 패키지 교체
dongoc Oct 30, 2024
5903000
eslint-disable 주석 추가
dongoc Oct 30, 2024
da26c4f
alteredBubble css 수정
dongoc Oct 30, 2024
e6fba98
유저 프로필 클릭 핸들러 추가
dongoc Nov 4, 2024
a57f4ec
aTagNavigator에 preventDefault, stopPropagation 추가
dongoc Jan 20, 2025
560355c
target new를 browser로 변경
dongoc Jan 20, 2025
1860038
파일명 오타 수정
guswl98 Jan 22, 2025
93ef7c9
답장하기 버튼에 data-id 추가
guswl98 Jan 22, 2025
7d73290
reply button 상수 추가
guswl98 Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"dependencies": {
"@titicaca/color-palette": "workspace:*",
"@titicaca/core-elements": "workspace:*",
"@titicaca/intersection-observer": "workspace:*",
"@titicaca/popup": "workspace:*",
"@titicaca/router": "workspace:*",
"@titicaca/triple-fallback-action": "workspace:*",
"@titicaca/triple-web-to-native-interfaces": "1.9.0",
"@titicaca/type-definitions": "workspace:*",
"@titicaca/view-utilities": "workspace:*",
"autolinker": "^4.0.0",
"moment": "^2.29.4",
"date-fns": "^3.3.1",
"react-intersection-observer": "^9.13.1",
"use-long-press": "^3.2.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ReceivedBubbleContainer = {
type: 'boolean',
},
},
profile: {
user: {
control: {
type: 'object',
},
Expand All @@ -76,12 +76,12 @@ export const ReceivedBubbleContainer = {
createdAt: new Date(2022, 10, 1).toISOString(),
unreadCount: null,
showInfo: true,
profile: {
imageUrl:
user: {
photo:
'https://assets.triple-dev.titicaca-corp.com/images/app-download@2x.png',
name: '테스트계정',
userId: 'test',
unregister: false,
unregistered: false,
},
},
}
86 changes: 74 additions & 12 deletions packages/chat/src/bubble-container/bubble-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PropsWithChildren } from 'react'
import { Container } from '@titicaca/core-elements'

import { DEFAULT_MESSAGE_ID_PREFIX } from '../chat/constants'
import { DEFAULT_MAX_USERNAME_LENGTH, formatUsername } from '../utils/profile'

import { BubbleInfo } from './bubble-info'
import {
Expand All @@ -12,12 +13,12 @@ import {
SendingFailureHandlerContainer,
Thanks,
} from './elements'
import { DeleteIcon, RetryIcon } from './icons'

const CHAT_CONTAINER_STYLES = {
marginTop: 20,
position: 'relative',
minHeight: 46,
width: '100%',
userSelect: 'none',
} as const

interface ContainerBaseProp {
Expand All @@ -26,12 +27,20 @@ interface ContainerBaseProp {
createdAt?: string // Date?
/** 해당 메시지를 읽지 않은 유저의 수 */
unreadCount: number | null
/** 시간 정보 등의 정보의 노출 여부 */
/** 정보 영역 노출 여부 (시간, 안읽음 등) */
showInfo?: boolean
/** 날짜 정보의 노출 여부 */
showDateInfo?: boolean
/** 시간 정보의 노출 여부 */
showTimeInfo?: boolean
/** 좋아요 정보 */
thanks?: { count: number; haveMine: boolean }
/** 좋아요 아이콘 클릭 시 작동하는 함수 */
onThanksClick?: () => void
/** 답장하기 아이콘 클릭 시 작동하는 함수 */
onReplyClick?: () => void
/** 메세지 ref에 주입되는 callback 함수 */
messageRefCallback?: (id: string) => void
}

type SentBubbleContainerProp = PropsWithChildren<
Expand All @@ -50,28 +59,43 @@ function SentBubbleContainer({
onRetryCancel,
unreadCount,
showInfo = true,
showDateInfo,
showTimeInfo,
thanks,
onThanksClick,
onReplyClick,
messageRefCallback,
children,
...props
}: SentBubbleContainerProp) {
return (
<Container
id={`${DEFAULT_MESSAGE_ID_PREFIX}-${id}`}
css={{ textAlign: 'right', ...CHAT_CONTAINER_STYLES }}
ref={() => messageRefCallback?.(id)}
{...props}
>
<div>
{!createdAt && onRetry && onRetryCancel ? (
<SendingFailureHandlerContainer>
<RetryButton onClick={onRetry} />
<DeleteButton onClick={onRetryCancel} />
<RetryButton onClick={onRetry}>
<RetryIcon />
</RetryButton>
<DeleteButton onClick={onRetryCancel}>
<DeleteIcon />
</DeleteButton>
</SendingFailureHandlerContainer>
) : null}

{createdAt && showInfo ? (
<BubbleInfo
align="right"
unreadCount={unreadCount}
date={createdAt}
css={{ marginRight: 8, textAlign: 'right' }}
showDateInfo={showDateInfo}
showTimeInfo={showTimeInfo}
onReplyClick={onReplyClick}
css={{ marginRight: 4, textAlign: 'right' }}
/>
) : null}

Expand Down Expand Up @@ -99,6 +123,10 @@ type ReceivedBubbleContainerProp = PropsWithChildren<
userId: string
unregistered?: boolean
}
/** 프로필 노출 여부 */
showProfile?: boolean
/** 유저 프로필 클릭 */
onUserClick?: (userId: string, unregistered: boolean) => void
}
>

Expand All @@ -108,28 +136,62 @@ function ReceivedBubbleContainer({
unreadCount,
createdAt,
showInfo,
showDateInfo,
showTimeInfo,
showProfile = true,
thanks,
onThanksClick,
onReplyClick,
messageRefCallback,
onUserClick,
children,
...props
}: ReceivedBubbleContainerProp) {
return (
<Container
id={`${DEFAULT_MESSAGE_ID_PREFIX}-${id}`}
css={{ ...CHAT_CONTAINER_STYLES }}
ref={() => messageRefCallback?.(id)}
{...props}
>
<ProfileImage src={user?.photo} />
<Container css={{ marginLeft: 50 }}>
<ProfileName size="mini" alpha={0.8} margin={{ bottom: 5 }}>
{user?.name || ''}
</ProfileName>
{showProfile ? (
<ProfileImage
src={
user && !user.unregistered && user.photo
? user.photo
: 'https://assets.triple.guide/images/ico-default-profile.svg'
}
onClick={() =>
onUserClick && user
? onUserClick(user.userId, user.unregistered || false)
: undefined
}
/>
) : null}
<Container css={{ marginLeft: 40 }}>
{showProfile ? (
<ProfileName size="mini" alpha={0.8} margin={{ bottom: 5 }}>
{user
? formatUsername({
name: user?.name,
unregistered: user?.unregistered,
maxLength: DEFAULT_MAX_USERNAME_LENGTH,
})
: ''}
</ProfileName>
) : null}

{children}

{createdAt && showInfo ? (
<BubbleInfo
align="left"
unreadCount={unreadCount}
showDateInfo={showDateInfo}
showTimeInfo={showTimeInfo}
onReplyClick={onReplyClick}
date={createdAt}
css={{ marginLeft: 8, textAlign: 'left' }}
css={{ marginLeft: 4, textAlign: 'left' }}
/>
) : null}

Expand Down
53 changes: 43 additions & 10 deletions packages/chat/src/bubble-container/bubble-info.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import moment from 'moment'
import styled from 'styled-components'
import { Container, Text } from '@titicaca/core-elements'
import { format, setDefaultOptions } from 'date-fns'
import { ko } from 'date-fns/locale'

import { ReplyMessageIcon } from '../icons/reply-message-icon'
import { REPLY_BUTTON_DATA_ID } from '../chat/constants'

const BubbleInfoContainer = styled(Container)`
vertical-align: bottom;
Expand All @@ -11,34 +15,63 @@ const UnreadMessageCountText = styled.div`
font-size: 10px;
`

moment.locale('ko')
const ReplyActionButton = styled.button<{
align: 'left' | 'right'
}>`
display: flex;
align-items: flex-end;
justify-content: ${({ align }) => (align === 'right' ? 'flex-end' : 'auto')};
width: 100%;
height: 22px;
padding-bottom: 3px;
cursor: pointer;
`

setDefaultOptions({ locale: ko })

export function BubbleInfo({
align,
unreadCount,
date,
showTimeInfo = true,
showDateInfo = false,
onReplyClick,
...props
}: {
align: 'left' | 'right'
unreadCount: number | null
date: string
showTimeInfo?: boolean
showDateInfo?: boolean
onReplyClick?: () => void
}) {
const showDate = !moment().isSame(date, 'day')
const showYear = !moment().isSame(date, 'year')

return (
<BubbleInfoContainer position="relative" display="inline-block" {...props}>
{onReplyClick ? (
<ReplyActionButton
align={align}
onClick={onReplyClick}
data-id={REPLY_BUTTON_DATA_ID}
>
<ReplyMessageIcon />
</ReplyActionButton>
) : null}

{unreadCount ? (
<UnreadMessageCountText>{unreadCount}</UnreadMessageCountText>
) : null}

{showDate ? (
{showDateInfo ? (
<Text size={10} alpha={0.51}>
{moment(date).format(showYear ? 'YYYY.MM.DD' : 'MM.DD')}
{format(new Date(date), 'MM.dd')}
</Text>
) : null}

<Text size={10} alpha={0.51}>
{moment(date).format('A hh:mm')}
</Text>
{showTimeInfo ? (
<Text size={10} alpha={0.51}>
{format(new Date(date), 'a h:mm')}
</Text>
) : null}
</BubbleInfoContainer>
)
}
11 changes: 6 additions & 5 deletions packages/chat/src/bubble-container/elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ export const HiddenElement = styled.div`
`

export const ProfileImage = styled.img`
width: 36px;
height: 36px;
border-radius: 26.8px;
width: 32px;
height: 32px;
border-radius: 32px;
box-shadow: rgba(0, 0, 0, 0.02) 0 0 0 1px;
outline-offset: -1px;
float: left;
`

export const ProfileName = styled(Text)`
font-size: 11px;
font-weight: 600;
`

Expand Down Expand Up @@ -41,15 +44,13 @@ export const RetryButton = styled.button`
${sendingFailureHandlerStyle};

width: 23.5px;
background-image: url('https://assets.triple.guide/images/btn-message-resend@3x.png');
`

export const DeleteButton = styled.button`
${sendingFailureHandlerStyle};

width: 24.5px;
border-left: 1px solid rgba(255, 255, 255, 0.3);
background-image: url('https://assets.triple.guide/images/btn-message-delete@3x.png');
`

const ThanksButton = styled(Button)<{ haveMine: boolean }>`
Expand Down
52 changes: 52 additions & 0 deletions packages/chat/src/bubble-container/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export function RetryIcon() {
return (
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.1765 9.09523C10.4332 10.6599 8.83833 11.7417 6.99083 11.7417C4.43302 11.7417 2.3595 9.66818 2.3595 7.11037C2.3595 4.55256 4.43302 2.47905 6.99083 2.47905C8.96589 2.47905 10.6522 3.71537 11.3181 5.45633"
stroke="white"
strokeWidth="1.4"
strokeLinecap="round"
/>
<path
d="M9.73587 5.33219L11.7016 5.60706L11.9765 3.64133"
stroke="white"
strokeWidth="1.4"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}

export function DeleteIcon() {
return (
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.047 11L7 7.024L3 3"
stroke="white"
strokeWidth="1.4"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M10.953 11L7 7.024L11 3"
stroke="white"
strokeWidth="1.4"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}
Loading
Loading