@daeryun/dr_components 0.1.92 → 0.1.95

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.
Files changed (55) hide show
  1. package/dist/asset/images/header/logo_b.webp +0 -0
  2. package/dist/asset/images/header/logo_w.webp +0 -0
  3. package/dist/asset/images/header/military.svg +38 -0
  4. package/dist/asset/images/header/military_w.svg +38 -0
  5. package/dist/components/Header/Header.d.ts +4 -0
  6. package/dist/components/Header/Header.jsx +189 -0
  7. package/dist/components/Header/Header.stories.d.ts +8 -0
  8. package/dist/components/Header/Header.stories.jsx +200 -0
  9. package/dist/components/Header/Header.stories.tsx +209 -0
  10. package/dist/components/Header/Header.tsx +281 -0
  11. package/dist/components/Header/Menu.d.ts +4 -0
  12. package/dist/components/Header/Menu.jsx +10 -0
  13. package/dist/components/Header/Menu.tsx +29 -0
  14. package/dist/components/Header/MobileMenu.d.ts +4 -0
  15. package/dist/components/Header/MobileMenu.jsx +209 -0
  16. package/dist/components/Header/MobileMenu.tsx +370 -0
  17. package/dist/components/Header/PCMenu.d.ts +4 -0
  18. package/dist/components/Header/PCMenu.jsx +130 -0
  19. package/dist/components/Header/PCMenu.tsx +243 -0
  20. package/dist/components/Header/main.module.css +150 -0
  21. package/dist/components/MapFix/AreaImage.jsx +10 -9
  22. package/dist/components/MapFix/AreaImage.tsx +21 -26
  23. package/dist/components/MapSection/MapSection.stories.jsx +16 -0
  24. package/dist/components/MapSection/MapSection.stories.tsx +34 -0
  25. package/dist/components/categoryView/CategoryView.jsx +1 -1
  26. package/dist/components/categoryView/CategoryView.tsx +1 -3
  27. package/dist/components/hook/useBrowser.d.ts +5 -0
  28. package/dist/components/hook/useBrowser.js +51 -0
  29. package/dist/components/hook/useBrowser.ts +58 -0
  30. package/dist/components/hook/useCountNum.d.ts +4 -0
  31. package/dist/components/hook/useCountNum.jsx +23 -0
  32. package/dist/components/hook/useCountNum.tsx +28 -0
  33. package/dist/components/hook/useElementObserve.d.ts +7 -0
  34. package/dist/components/hook/useElementObserve.js +39 -0
  35. package/dist/components/hook/useElementObserve.ts +46 -0
  36. package/dist/components/hook/useScrollRestoration.d.ts +5 -0
  37. package/dist/components/hook/useScrollRestoration.js +61 -0
  38. package/dist/components/hook/useScrollRestoration.ts +80 -0
  39. package/dist/components/hook/useScrollRestorationException.d.ts +2 -0
  40. package/dist/components/hook/useScrollRestorationException.js +24 -0
  41. package/dist/components/hook/useScrollRestorationException.ts +30 -0
  42. package/dist/components/index.js +1 -0
  43. package/dist/components/index.ts +1 -0
  44. package/dist/components/myCase/MyCase.d.ts +5 -0
  45. package/dist/components/myCase/MyCase.jsx +26 -0
  46. package/dist/components/myCase/MyCase.tsx +47 -0
  47. package/dist/components/routes/gnb.d.ts +11 -0
  48. package/dist/components/routes/gnb.jsx +165 -0
  49. package/dist/components/routes/gnb.tsx +172 -0
  50. package/dist/styles/globals.css +324 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/dist/types/header.d.ts +53 -0
  53. package/dist/types/header.js +1 -0
  54. package/dist/types/header.ts +55 -0
  55. package/package.json +1 -1
