This repository was archived by the owner on Jan 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubble-info.tsx
More file actions
83 lines (74 loc) · 1.98 KB
/
bubble-info.tsx
File metadata and controls
83 lines (74 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Container, Text } from '@titicaca/tds-ui'
import styled, { CSSProp } from 'styled-components'
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;
`
const UnreadMessageCountText = styled.div`
color: #26cec2;
font-size: 10px;
`
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,
dateTimeStyle,
unreadCountStyle,
...props
}: {
align: 'left' | 'right'
unreadCount: number | null
date: string
showTimeInfo?: boolean
showDateInfo?: boolean
onReplyClick?: () => void
dateTimeStyle?: { css?: CSSProp }
unreadCountStyle?: { css?: CSSProp }
}) {
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 css={unreadCountStyle?.css}>
{unreadCount}
</UnreadMessageCountText>
) : null}
{showDateInfo ? (
<Text size={10} alpha={0.51} css={dateTimeStyle?.css}>
{format(new Date(date), 'MM.dd')}
</Text>
) : null}
{showTimeInfo ? (
<Text size={10} alpha={0.51} css={dateTimeStyle?.css}>
{format(new Date(date), 'a h:mm')}
</Text>
) : null}
</BubbleInfoContainer>
)
}