@daeryun/dr_components 0.8.69 → 0.8.70
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 +54 -25
- package/dist/components/Daeryuntalk/ChatConversation.tsx +84 -42
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.tsx +3 -1
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +6 -4
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +10 -5
- package/dist/components/Daeryuntalk/ChatInput.jsx +9 -7
- package/dist/components/Daeryuntalk/ChatInput.tsx +15 -12
- package/dist/components/Daeryuntalk/ChatWidget.jsx +15 -16
- package/dist/components/Daeryuntalk/ChatWidget.tsx +19 -20
- package/dist/components/Daeryuntalk/HistoryView.jsx +9 -3
- package/dist/components/Daeryuntalk/HistoryView.tsx +15 -3
- package/dist/components/Daeryuntalk/HomeView.jsx +73 -92
- package/dist/components/Daeryuntalk/HomeView.tsx +83 -103
- package/dist/components/Daeryuntalk/NavigationFooter.jsx +1 -1
- package/dist/components/Daeryuntalk/NavigationFooter.tsx +1 -1
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +1 -0
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +3 -3
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +4 -3
- package/dist/components/Daeryuntalk/ViewportHandler.d.ts +1 -1
- package/dist/components/Daeryuntalk/ViewportHandler.jsx +5 -23
- package/dist/components/Daeryuntalk/ViewportHandler.tsx +44 -30
- package/dist/components/common/integrate/index.d.ts +1 -1
- package/dist/styles/globals.css +369 -331
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
4
|
import Image from 'next/image';
|
|
3
5
|
import TimeIcon from '../../asset/images/daeryuntalk/time.svg';
|
|
4
6
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
@@ -6,8 +8,7 @@ import ShadowBox from './_ui/ShadowBox';
|
|
|
6
8
|
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
7
9
|
import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
|
|
8
10
|
import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
9
|
-
|
|
10
|
-
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
11
|
+
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk_home_bg.png';
|
|
11
12
|
import DaeryuntalkHomeLogo from '../../asset/images/daeryuntalk/home_bg_logo.png';
|
|
12
13
|
import CloseSvgIcon from '../../asset/images/daeryuntalk/close.svg';
|
|
13
14
|
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
@@ -21,183 +22,162 @@ interface IHomeViewProps {
|
|
|
21
22
|
onClose: () => void;
|
|
22
23
|
isHash: boolean;
|
|
23
24
|
}
|
|
25
|
+
|
|
24
26
|
const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClose, isHash }: IHomeViewProps) => {
|
|
25
27
|
const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow<HTMLDivElement>();
|
|
26
28
|
|
|
27
|
-
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
28
|
-
const [
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
30
|
+
const [contentHeight, setContentHeight] = useState(210);
|
|
31
|
+
const currentHeightRef = useRef(210);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (isMobile) return;
|
|
35
|
+
let animationFrame: number;
|
|
36
|
+
|
|
37
|
+
const animate = () => {
|
|
38
|
+
if (!wrapperRef.current) return;
|
|
39
|
+
|
|
40
|
+
const { top } = wrapperRef.current.getBoundingClientRect();
|
|
41
|
+
const gap = top;
|
|
42
|
+
const current = currentHeightRef.current;
|
|
43
|
+
|
|
44
|
+
let target = current;
|
|
45
|
+
|
|
46
|
+
// 줄어드는 방향
|
|
47
|
+
if (gap <= 20) {
|
|
48
|
+
if (current > 140) {
|
|
49
|
+
target = 140;
|
|
50
|
+
} else if (current > 80) {
|
|
51
|
+
target = 80;
|
|
52
|
+
}
|
|
39
53
|
}
|
|
40
|
-
//
|
|
54
|
+
// 늘어나는 방향
|
|
41
55
|
else {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setClampHeight(210);
|
|
56
|
+
if (current < 140) {
|
|
57
|
+
target = 140;
|
|
58
|
+
} else if (current < 210) {
|
|
59
|
+
target = 210;
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (wrapperRef.current) {
|
|
57
|
-
resizeObserver.observe(wrapperRef.current);
|
|
58
|
-
}
|
|
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;
|
|
59
67
|
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
currentHeightRef.current = next;
|
|
69
|
+
setContentHeight(next);
|
|
70
|
+
}
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
resizeObserver.disconnect();
|
|
65
|
-
window.removeEventListener('resize', updateDistance);
|
|
72
|
+
animationFrame = requestAnimationFrame(animate);
|
|
66
73
|
};
|
|
67
|
-
}, []);
|
|
68
74
|
|
|
75
|
+
animationFrame = requestAnimationFrame(animate);
|
|
76
|
+
return () => cancelAnimationFrame(animationFrame);
|
|
77
|
+
}, [inquiryMainData]);
|
|
69
78
|
useEffect(() => {
|
|
70
79
|
checkScroll();
|
|
71
80
|
}, [inquiryMainData]);
|
|
72
|
-
// 아직 커버이미지 url이 안나옴
|
|
73
|
-
const backgroundImage = inquiryMainData?.sleeve_image_url ? inquiryMainData.sleeve_image_url : DaeryuntalkIntro;
|
|
74
81
|
|
|
82
|
+
const backgroundImage = inquiryMainData?.sleeve_image_url || DaeryuntalkIntro;
|
|
75
83
|
return (
|
|
76
|
-
// 중간 부분에 min-h-[80px]이 되면 여기서 스크롤이 생겨야함
|
|
77
84
|
<div
|
|
78
85
|
ref={wrapperRef}
|
|
79
86
|
className={`
|
|
80
|
-
relative w-full
|
|
81
|
-
${
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
no-scrollbar relative w-full rounded-t-[30px]
|
|
88
|
+
${
|
|
89
|
+
isMobile
|
|
90
|
+
? 'flex h-[calc(100dvh-64px)] flex-col items-center justify-between '
|
|
91
|
+
: 'flex h-[100vh] flex-col items-center justify-between xs:h-[calc(100vh-165px-64px)] lg:h-[calc(100vh-110px-64px)] ' +
|
|
92
|
+
' xs:max-h-[626px] xs:min-h-[320px] '
|
|
93
|
+
}
|
|
94
|
+
`}
|
|
86
95
|
>
|
|
87
|
-
<header
|
|
88
|
-
className=
|
|
89
|
-
z-10
|
|
90
|
-
flex h-[56px] w-full justify-between px-[20px]
|
|
91
|
-
`}
|
|
92
|
-
>
|
|
93
|
-
<div
|
|
94
|
-
className={`
|
|
95
|
-
dr_talk_subtitle_small flex items-center gap-[2px] pt-[31.5px] text-drTalkGrayscale1
|
|
96
|
-
`}
|
|
97
|
-
>
|
|
96
|
+
<header className="z-10 flex h-[56px] w-full justify-between rounded-t-[30px] px-[20px]">
|
|
97
|
+
<div className="dr_talk_subtitle_small flex items-center gap-[2px] pt-[31.5px] text-drTalkGrayscale1">
|
|
98
98
|
<TimeIcon width={20} height={20} />
|
|
99
|
-
<span>24시간
|
|
99
|
+
<span>24시간 운영</span>
|
|
100
100
|
</div>
|
|
101
101
|
<div
|
|
102
|
-
className={`${isHash ? 'pointer-events-none !opacity-0' : ''} ${isMobile ? 'block' : '
|
|
102
|
+
className={`${isHash ? 'pointer-events-none !opacity-0' : ''} ${isMobile ? 'block' : 'xs:pointer-events-none xs:!opacity-0'} py-[14px] text-drTalkGrayscale2 hover:cursor-pointer`}
|
|
103
103
|
onClick={onClose}
|
|
104
104
|
>
|
|
105
105
|
<CloseSvgIcon width={28} height={28} />
|
|
106
106
|
</div>
|
|
107
107
|
</header>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
</div>
|
|
111
|
-
<div className={'absolute left-0 top-0 z-0 h-full w-full overflow-hidden'}>
|
|
108
|
+
|
|
109
|
+
<div className="absolute left-0 top-0 z-0 h-full w-full overflow-hidden">
|
|
112
110
|
<Image
|
|
113
111
|
src={backgroundImage}
|
|
114
112
|
alt="대화 배경"
|
|
115
113
|
fill
|
|
116
|
-
className={
|
|
117
|
-
|
|
114
|
+
className={`${
|
|
115
|
+
isMobile
|
|
116
|
+
? 'h-full max-h-[360px] w-full object-center will-change-transform'
|
|
117
|
+
: 'w-full object-contain object-top will-change-transform'
|
|
118
|
+
}`}
|
|
118
119
|
/>
|
|
119
120
|
</div>
|
|
120
121
|
|
|
121
122
|
<div
|
|
122
|
-
className={`
|
|
123
|
-
relative z-10 px-[20px]
|
|
124
|
-
${
|
|
125
|
-
isMobile
|
|
126
|
-
? `flex w-full justify-center `
|
|
127
|
-
: `
|
|
128
|
-
flex h-full w-full flex-col justify-center
|
|
129
|
-
`
|
|
130
|
-
}
|
|
131
|
-
`}
|
|
123
|
+
className={`relative z-10 px-[20px] ${isMobile ? 'flex w-full justify-center' : 'flex h-full w-full flex-col justify-center'}`}
|
|
132
124
|
>
|
|
133
125
|
<section
|
|
134
|
-
className={`
|
|
135
|
-
|
|
136
|
-
${isMobile ? `w-full` : ``}
|
|
137
|
-
`}
|
|
138
|
-
style={{
|
|
139
|
-
boxShadow: '0px 4px 10px 0px #00000026'
|
|
140
|
-
}}
|
|
126
|
+
className={`flex flex-col rounded-[12px] bg-white px-[16px] py-[24px] ${isMobile ? 'w-full' : ''}`}
|
|
127
|
+
style={{ boxShadow: '0px 4px 10px 0px #00000026' }}
|
|
141
128
|
>
|
|
142
|
-
|
|
143
|
-
|
|
129
|
+
{/* 해당 컴포넌트의 최상위 부모와 브라우저 상단과 닿았을 때 우선적으로 해당 부분의 높이가 먼저 줄어들게 하고 싶다*/}
|
|
130
|
+
<div className="relative">
|
|
144
131
|
<div
|
|
145
132
|
ref={containerRef}
|
|
146
|
-
className=
|
|
147
|
-
|
|
148
|
-
`}
|
|
149
|
-
style={{
|
|
150
|
-
height: `${clampHeight}px`
|
|
151
|
-
}}
|
|
133
|
+
className="no-scrollbar flex max-h-[210px] min-h-[80px] flex-col overflow-auto"
|
|
134
|
+
style={{ maxHeight: `${contentHeight}px` }}
|
|
152
135
|
>
|
|
153
|
-
<div className=
|
|
136
|
+
<div className="flex items-center gap-[10px]">
|
|
154
137
|
{inquiryMainData?.channel_logo_image_url ? (
|
|
155
138
|
<Image
|
|
156
139
|
src={inquiryMainData.channel_logo_image_url}
|
|
157
140
|
alt="로고"
|
|
158
141
|
width={32}
|
|
159
142
|
height={32}
|
|
160
|
-
className={''}
|
|
161
143
|
/>
|
|
162
144
|
) : (
|
|
163
145
|
<DaeryunLogoIcon width={24} height={24} className="mr-2" />
|
|
164
146
|
)}
|
|
165
|
-
<h1 className=
|
|
147
|
+
<h1 className="dr_talk_title_small text-drTalkBlack">
|
|
166
148
|
{inquiryMainData?.channel_name || '법무법인(유한)대륜'}
|
|
167
149
|
</h1>
|
|
168
150
|
</div>
|
|
169
|
-
<div className=
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
`안녕하세요.
|
|
151
|
+
<div className="dr_talk_body_medium2 relative ml-[42px] mr-[16px] mt-[16px] whitespace-pre-line">
|
|
152
|
+
{inquiryMainData?.salutation ||
|
|
153
|
+
`안녕하세요.
|
|
173
154
|
법무법인(유한)대륜입니다.
|
|
174
155
|
방문해 주셔서 감사합니다.\n
|
|
175
156
|
궁금한 점이나 도움이 필요하신 부분
|
|
176
157
|
말씀해 주시면 도와드리겠습니다.
|
|
177
158
|
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
|
|
178
|
-
|
|
179
|
-
</div>
|
|
159
|
+
`}
|
|
180
160
|
</div>
|
|
181
161
|
</div>
|
|
182
162
|
{isScroll && !isBottom && <ShadowBox />}
|
|
183
163
|
</div>
|
|
184
164
|
|
|
185
|
-
<Button3 onClick={handleStartChat} isDisabled={isLoading} className=
|
|
186
|
-
<div className=
|
|
165
|
+
<Button3 onClick={handleStartChat} isDisabled={isLoading} className="mt-[40px]">
|
|
166
|
+
<div className="flex items-center justify-center gap-[4px]">
|
|
187
167
|
<div>{isLoading ? '로딩 중...' : '문의하기'}</div>
|
|
188
168
|
{!isLoading && <SendIcon width={24} height={24} />}
|
|
189
169
|
</div>
|
|
190
170
|
</Button3>
|
|
191
171
|
|
|
192
|
-
<div className=
|
|
172
|
+
<div className="flex items-center justify-center gap-[4px] pt-[20px]">
|
|
193
173
|
<InfoIcon width={20} height={20} />
|
|
194
|
-
<span className=
|
|
174
|
+
<span className="dr_talk_body_small1 text-drTalkGrayscale2">
|
|
195
175
|
{inquiryMainData?.answer_speed_message || '빠르게 답변 받으실 수 있어요'}
|
|
196
176
|
</span>
|
|
197
177
|
</div>
|
|
198
178
|
</section>
|
|
199
179
|
</div>
|
|
200
|
-
{isMobile && <div
|
|
180
|
+
{isMobile && <div />}
|
|
201
181
|
</div>
|
|
202
182
|
);
|
|
203
183
|
};
|
|
@@ -5,7 +5,7 @@ const NavigationFooter = ({ activeView, onHomeClick, onHistoryClick, historyList
|
|
|
5
5
|
if (activeView === 'conversation') {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
|
-
return (<footer>
|
|
8
|
+
return (<footer className={`z-10`}>
|
|
9
9
|
<div className="h-px w-full bg-drTalkGrayscale4" role="separator"></div>
|
|
10
10
|
<nav className={' flex h-[64px] justify-around px-8 pb-[12px] pt-[8px]'}>
|
|
11
11
|
<div className={`group flex cursor-pointer flex-col items-center ${activeView === 'home' ? 'text-drTalkCrimson' : 'text-gray-400 hover:text-drTalkCrimson'}`} role="button" tabIndex={0} onClick={onHomeClick}>
|
|
@@ -22,7 +22,7 @@ const NavigationFooter: React.FC<NavigationFooterProps> = ({
|
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
return (
|
|
25
|
-
<footer>
|
|
25
|
+
<footer className={`z-10`}>
|
|
26
26
|
<div className="h-px w-full bg-drTalkGrayscale4" role="separator"></div>
|
|
27
27
|
<nav className={' flex h-[64px] justify-around px-8 pb-[12px] pt-[8px]'}>
|
|
28
28
|
<div
|
|
@@ -12,6 +12,7 @@ interface TiptapProps {
|
|
|
12
12
|
placeholder?: string;
|
|
13
13
|
onEnterKeyPress?: () => void;
|
|
14
14
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
15
|
+
contentClassName?: string;
|
|
15
16
|
}
|
|
16
17
|
declare const Tiptap: import("react").ForwardRefExoticComponent<TiptapProps & import("react").RefAttributes<TiptapEditorRef>>;
|
|
17
18
|
export default Tiptap;
|
|
@@ -5,7 +5,7 @@ import HardBreak from '@tiptap/extension-hard-break'; // 추가
|
|
|
5
5
|
import Document from '@tiptap/extension-document';
|
|
6
6
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
7
7
|
import Text from '@tiptap/extension-text';
|
|
8
|
-
const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown }, ref) => {
|
|
8
|
+
const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown, contentClassName = '' }, ref) => {
|
|
9
9
|
const editor = useEditor({
|
|
10
10
|
extensions: [
|
|
11
11
|
Document,
|
|
@@ -36,7 +36,7 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
36
36
|
},
|
|
37
37
|
editorProps: {
|
|
38
38
|
attributes: {
|
|
39
|
-
class:
|
|
39
|
+
class: `dr_talk_body_medium2 focus:outline-none min-h-[36px] max-h-[72px] overflow-y-auto resize-none pt-[6px] pb-[4px] break-words whitespace-pre-wrap word-wrap break-word overflow-wrap-anywhere no-scrollbar `
|
|
40
40
|
},
|
|
41
41
|
handleKeyDown: (view, event) => {
|
|
42
42
|
if (event.key === 'Enter') {
|
|
@@ -91,7 +91,7 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
91
91
|
if (!editor)
|
|
92
92
|
return null;
|
|
93
93
|
// return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white" />;
|
|
94
|
-
return (<EditorContent editor={editor} tabIndex={0} className=
|
|
94
|
+
return (<EditorContent editor={editor} tabIndex={0} className={`${contentClassName} w-full overflow-hidden rounded-md border text-black dark:text-white`}/>);
|
|
95
95
|
});
|
|
96
96
|
Tiptap.displayName = 'Tiptap';
|
|
97
97
|
export default Tiptap;
|
|
@@ -22,10 +22,11 @@ interface TiptapProps {
|
|
|
22
22
|
placeholder?: string;
|
|
23
23
|
onEnterKeyPress?: () => void;
|
|
24
24
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
25
|
+
contentClassName?: string;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
28
|
-
({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown }, ref) => {
|
|
29
|
+
({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown, contentClassName = '' }, ref) => {
|
|
29
30
|
const editor = useEditor({
|
|
30
31
|
extensions: [
|
|
31
32
|
Document,
|
|
@@ -56,7 +57,7 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
56
57
|
},
|
|
57
58
|
editorProps: {
|
|
58
59
|
attributes: {
|
|
59
|
-
class:
|
|
60
|
+
class: `dr_talk_body_medium2 focus:outline-none min-h-[36px] max-h-[72px] overflow-y-auto resize-none pt-[6px] pb-[4px] break-words whitespace-pre-wrap word-wrap break-word overflow-wrap-anywhere no-scrollbar `
|
|
60
61
|
},
|
|
61
62
|
handleKeyDown: (view, event) => {
|
|
62
63
|
if (event.key === 'Enter') {
|
|
@@ -118,7 +119,7 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
118
119
|
<EditorContent
|
|
119
120
|
editor={editor}
|
|
120
121
|
tabIndex={0}
|
|
121
|
-
className=
|
|
122
|
+
className={`${contentClassName} w-full overflow-hidden rounded-md border text-black dark:text-white`}
|
|
122
123
|
/>
|
|
123
124
|
);
|
|
124
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function ViewportHandler():
|
|
1
|
+
export default function ViewportHandler(): import("react").JSX.Element;
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
2
|
+
'use client';
|
|
3
|
+
import Head from 'next/head';
|
|
3
4
|
export default function ViewportHandler() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function updateViewport() {
|
|
8
|
-
const viewportMeta = document.querySelector('meta[name="viewport"]');
|
|
9
|
-
if (!viewportMeta)
|
|
10
|
-
return;
|
|
11
|
-
if (window.screen.width < 360) {
|
|
12
|
-
const scale = window.screen.width / 360;
|
|
13
|
-
viewportMeta.setAttribute('content', `width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
updateViewport();
|
|
17
|
-
// cleanup: 원래 상태로 복원
|
|
18
|
-
return () => {
|
|
19
|
-
const viewportMeta = document.querySelector('meta[name="viewport"]');
|
|
20
|
-
if (viewportMeta && originalContent) {
|
|
21
|
-
viewportMeta.setAttribute('content', originalContent);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}, []);
|
|
25
|
-
return null;
|
|
5
|
+
return (<Head>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
|
7
|
+
</Head>);
|
|
26
8
|
}
|
|
@@ -1,35 +1,49 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
'use client';
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
+
import Head from 'next/head';
|
|
4
5
|
|
|
5
6
|
export default function ViewportHandler() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (window.screen.width < 360) {
|
|
15
|
-
const scale = window.screen.width / 360;
|
|
16
|
-
viewportMeta.setAttribute(
|
|
17
|
-
'content',
|
|
18
|
-
`width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
updateViewport();
|
|
24
|
-
|
|
25
|
-
// cleanup: 원래 상태로 복원
|
|
26
|
-
return () => {
|
|
27
|
-
const viewportMeta = document.querySelector('meta[name="viewport"]') as HTMLMetaElement;
|
|
28
|
-
if (viewportMeta && originalContent) {
|
|
29
|
-
viewportMeta.setAttribute('content', originalContent);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
|
-
return null;
|
|
7
|
+
return (
|
|
8
|
+
<Head>
|
|
9
|
+
<meta
|
|
10
|
+
name="viewport"
|
|
11
|
+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
|
12
|
+
/>
|
|
13
|
+
</Head>
|
|
14
|
+
);
|
|
35
15
|
}
|
|
16
|
+
|
|
17
|
+
// import { useEffect } from 'react';
|
|
18
|
+
//
|
|
19
|
+
// export default function ViewportHandler() {
|
|
20
|
+
// useEffect(() => {
|
|
21
|
+
// const originalContent = document.querySelector('meta[name="viewport"]')?.getAttribute('content');
|
|
22
|
+
//
|
|
23
|
+
// function updateViewport() {
|
|
24
|
+
// const viewportMeta = document.querySelector('meta[name="viewport"]') as HTMLMetaElement;
|
|
25
|
+
//
|
|
26
|
+
// if (!viewportMeta) return;
|
|
27
|
+
//
|
|
28
|
+
// if (window.screen.width < 360) {
|
|
29
|
+
// const scale = window.screen.width / 360;
|
|
30
|
+
// viewportMeta.setAttribute(
|
|
31
|
+
// 'content',
|
|
32
|
+
// `width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`
|
|
33
|
+
// );
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
//
|
|
37
|
+
// updateViewport();
|
|
38
|
+
//
|
|
39
|
+
// // cleanup: 원래 상태로 복원
|
|
40
|
+
// return () => {
|
|
41
|
+
// const viewportMeta = document.querySelector('meta[name="viewport"]') as HTMLMetaElement;
|
|
42
|
+
// if (viewportMeta && originalContent) {
|
|
43
|
+
// viewportMeta.setAttribute('content', originalContent);
|
|
44
|
+
// }
|
|
45
|
+
// };
|
|
46
|
+
// }, []);
|
|
47
|
+
//
|
|
48
|
+
// return null;
|
|
49
|
+
// }
|