@daeryun/dr_components 0.8.70 → 0.8.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,10 +8,87 @@ import { InquiryStatus } from './_enums/ask-status';
8
8
  import Button3 from './_ui/buttons/Button3';
9
9
  import ChatConversationHeader from './ChatConversationItem/ChatConversationHeader';
10
10
  import ChatLoading from './ChatItem/ChatLoading';
11
+ import { useWindowSize } from './_hooks/useWindowSize';
11
12
  const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose, isHash }) => {
12
13
  const { inquiryStatus, messages, isLoading, inquiryMainData, messageObject, workFlowBack, workFlowStack, chatInquiryNumber } = useDaeryuntalk();
13
14
  const [isHovered, setIsHovered] = useState(false);
14
15
  const messagesEndRef = useRef(null);
16
+ const headerRef = useRef(null);
17
+ const noticeRef = useRef(null);
18
+ const bottomRef = useRef(null);
19
+ const [bottomHeight, setBottomHeight] = useState(0);
20
+ const [availableHeight, setAvailableHeight] = useState(null);
21
+ const wrapperRef = useRef(null);
22
+ const messageAreaRef = useRef(null);
23
+ const windowSize = useWindowSize();
24
+ useEffect(() => {
25
+ if (!isMobile)
26
+ return;
27
+ const calcMessageAreaHeight = () => {
28
+ var _a, _b, _c, _d;
29
+ const headerHeight = (_b = (_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) !== null && _b !== void 0 ? _b : 0;
30
+ const noticeHeight = (_d = (_c = noticeRef.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().height) !== null && _d !== void 0 ? _d : 0;
31
+ const total = headerHeight + noticeHeight + bottomHeight;
32
+ const available = window.innerHeight - total;
33
+ setAvailableHeight(available);
34
+ };
35
+ calcMessageAreaHeight();
36
+ const resizeObserver = new ResizeObserver(calcMessageAreaHeight);
37
+ if (headerRef.current)
38
+ resizeObserver.observe(headerRef.current);
39
+ if (noticeRef.current)
40
+ resizeObserver.observe(noticeRef.current);
41
+ window.addEventListener('resize', calcMessageAreaHeight);
42
+ return () => {
43
+ resizeObserver.disconnect();
44
+ window.removeEventListener('resize', calcMessageAreaHeight);
45
+ };
46
+ }, [isMobile]);
47
+ useEffect(() => {
48
+ if (!bottomRef.current)
49
+ return;
50
+ const updateHeight = () => {
51
+ var _a, _b;
52
+ const height = (_b = (_a = bottomRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) !== null && _b !== void 0 ? _b : 0;
53
+ setBottomHeight(height);
54
+ };
55
+ updateHeight(); // 초기 측정
56
+ const resizeObserver = new ResizeObserver(updateHeight);
57
+ // bottomRef 자체 감지
58
+ resizeObserver.observe(bottomRef.current);
59
+ // TipTap 내부 wrapper도 별도로 감지
60
+ const tiptapWrapper = bottomRef.current.querySelector('.tiptap-editor-wrapper');
61
+ if (tiptapWrapper) {
62
+ resizeObserver.observe(tiptapWrapper);
63
+ }
64
+ // 윈도우 리사이즈 대응
65
+ window.addEventListener('resize', updateHeight);
66
+ return () => {
67
+ resizeObserver.disconnect();
68
+ window.removeEventListener('resize', updateHeight);
69
+ };
70
+ }, []);
71
+ useEffect(() => {
72
+ if (!bottomRef.current || !wrapperRef.current || !messageAreaRef.current)
73
+ return;
74
+ const updateAvailableHeight = () => {
75
+ const wrapperRect = wrapperRef.current.getBoundingClientRect();
76
+ const bottomHeight = bottomRef.current.getBoundingClientRect().height;
77
+ const topOfMessage = messageAreaRef.current.getBoundingClientRect().top;
78
+ const visibleHeight = window.innerHeight - bottomHeight;
79
+ const contentHeight = visibleHeight - (topOfMessage - wrapperRect.top); // header + notice 높이 제거
80
+ setAvailableHeight(contentHeight);
81
+ };
82
+ updateAvailableHeight();
83
+ const resizeObserver = new ResizeObserver(updateAvailableHeight);
84
+ resizeObserver.observe(bottomRef.current);
85
+ resizeObserver.observe(wrapperRef.current);
86
+ window.addEventListener('resize', updateAvailableHeight);
87
+ return () => {
88
+ resizeObserver.disconnect();
89
+ window.removeEventListener('resize', updateAvailableHeight);
90
+ };
91
+ }, [isMobile]);
15
92
  const defaultNoticeContent = (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_explanation) ||
16
93
  '본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
17
94
  const noticeContent = defaultNoticeContent;
@@ -50,20 +127,34 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
50
127
  return elements;
51
128
  };
52
129
  return (<>
53
- <div className={`${isMobile ? 'h-[100dvh]' : 'h-[100dvh]'} flex flex-col justify-between xs:h-auto xs:justify-start`}>
130
+ {/*isMoblie true일때 헤더 주의 내용이 상단에 있고 ,나머지 높이영역은 메시지 리스트로 붙게*/}
131
+ <div className={`flex flex-col justify-between xs:h-auto xs:justify-start`} style={{
132
+ height: isMobile
133
+ ? undefined
134
+ : windowSize.width < 480
135
+ ? `calc(100dvh - ${bottomHeight}px)`
136
+ : undefined
137
+ }}>
54
138
  <div className={`
55
- no-scrollbar relative w-full rounded-t-[30px]
56
- ${isMobile
139
+ no-scrollbar relative w-full rounded-t-[30px]
140
+ ${isMobile
57
141
  ? 'flex flex-col items-center justify-between'
58
142
  : 'flex h-[100dvh] flex-col items-center xs:h-[calc(100vh-165px-64px)] lg:h-[calc(100vh-110px-64px)] ' +
59
143
  ' xs:max-h-[626px] xs:min-h-[320px] '}
60
144
  `}>
61
145
  {/* 헤더 부분 */}
62
- <ChatConversationHeader inquiryMainData={inquiryMainData !== null && inquiryMainData !== void 0 ? inquiryMainData : null} isMobile={isMobile} onClose={onClose} isHash={isHash} onBackClick={onBackClick}/>
146
+ <div ref={headerRef} className={`w-full`}>
147
+ <ChatConversationHeader inquiryMainData={inquiryMainData !== null && inquiryMainData !== void 0 ? inquiryMainData : null} isMobile={isMobile} onClose={onClose} isHash={isHash} onBackClick={onBackClick}/>
148
+ </div>
63
149
  {/* 주의내용 */}
64
- <NoticeMessage content={noticeContent}/>
150
+ <div ref={noticeRef}>
151
+ <NoticeMessage content={noticeContent} isMobile={isMobile}/>
152
+ </div>
65
153
  {/* 메시지 노출 부분 -> 무한스크롤 변환 필요 */}
66
- <div className={`${isMobile ? 'h-auto' : 'flex-1'} no-scrollbar mx-[20px] overflow-auto pb-[100px] pt-[20px]`}>
154
+ {/* 여기서 isMpblie일때 위에 2개 헤더부분이랑 아래 메시지 입력이랑 높이를 빼서 넣어야한ㄷ */}
155
+ <div className={`${isMobile ? ' ' : 'flex-1 xs:pb-[100px]'} no-scrollbar mx-[20px] overflow-auto pt-[20px]`} style={{
156
+ height: isMobile ? (availableHeight !== null && availableHeight !== void 0 ? availableHeight : undefined) : undefined
157
+ }}>
67
158
  {messages.length === 0 ? (<div className="dr_talk_body_medium2 flex h-full flex-col items-center justify-center text-center text-drTalkGrayscale1">
68
159
  <p>문의하실 내용을 입력해 주세요.</p>
69
160
  <p className="mt-2 text-sm">24시간 운영하고 있습니다.</p>
@@ -93,7 +184,8 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
93
184
  </div>
94
185
  </div>
95
186
  </div>
96
- <div className={`block w-full xs:hidden`}>
187
+ {/* isMoblie true일때 한 화면에 하단에 붙게 */}
188
+ <div ref={bottomRef} className={`block w-full xs:hidden`}>
97
189
  {/* 높이가 부모에 스크롤이 줄어도 해당 부분은 바텀에 고정 필요 */}
98
190
  {inquiryStatus === InquiryStatus.CLOSED ? (<div className="w-full border-t border-drTalkGrayscale4 px-[20px] py-[16px]">
99
191
  <div className="">
@@ -1,21 +1,14 @@
1
- import React, { useEffect, useMemo, useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { useDaeryuntalk } from './DaeryuntalkContext';
3
3
  import ChatMessage from './ChatMessage';
4
4
  import ChatInput from './ChatInput';
5
5
  import NoticeMessage from './NoticeMessage';
6
6
  import DateSeparator from './DateSeparator';
7
- import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
8
- import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
9
- import Image from 'next/image';
10
- import { useChatSocketState } from './_hooks/view/useChatSocketState';
11
- import { getMessageFileDownloadUrl } from './_api';
12
7
  import { InquiryStatus } from './_enums/ask-status';
13
- import SendIcon from '../../asset/images/daeryuntalk/send.svg';
14
- import CloseSvgIcon from '../../asset/images/daeryuntalk/close.svg';
15
8
  import Button3 from './_ui/buttons/Button3';
16
9
  import ChatConversationHeader from './ChatConversationItem/ChatConversationHeader';
17
- import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
18
10
  import ChatLoading from './ChatItem/ChatLoading';
11
+ import { useWindowSize } from './_hooks/useWindowSize';
19
12
 
20
13
  type ChatConversationProps = {
21
14
  onBackClick?: () => void;
@@ -46,6 +39,97 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
46
39
  } = useDaeryuntalk();
47
40
  const [isHovered, setIsHovered] = useState<boolean>(false);
48
41
  const messagesEndRef = useRef<HTMLDivElement>(null);
42
+ const headerRef = useRef<HTMLDivElement | null>(null);
43
+ const noticeRef = useRef<HTMLDivElement | null>(null);
44
+ const bottomRef = useRef<HTMLDivElement | null>(null);
45
+ const [bottomHeight, setBottomHeight] = useState(0);
46
+
47
+ const [availableHeight, setAvailableHeight] = useState<number | null>(null);
48
+ const wrapperRef = useRef<HTMLDivElement | null>(null);
49
+ const messageAreaRef = useRef<HTMLDivElement | null>(null);
50
+ const windowSize = useWindowSize();
51
+ useEffect(() => {
52
+ if (!isMobile) return;
53
+
54
+ const calcMessageAreaHeight = () => {
55
+ const headerHeight = headerRef.current?.getBoundingClientRect().height ?? 0;
56
+ const noticeHeight = noticeRef.current?.getBoundingClientRect().height ?? 0;
57
+ const total = headerHeight + noticeHeight + bottomHeight;
58
+ const available = window.innerHeight - total;
59
+ setAvailableHeight(available);
60
+ };
61
+
62
+ calcMessageAreaHeight();
63
+
64
+ const resizeObserver = new ResizeObserver(calcMessageAreaHeight);
65
+ if (headerRef.current) resizeObserver.observe(headerRef.current);
66
+ if (noticeRef.current) resizeObserver.observe(noticeRef.current);
67
+
68
+ window.addEventListener('resize', calcMessageAreaHeight);
69
+
70
+ return () => {
71
+ resizeObserver.disconnect();
72
+ window.removeEventListener('resize', calcMessageAreaHeight);
73
+ };
74
+ }, [isMobile]);
75
+
76
+ useEffect(() => {
77
+ if (!bottomRef.current) return;
78
+
79
+ const updateHeight = () => {
80
+ const height = bottomRef.current?.getBoundingClientRect().height ?? 0;
81
+ setBottomHeight(height);
82
+ };
83
+
84
+ updateHeight(); // 초기 측정
85
+
86
+ const resizeObserver = new ResizeObserver(updateHeight);
87
+
88
+ // bottomRef 자체 감지
89
+ resizeObserver.observe(bottomRef.current);
90
+
91
+ // TipTap 내부 wrapper도 별도로 감지
92
+ const tiptapWrapper = bottomRef.current.querySelector('.tiptap-editor-wrapper');
93
+ if (tiptapWrapper) {
94
+ resizeObserver.observe(tiptapWrapper);
95
+ }
96
+
97
+ // 윈도우 리사이즈 대응
98
+ window.addEventListener('resize', updateHeight);
99
+
100
+ return () => {
101
+ resizeObserver.disconnect();
102
+ window.removeEventListener('resize', updateHeight);
103
+ };
104
+ }, []);
105
+
106
+ useEffect(() => {
107
+ if (!bottomRef.current || !wrapperRef.current || !messageAreaRef.current) return;
108
+
109
+ const updateAvailableHeight = () => {
110
+ const wrapperRect = wrapperRef.current!.getBoundingClientRect();
111
+ const bottomHeight = bottomRef.current!.getBoundingClientRect().height;
112
+ const topOfMessage = messageAreaRef.current!.getBoundingClientRect().top;
113
+
114
+ const visibleHeight = window.innerHeight - bottomHeight;
115
+ const contentHeight = visibleHeight - (topOfMessage - wrapperRect.top); // header + notice 높이 제거
116
+
117
+ setAvailableHeight(contentHeight);
118
+ };
119
+
120
+ updateAvailableHeight();
121
+
122
+ const resizeObserver = new ResizeObserver(updateAvailableHeight);
123
+ resizeObserver.observe(bottomRef.current);
124
+ resizeObserver.observe(wrapperRef.current);
125
+
126
+ window.addEventListener('resize', updateAvailableHeight);
127
+
128
+ return () => {
129
+ resizeObserver.disconnect();
130
+ window.removeEventListener('resize', updateAvailableHeight);
131
+ };
132
+ }, [isMobile]);
49
133
 
50
134
  const defaultNoticeContent =
51
135
  inquiryMainData?.channel_explanation ||
@@ -109,33 +193,49 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
109
193
 
110
194
  return (
111
195
  <>
196
+ {/*isMoblie true일때 헤더 주의 내용이 상단에 있고 ,나머지 높이영역은 메시지 리스트로 붙게*/}
112
197
  <div
113
- className={`${isMobile ? 'h-[100dvh]' : 'h-[100dvh]'} flex flex-col justify-between xs:h-auto xs:justify-start`}
198
+ className={`flex flex-col justify-between xs:h-auto xs:justify-start`}
199
+ style={{
200
+ height: isMobile
201
+ ? undefined
202
+ : windowSize.width < 480
203
+ ? `calc(100dvh - ${bottomHeight}px)`
204
+ : undefined
205
+ }}
114
206
  >
115
207
  <div
116
208
  className={`
117
- no-scrollbar relative w-full rounded-t-[30px]
118
- ${
119
- isMobile
120
- ? 'flex flex-col items-center justify-between'
121
- : 'flex h-[100dvh] flex-col items-center xs:h-[calc(100vh-165px-64px)] lg:h-[calc(100vh-110px-64px)] ' +
122
- ' xs:max-h-[626px] xs:min-h-[320px] '
123
- }
209
+ no-scrollbar relative w-full rounded-t-[30px]
210
+ ${
211
+ isMobile
212
+ ? 'flex flex-col items-center justify-between'
213
+ : 'flex h-[100dvh] flex-col items-center xs:h-[calc(100vh-165px-64px)] lg:h-[calc(100vh-110px-64px)] ' +
214
+ ' xs:max-h-[626px] xs:min-h-[320px] '
215
+ }
124
216
  `}
125
217
  >
126
218
  {/* 헤더 부분 */}
127
- <ChatConversationHeader
128
- inquiryMainData={inquiryMainData ?? null}
129
- isMobile={isMobile}
130
- onClose={onClose}
131
- isHash={isHash}
132
- onBackClick={onBackClick}
133
- />
219
+ <div ref={headerRef} className={`w-full`}>
220
+ <ChatConversationHeader
221
+ inquiryMainData={inquiryMainData ?? null}
222
+ isMobile={isMobile}
223
+ onClose={onClose}
224
+ isHash={isHash}
225
+ onBackClick={onBackClick}
226
+ />
227
+ </div>
134
228
  {/* 주의내용 */}
135
- <NoticeMessage content={noticeContent} />
229
+ <div ref={noticeRef}>
230
+ <NoticeMessage content={noticeContent} isMobile={isMobile} />
231
+ </div>
136
232
  {/* 메시지 노출 부분 -> 무한스크롤 변환 필요 */}
233
+ {/* 여기서 isMpblie일때 위에 2개 헤더부분이랑 아래 메시지 입력이랑 높이를 빼서 넣어야한ㄷ */}
137
234
  <div
138
- className={`${isMobile ? 'h-auto' : 'flex-1'} no-scrollbar mx-[20px] overflow-auto pb-[100px] pt-[20px]`}
235
+ className={`${isMobile ? ' ' : 'flex-1 xs:pb-[100px]'} no-scrollbar mx-[20px] overflow-auto pt-[20px]`}
236
+ style={{
237
+ height: isMobile ? (availableHeight ?? undefined) : undefined
238
+ }}
139
239
  >
140
240
  {messages.length === 0 ? (
141
241
  <div className="dr_talk_body_medium2 flex h-full flex-col items-center justify-center text-center text-drTalkGrayscale1">
@@ -183,7 +283,8 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
183
283
  </div>
184
284
  </div>
185
285
  </div>
186
- <div className={`block w-full xs:hidden`}>
286
+ {/* isMoblie true일때 한 화면에 하단에 붙게 */}
287
+ <div ref={bottomRef} className={`block w-full xs:hidden`}>
187
288
  {/* 높이가 부모에 스크롤이 줄어도 해당 부분은 바텀에 고정 필요 */}
188
289
  {inquiryStatus === InquiryStatus.CLOSED ? (
189
290
  <div className="w-full border-t border-drTalkGrayscale4 px-[20px] py-[16px]">
@@ -11,7 +11,7 @@ const ChatConversationHeader = ({ inquiryMainData, isMobile, onClose, isHash, on
11
11
  onBackClick();
12
12
  }
13
13
  };
14
- return (<div className={`${isMobile ? 'sticky top-0 z-10 bg-white ' : ''} flex h-[56px] w-full items-center justify-between border-b border-gray-200 px-[16px]`}>
14
+ return (<div className={`${isMobile ? 'sticky top-0 z-10 ' : ''} flex h-[56px] w-full items-center justify-between border-b border-gray-200 px-[16px]`}>
15
15
  <button className="flex h-[28px] w-[28px] items-center justify-center" aria-label="이전" onClick={handleBackClick}>
16
16
  <PrevIcon width={28} height={28}/>
17
17
  </button>
@@ -29,7 +29,7 @@ const ChatConversationHeader = ({
29
29
  };
30
30
  return (
31
31
  <div
32
- className={`${isMobile ? 'sticky top-0 z-10 bg-white ' : ''} flex h-[56px] w-full items-center justify-between border-b border-gray-200 px-[16px]`}
32
+ className={`${isMobile ? 'sticky top-0 z-10 ' : ''} flex h-[56px] w-full items-center justify-between border-b border-gray-200 px-[16px]`}
33
33
  >
34
34
  <button
35
35
  className="flex h-[28px] w-[28px] items-center justify-center"
@@ -56,7 +56,7 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
56
56
  return (
57
57
  //
58
58
  <main className={`
59
- relative flex justify-end
59
+ relative flex justify-end border-[1px]
60
60
  ${isMobile ? 'h-[100dvh]' : 'h-[100dvh] xs:h-auto xs:rounded-[30px] '}
61
61
  `}>
62
62
  <div className={`
@@ -78,7 +78,7 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
78
78
  `}
79
79
 
80
80
  `}>
81
- <div className="flex h-full flex-col justify-between border-[1px] border-solid xs:justify-start xs:rounded-[30px]" style={{
81
+ <div className="flex h-full flex-col justify-between border-[0px] border-solid xs:justify-start xs:rounded-[30px]" style={{
82
82
  boxShadow: 'box-shadow: 0px 0px 20px 0px #00000040'
83
83
  }}>
84
84
  <div className={`no-scrollbar ${isMobile ? '' : 'overflow-auto'} `}>{content}</div>
@@ -108,7 +108,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
108
108
  //
109
109
  <main
110
110
  className={`
111
- relative flex justify-end
111
+ relative flex justify-end border-[1px]
112
112
  ${isMobile ? 'h-[100dvh]' : 'h-[100dvh] xs:h-auto xs:rounded-[30px] '}
113
113
  `}
114
114
  >
@@ -138,7 +138,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
138
138
  `}
139
139
  >
140
140
  <div
141
- className="flex h-full flex-col justify-between border-[1px] border-solid xs:justify-start xs:rounded-[30px]"
141
+ className="flex h-full flex-col justify-between border-[0px] border-solid xs:justify-start xs:rounded-[30px]"
142
142
  style={{
143
143
  boxShadow: 'box-shadow: 0px 0px 20px 0px #00000040'
144
144
  }}
@@ -33,7 +33,7 @@ const ChatInput = () => {
33
33
  {/*내용이 2줄 이상되면 입력창 높이도 키워져야합니다. 최대한 4줄까지만 보이도록 해주시고, 그 이상은 스크롤 될 수 있도록 해주시는 게 좋을 것 같습니다. max height 값을 72로 지정 부탁드립니다*/}
34
34
  <Tiptap ref={tiptapRef}
35
35
  // value={message}
36
- onChange={setMessage} onEnterKeyPress={handleEnter} placeholder="메시지를 입력하세요..." contentClassName={`!outline-none !border-[0px]`}/>
36
+ onChange={setMessage} onEnterKeyPress={handleEnter} placeholder="메시지를 입력하세요..." contentClassName={`!outline-none !border-[0px] !pt-[4px] !pl-[4px]`}/>
37
37
  <div className={`flex flex-col justify-end`}>
38
38
  <button type="submit" className={`flex h-10 w-10 items-center justify-center rounded-[8px] bg-drTalkBtnActive2 text-white ${isLoading || !message.trim() ? 'cursor-not-allowed opacity-50' : ' bg-drTalkCrimson '}`} disabled={isLoading || !message.trim()}>
39
39
  <div className="flex h-9 w-9 items-center justify-center">
@@ -40,7 +40,7 @@ const ChatInput: React.FC = () => {
40
40
  onChange={setMessage}
41
41
  onEnterKeyPress={handleEnter}
42
42
  placeholder="메시지를 입력하세요..."
43
- contentClassName={`!outline-none !border-[0px]`}
43
+ contentClassName={`!outline-none !border-[0px] !pt-[4px] !pl-[4px]`}
44
44
  />
45
45
  <div className={`flex flex-col justify-end`}>
46
46
  <button
@@ -61,7 +61,7 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue }) => {
61
61
  {/* 여기서 외각 스크롤 생김 */}
62
62
  <div ref={containerRef} className={`
63
63
  relative z-[999998]
64
- flex h-full flex-col items-center justify-end
64
+ flex h-full flex-col items-center justify-end
65
65
  ${isMobile ? `${innerMobileWrapperCss}` : `${innerWebSmallWrapperCss} ${innerWebTbPCWrapperCss}`}
66
66
  `}>
67
67
  {/* 여기서 보장해줘야하나? */}
@@ -87,7 +87,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
87
87
  ref={containerRef}
88
88
  className={`
89
89
  relative z-[999998]
90
- flex h-full flex-col items-center justify-end
90
+ flex h-full flex-col items-center justify-end
91
91
  ${isMobile ? `${innerMobileWrapperCss}` : `${innerWebSmallWrapperCss} ${innerWebTbPCWrapperCss}`}
92
92
  `}
93
93
  >
@@ -16,46 +16,57 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
16
16
  const [contentHeight, setContentHeight] = useState(210);
17
17
  const currentHeightRef = useRef(210);
18
18
  useEffect(() => {
19
- if (isMobile)
20
- return;
21
- let animationFrame;
22
- const animate = () => {
19
+ const updateContentHeight = () => {
23
20
  if (!wrapperRef.current)
24
21
  return;
25
- const { top } = wrapperRef.current.getBoundingClientRect();
26
- const gap = top;
27
- const current = currentHeightRef.current;
28
- let target = current;
29
- // 줄어드는 방향
30
- if (gap <= 20) {
31
- if (current > 140) {
32
- target = 140;
22
+ // 모바일이거나 width가 480px 미만이면 contentHeight를 210으로 되돌림
23
+ if (isMobile || window.innerWidth < 480) {
24
+ currentHeightRef.current = 210;
25
+ setContentHeight(210);
26
+ return;
27
+ }
28
+ const rect = wrapperRef.current.getBoundingClientRect();
29
+ const gap = rect.top;
30
+ const currentHeight = currentHeightRef.current;
31
+ // 줄어드는 애니메이션 (2단계)
32
+ if (gap <= 1) {
33
+ if (currentHeight > 140) {
34
+ // 1단계: 210 → 140
35
+ const next = Math.max(140, currentHeight - 6);
36
+ currentHeightRef.current = next;
37
+ setContentHeight(next);
33
38
  }
34
- else if (current > 80) {
35
- target = 80;
39
+ else if (currentHeight > 80) {
40
+ // 2단계: 140 → 80
41
+ const next = Math.max(80, currentHeight - 4);
42
+ currentHeightRef.current = next;
43
+ setContentHeight(next);
36
44
  }
37
45
  }
38
- // 늘어나는 방향
39
- else {
40
- if (current < 140) {
41
- target = 140;
46
+ // 다시 늘어나는 애니메이션 (2단계)
47
+ else if (gap > 1) {
48
+ if (currentHeight < 140) {
49
+ // 1단계: 80 → 140
50
+ const next = Math.min(140, currentHeight + 4);
51
+ currentHeightRef.current = next;
52
+ setContentHeight(next);
42
53
  }
43
- else if (current < 210) {
44
- target = 210;
54
+ else if (currentHeight < 210) {
55
+ // 2단계: 140 → 210
56
+ const next = Math.min(210, currentHeight + 6);
57
+ currentHeightRef.current = next;
58
+ setContentHeight(next);
45
59
  }
46
60
  }
47
- if (current !== target) {
48
- const diff = target - current;
49
- const step = diff > 0 ? Math.min(diff, 2) : Math.max(diff, -4); // 줄일 땐 -4px씩, 늘릴 땐 +2px씩
50
- const next = current + step;
51
- currentHeightRef.current = next;
52
- setContentHeight(next);
53
- }
54
- animationFrame = requestAnimationFrame(animate);
55
61
  };
56
- animationFrame = requestAnimationFrame(animate);
57
- return () => cancelAnimationFrame(animationFrame);
58
- }, [inquiryMainData]);
62
+ let rafId;
63
+ const loop = () => {
64
+ updateContentHeight();
65
+ rafId = requestAnimationFrame(loop);
66
+ };
67
+ rafId = requestAnimationFrame(loop);
68
+ return () => cancelAnimationFrame(rafId);
69
+ }, [isMobile, inquiryMainData]);
59
70
  useEffect(() => {
60
71
  checkScroll();
61
72
  }, [inquiryMainData]);
@@ -31,50 +31,61 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
31
31
  const currentHeightRef = useRef(210);
32
32
 
33
33
  useEffect(() => {
34
- if (isMobile) return;
35
- let animationFrame: number;
36
-
37
- const animate = () => {
34
+ const updateContentHeight = () => {
38
35
  if (!wrapperRef.current) return;
39
36
 
40
- const { top } = wrapperRef.current.getBoundingClientRect();
41
- const gap = top;
42
- const current = currentHeightRef.current;
43
-
44
- let target = current;
37
+ // 모바일이거나 width가 480px 미만이면 contentHeight를 210으로 되돌림
38
+ if (isMobile || window.innerWidth < 480) {
39
+ currentHeightRef.current = 210;
40
+ setContentHeight(210);
41
+ return;
42
+ }
45
43
 
46
- // 줄어드는 방향
47
- if (gap <= 20) {
48
- if (current > 140) {
49
- target = 140;
50
- } else if (current > 80) {
51
- target = 80;
44
+ const rect = wrapperRef.current.getBoundingClientRect();
45
+ const gap = rect.top;
46
+
47
+ const currentHeight = currentHeightRef.current;
48
+
49
+ // 줄어드는 애니메이션 (2단계)
50
+ if (gap <= 1) {
51
+ if (currentHeight > 140) {
52
+ // 1단계: 210 → 140
53
+ const next = Math.max(140, currentHeight - 6);
54
+ currentHeightRef.current = next;
55
+ setContentHeight(next);
56
+ } else if (currentHeight > 80) {
57
+ // 2단계: 140 → 80
58
+ const next = Math.max(80, currentHeight - 4);
59
+ currentHeightRef.current = next;
60
+ setContentHeight(next);
52
61
  }
53
62
  }
54
- // 늘어나는 방향
55
- else {
56
- if (current < 140) {
57
- target = 140;
58
- } else if (current < 210) {
59
- target = 210;
63
+ // 다시 늘어나는 애니메이션 (2단계)
64
+ else if (gap > 1) {
65
+ if (currentHeight < 140) {
66
+ // 1단계: 80 → 140
67
+ const next = Math.min(140, currentHeight + 4);
68
+ currentHeightRef.current = next;
69
+ setContentHeight(next);
70
+ } else if (currentHeight < 210) {
71
+ // 2단계: 140 → 210
72
+ const next = Math.min(210, currentHeight + 6);
73
+ currentHeightRef.current = next;
74
+ setContentHeight(next);
60
75
  }
61
76
  }
77
+ };
62
78
 
63
- if (current !== target) {
64
- const diff = target - current;
65
- const step = diff > 0 ? Math.min(diff, 2) : Math.max(diff, -4); // 줄일 땐 -4px씩, 늘릴 땐 +2px씩
66
- const next = current + step;
67
-
68
- currentHeightRef.current = next;
69
- setContentHeight(next);
70
- }
71
-
72
- animationFrame = requestAnimationFrame(animate);
79
+ let rafId: number;
80
+ const loop = () => {
81
+ updateContentHeight();
82
+ rafId = requestAnimationFrame(loop);
73
83
  };
74
84
 
75
- animationFrame = requestAnimationFrame(animate);
76
- return () => cancelAnimationFrame(animationFrame);
77
- }, [inquiryMainData]);
85
+ rafId = requestAnimationFrame(loop);
86
+
87
+ return () => cancelAnimationFrame(rafId);
88
+ }, [isMobile, inquiryMainData]);
78
89
  useEffect(() => {
79
90
  checkScroll();
80
91
  }, [inquiryMainData]);
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  type NoticeMessageProps = {
3
3
  content: string;
4
+ isMobile: boolean;
4
5
  };
5
6
  declare const NoticeMessage: React.FC<NoticeMessageProps>;
6
7
  export default NoticeMessage;
@@ -1,9 +1,9 @@
1
1
  import React, { useState } from 'react';
2
2
  import NoticeIcon from '../../asset/images/daeryuntalk/notice.svg';
3
3
  import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
4
- const NoticeMessage = ({ content }) => {
4
+ const NoticeMessage = ({ content, isMobile }) => {
5
5
  const [isExpanded, setIsExpanded] = useState(false);
6
- return (<div className="bg-[#F7F7F7]/90 px-[20px] pb-[12px] pt-[8px] backdrop-blur-[4px]">
6
+ return (<div className={`bg-[#F7F7F7]/90 px-[20px] pb-[12px] pt-[8px] backdrop-blur-[4px]`}>
7
7
  <div className="flex items-start gap-[8px]">
8
8
  <div className="flex-shrink-0">
9
9
  <NoticeIcon width={24} height={24}/>