@daeryun/dr_components 0.8.70 → 0.8.72
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.
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatConversation.jsx +99 -7
- package/dist/components/Daeryuntalk/ChatConversation.tsx +128 -27
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +2 -2
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +2 -2
- package/dist/components/Daeryuntalk/ChatInput.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatInput.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatWidget.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatWidget.tsx +1 -1
- package/dist/components/Daeryuntalk/HomeView.jsx +42 -31
- package/dist/components/Daeryuntalk/HomeView.tsx +45 -34
- package/dist/components/Daeryuntalk/NoticeMessage.d.ts +1 -0
- package/dist/components/Daeryuntalk/NoticeMessage.jsx +2 -2
- package/dist/components/Daeryuntalk/NoticeMessage.tsx +3 -2
- package/dist/components/Daeryuntalk/_hooks/useWindowSize.d.ts +6 -0
- package/dist/components/Daeryuntalk/_hooks/useWindowSize.js +20 -0
- package/dist/components/Daeryuntalk/_hooks/useWindowSize.ts +30 -0
- package/dist/components/page/Integrate/Lawyer.jsx +2 -2
- package/dist/components/page/Integrate/Lawyer.tsx +9 -5
- package/dist/styles/globals.css +29 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
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={
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
<
|
|
229
|
+
<div ref={noticeRef}>
|
|
230
|
+
<NoticeMessage content={noticeContent} isMobile={isMobile} />
|
|
231
|
+
</div>
|
|
136
232
|
{/* 메시지 노출 부분 -> 무한스크롤 변환 필요 */}
|
|
233
|
+
{/* 여기서 isMpblie일때 위에 2개 헤더부분이랑 아래 메시지 입력이랑 높이를 빼서 넣어야한ㄷ */}
|
|
137
234
|
<div
|
|
138
|
-
className={`${isMobile ? '
|
|
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
|
-
|
|
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
|
|
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
|
|
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-[
|
|
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-[
|
|
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
|
-
|
|
20
|
-
return;
|
|
21
|
-
let animationFrame;
|
|
22
|
-
const animate = () => {
|
|
19
|
+
const updateContentHeight = () => {
|
|
23
20
|
if (!wrapperRef.current)
|
|
24
21
|
return;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 (
|
|
35
|
-
|
|
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 (
|
|
41
|
-
|
|
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 (
|
|
44
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
35
|
-
let animationFrame: number;
|
|
36
|
-
|
|
37
|
-
const animate = () => {
|
|
34
|
+
const updateContentHeight = () => {
|
|
38
35
|
if (!wrapperRef.current) return;
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
rafId = requestAnimationFrame(loop);
|
|
86
|
+
|
|
87
|
+
return () => cancelAnimationFrame(rafId);
|
|
88
|
+
}, [isMobile, inquiryMainData]);
|
|
78
89
|
useEffect(() => {
|
|
79
90
|
checkScroll();
|
|
80
91
|
}, [inquiryMainData]);
|
|
@@ -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=
|
|
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}/>
|
|
@@ -5,13 +5,14 @@ import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
|
5
5
|
|
|
6
6
|
type NoticeMessageProps = {
|
|
7
7
|
content: string;
|
|
8
|
+
isMobile: boolean;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
const NoticeMessage: React.FC<NoticeMessageProps> = ({ content }) => {
|
|
11
|
+
const NoticeMessage: React.FC<NoticeMessageProps> = ({ content, isMobile }) => {
|
|
11
12
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
|
-
<div className=
|
|
15
|
+
<div className={`bg-[#F7F7F7]/90 px-[20px] pb-[12px] pt-[8px] backdrop-blur-[4px]`}>
|
|
15
16
|
<div className="flex items-start gap-[8px]">
|
|
16
17
|
<div className="flex-shrink-0">
|
|
17
18
|
<NoticeIcon width={24} height={24} />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export const useWindowSize = () => {
|
|
3
|
+
const [windowSize, setWindowSize] = useState({
|
|
4
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
5
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 0
|
|
6
|
+
});
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const handleResize = () => {
|
|
9
|
+
setWindowSize({
|
|
10
|
+
width: window.innerWidth,
|
|
11
|
+
height: window.innerHeight
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
// 초기 실행
|
|
15
|
+
handleResize();
|
|
16
|
+
window.addEventListener('resize', handleResize);
|
|
17
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
18
|
+
}, []);
|
|
19
|
+
return windowSize;
|
|
20
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
type WindowSize = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const useWindowSize = (): WindowSize => {
|
|
9
|
+
const [windowSize, setWindowSize] = useState<WindowSize>({
|
|
10
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 0,
|
|
11
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 0
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const handleResize = () => {
|
|
16
|
+
setWindowSize({
|
|
17
|
+
width: window.innerWidth,
|
|
18
|
+
height: window.innerHeight
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 초기 실행
|
|
23
|
+
handleResize();
|
|
24
|
+
|
|
25
|
+
window.addEventListener('resize', handleResize);
|
|
26
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
return windowSize;
|
|
30
|
+
};
|
|
@@ -95,7 +95,7 @@ const IntegrateLawyer = (props) => {
|
|
|
95
95
|
pathname: '/lawyer/' + item.id,
|
|
96
96
|
query: search != '' ? { integrate_search: search } : {}
|
|
97
97
|
}} tabIndex={-1}>
|
|
98
|
-
<div className={'relative flex items-center justify-center '}>
|
|
98
|
+
<div className={'relative flex aspect-[0.818] w-full items-center justify-center overflow-hidden sm:aspect-[0.874]'}>
|
|
99
99
|
<Image src={`${process.env.NEXT_PUBLIC_S3_URL}/lawyer/list_bg${fixBg ? '3' : isEven ? '' : '2'}.webp`} alt={'변호사 리스트 배경'} fill className={'object-cover'}/>
|
|
100
100
|
<Image loading={'lazy'} src={lawyerImagePath + '/' + item.nukki} alt={item.careers &&
|
|
101
101
|
item.careers.indexOf(selectedFilter) > -1 &&
|
|
@@ -105,7 +105,7 @@ const IntegrateLawyer = (props) => {
|
|
|
105
105
|
item.careers.indexOf(selectedFilter) > -1 &&
|
|
106
106
|
selectedFilter !== '전체'
|
|
107
107
|
? `${selectedFilter}전문변호사 ${item.name} ${item.code}`
|
|
108
|
-
: `${item.name} ${item.code}`}
|
|
108
|
+
: `${item.name} ${item.code}`} fill sizes="(max-width: 639px) 45vw, 307px" className={'z-10 translate-y-4 scale-95 object-contain'} unoptimized/>
|
|
109
109
|
{item.mark ? (<Mark type={item.mark} color={'white'} className={'absolute bottom-[15px] right-[15px] z-20 h-auto w-[25%]'}/>) : (<></>)}
|
|
110
110
|
</div>
|
|
111
111
|
</Link>
|
|
@@ -182,7 +182,11 @@ const IntegrateLawyer = (props: {
|
|
|
182
182
|
}}
|
|
183
183
|
tabIndex={-1}
|
|
184
184
|
>
|
|
185
|
-
<div
|
|
185
|
+
<div
|
|
186
|
+
className={
|
|
187
|
+
'relative flex aspect-[0.818] w-full items-center justify-center overflow-hidden sm:aspect-[0.874]'
|
|
188
|
+
}
|
|
189
|
+
>
|
|
186
190
|
<Image
|
|
187
191
|
src={`${process.env.NEXT_PUBLIC_S3_URL}/lawyer/list_bg${fixBg ? '3' : isEven ? '' : '2'}.webp`}
|
|
188
192
|
alt={'변호사 리스트 배경'}
|
|
@@ -206,10 +210,10 @@ const IntegrateLawyer = (props: {
|
|
|
206
210
|
? `${selectedFilter}전문변호사 ${item.name} ${item.code}`
|
|
207
211
|
: `${item.name} ${item.code}`
|
|
208
212
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
className={'z-10
|
|
212
|
-
|
|
213
|
+
fill
|
|
214
|
+
sizes="(max-width: 639px) 45vw, 307px"
|
|
215
|
+
className={'z-10 translate-y-4 scale-95 object-contain'}
|
|
216
|
+
unoptimized
|
|
213
217
|
/>
|
|
214
218
|
{item.mark ? (
|
|
215
219
|
<Mark
|