@daeryun/dr_components 1.2.53 → 1.2.54

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,19 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import style from './TopBanner.module.css';
12
11
  import { useEffect, useState, useRef } from 'react';
13
12
  import 'swiper/css';
14
- import { Swiper, SwiperSlide } from 'swiper/react';
15
- import { Autoplay } from 'swiper/modules';
16
- import Image from 'next/image';
17
13
  import { useQuery } from '@tanstack/react-query';
18
- import { isCurrentTimeWithinPopupRange, paramFetch } from '../../lib';
14
+ import { paramFetch } from '../../lib';
19
15
  import { DateTime } from 'luxon';
20
- import classNames from 'classnames';
21
- import Link from 'next/link';
22
16
  import useBrowser from '../hook/useBrowser';
23
17
  import { usePathname, useRouter } from 'next/navigation';
18
+ import PCTopBanner from './PCTopBanner';
19
+ import MobileTopBanner from './MobileTopBanner';
20
+ import { isTopPopupMobileHidden } from './common';
24
21
  // 팝업 컴포넌트 스토리북 확인용 더미 데이터
25
22
  // const POPUP_DUMMY: IBannerTypes[] = [
26
23
  // {
@@ -93,6 +90,9 @@ const TopBanner = ({ setBannerHeight }) => {
93
90
  const pathname = usePathname();
94
91
  //팝업 리스트
95
92
  const [popup, setPopup] = useState([]);
93
+ const [mobileOpen, setMobileOpen] = useState(() => {
94
+ return !isTopPopupMobileHidden();
95
+ });
96
96
  const addClickCnt = (idx) => {
97
97
  paramFetch('https://mng.daeryunlaw.com/api/popup/top/click', { idx: idx }, null);
98
98
  };
@@ -293,83 +293,11 @@ const TopBanner = ({ setBannerHeight }) => {
293
293
  // const endHour = 8//팝업종료 시간의 '시'
294
294
  // const endMin = 50//팝업종료 시간의 '분'
295
295
  return (<>
296
- <div ref={bannerRef} className={style.header_banner_wrap}>
297
- {/* pc */}
298
- {width > 900 && (<div className={style.header_banner}>
299
- {popup && popup.filter(item => item.file_type === 'file_pc').length > 0 ? (<Swiper autoplay={{ delay: 5000 }} modules={[Autoplay]} loop={popup.filter(item => item.file_type === 'file_pc').length > 1}>
300
- {popup.length > 0 ? (popup
301
- .filter((item) => item.file_type === 'file_pc' &&
302
- isCurrentTimeWithinPopupRange(item.days, item.startHour, item.startMin, item.endHour, item.endMin))
303
- .map((item, index) => {
304
- // {popup.length > 0 ? popup.filter((item: IBannerTypes) => item.file_type === 'file_pc').map((item: IBannerTypes, index: number) => {
305
- return (<SwiperSlide key={index}>
306
- <div className={style.header_banner_btn}>
307
- <button onClick={() => {
308
- filterClose(item.idx);
309
- addCookie(item.idx);
310
- }}>
311
- 하루동안 보지않기
312
- </button>
313
- <button onClick={() => {
314
- filterClose(item.idx);
315
- }}>
316
- <Image src="/images/banner_btn.webp" alt="대륜 배너 닫기 이미지" width={42} height={42}/>
317
- </button>
318
- </div>
319
- <div className={style.banner_block} style={{ background: `#${item.color_code}` }}>
320
- <Link href={item.pc_link || item.p_link} target={item.link_type} onClick={() => {
321
- addClickCnt(item.idx);
322
- }} rel={validateUrl(item.p_link)}>
323
- <Image src={ImagePath +
324
- item.file_path +
325
- '/' +
326
- item.save_file_name} alt={item.file_alt} width={2000} height={60} priority={true} quality={100} loading={'eager'}/>
327
- {/*<Image src={"/images/대표메인_팝업_PC.jpg"} alt={item.file_alt} width={1920} height={50} priority={true} />*/}
328
- </Link>
329
- </div>
330
- </SwiperSlide>);
331
- })) : (<></>)}
332
- </Swiper>) : (<></>)}
333
- </div>)}
296
+ {/*pc*/}
297
+ {width > 900 && <PCTopBanner popup={popup} setPopup={setPopup} addClickCnt={addClickCnt}/>}
334
298
 
335
- {/* mobile */}
336
- {width <= 900 && (<div className={classNames({
337
- [style.header_banner_m]: true
338
- })}>
339
- {popup && popup.filter(item => item.file_type === 'file_mobile').length > 0 ? (<Swiper autoplay={{ delay: 5000 }} modules={[Autoplay]} loop={popup.filter((item) => item.file_type === 'file_mobile').length > 1}>
340
- {popup.length > 0 ? (popup
341
- .filter((item) => item.file_type === 'file_mobile')
342
- .map((item, index) => {
343
- return (<SwiperSlide key={index}>
344
- <div className={style.header_banner_m_btn}>
345
- <button onClick={() => {
346
- filterClose(item.idx);
347
- addCookie(item.idx);
348
- }}>
349
- 하루동안 보지않기
350
- </button>
351
- <button onClick={() => {
352
- filterClose(item.idx);
353
- }}>
354
- 닫기
355
- </button>
356
- </div>
357
- <div className={style.banner_block_m}>
358
- <Link href={item.mobile_link || item.p_link} target={item.link_type} rel={validateUrl(item.p_link)}>
359
- <Image src={ImagePath +
360
- item.file_path +
361
- '/' +
362
- item.save_file_name} alt={item.file_alt} width={900} height={150} priority={true} onClick={() => {
363
- addClickCnt(item.idx);
364
- }} quality={100}/>
365
- {/*<Image src={"/images/대표메인_팝업_900.jpg"} alt={item.file_alt} width={900} height={70} priority={true} />*/}
366
- </Link>
367
- </div>
368
- </SwiperSlide>);
369
- })) : (<></>)}
370
- </Swiper>) : (<></>)}
371
- </div>)}
372
- </div>
299
+ {/*mobile*/}
300
+ {width <= 900 && mobileOpen && (<MobileTopBanner popup={popup} setMobileOpen={setMobileOpen} addClickCnt={addClickCnt}/>)}
373
301
  </>);
374
302
  };
375
303
  export default TopBanner;
@@ -14,12 +14,20 @@ import Link from 'next/link';
14
14
  import useBrowser from '../hook/useBrowser';
15
15
  import { SetterOrUpdater } from 'recoil';
16
16
  import { usePathname, useRouter } from 'next/navigation';
17
+ import PCTopBanner from './PCTopBanner';
18
+ import MobileTopBanner from './MobileTopBanner';
19
+ import { isTopPopupMobileHidden } from './common';
17
20
 
18
21
  //배너타입
19
- interface IBannerTypes {
22
+ export interface IBannerTypes {
20
23
  color_code: string;
21
- days: number[];
24
+ days: string[];
25
+ start_at: string;
26
+ start_hour: number;
27
+ start_min: number;
22
28
  end_at: string;
29
+ end_hour: number;
30
+ end_min: number;
23
31
  file_alt: string;
24
32
  file_path: string;
25
33
  file_type: string;
@@ -29,7 +37,6 @@ interface IBannerTypes {
29
37
  p_link: string;
30
38
  p_sort: number;
31
39
  save_file_name: string;
32
- start_at: string;
33
40
  pc_link?: string;
34
41
  mobile_link?: string;
35
42
  }
@@ -109,6 +116,10 @@ const TopBanner = ({ setBannerHeight }: { setBannerHeight?: SetterOrUpdater<numb
109
116
  //팝업 리스트
110
117
  const [popup, setPopup] = useState<IBannerTypes[]>([]);
111
118
 
119
+ const [mobileOpen, setMobileOpen] = useState<boolean>(() => {
120
+ return !isTopPopupMobileHidden();
121
+ });
122
+
112
123
  const addClickCnt = (idx: number) => {
113
124
  paramFetch('https://mng.daeryunlaw.com/api/popup/top/click', { idx: idx }, null);
114
125
  };
@@ -335,171 +346,13 @@ const TopBanner = ({ setBannerHeight }: { setBannerHeight?: SetterOrUpdater<numb
335
346
 
336
347
  return (
337
348
  <>
338
- <div ref={bannerRef} className={style.header_banner_wrap}>
339
- {/* pc */}
340
- {width > 900 && (
341
- <div className={style.header_banner}>
342
- {popup && popup.filter(item => item.file_type === 'file_pc').length > 0 ? (
343
- <Swiper
344
- autoplay={{ delay: 5000 }}
345
- modules={[Autoplay]}
346
- loop={popup.filter(item => item.file_type === 'file_pc').length > 1}
347
- >
348
- {popup.length > 0 ? (
349
- popup
350
- .filter(
351
- (item: any) =>
352
- item.file_type === 'file_pc' &&
353
- isCurrentTimeWithinPopupRange(
354
- item.days,
355
- item.startHour,
356
- item.startMin,
357
- item.endHour,
358
- item.endMin
359
- )
360
- )
361
- .map((item: IBannerTypes, index: number) => {
362
- // {popup.length > 0 ? popup.filter((item: IBannerTypes) => item.file_type === 'file_pc').map((item: IBannerTypes, index: number) => {
363
- return (
364
- <SwiperSlide key={index}>
365
- <div className={style.header_banner_btn}>
366
- <button
367
- onClick={() => {
368
- filterClose(item.idx);
369
- addCookie(item.idx);
370
- }}
371
- >
372
- 하루동안 보지않기
373
- </button>
374
- <button
375
- onClick={() => {
376
- filterClose(item.idx);
377
- }}
378
- >
379
- <Image
380
- src="/images/banner_btn.webp"
381
- alt="대륜 배너 닫기 이미지"
382
- width={42}
383
- height={42}
384
- />
385
- </button>
386
- </div>
387
- <div
388
- className={style.banner_block}
389
- style={{ background: `#${item.color_code}` }}
390
- >
391
- <Link
392
- href={item.pc_link || item.p_link}
393
- target={item.link_type}
394
- onClick={() => {
395
- addClickCnt(item.idx);
396
- }}
397
- rel={validateUrl(item.p_link)}
398
- >
399
- <Image
400
- src={
401
- ImagePath +
402
- item.file_path +
403
- '/' +
404
- item.save_file_name
405
- }
406
- alt={item.file_alt}
407
- width={2000}
408
- height={60}
409
- priority={true}
410
- quality={100}
411
- loading={'eager'}
412
- />
413
- {/*<Image src={"/images/대표메인_팝업_PC.jpg"} alt={item.file_alt} width={1920} height={50} priority={true} />*/}
414
- </Link>
415
- </div>
416
- </SwiperSlide>
417
- );
418
- })
419
- ) : (
420
- <></>
421
- )}
422
- </Swiper>
423
- ) : (
424
- <></>
425
- )}
426
- </div>
427
- )}
428
-
429
- {/* mobile */}
430
- {width <= 900 && (
431
- <div
432
- className={classNames({
433
- [style.header_banner_m]: true
434
- })}
435
- >
436
- {popup && popup.filter(item => item.file_type === 'file_mobile').length > 0 ? (
437
- <Swiper
438
- autoplay={{ delay: 5000 }}
439
- modules={[Autoplay]}
440
- loop={popup.filter((item: IBannerTypes) => item.file_type === 'file_mobile').length > 1}
441
- >
442
- {popup.length > 0 ? (
443
- popup
444
- .filter((item: IBannerTypes) => item.file_type === 'file_mobile')
445
- .map((item: IBannerTypes, index: number) => {
446
- return (
447
- <SwiperSlide key={index}>
448
- <div className={style.header_banner_m_btn}>
449
- <button
450
- onClick={() => {
451
- filterClose(item.idx);
452
- addCookie(item.idx);
453
- }}
454
- >
455
- 하루동안 보지않기
456
- </button>
457
- <button
458
- onClick={() => {
459
- filterClose(item.idx);
460
- }}
461
- >
462
- 닫기
463
- </button>
464
- </div>
465
- <div className={style.banner_block_m}>
466
- <Link
467
- href={item.mobile_link || item.p_link}
468
- target={item.link_type}
469
- rel={validateUrl(item.p_link)}
470
- >
471
- <Image
472
- src={
473
- ImagePath +
474
- item.file_path +
475
- '/' +
476
- item.save_file_name
477
- }
478
- alt={item.file_alt}
479
- width={900}
480
- height={150}
481
- priority={true}
482
- onClick={() => {
483
- addClickCnt(item.idx);
484
- }}
485
- quality={100}
486
- />
487
- {/*<Image src={"/images/대표메인_팝업_900.jpg"} alt={item.file_alt} width={900} height={70} priority={true} />*/}
488
- </Link>
489
- </div>
490
- </SwiperSlide>
491
- );
492
- })
493
- ) : (
494
- <></>
495
- )}
496
- </Swiper>
497
- ) : (
498
- <></>
499
- )}
500
- </div>
501
- )}
502
- </div>
349
+ {/*pc*/}
350
+ {width > 900 && <PCTopBanner popup={popup} setPopup={setPopup} addClickCnt={addClickCnt} />}
351
+
352
+ {/*mobile*/}
353
+ {width <= 900 && mobileOpen && (
354
+ <MobileTopBanner popup={popup} setMobileOpen={setMobileOpen} addClickCnt={addClickCnt} />
355
+ )}
503
356
  </>
504
357
  );
505
358
  };
@@ -0,0 +1,3 @@
1
+ import { IBannerTypes } from './TopBanner';
2
+ export declare const isTopPopupMobileHidden: () => boolean;
3
+ export declare const tempData: IBannerTypes[];
@@ -0,0 +1,163 @@
1
+ export const isTopPopupMobileHidden = () => {
2
+ if (typeof window === 'undefined')
3
+ return false;
4
+ const hideUntil = localStorage.getItem('topPopupMobileHideUntil');
5
+ if (!hideUntil)
6
+ return false;
7
+ return Number(hideUntil) > Date.now();
8
+ };
9
+ // 임시데이터
10
+ export const tempData = [
11
+ {
12
+ idx: 89,
13
+ color_code: '',
14
+ days: ['월', '화', '수', '목', '금', '토', '일'],
15
+ end_at: '2026-01-16T13:26:00.000Z',
16
+ end_hour: 23,
17
+ end_min: 59,
18
+ file_alt: '법무법인대륜 상단 팝업이미지',
19
+ file_path: '/topBanner',
20
+ file_type: 'file_tab',
21
+ is_show: true,
22
+ link_type: '_blank',
23
+ p_link: 'https://www.daeryunlaw.com/suit/form?type=ST006',
24
+ p_sort: 4,
25
+ save_file_name: 'top_banner_01_tb.webp',
26
+ start_at: '2025-12-02T13:26:00.000Z',
27
+ start_hour: 0,
28
+ start_min: 0
29
+ },
30
+ {
31
+ idx: 89,
32
+ color_code: '',
33
+ days: ['월', '화', '수', '목', '금', '토', '일'],
34
+ end_at: '2026-01-16T13:26:00.000Z',
35
+ end_hour: 23,
36
+ end_min: 59,
37
+ file_alt: '법무법인대륜 상단 팝업이미지',
38
+ file_path: '/topBanner',
39
+ file_type: 'file_mobile',
40
+ is_show: true,
41
+ link_type: '_blank',
42
+ p_link: 'https://www.daeryunlaw.com/suit/form?type=ST006',
43
+ p_sort: 4,
44
+ save_file_name: 'top_banner_01_mo.webp',
45
+ start_at: '2025-12-02T13:26:00.000Z',
46
+ start_hour: 0,
47
+ start_min: 0
48
+ },
49
+ {
50
+ idx: 94,
51
+ color_code: '',
52
+ days: ['월', '화', '수', '목', '금', '토', '일'],
53
+ end_at: '2026-01-27T11:26:00.000Z',
54
+ end_hour: 23,
55
+ end_min: 59,
56
+ file_alt: '법무법인대륜 상단 팝업이미지',
57
+ file_path: '/topBanner',
58
+ file_type: 'file_tab',
59
+ is_show: true,
60
+ link_type: '_blank',
61
+ p_link: 'https://www.daeryunlaw.com/seminar/24',
62
+ p_sort: 3,
63
+ save_file_name: 'top_banner_02_tb.webp',
64
+ start_at: '2026-01-14T11:26:00.000Z',
65
+ start_hour: 0,
66
+ start_min: 0
67
+ },
68
+ {
69
+ idx: 94,
70
+ color_code: '',
71
+ days: ['월', '화', '수', '목', '금', '토', '일'],
72
+ end_at: '2026-01-27T11:26:00.000Z',
73
+ end_hour: 23,
74
+ end_min: 59,
75
+ file_alt: '법무법인대륜 상단 팝업이미지',
76
+ file_path: '/topBanner',
77
+ file_type: 'file_mobile',
78
+ is_show: true,
79
+ link_type: '_blank',
80
+ p_link: 'https://www.daeryunlaw.com/seminar/24',
81
+ p_sort: 3,
82
+ save_file_name: 'top_banner_02_mo.webp',
83
+ start_at: '2026-01-14T11:26:00.000Z',
84
+ start_hour: 0,
85
+ start_min: 0
86
+ },
87
+ {
88
+ idx: 93,
89
+ color_code: '',
90
+ days: ['월', '화', '수', '목', '금', '토', '일'],
91
+ end_at: '2026-01-29T16:35:00.000Z',
92
+ end_hour: 23,
93
+ end_min: 59,
94
+ file_alt: '법무법인대륜 상단 팝업이미지',
95
+ file_path: '/topBanner',
96
+ file_type: 'file_tab',
97
+ is_show: true,
98
+ link_type: '_blank',
99
+ p_link: 'https://www.daeryunlaw.com/notice/6038',
100
+ p_sort: 2,
101
+ save_file_name: 'top_banner_03_tb.webp',
102
+ start_at: '2026-01-14T16:35:00.000Z',
103
+ start_hour: 0,
104
+ start_min: 0
105
+ },
106
+ {
107
+ idx: 93,
108
+ color_code: '',
109
+ days: ['월', '화', '수', '목', '금', '토', '일'],
110
+ end_at: '2026-01-29T16:35:00.000Z',
111
+ end_hour: 23,
112
+ end_min: 59,
113
+ file_alt: '법무법인대륜 상단 팝업이미지',
114
+ file_path: '/topBanner',
115
+ file_type: 'file_mobile',
116
+ is_show: true,
117
+ link_type: '_blank',
118
+ p_link: 'https://www.daeryunlaw.com/notice/6038',
119
+ p_sort: 2,
120
+ save_file_name: 'top_banner_03_mo.webp',
121
+ start_at: '2026-01-14T16:35:00.000Z',
122
+ start_hour: 0,
123
+ start_min: 0
124
+ },
125
+ {
126
+ idx: 90,
127
+ color_code: '',
128
+ days: ['월', '화', '수', '목', '금', '토', '일'],
129
+ end_at: '2026-01-23T11:14:00.000Z',
130
+ end_hour: 23,
131
+ end_min: 59,
132
+ file_alt: '법무법인대륜 상단 팝업이미지',
133
+ file_path: '/topBanner',
134
+ file_type: 'file_tab',
135
+ is_show: true,
136
+ link_type: '_blank',
137
+ p_link: 'https://forms.gle/verSBoCxvqraQy68A',
138
+ p_sort: 1,
139
+ save_file_name: 'top_banner_04_tb.webp',
140
+ start_at: '2025-12-16T11:14:00.000Z',
141
+ start_hour: 0,
142
+ start_min: 0
143
+ },
144
+ {
145
+ idx: 90,
146
+ color_code: '',
147
+ days: ['월', '화', '수', '목', '금', '토', '일'],
148
+ end_at: '2026-01-23T11:14:00.000Z',
149
+ end_hour: 23,
150
+ end_min: 59,
151
+ file_alt: '법무법인대륜 상단 팝업이미지',
152
+ file_path: '/topBanner',
153
+ file_type: 'file_mobile',
154
+ is_show: true,
155
+ link_type: '_blank',
156
+ p_link: 'https://forms.gle/verSBoCxvqraQy68A',
157
+ p_sort: 1,
158
+ save_file_name: 'top_banner_04_mo.webp',
159
+ start_at: '2025-12-16T11:14:00.000Z',
160
+ start_hour: 0,
161
+ start_min: 0
162
+ }
163
+ ];