@daeryun/dr_components 0.2.30 → 0.2.32

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,6 +8,7 @@ import { useQuery } from 'react-query';
8
8
  import { isCurrentTimeWithinPopupRange, paramFetch } from '../../lib';
9
9
  import { DateTime } from 'luxon';
10
10
  import classNames from 'classnames';
11
+ import Link from 'next/link';
11
12
 
12
13
  //배너타입
13
14
  interface IBannerTypes {
@@ -26,6 +27,70 @@ interface IBannerTypes {
26
27
  start_at: string;
27
28
  }
28
29
 
30
+ // 팝업 컴포넌트 스토리북 확인용 더미 데이터
31
+ // const POPUP_DUMMY: IBannerTypes[] = [
32
+ // {
33
+ // color_code: '',
34
+ // days: [0, 1, 2, 3, 4, 5, 6],
35
+ // end_at: '2025-01-30T10:15:00.000Z',
36
+ // file_alt: '법무법인대륜 상단 팝업 더미 이미지 (1) - pc',
37
+ // file_path: '/upload/board/popup',
38
+ // file_type: 'file_pc',
39
+ // idx: 73,
40
+ // is_show: true,
41
+ // link_type: '_blank',
42
+ // p_link: 'https://forms.gle/GAkHoRwHriLHZM46A',
43
+ // p_sort: 0,
44
+ // save_file_name: '20250114105159551.webp',
45
+ // start_at: '2025-01-20T10:15:00.000Z'
46
+ // },
47
+ // {
48
+ // color_code: '',
49
+ // days: [0, 1, 2, 3, 4, 5, 6],
50
+ // end_at: '2025-01-30T10:15:00.000Z',
51
+ // file_alt: '법무법인대륜 상단 팝업 더미 이미지 (1) - mobile',
52
+ // file_path: '/upload/board/popup',
53
+ // file_type: 'file_mobile',
54
+ // idx: 74,
55
+ // is_show: true,
56
+ // link_type: '_blank',
57
+ // p_link: '"https://forms.gle/GAkHoRwHriLHZM46A"',
58
+ // p_sort: 0,
59
+ // save_file_name: '20250114105200057.webp',
60
+ // start_at: '2025-01-20T10:15:00.000Z'
61
+ // },
62
+ // {
63
+ // color_code: '',
64
+ // days: [0, 1, 2, 3, 4, 5, 6],
65
+ // end_at: '2025-01-30T10:15:00.000Z',
66
+ // file_alt: '법무법인대륜 상단 팝업 더미 이미지 (2) - pc',
67
+ // file_path: '/upload/board/popup',
68
+ // file_type: 'file_pc',
69
+ // idx: 73,
70
+ // is_show: true,
71
+ // link_type: '_blank',
72
+ // p_link: 'https://www.daeryunlaw.com/choice',
73
+ // p_sort: 0,
74
+ // save_file_name: '20250116011646039.webp',
75
+ // start_at: '2025-01-20T10:15:00.000Z'
76
+ // },
77
+ // {
78
+ // color_code: '',
79
+ // days: [0, 1, 2, 3, 4, 5, 6],
80
+ // end_at: '2025-01-30T10:15:00.000Z',
81
+ // file_alt: '법무법인대륜 상단 팝업 더미 이미지 (2) - mobile',
82
+ // file_path: '/upload/board/popup',
83
+ // file_type: 'file_mobile',
84
+ // idx: 74,
85
+ // is_show: true,
86
+ // link_type: '_blank',
87
+ // p_link: 'https://www.daeryunlaw.com/choice',
88
+ // p_sort: 0,
89
+ // save_file_name: '20250116011645661.webp',
90
+ // start_at: '2025-01-20T10:15:00.000Z'
91
+ // }
92
+ // ];
93
+
29
94
  const TopBanner = () => {
30
95
  //이미지 패스
31
96
  const ImagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
@@ -72,7 +137,7 @@ const TopBanner = () => {
72
137
  };
73
138
  }, [handleScroll]);
74
139
 
75
- //userQuery
140
+ // userQuery
76
141
  useQuery({
77
142
  queryKey: ['popUpImg'],
78
143
  queryFn: () => getPopUpData(),
@@ -107,6 +172,12 @@ const TopBanner = () => {
107
172
  }
108
173
  });
109
174
 
