@daeryun/dr_components 0.2.36 → 0.2.38

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.
@@ -1,285 +0,0 @@
1
- import React, { useEffect, useState, useRef, useCallback } from 'react';
2
- import Image from 'next/image';
3
- import { useRouter } from 'next/router';
4
- import Menu from './Menu';
5
- import { insert } from '../../lib';
6
- import { savePowerLinkConversion, saveTelNumber } from '../../lib';
7
- import Link from 'next/link';
8
- import * as gtag from '../../lib/gtag';
9
- import { removeScrollPos } from '../hook/useScrollRestoration';
10
- import Wrapper from '../Layout/Wrapper';
11
- import { IHeaderType } from '../../types/header';
12
-
13
- import Call from '../../asset/images/header/h_call_line.webp';
14
- import Call_b from '../../asset/images/header/h_call_line_b.webp';
15
- import H_menu from '../../asset/images/header/h_menu.webp';
16
- import H_menu_b from '../../asset/images/header/h_menu_b.webp';
17
-
18
- const Header = ({
19
- tel,
20
- setTel,
21
- footerTel,
22
- setFooterTel,
23
- logo,
24
- logo_w,
25
- routes,
26
- keywordArr,
27
- categoryType,
28
- doNotWrite,
29
- name,
30
- isBrochureBtn,
31
- isMedical
32
- }: IHeaderType) => {
33
- const router = useRouter();
34
- const mobile = require('is-mobile');
35
- const [isTop, setIsTop] = useState(true);
36
- const [isMain, setIsMain] = useState(true);
37
- const [isMobile, setIsMobile] = useState<boolean>(false);
38
- const [opacity, setOpacity] = useState<number>(0);
39
- const [menuToggle, setMenuToggle] = useState<boolean>(false);
40
- const timeoutRef = useRef<NodeJS.Timeout>();
41
-
42
- const headerRef = useRef<HTMLHtmlElement | null>(null);
43
-
44
- const setNaverLinkTel = () => {
45
- setTel('1660-1043');
46
- setFooterTel('1660 - 1043');
47
- };
48
-
49
- const setGoogleLinkTel = () => {
50
- setTel('1660-1028');
51
- setFooterTel('1660 - 1028');
52
- };
53
-
54
- const setResetTel = () => {
55
- setTel(tel);
56
- setFooterTel(footerTel);
57
- };
58
-
59
- const setYoutubeTel = () => {
60
- setTel('02-6958-6578');
61
- setFooterTel('02 - 6958 - 6578');
62
- };
63
-
64
- useEffect(() => {
65
- const is_mobile = mobile();
66
- saveTelNumber(is_mobile, setNaverLinkTel, setGoogleLinkTel, setYoutubeTel, setResetTel);
67
- }, []);
68
-
69
- const handleScroll = useCallback(() => {
70
- const scrollElm: Element | null = document.scrollingElement;
71
- if (scrollElm !== null) {
72
- const scrollTop: number = Math.max(scrollElm.scrollTop, document.body.scrollTop);
73
- if (scrollTop > 0) {
74
- setIsTop(false);
75
- } else {
76
- setIsTop(true);
77
- }
78
- }
79
- }, []);
80
-
81
- const topTelClick = () => {
82
- gtag.event({
83
- action: 'mobile_toptel',
84
- category: 'toptel',
85
- label: '모바일상단전화버튼',
86
- value: '1'
87
- });
88
- };
89
-
90
- const ace_ToptelClick = () => {
91
- try {
92
- // @ts-ignore
93
- AM_PL('/m_Toptel');
94
- } catch (e) {}
95
- };
96
-
97
- const handleMenuToggle = useCallback(
98
- (url?: string) => {
99
- if (!menuToggle) {
100
- timeoutRef.current = setInterval(() => {
101
- setOpacity(prev => prev + 0.2);
102
- }, 40);
103
- } else {
104
- setOpacity(0);
105
- clearInterval(timeoutRef.current);
106
- }
107
- setMenuToggle(prev => !prev);
108
- if (url) {
109
- removeScrollPos(url);
110
- }
111
- },
112
- [menuToggle]
113
- );
114
- const handleKeyPress = (e: any) => {
115
- if (e.key === 'Enter') {
116
- handleMenuToggle();
117
- }
118
- };
119
-
120
- useEffect(() => {
121
- const isRootPath = router.pathname === '/';
122
- const isStrengthPath = router.pathname === '/strength';
123
- const isIntroPath = router.pathname === '/intro';
124
-
125
- const conditionMap: { [key: string]: boolean[] } = {
126
- main: [isRootPath, isStrengthPath],
127
- divorce: [(isRootPath || isStrengthPath) && !doNotWrite],
128
- assault: [(isRootPath || isStrengthPath) && !doNotWrite],
129
- medical: [(isRootPath || isStrengthPath) && !doNotWrite],
130
- detective: [isRootPath, isIntroPath],
131
- labor: [isRootPath, isIntroPath],
132
- trade: [isRootPath, isIntroPath],
133
- comp: [isRootPath, isStrengthPath, router.pathname === '/advice', router.pathname === '/management'],
134
- school: [isRootPath],
135
- discovery: [isRootPath],
136
- tax: [isRootPath],
137
- inherit: [isRootPath],
138
- estate: [isStrengthPath],
139
- military: [isStrengthPath],
140
- accounting: [isRootPath && !doNotWrite],
141
- traffic: [isRootPath, isStrengthPath, isIntroPath],
142
- consulting: [isStrengthPath],
143
- entertainment: [isRootPath && !doNotWrite]
144
- };
145
-
146
- const checkCondition = () => {
147
- const conditions = conditionMap[name];
148
- return conditions ? conditions.some(Boolean) : false;
149
- };
150
-
151
- if (checkCondition()) {
152
- setIsTop(true);
153
- setIsMain(true);
154
- document.addEventListener('scroll', handleScroll);
155
- return () => {
156
- document.removeEventListener('scroll', handleScroll);
157
- };
158
- } else {
159
- setIsMain(true);
160
- setIsTop(false);
161
- }
162
- }, [handleScroll, router.pathname]);
163
-
164
- useEffect(() => {
165
- setIsMobile(mobile());
166
- }, []);
167
-
168
- useEffect(() => {
169
- const pathsToExclude: {
170
- mainStrength: string[];
171
- strength: string[];
172
- mainIntro: string[];
173
- introStrength: string[];
174
- main: string[];
175
- } = {
176
- mainStrength: ['/', '/strength'],
177
- strength: ['/strength'],
178
- mainIntro: ['/', '/intro'],
179
- introStrength: ['/', '/strength', '/intro'],
180
- main: ['/']
181
- };
182
-
183
- const shouldSetStates =
184
- //@ts-ignore
185
- categoryType in pathsToExclude && !pathsToExclude[categoryType].includes(router.pathname);
186
-
187
- if (shouldSetStates) {
188
- setIsTop(false);
189
- setIsMain(false);
190
- }
191
- }, [router.pathname, categoryType]);
192
-
193
- useEffect(() => {
194
- if (opacity > 1) {
195
- clearInterval(timeoutRef.current);
196
- }
197
- }, [opacity]);
198
-
199
- return (
200
- <>
201
- <header
202
- ref={headerRef}
203
- className={
204
- 'fixed top-0 z-[3000] h-[90px] w-full bg-white font-[SUIT] max-md2:h-[80px] max-md:h-[70px] ' +
205
- (isMain
206
- ? isTop
207
- ? ' bg-opacity-0 '
208
- : ' bg-opacity-90 shadow-sm'
209
- : 'border-b-[2px] border-solid border-[#e5e7eb] bg-opacity-100')
210
- }
211
- >
212
- <Wrapper className={'flex h-full items-center justify-between'}>
213
- <Link href={`/`} className={'block'}>
214
- <Image
215
- src={isTop ? logo_w : logo}
216
- alt={`${process.env.NEXT_PUBLIC_KEYWORD}전문변호사 로고`}
217
- width={348}
218
- height={70}
219
- priority
220
- property={'eager'}
221
- className={'h-[36px] w-auto max-md2:h-[32px] max-md:h-[28px]'}
222
- />
223
- </Link>
224
-
225
- <div className={'flex h-full items-center'}>
226
- <Link
227
- href={`tel:${tel}`}
228
- onClick={() => {
229
- insert('call', isMobile);
230
- savePowerLinkConversion('call', isMobile);
231
- topTelClick();
232
- ace_ToptelClick();
233
- }}
234
- aria-label={'tel'}
235
- className={
236
- 'flex items-center gap-[18px] text-[20px] font-[800] leading-none tracking-[-0.4px] max-md2:gap-[10px] max-md2:text-[18px] max-md:text-[16px] max-xs:hidden ' +
237
- (isTop ? 'text-white' : '')
238
- }
239
- >
240
- <Image
241
- src={isTop ? Call : Call_b}
242
- alt={'tel'}
243
- width={76}
244
- height={76}
245
- className={
246
- 'h-[38px] w-[38px] max-md2:h-[36px] max-md2:w-[36px] max-md:h-[32px] max-md:w-[32px] '
247
- }
248
- />
249
- {tel}
250
- </Link>
251
-
252
- <Menu
253
- menuToggle={menuToggle}
254
- handleMenuToggle={handleMenuToggle}
255
- opacity={opacity}
256
- routes={routes}
257
- tel={tel}
258
- logo={logo}
259
- keywordArr={keywordArr}
260
- isBrochureBtn={isBrochureBtn}
261
- isMedical={isMedical}
262
- />
263
-
264
- {!menuToggle && (
265
- <Image
266
- onKeyDown={handleKeyPress}
267
- tabIndex={0}
268
- src={isTop ? H_menu : H_menu_b}
269
- alt="메뉴바"
270
- width={38}
271
- height={17}
272
- className={
273
- 'z-10 ml-[40px] h-auto w-[28px] cursor-pointer max-md2:w-[25px] max-md:ml-[30px] max-md:w-[22px]'
274
- }
275
- onClick={() => handleMenuToggle()}
276
- />
277
- )}
278
- </div>
279
- </Wrapper>
280
- </header>
281
- </>
282
- );
283
- };
284
-
285
- export default Header;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { IMenuType } from '../../types/header';
3
- declare const Menu: ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo, isBrochureBtn, isMedical }: IMenuType) => React.JSX.Element;
4
- export default Menu;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import MobileMenu from './MobileMenu';
3
- import PCMenu from './PCMenu';
4
- const Menu = ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo, isBrochureBtn, isMedical }) => {
5
- return (<>
6
- <MobileMenu logo={logo} handleMenuToggle={handleMenuToggle} opacity={opacity} menuToggle={menuToggle} routes={routes} tel={tel} keywordArr={keywordArr} isBrochureBtn={isBrochureBtn} isMedical={isMedical}/>
7
- <PCMenu handleMenuToggle={handleMenuToggle} opacity={opacity} menuToggle={menuToggle} routes={routes} tel={tel} isBrochureBtn={isBrochureBtn} isMedical={isMedical}/>
8
- </>);
9
- };
10
- export default Menu;
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import MobileMenu from './MobileMenu';
3
- import PCMenu from './PCMenu';
4
- import { IMenuType } from '../../types/header';
5
-
6
- const Menu = ({
7
- handleMenuToggle,
8
- opacity,
9
- menuToggle,
10
- routes,
11
- tel,
12
- keywordArr,
13
- logo,
14
- isBrochureBtn,
15
- isMedical
16
- }: IMenuType) => {
17
- return (
18
- <>
19
- <MobileMenu
20
- logo={logo}
21
- handleMenuToggle={handleMenuToggle}
22
- opacity={opacity}
23
- menuToggle={menuToggle}
24
- routes={routes}
25
- tel={tel}
26
- keywordArr={keywordArr}
27
- isBrochureBtn={isBrochureBtn}
28
- isMedical={isMedical}
29
- />
30
- <PCMenu
31
- handleMenuToggle={handleMenuToggle}
32
- opacity={opacity}
33
- menuToggle={menuToggle}
34
- routes={routes}
35
- tel={tel}
36
- isBrochureBtn={isBrochureBtn}
37
- isMedical={isMedical}
38
- />
39
- </>
40
- );
41
- };
42
-
43
- export default Menu;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { IMobileMenuType } from '../../types/header';
3
- declare const MobileMenu: ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo, isBrochureBtn, isMedical }: IMobileMenuType) => React.JSX.Element;
4
- export default MobileMenu;
@@ -1,209 +0,0 @@
1
- import Link from 'next/link';
2
- import React, { useEffect, useState } from 'react';
3
- import Image from 'next/image';
4
- import { insert } from '../../lib';
5
- import * as gtag from '../../lib/gtag';
6
- import { useRouter } from 'next/router';
7
- import { savePowerLinkConversion } from '../../lib';
8
- import MyCase from '../myCase/MyCase';
9
- import Menu_x from '../../asset/images/header/menu_x.webp';
10
- import M_sr from '../../asset/images/header/m_sr.webp';
11
- import M_right from '../../asset/images/header/m_right.webp';
12
- import Call from '../../asset/images/header/h_call_line_b.webp';
13
- import { blankArr } from '../../types/header';
14
- import BrochureBtn from '../BrochureBtn/BrochureBtn';
15
- const MobileMenu = ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo, isBrochureBtn, isMedical }) => {
16
- const router = useRouter();
17
- const mobile = require('is-mobile');
18
- const [isMobile, setIsMobile] = useState(false);
19
- //활성화 메뉴관리
20
- const currentPath = router.pathname;
21
- const [activeMenu, setActiveMenu] = useState();
22
- //검색기능
23
- const [search, setSearch] = useState('');
24
- //나의사건검색
25
- const [isMyCaseOn, setIsMyCaseOn] = useState(false);
26
- // GA 클릭이벤트
27
- const menuTelClickMo = () => {
28
- gtag.event({
29
- action: 'mobile_menu_tel',
30
- category: 'menutel',
31
- label: '모바일메뉴내전화버튼',
32
- value: '1'
33
- });
34
- };
35
- // 에이스카운터 전환태그
36
- const ace_ToptelClick = () => {
37
- try {
38
- // @ts-ignore
39
- AM_PL('/m_Toptel');
40
- }
41
- catch (e) { }
42
- };
43
- // 현재 주소로 활성화
44
- const findOuterName = (currentPath) => {
45
- for (const route of routes) {
46
- if (currentPath === route.path || currentPath.startsWith(route.path + '/')) {
47
- return route.name;
48
- }
49
- for (const nestedRoute of route.routes) {
50
- if (currentPath === nestedRoute.path || currentPath.startsWith(nestedRoute.path + '/')) {
51
- return route.name;
52
- }
53
- }
54
- }
55
- return routes[0].name;
56
- };
57
- // 클릭시 활성화
58
- const handleClickForMobile = (e) => {
59
- setActiveMenu(e.target.textContent);
60
- };
61
- //감색기능 엔터
62
- const handleKeyPressSearch = (e) => {
63
- e.preventDefault();
64
- if (e.key === 'Enter' && search.length > 0) {
65
- handleMenuToggle(`https://www.daeryunlaw.com/integrate?tab=전체&search=${search}`);
66
- window.open(`https://www.daeryunlaw.com/integrate?tab=전체&search=${search}`, '_blank');
67
- }
68
- };
69
- //감색기능 클릭
70
- const handleClickSearch = () => {
71
- handleMenuToggle(`https://www.daeryunlaw.com/integrate?tab=전체&search=${search}`);
72
- window.open(`https://www.daeryunlaw.com/integrate?tab=전체&search=${search}`, '_blank');
73
- };
74
- const handleClickKeyword = (keyword) => {
75
- //recommend - 추천 검색어 버튼 클릭이면 true
76
- if (keyword) {
77
- handleMenuToggle(`https://www.daeryunlaw.com/integrate?tab=전체&search=${keyword}&recommend=true`);
78
- window.open(`https://www.daeryunlaw.com/integrate?tab=전체&search=${keyword}&recommend=true`, '_blank');
79
- }
80
- };
81
- //나의사건검샛
82
- const onClickMyCase = () => {
83
- setIsMyCaseOn(false);
84
- };
85
- //페이지 내부에서 쿼리 파라미터 없이 루트 경로로 돌아갈 때 새로고침
86
- const reloadUrl = (url) => {
87
- if (router.pathname === url) {
88
- router.push(url).then(() => {
89
- router.reload();
90
- });
91
- }
92
- };
93
- useEffect(() => {
94
- setIsMobile(mobile());
95
- setActiveMenu(findOuterName(currentPath));
96
- }, []);
97
- return (<>
98
- {isMyCaseOn ? <MyCase onClick={onClickMyCase}/> : <></>}
99
-
100
- {/*모바일 메뉴 1024px*/}
101
- {/*<div style={{ opacity }} className={style.main + ' hidden max-lg:block fixed top-0 left-0 w-full h-full'}>*/}
102
- <div style={{ opacity, zIndex: menuToggle ? 50 : -9999, pointerEvents: menuToggle ? 'auto' : 'none' }} className={' fixed left-0 top-0 hidden h-full w-full max-lg:block'}>
103
- <div className={'absolute left-0 top-0 h-full w-full bg-black bg-opacity-[55%]'} onClick={() => handleMenuToggle()}></div>
104
- <span style={{
105
- //스크롤 숨기기
106
- msOverflowStyle: 'none',
107
- scrollbarWidth: 'none'
108
- }} className={'absolute right-0 top-0 z-0 h-full w-[65%] overflow-y-auto ' +
109
- //640px
110
- 'bg-white max-sm:w-[100%]'}>
111
- <nav className={'h-full min-h-[800px] w-full'}>
112
- {/*세로 800px 이상이면 스크롤가능*/}
113
- <div className={'flex h-[55%] max-h-[290px] w-full flex-col justify-end border-b-[1px] border-solid border-b-[#F2F2F2] px-[30px] py-[30px] ' +
114
- //768px
115
- 'max-md:h-[20%] max-md:max-h-[180px] max-md:min-h-[250px]'}>
116
- {/* x icon */}
117
- <Image tabIndex={0} src={Menu_x} width={54} height={54} alt={'메뉴'} className={'absolute right-[20px] top-[30px] h-[18px] w-[18px] cursor-pointer ' +
118
- //768px
119
- 'max-md:h-[15px] max-md:w-[15px]'} draggable={false} onKeyDown={(e) => {
120
- if (e.key === 'Enter') {
121
- handleMenuToggle();
122
- }
123
- }} onClick={() => handleMenuToggle()}/>
124
- <span>
125
- <Link href="/" onClick={() => handleMenuToggle('/')}>
126
- <Image src={logo} alt={`${process.env.NEXT_PUBLIC_KEYWORD}전문변호사 로고`} width={324} height={50} className={'h-auto w-[200px] ' +
127
- //768px
128
- 'max-md:w-[155px]'}/>
129
- </Link>
130
- <div className={'relative mt-[20px] h-[50px] w-full ' + //768px
131
- 'max-md:h-[40px] '}>
132
- <input placeholder={'사건분야, 변호사, 법률정보 등을 검색해보세요'} className={'h-full w-full border-[1px] border-solid border-[#285FA7] px-[20px] text-base tracking-[-0.6px] ' +
133
- //768px
134
- 'max-md:text-sm'} onChange={e => {
135
- setSearch(e.target.value);
136
- }} onKeyUp={handleKeyPressSearch}></input>
137
- <Image src={M_sr} alt={'sr_icon'} width={35} height={34} className={'absolute right-[15px] top-[50%] h-auto w-[20px] translate-y-[-50%] cursor-pointer ' +
138
- //768px
139
- 'max-md:w-[17px]'} onClick={handleClickSearch}/>
140
- </div>
141
-
142
- <div className={'relative mt-[20px] grid w-full grid-cols-4 gap-2 '}>
143
- {keywordArr.map((item, index) => (<div key={index} tabIndex={0} className={'cursor-pointer rounded-full border-[1px] border-solid border-[#285FA7] p-1 text-center text-[14px] font-[800] tracking-tighter text-[#285FA7] max-xs:text-[12px] '} onKeyDown={(e) => {
144
- if (e.key === 'Enter') {
145
- handleClickKeyword(item);
146
- }
147
- }} onClick={() => {
148
- handleClickKeyword(item);
149
- }}>
150
- #{item}
151
- </div>))}
152
- </div>
153
- </span>
154
- </div>
155
-
156
- {/*메뉴시작*/}
157
- <div className={'relative h-[60%] max-h-[600px] w-full bg-[#FCFCFC] py-[30px]'}>
158
- <div className={'absolute top-0 h-full w-[45%] bg-[#F7F7F7]'}></div>
159
- <div className={'flex h-full w-full flex-col justify-between'}>
160
- {routes.map((menu, index) => {
161
- var _a;
162
- return (<span key={index} className={'relative w-full'}>
163
- {/*main menu*/}
164
- <button type={'button'} className={'h-[35px] w-[48%] flex-shrink-0 translate-x-[15px] rounded-full pl-[20px] text-left text-base font-[800] ' +
165
- //버튼 활성화상태
166
- `${activeMenu == menu.name
167
- ? '!bg-[#285FA7] text-white '
168
- : 'hover:bg-[#EAEAEA]'}`} onClick={handleClickForMobile}>
169
- {menu.name}
170
- </button>
171
- {/*sub menu*/}
172
- {menu.routes ? (<ul className={'absolute right-0 top-[5px] z-10 flex max-h-[160px] w-[55%] flex-col gap-[2vh] ' +
173
- `${activeMenu == menu.name ? '' : 'hidden'}`}>
174
- {(_a = menu.routes) === null || _a === void 0 ? void 0 : _a.map((submenu, index) => (<li key={index} className={' pl-[50px] pr-[30px] '}>
175
- {submenu.name !== '나의 사건검색' ? (<Link href={submenu.path} className={'flex items-center justify-between text-base text-[#5C5C5C] hover:text-[#333333] '} onClick={() => {
176
- handleMenuToggle(submenu.path);
177
- reloadUrl(submenu.path);
178
- }} target={blankArr.includes(submenu.name) ? '_blank' : '_self'}>
179
- {submenu.name}
180
- <Image src={M_right} alt={'arrow_icon'} width={12} height={23} className={'h-auto w-[4px]'}/>
181
- </Link>) : (<div className={'flex cursor-pointer items-center justify-between text-base text-[#5C5C5C] hover:text-[#333333] '} onClick={() => setIsMyCaseOn(true)}>
182
- {submenu.name}
183
- <Image src={M_right} alt={'arrow_icon'} width={12} height={23} className={'h-auto w-[4px]'}/>
184
- </div>)}
185
- </li>))}
186
- </ul>) : ('')}
187
- </span>);
188
- })}
189
- </div>
190
- </div>
191
- {/*전화번호*/}
192
- <div className={'mt-[30px] flex w-full justify-start pb-[100px] max-2xs:flex-col'}>
193
- <Link href={`tel:${tel}`} onClick={() => {
194
- insert('call', isMobile);
195
- savePowerLinkConversion('call', isMobile);
196
- menuTelClickMo();
197
- ace_ToptelClick();
198
- }} className={'ml-[30px] flex w-fit items-center justify-end gap-[10px] text-lg font-black'}>
199
- <Image src={Call} width={57} height={57} alt={'전화상담'} className={'h-auto w-[30px]'}/>
200
- {tel}
201
- </Link>
202
- {isBrochureBtn ? (<BrochureBtn width={'280px'} height={'58px'} className={'scale-75 max-md:-mx-[23px] max-xs:scale-[0.7] max-2xs:-mx-[15px] max-2xs:mt-1 '}/>) : (<></>)}
203
- </div>
204
- </nav>
205
- </span>
206
- </div>
207
- </>);
208
- };
209
- export default MobileMenu;