@@ -0,0 +1,209 @@
1
+ import Header from './Header';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import '../../styles/globals.css';
4
+ import '../../styles/font_style.css';
5
+ import { useRecoilState, RecoilRoot, atom } from 'recoil';
6
+ import Logo from '../../asset/images/header/logo_b.webp';
7
+ import Logo_w from '../../asset/images/header/logo_w.webp';
8
+ import { useState } from 'react';
9
+
10
+ const meta: Meta<typeof Header> = {
11
+ component: Header,
12
+ title: 'Header'
13
+ };
14
+
15
+ export default meta;
16
+
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ const footerTelAtom = atom({
20
+ key: 'footer-tel',
21
+ default: '1660 - 1807'
22
+ });
23
+
24
+ export const Default: Story = {
25
+ render: args => {
26
+ const [footerTel, setFooterTel] = useState('');
27
+ return (
28
+ <div className={'h-[800px] w-full bg-gray-200'}>
29
+ <Header {...args} setFooterTel={setFooterTel} />
30
+ <span className={'block pt-40'}> {footerTel}</span>
31
+ </div>
32
+ );
33
+ },
34
+ args: {
35
+ setTel: () => {},
36
+ setFooterTel: () => {},
37
+ tel: '1800-7905',
38
+ logo: Logo,
39
+ logo_w: Logo_w,
40
+ categoryType: 'mainStrength',
41
+ keywordArr: ['보이스피싱', '성범죄', '교통사고', '음주운전', '학교폭력', '마약', '명예훼손', '중대재해'],
42
+ name: 'detective',
43
+ routes: [
44
+ {
45
+ path: '/greeting',
46
+ name: '그룹소개',
47
+ routes: [
48
+ {
49
+ path: '/greeting',
50
+ name: '비전',
51
+ ename: 'VISION'
52
+ },
53
+ {
54
+ path: '/strength',
55
+ name: '대륜의 강점',
56
+ ename: 'String point'
57
+ },
58
+ {
59
+ path: '/map',
60
+ name: '오시는 길',
61
+ ename: 'Locations'
62
+ },
63
+ {
64
+ path: 'https://www.daeryunlaw.com/integrate?search=&tab=전체',
65
+ name: '통합검색',
66
+ ename: 'Search entire site'
67
+ }
68
+ ]
69
+ },
70
+ {
71
+ path: '/success?page=1',
72
+ name: '업무사례',
73
+ routes: [
74
+ {
75
+ path: '/success?page=1&search=',
76
+ name: '업무사례',
77
+ ename: 'Deals & Cases'
78
+ },
79
+ {
80
+ path: 'https://www.daeryunlaw.com/trend',
81
+ name: '판결분석',
82
+ ename: 'Class action'
83
+ },
84
+ {
85
+ path: '/info',
86
+ name: '법률정보',
87
+ ename: 'LawInfo'
88
+ },
89
+ {
90
+ path: 'https://www.daeryunlaw.com/webtoon',
91
+ name: '만화로 보는 사례',
92
+ ename: 'Cartoon cases'
93
+ },
94
+ {
95
+ path: '/reply',
96
+ name: '고객후기',
97
+ ename: "Client's reviews"
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ path: '/field/area',
103
+ name: '업무분야',
104
+ routes: [
105
+ {
106
+ path: '/field/area',
107
+ name: '형사그룹 업무',
108
+ ename: 'Practices'
109
+ },
110
+ {
111
+ path: '/field/areaAll',
112
+ name: '전체',
113
+ ename: 'All'
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ path: '/lawyer?pro=false&page=1&search=',
119
+ name: '구성원 소개',
120
+ routes: [
121
+ {
122
+ path: '/lawyer?pro=false&page=1&search=',
123
+ name: '형사그룹 전문변호사',
124
+ ename: 'Attorneys'
125
+ },
126
+ {
127
+ path: '/lawyer?pro=true&page=1&search=',
128
+ name: '특수분야전문가',
129
+ ename: 'Specialists'
130
+ }
131
+ ]
132
+ },
133
+ {
134
+ path: '/broadcast',
135
+ name: '소식/자료',
136
+ routes: [
137
+ {
138
+ path: 'https://www.daeryunlaw.com/broadcast',
139
+ name: '언론보도',
140
+ ename: 'News'
141
+ },
142
+ {
143
+ path: '/notice',
144
+ name: '공지사항',
145
+ ename: 'Notices'
146
+ },
147
+ {
148
+ path: '/archive',
149
+ name: '법률서식',
150
+ ename: 'Archive'
151
+ },
152
+ {
153
+ path: 'https://career.daeryunlaw.com',
154
+ name: '인재채용',
155
+ ename: 'Career'
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ path: '/youtube?search=&page=1',
161
+ name: 'SNS',
162
+ routes: [
163
+ {
164
+ path: '/youtube?search=&page=1',
165
+ name: '유튜브',
166
+ ename: 'Youtube'
167
+ },
168
+ {
169
+ path: '/blog',
170
+ name: '블로그',
171
+ ename: 'Blog'
172
+ },
173
+ {
174
+ path: '/instagram?page=1',
175
+ name: '인스타그램',
176
+ ename: 'Instagram'
177
+ },
178
+ {
179
+ path: '/kin?page=1',
180
+ name: '법률지식인',
181
+ ename: 'Legal Expert'
182
+ }
183
+ ]
184
+ },
185
+ {
186
+ path: 'https://www.scourt.go.kr/portal/information/events/search/search.jsp',
187
+ name: '나의 사건검색',
188
+ routes: [
189
+ {
190
+ path: 'https://www.scourt.go.kr/portal/information/events/search/search.jsp',
191
+ name: '나의 사건검색',
192
+ ename: 'Find my cases'
193
+ }
194
+ ]
195
+ },
196
+ {
197
+ path: '/choice',
198
+ name: '대륜법률상담예약',
199
+ routes: [
200
+ {
201
+ path: '/choice',
202
+ name: '대륜법률상담예약',
203
+ ename: 'Request a counseling'
204
+ }
205
+ ]
206
+ }
207
+ ]
208
+ }
209
+ };
@@ -0,0 +1,281 @@
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
+ }: IHeaderType) => {
31
+ const router = useRouter();
32
+ const mobile = require('is-mobile');
33
+ const [isTop, setIsTop] = useState(true);
34
+ const [isMain, setIsMain] = useState(true);
35
+ const [isMobile, setIsMobile] = useState<boolean>(false);
36
+ const [opacity, setOpacity] = useState<number>(0);
37
+ const [menuToggle, setMenuToggle] = useState<boolean>(false);
38
+ const timeoutRef = useRef<NodeJS.Timeout>();
39
+
40
+ const headerRef = useRef<HTMLHtmlElement | null>(null);
41
+
42
+ const setNaverLinkTel = () => {
43
+ setTel('1660-1043');
44
+ setFooterTel('1660 - 1043');
45
+ };
46
+
47
+ const setGoogleLinkTel = () => {
48
+ setTel('1660-1028');
49
+ setFooterTel('1660 - 1028');
50
+ };
51
+
52
+ const setResetTel = () => {
53
+ setTel(tel);
54
+ setFooterTel(footerTel);
55
+ };
56
+
57
+ const setYoutubeTel = () => {
58
+ setTel('02-6958-6578');
59
+ setFooterTel('02 - 6958 - 6578');
60
+ };
61
+
62
+ useEffect(() => {
63
+ const is_mobile = mobile();
64
+ saveTelNumber(is_mobile, setNaverLinkTel, setGoogleLinkTel, setYoutubeTel, setResetTel);
65
+ }, []);
66
+
67
+ const handleScroll = useCallback(() => {
68
+ const scrollElm: Element | null = document.scrollingElement;
69
+ if (scrollElm !== null) {
70
+ const scrollTop: number = Math.max(scrollElm.scrollTop, document.body.scrollTop);
71
+ if (scrollTop > 0) {
72
+ setIsTop(false);
73
+ } else {
74
+ setIsTop(true);
75
+ }
76
+ }
77
+ }, []);
78
+
79
+ const topTelClick = () => {
80
+ gtag.event({
81
+ action: 'mobile_toptel',
82
+ category: 'toptel',
83
+ label: '모바일상단전화버튼',
84
+ value: '1'
85
+ });
86
+ };
87
+
88
+ const ace_ToptelClick = () => {
89
+ try {
90
+ // @ts-ignore
91
+ AM_PL('/m_Toptel');
92
+ } catch (e) {}
93
+ };
94
+
95
+ const handleMenuToggle = useCallback(
96
+ (url?: string) => {
97
+ if (!menuToggle) {
98
+ timeoutRef.current = setInterval(() => {
99
+ setOpacity(prev => prev + 0.2);
100
+ }, 40);
101
+ } else {
102
+ setOpacity(0);
103
+ clearInterval(timeoutRef.current);
104
+ }
105
+ setMenuToggle(prev => !prev);
106
+ if (url) {
107
+ removeScrollPos(url);
108
+ }
109
+ },
110
+ [menuToggle]
111
+ );
112
+ const handleKeyPress = (e: any) => {
113
+ if (e.key === 'Enter') {
114
+ handleMenuToggle();
115
+ }
116
+ };
117
+
118
+ useEffect(() => {
119
+ const isRootPath = router.pathname === '/';
120
+ const isStrengthPath = router.pathname === '/strength';
121
+ const isIntroPath = router.pathname === '/intro';
122
+
123
+ const conditionMap: { [key: string]: boolean[] } = {
124
+ main: [isRootPath, isStrengthPath],
125
+ divorce: [(isRootPath || isStrengthPath) && !doNotWrite],
126
+ assault: [(isRootPath || isStrengthPath) && !doNotWrite],
127
+ medical: [(isRootPath || isStrengthPath) && !doNotWrite],
128
+ detective: [isRootPath, isIntroPath],
129
+ labor: [isRootPath, isIntroPath],
130
+ trade: [isRootPath, isIntroPath],
131
+ comp: [isRootPath, isStrengthPath, router.pathname === '/advice', router.pathname === '/management'],
132
+ school: [isRootPath],
133
+ discovery: [isRootPath],
134
+ tax: [isRootPath],
135
+ inherit: [isRootPath],
136
+ estate: [isStrengthPath],
137
+ military: [isStrengthPath],
138
+ accounting: [isRootPath && !doNotWrite],
139
+ traffic: [isRootPath, isStrengthPath, isIntroPath],
140
+ consulting: [isStrengthPath],
141
+ entertainment: [isRootPath && !doNotWrite]
142
+ };
143
+
144
+ const checkCondition = () => {
145
+ const conditions = conditionMap[name];
146
+ return conditions ? conditions.some(Boolean) : false;
147
+ };
148
+
149
+ if (checkCondition()) {
150
+ setIsTop(true);
151
+ setIsMain(true);
152
+ document.addEventListener('scroll', handleScroll);
153
+ return () => {
154
+ document.removeEventListener('scroll', handleScroll);
155
+ };
156
+ } else {
157
+ setIsMain(true);
158
+ setIsTop(false);
159
+ }
160
+ }, [handleScroll, router.pathname]);
161
+
162
+ useEffect(() => {
163
+ setIsMobile(mobile());
164
+ }, []);
165
+
166
+ useEffect(() => {
167
+ const pathsToExclude: {
168
+ mainStrength: string[];
169
+ strength: string[];
170
+ mainIntro: string[];
171
+ introStrength: string[];
172
+ main: string[];
173
+ } = {
174
+ mainStrength: ['/', '/strength'],
175
+ strength: ['/strength'],
176
+ mainIntro: ['/', '/intro'],
177
+ introStrength: ['/', '/strength', '/intro'],
178
+ main: ['/']
179
+ };
180
+
181
+ const shouldSetStates =
182
+ //@ts-ignore
183
+ categoryType in pathsToExclude && !pathsToExclude[categoryType].includes(router.pathname);
184
+
185
+ if (shouldSetStates) {
186
+ setIsTop(false);
187
+ setIsMain(false);
188
+ }
189
+ }, [router.pathname, categoryType]);
190
+
191
+ useEffect(() => {
192
+ if (opacity > 1) {
193
+ clearInterval(timeoutRef.current);
194
+ }
195
+ }, [opacity]);
196
+
197
+ return (
198
+ <>
199
+ <header
200
+ ref={headerRef}
201
+ className={
202
+ 'fixed top-0 z-[3000] h-[90px] w-full bg-white font-[SUIT] max-md2:h-[80px] max-md:h-[70px] ' +
203
+ (isMain
204
+ ? isTop
205
+ ? ' bg-opacity-0 '
206
+ : ' bg-opacity-90 shadow-sm'
207
+ : 'border-b-[2px] border-solid border-[#e5e7eb] bg-opacity-100')
208
+ }
209
+ >
210
+ <Wrapper className={'flex h-full items-center justify-between'}>
211
+ <Link href={`/`} className={'block'}>
212
+ <Image
213
+ src={isTop ? logo_w : logo}
214
+ alt={`${process.env.NEXT_PUBLIC_KEYWORD}전문변호사 로고`}
215
+ width={348}
216
+ height={70}
217
+ priority
218
+ property={'eager'}
219
+ className={'h-[36px] w-auto max-md2:h-[32px] max-md:h-[28px]'}
220
+ />
221
+ </Link>
222
+
223
+ <div className={'flex h-full items-center'}>
224
+ <Link
225
+ href={`tel:${tel}`}
226
+ onClick={() => {
227
+ insert('call', isMobile);
228
+ savePowerLinkConversion('call', isMobile);
229
+ topTelClick();
230
+ ace_ToptelClick();
231
+ }}
232
+ aria-label={'tel'}
233
+ className={
234
+ '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 ' +
235
+ (isTop ? 'text-white' : '')
236
+ }
237
+ >
238
+ <Image
239
+ src={isTop ? Call : Call_b}
240
+ alt={'tel'}
241
+ width={76}
242
+ height={76}
243
+ className={
244
+ 'h-[38px] w-[38px] max-md2:h-[36px] max-md2:w-[36px] max-md:h-[32px] max-md:w-[32px] '
245
+ }
246
+ />
247
+ {tel}
248
+ </Link>
249
+
250
+ <Menu
251
+ menuToggle={menuToggle}
252
+ handleMenuToggle={handleMenuToggle}
253
+ opacity={opacity}
254
+ routes={routes}
255
+ tel={tel}
256
+ logo={logo}
257
+ keywordArr={keywordArr}
258
+ />
259
+
260
+ {!menuToggle && (
261
+ <Image
262
+ onKeyDown={handleKeyPress}
263
+ tabIndex={0}
264
+ src={isTop ? H_menu : H_menu_b}
265
+ alt="메뉴바"
266
+ width={38}
267
+ height={17}
268
+ className={
269
+ 'z-10 ml-[40px] h-auto w-[28px] cursor-pointer max-md2:w-[25px] max-md:ml-[30px] max-md:w-[22px]'
270
+ }
271
+ onClick={() => handleMenuToggle()}
272
+ />
273
+ )}
274
+ </div>
275
+ </Wrapper>
276
+ </header>
277
+ </>
278
+ );
279
+ };
280
+
281
+ export default Header;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IMenuType } from '../../types/header';
3
+ declare const Menu: ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo }: IMenuType) => React.JSX.Element;
4
+ export default Menu;
@@ -0,0 +1,10 @@
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 }) => {
5
+ return (<>
6
+ <MobileMenu logo={logo} handleMenuToggle={handleMenuToggle} opacity={opacity} menuToggle={menuToggle} routes={routes} tel={tel} keywordArr={keywordArr}/>
7
+ <PCMenu handleMenuToggle={handleMenuToggle} opacity={opacity} menuToggle={menuToggle} routes={routes} tel={tel}/>
8
+ </>);
9
+ };
10
+ export default Menu;
@@ -0,0 +1,29 @@
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 = ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo }: IMenuType) => {
7
+ return (
8
+ <>
9
+ <MobileMenu
10
+ logo={logo}
11
+ handleMenuToggle={handleMenuToggle}
12
+ opacity={opacity}
13
+ menuToggle={menuToggle}
14
+ routes={routes}
15
+ tel={tel}
16
+ keywordArr={keywordArr}
17
+ />
18
+ <PCMenu
19
+ handleMenuToggle={handleMenuToggle}
20
+ opacity={opacity}
21
+ menuToggle={menuToggle}
22
+ routes={routes}
23
+ tel={tel}
24
+ />
25
+ </>
26
+ );
27
+ };
28
+
29
+ export default Menu;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IMobileMenuType } from '../../types/header';
3
+ declare const MobileMenu: ({ handleMenuToggle, opacity, menuToggle, routes, tel, keywordArr, logo, isBrochureBtn }: IMobileMenuType) => React.JSX.Element;
4
+ export default MobileMenu;