175
+ // 테스트 로직, 스토리북으로 확인할 때만 활성화 (useQuery는 주석하고)
176
+ // useEffect(() => {
177
+ // setPopup(POPUP_DUMMY);
178
+ // console.log('popup : ', popup);
179
+ // }, [popup]);
180
+
110
181
  const findDays = (item: any, today: string) => {
111
182
  if (item.days) {
112
183
  return item.days.includes(today);
@@ -177,6 +248,21 @@ const TopBanner = () => {
177
248
  localStorage.setItem(idx + '_CloseTopPop', String(expires));
178
249
  };
179
250
 
251
+ // Link Component rel='nofollow' 적용 유무를 위한 함수
252
+ const validateUrl = (linkUrl: string) => {
253
+ if (linkUrl.includes('http')) {
254
+ // 해당 링크가 대륜 페이지로 이동하는지 재확인
255
+ if (linkUrl.includes('daeryunlaw')) {
256
+ return '';
257
+ }
258
+
259
+ // 대륜 이외 페이지라면 nofollow
260
+ return 'nofollow';
261
+ } else {
262
+ return '';
263
+ }
264
+ };
265
+
180
266
  // //query보다 먼저 실행
181
267
  // useEffect(() => {
182
268
  // if (typeof localStorage != 'undefined') {
@@ -196,142 +282,155 @@ const TopBanner = () => {
196
282
  return (
197
283
  <>
198
284
  <div className={style.header_banner_wrap}>
199
- {/*pc*/}
285
+ {/* pc */}
200
286
  <div className={style.header_banner}>
201
- <Swiper
202
- autoplay={{ delay: 5000 }}
203
- modules={[Autoplay]}
204
- loop={popup.filter(item => item.file_type === 'file_pc').length > 1}
205
- >
206
- {popup.length > 0 ? (
207
- popup
208
- .filter(
209
- (item: any) =>
210
- item.file_type === 'file_pc' &&
211
- isCurrentTimeWithinPopupRange(
212
- item.days,
213
- item.startHour,
214
- item.startMin,
215
- item.endHour,
216
- item.endMin
217
- )
218
- )
219
- .map((item: IBannerTypes, index: number) => {
220
- // {popup.length > 0 ? popup.filter((item: IBannerTypes) => item.file_type === 'file_pc').map((item: IBannerTypes, index: number) => {
221
- return (
222
- <SwiperSlide key={index}>
223
- <div className={style.header_banner_btn}>
224
- <button
225
- onClick={() => {
226
- filterClose(item.idx);
227
- addCookie(item.idx);
228
- }}
229
- >
230
- 하루동안 보지않기
231
- </button>
232
- <button
233
- onClick={() => {
234
- filterClose(item.idx);
235
- }}
236
- >
237
- <Image
238
- src="/images/banner_btn.webp"
239
- alt="대륜 배너 이미지"
240
- width={42}
241
- height={42}
242
- />
243
- </button>
244
- </div>
245
- <div
246
- className={style.banner_block}
247
- style={{ background: `#${item.color_code}` }}
248
- >
249
- <a
250
- href={item.p_link}
251
- target={item.link_type}
252
- onClick={() => {
253
- addClickCnt(item.idx);
254
- }}
287
+ {popup && popup.filter(item => item.file_type === 'file_pc').length > 0 ? (
288
+ <Swiper
289
+ autoplay={{ delay: 5000 }}
290
+ modules={[Autoplay]}
291
+ loop={popup.filter(item => item.file_type === 'file_pc').length > 1}
292
+ >
293
+ {popup.length > 0 ? (
294
+ popup
295
+ .filter(
296
+ (item: any) =>
297
+ item.file_type === 'file_pc' &&
298
+ isCurrentTimeWithinPopupRange(
299
+ item.days,
300
+ item.startHour,
301
+ item.startMin,
302
+ item.endHour,
303
+ item.endMin
304
+ )
305
+ )
306
+ .map((item: IBannerTypes, index: number) => {
307
+ // {popup.length > 0 ? popup.filter((item: IBannerTypes) => item.file_type === 'file_pc').map((item: IBannerTypes, index: number) => {
308
+ return (
309
+ <SwiperSlide key={index}>
310
+ <div className={style.header_banner_btn}>
311
+ <button
312
+ onClick={() => {
313
+ filterClose(item.idx);
314
+ addCookie(item.idx);
315
+ }}
316
+ >
317
+ 하루동안 보지않기
318
+ </button>
319
+ <button
320
+ onClick={() => {
321
+ filterClose(item.idx);
322
+ }}
323
+ >
324
+ <Image
325
+ src="/images/banner_btn.webp"
326
+ alt="대륜 배너 닫기 이미지"
327
+ width={42}
328
+ height={42}
329
+ />
330
+ </button>
331
+ </div>
332
+ <div
333
+ className={style.banner_block}
334
+ style={{ background: `#${item.color_code}` }}
255
335
  >
256
- <Image
257
- src={ImagePath + item.file_path + '/' + item.save_file_name}
258
- alt={item.file_alt}
259
- width={2000}
260
- height={60}
261
- priority={true}
262
- quality={100}
263
- loading={'eager'}
264
- />
265
- {/*<Image src={"/images/대표메인_팝업_PC.jpg"} alt={item.file_alt} width={1920} height={50} priority={true} />*/}
266
- </a>
267
- </div>
268
- </SwiperSlide>
269
- );
270
- })
271
- ) : (
272
- <></>
273
- )}
274
- </Swiper>
336
+ <Link
337
+ href={item.p_link}
338
+ target={item.link_type}
339
+ onClick={() => {
340
+ addClickCnt(item.idx);
341
+ }}
342
+ rel={validateUrl(item.p_link)}
343
+ >
344
+ <Image
345
+ src={ImagePath + item.file_path + '/' + item.save_file_name}
346
+ alt={item.file_alt}
347
+ width={2000}
348
+ height={60}
349
+ priority={true}
350
+ quality={100}
351
+ loading={'eager'}
352
+ />
353
+ {/*<Image src={"/images/대표메인_팝업_PC.jpg"} alt={item.file_alt} width={1920} height={50} priority={true} />*/}
354
+ </Link>
355
+ </div>
356
+ </SwiperSlide>
357
+ );
358
+ })
359
+ ) : (
360
+ <></>
361
+ )}
362
+ </Swiper>
363
+ ) : (
364
+ <></>
365
+ )}
275
366
  </div>
276
367
 
277
- {/*mobile*/}
368
+ {/* mobile */}
278
369
  <div
279
370
  className={classNames({
280
371
  [style.header_banner_m]: true,
281
372
  [style.header_banner_fix]: isTop === true ? true : false
282
373
  })}
283
374
  >
284
- <Swiper
285
- autoplay={{ delay: 5000 }}
286
- modules={[Autoplay]}
287
- loop={popup.filter((item: IBannerTypes) => item.file_type === 'file_mobile').length > 1}
288
- >
289
- {popup.length > 0 ? (
290
- popup
291
- .filter((item: IBannerTypes) => item.file_type === 'file_mobile')
292
- .map((item: IBannerTypes, index: number) => {
293
- return (
294
- <SwiperSlide key={index}>
295
- <div className={style.header_banner_m_btn}>
296
- <button
297
- onClick={() => {
298
- filterClose(item.idx);
299
- addCookie(item.idx);
300
- }}
301
- >
302
- 하루동안 보지않기
303
- </button>
304
- <button
305
- onClick={() => {
306
- filterClose(item.idx);
307
- }}
308
- >
309
- 닫기
310
- </button>
311
- </div>
312
- <div className={style.banner_block_m}>
313
- <a href={item.p_link} target={item.link_type}>
314
- <Image
315
- src={ImagePath + item.file_path + '/' + item.save_file_name}
316
- alt={item.file_alt}
317
- width={900}
318
- height={150}
319
- priority={true}
375
+ {popup && popup.filter(item => item.file_type === 'file_mobile').length > 0 ? (
376
+ <Swiper
377
+ autoplay={{ delay: 5000 }}
378
+ modules={[Autoplay]}
379
+ loop={popup.filter((item: IBannerTypes) => item.file_type === 'file_mobile').length > 1}
380
+ >
381
+ {popup.length > 0 ? (
382
+ popup
383
+ .filter((item: IBannerTypes) => item.file_type === 'file_mobile')
384
+ .map((item: IBannerTypes, index: number) => {
385
+ return (
386
+ <SwiperSlide key={index}>
387
+ <div className={style.header_banner_m_btn}>
388
+ <button
320
389
  onClick={() => {
321
- addClickCnt(item.idx);
390
+ filterClose(item.idx);
391
+ addCookie(item.idx);
392
+ }}
393
+ >
394
+ 하루동안 보지않기
395
+ </button>
396
+ <button
397
+ onClick={() => {
398
+ filterClose(item.idx);
322
399
  }}
323
- quality={100}
324
- />
325
- {/*<Image src={"/images/대표메인_팝업_900.jpg"} alt={item.file_alt} width={900} height={70} priority={true} />*/}
326
- </a>
327
- </div>
328
- </SwiperSlide>
329
- );
330
- })
331
- ) : (
332
- <></>
333
- )}
334
- </Swiper>
400
+ >
401
+ 닫기
402
+ </button>
403
+ </div>
404
+ <div className={style.banner_block_m}>
405
+ <Link
406
+ href={item.p_link}
407
+ target={item.link_type}
408
+ rel={validateUrl(item.p_link)}
409
+ >
410
+ <Image
411
+ src={ImagePath + item.file_path + '/' + item.save_file_name}
412
+ alt={item.file_alt}
413
+ width={900}
414
+ height={150}
415
+ priority={true}
416
+ onClick={() => {
417
+ addClickCnt(item.idx);
418
+ }}
419
+ quality={100}
420
+ />
421
+ {/*<Image src={"/images/대표메인_팝업_900.jpg"} alt={item.file_alt} width={900} height={70} priority={true} />*/}
422
+ </Link>
423
+ </div>
424
+ </SwiperSlide>
425
+ );
426
+ })
427
+ ) : (
428
+ <></>
429
+ )}
430
+ </Swiper>
431
+ ) : (
432
+ <></>
433
+ )}
335
434
  </div>
336
435
  </div>
337
436
  </>