@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.
- package/dist/components/banner/MobileTopBanner.d.ts +7 -0
- package/dist/components/banner/MobileTopBanner.jsx +122 -0
- package/dist/components/banner/MobileTopBanner.tsx +183 -0
- package/dist/components/banner/PCTopBanner.d.ts +10 -0
- package/dist/components/banner/PCTopBanner.jsx +101 -0
- package/dist/components/banner/PCTopBanner.tsx +172 -0
- package/dist/components/banner/TopBanner.d.ts +21 -0
- package/dist/components/banner/TopBanner.jsx +11 -83
- package/dist/components/banner/TopBanner.tsx +21 -168
- package/dist/components/banner/common.d.ts +3 -0
- package/dist/components/banner/common.js +163 -0
- package/dist/components/banner/common.ts +167 -0
- package/dist/styles/globals.css +77 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IBannerTypes } from './TopBanner';
|
|
2
|
+
declare const MobileTopBanner: ({ popup, setMobileOpen, addClickCnt }: {
|
|
3
|
+
popup: IBannerTypes[];
|
|
4
|
+
setMobileOpen: (v: boolean) => void;
|
|
5
|
+
addClickCnt: (idx: number) => void;
|
|
6
|
+
}) => false | import("react").JSX.Element;
|
|
7
|
+
export default MobileTopBanner;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Swiper } from 'swiper';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import Image from 'next/image';
|
|
5
|
+
import { tempData } from './common';
|
|
6
|
+
import useBrowser from '../hook/useBrowser';
|
|
7
|
+
import { Autoplay } from 'swiper/modules';
|
|
8
|
+
const MobileTopBanner = ({ popup, setMobileOpen, addClickCnt }) => {
|
|
9
|
+
const { width } = useBrowser(true);
|
|
10
|
+
const swiper = useRef(null);
|
|
11
|
+
const [index, setIndex] = useState(1);
|
|
12
|
+
// const currentPopup = useMemo(() => {
|
|
13
|
+
// if (width === 0) return []
|
|
14
|
+
// return popup.filter((item) => item.file_type === (width >= 640 ? 'file_tab' : 'file_mobile'))
|
|
15
|
+
// }, [popup, width])
|
|
16
|
+
const currentPopup = useMemo(() => {
|
|
17
|
+
if (width === 0)
|
|
18
|
+
return [];
|
|
19
|
+
return tempData.filter(item => item.file_type === (width >= 480 ? 'file_tab' : 'file_mobile'));
|
|
20
|
+
}, [popup, width]);
|
|
21
|
+
//이미지 패스
|
|
22
|
+
const ImagePath = process.env.NEXT_PUBLIC_S3_URL + '';
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const el = document.querySelector('#swiper-banner');
|
|
25
|
+
if (!el)
|
|
26
|
+
return;
|
|
27
|
+
swiper.current = new Swiper(el, {
|
|
28
|
+
spaceBetween: 0,
|
|
29
|
+
slidesPerView: 1,
|
|
30
|
+
autoplay: { delay: 3500, disableOnInteraction: false },
|
|
31
|
+
modules: [Autoplay],
|
|
32
|
+
on: {
|
|
33
|
+
slideChange(sw) {
|
|
34
|
+
if (sw.destroyed)
|
|
35
|
+
return;
|
|
36
|
+
setIndex(sw.realIndex + 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return () => {
|
|
41
|
+
if (swiper.current && swiper.current.destroy) {
|
|
42
|
+
swiper.current.destroy();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, [currentPopup]);
|
|
46
|
+
//휠 잠금
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (currentPopup.length > 0) {
|
|
49
|
+
const scrollY = window.scrollY;
|
|
50
|
+
document.body.style.position = 'fixed';
|
|
51
|
+
document.body.style.top = `-${scrollY}px`;
|
|
52
|
+
document.body.style.width = '100%';
|
|
53
|
+
}
|
|
54
|
+
return () => {
|
|
55
|
+
document.body.style.position = '';
|
|
56
|
+
document.body.style.top = '';
|
|
57
|
+
document.body.style.width = '';
|
|
58
|
+
window.scrollTo(0, scrollY);
|
|
59
|
+
};
|
|
60
|
+
}, [currentPopup]);
|
|
61
|
+
// 하루동안 보지않기
|
|
62
|
+
const closeForOneDay = () => {
|
|
63
|
+
//내일 현재시간까지
|
|
64
|
+
const nowDate = new Date();
|
|
65
|
+
const expires = nowDate.setHours(nowDate.getHours() + 24);
|
|
66
|
+
localStorage.setItem('topPopupMobileHideUntil', String(expires));
|
|
67
|
+
setMobileOpen(false);
|
|
68
|
+
};
|
|
69
|
+
// Link Component rel='nofollow' 적용 유무를 위한 함수
|
|
70
|
+
const validateUrl = (linkUrl) => {
|
|
71
|
+
if (linkUrl.includes('http')) {
|
|
72
|
+
// 해당 링크가 대륜 페이지로 이동하는지 재확인
|
|
73
|
+
if (linkUrl.includes('daeryunlaw')) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
// 대륜 이외 페이지라면 nofollow
|
|
77
|
+
return 'nofollow';
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return (currentPopup.length > 0 && (<>
|
|
84
|
+
<div className={'animate-fadeInFast pointer-events-auto fixed left-0 top-0 z-[9999] h-full w-full bg-[#000] bg-opacity-75'} onClick={() => {
|
|
85
|
+
setMobileOpen(false);
|
|
86
|
+
}}/>
|
|
87
|
+
<div className={'pointer-events-auto fixed bottom-0 left-0 z-[99991] flex w-full flex-col '}>
|
|
88
|
+
<div className={'mb-[16px] mr-[60px] flex w-[66px] items-center justify-center self-end rounded-full bg-[#90909080] py-[6px] text-[18px] tracking-[-0.02em] text-white ' +
|
|
89
|
+
'max-md:mr-[40px] ' +
|
|
90
|
+
'max-sm:mr-[16px] max-sm:w-[47px] max-sm:py-[4px] max-sm:text-[14px]'}>
|
|
91
|
+
{index} / {currentPopup.length}
|
|
92
|
+
</div>
|
|
93
|
+
<div id={'swiper-banner'} className={'swiper aspect-[900/392] h-auto w-full rounded-t-[40px] bg-[#ddd] ' +
|
|
94
|
+
'max-xs:aspect-[360/216] max-xs:rounded-t-[20px] '}>
|
|
95
|
+
<span className={'swiper-wrapper'}>
|
|
96
|
+
{currentPopup.map((item, index) => {
|
|
97
|
+
return (<Link key={'Banner_m_' + index} href={item.mobile_link || item.p_link} target={item.link_type} className={'swiper-slide relative'} rel={validateUrl(item.mobile_link || item.p_link)}>
|
|
98
|
+
<Image src={ImagePath + item.file_path + '/' + item.save_file_name}
|
|
99
|
+
// alt={item.file_alt}
|
|
100
|
+
alt={'주말, 공휴일에도 방문상담 접수 진행 중입니다.'} fill onClick={() => {
|
|
101
|
+
addClickCnt(item.idx);
|
|
102
|
+
}} priority fetchPriority="high" sizes={'100vw'} className={'h-full w-full object-contain'}/>
|
|
103
|
+
</Link>);
|
|
104
|
+
})}
|
|
105
|
+
</span>
|
|
106
|
+
</div>
|
|
107
|
+
<div className={'flex h-[80px] w-full items-start justify-between bg-white px-[60px] py-[20px] ' +
|
|
108
|
+
'max-md:px-[40px] max-md:text-[16px] ' +
|
|
109
|
+
'max-sm:h-[60px] max-sm:p-[16px]'}>
|
|
110
|
+
<button className={'text-[18px] leading-[1.4] tracking-[-0.02em] text-[#909090] max-sm:text-[13px]'} onClick={closeForOneDay}>
|
|
111
|
+
오늘 하루 보지 않기
|
|
112
|
+
</button>
|
|
113
|
+
<button className={'text-[18px] leading-[1.4] tracking-[-0.02em] max-sm:text-[13px]'} onClick={() => {
|
|
114
|
+
setMobileOpen(false);
|
|
115
|
+
}}>
|
|
116
|
+
닫기
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</>));
|
|
121
|
+
};
|
|
122
|
+
export default MobileTopBanner;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { IBannerTypes } from './TopBanner';
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Swiper } from 'swiper';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import Image from 'next/image';
|
|
6
|
+
import { useTranslation } from 'next-i18next';
|
|
7
|
+
import { tempData } from './common';
|
|
8
|
+
import useBrowser from '../hook/useBrowser';
|
|
9
|
+
import { Autoplay } from 'swiper/modules';
|
|
10
|
+
|
|
11
|
+
const MobileTopBanner = ({
|
|
12
|
+
popup,
|
|
13
|
+
setMobileOpen,
|
|
14
|
+
addClickCnt
|
|
15
|
+
}: {
|
|
16
|
+
popup: IBannerTypes[];
|
|
17
|
+
setMobileOpen: (v: boolean) => void;
|
|
18
|
+
addClickCnt: (idx: number) => void;
|
|
19
|
+
}) => {
|
|
20
|
+
const { width } = useBrowser(true);
|
|
21
|
+
const swiper = useRef<Swiper | null>(null);
|
|
22
|
+
const [index, setIndex] = useState(1);
|
|
23
|
+
// const currentPopup = useMemo(() => {
|
|
24
|
+
// if (width === 0) return []
|
|
25
|
+
// return popup.filter((item) => item.file_type === (width >= 640 ? 'file_tab' : 'file_mobile'))
|
|
26
|
+
// }, [popup, width])
|
|
27
|
+
const currentPopup = useMemo(() => {
|
|
28
|
+
if (width === 0) return [];
|
|
29
|
+
return tempData.filter(item => item.file_type === (width >= 480 ? 'file_tab' : 'file_mobile'));
|
|
30
|
+
}, [popup, width]);
|
|
31
|
+
|
|
32
|
+
//이미지 패스
|
|
33
|
+
const ImagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const el = document.querySelector('#swiper-banner');
|
|
37
|
+
if (!el) return;
|
|
38
|
+
|
|
39
|
+
swiper.current = new Swiper(el as HTMLElement, {
|
|
40
|
+
spaceBetween: 0,
|
|
41
|
+
slidesPerView: 1,
|
|
42
|
+
autoplay: { delay: 3500, disableOnInteraction: false },
|
|
43
|
+
modules: [Autoplay],
|
|
44
|
+
on: {
|
|
45
|
+
slideChange(sw) {
|
|
46
|
+
if (sw.destroyed) return;
|
|
47
|
+
setIndex(sw.realIndex + 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
if (swiper.current && swiper.current.destroy) {
|
|
54
|
+
swiper.current.destroy();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [currentPopup]);
|
|
58
|
+
|
|
59
|
+
//휠 잠금
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (currentPopup.length > 0) {
|
|
62
|
+
const scrollY = window.scrollY;
|
|
63
|
+
document.body.style.position = 'fixed';
|
|
64
|
+
document.body.style.top = `-${scrollY}px`;
|
|
65
|
+
document.body.style.width = '100%';
|
|
66
|
+
}
|
|
67
|
+
return () => {
|
|
68
|
+
document.body.style.position = '';
|
|
69
|
+
document.body.style.top = '';
|
|
70
|
+
document.body.style.width = '';
|
|
71
|
+
window.scrollTo(0, scrollY);
|
|
72
|
+
};
|
|
73
|
+
}, [currentPopup]);
|
|
74
|
+
|
|
75
|
+
// 하루동안 보지않기
|
|
76
|
+
const closeForOneDay = () => {
|
|
77
|
+
//내일 현재시간까지
|
|
78
|
+
const nowDate = new Date();
|
|
79
|
+
const expires = nowDate.setHours(nowDate.getHours() + 24);
|
|
80
|
+
localStorage.setItem('topPopupMobileHideUntil', String(expires));
|
|
81
|
+
setMobileOpen(false);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Link Component rel='nofollow' 적용 유무를 위한 함수
|
|
85
|
+
const validateUrl = (linkUrl: string) => {
|
|
86
|
+
if (linkUrl.includes('http')) {
|
|
87
|
+
// 해당 링크가 대륜 페이지로 이동하는지 재확인
|
|
88
|
+
if (linkUrl.includes('daeryunlaw')) {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 대륜 이외 페이지라면 nofollow
|
|
93
|
+
return 'nofollow';
|
|
94
|
+
} else {
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
currentPopup.length > 0 && (
|
|
101
|
+
<>
|
|
102
|
+
<div
|
|
103
|
+
className={
|
|
104
|
+
'animate-fadeInFast pointer-events-auto fixed left-0 top-0 z-[9999] h-full w-full bg-[#000] bg-opacity-75'
|
|
105
|
+
}
|
|
106
|
+
onClick={() => {
|
|
107
|
+
setMobileOpen(false);
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
<div className={'pointer-events-auto fixed bottom-0 left-0 z-[99991] flex w-full flex-col '}>
|
|
111
|
+
<div
|
|
112
|
+
className={
|
|
113
|
+
'mb-[16px] mr-[60px] flex w-[66px] items-center justify-center self-end rounded-full bg-[#90909080] py-[6px] text-[18px] tracking-[-0.02em] text-white ' +
|
|
114
|
+
'max-md:mr-[40px] ' +
|
|
115
|
+
'max-sm:mr-[16px] max-sm:w-[47px] max-sm:py-[4px] max-sm:text-[14px]'
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
{index} / {currentPopup.length}
|
|
119
|
+
</div>
|
|
120
|
+
<div
|
|
121
|
+
id={'swiper-banner'}
|
|
122
|
+
className={
|
|
123
|
+
'swiper aspect-[900/392] h-auto w-full rounded-t-[40px] bg-[#ddd] ' +
|
|
124
|
+
'max-xs:aspect-[360/216] max-xs:rounded-t-[20px] '
|
|
125
|
+
}
|
|
126
|
+
>
|
|
127
|
+
<span className={'swiper-wrapper'}>
|
|
128
|
+
{currentPopup.map((item: IBannerTypes, index: number) => {
|
|
129
|
+
return (
|
|
130
|
+
<Link
|
|
131
|
+
key={'Banner_m_' + index}
|
|
132
|
+
href={item.mobile_link || item.p_link}
|
|
133
|
+
target={item.link_type}
|
|
134
|
+
className={'swiper-slide relative'}
|
|
135
|
+
rel={validateUrl(item.mobile_link || item.p_link)}
|
|
136
|
+
>
|
|
137
|
+
<Image
|
|
138
|
+
src={ImagePath + item.file_path + '/' + item.save_file_name}
|
|
139
|
+
// alt={item.file_alt}
|
|
140
|
+
alt={'주말, 공휴일에도 방문상담 접수 진행 중입니다.'}
|
|
141
|
+
fill
|
|
142
|
+
onClick={() => {
|
|
143
|
+
addClickCnt(item.idx);
|
|
144
|
+
}}
|
|
145
|
+
priority
|
|
146
|
+
fetchPriority="high"
|
|
147
|
+
sizes={'100vw'}
|
|
148
|
+
className={'h-full w-full object-contain'}
|
|
149
|
+
/>
|
|
150
|
+
</Link>
|
|
151
|
+
);
|
|
152
|
+
})}
|
|
153
|
+
</span>
|
|
154
|
+
</div>
|
|
155
|
+
<div
|
|
156
|
+
className={
|
|
157
|
+
'flex h-[80px] w-full items-start justify-between bg-white px-[60px] py-[20px] ' +
|
|
158
|
+
'max-md:px-[40px] max-md:text-[16px] ' +
|
|
159
|
+
'max-sm:h-[60px] max-sm:p-[16px]'
|
|
160
|
+
}
|
|
161
|
+
>
|
|
162
|
+
<button
|
|
163
|
+
className={'text-[18px] leading-[1.4] tracking-[-0.02em] text-[#909090] max-sm:text-[13px]'}
|
|
164
|
+
onClick={closeForOneDay}
|
|
165
|
+
>
|
|
166
|
+
오늘 하루 보지 않기
|
|
167
|
+
</button>
|
|
168
|
+
<button
|
|
169
|
+
className={'text-[18px] leading-[1.4] tracking-[-0.02em] max-sm:text-[13px]'}
|
|
170
|
+
onClick={() => {
|
|
171
|
+
setMobileOpen(false);
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
닫기
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</>
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export default MobileTopBanner;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IBannerTypes } from './TopBanner';
|
|
3
|
+
import { SetterOrUpdater } from 'recoil';
|
|
4
|
+
declare const PCTopBanner: ({ popup, setPopup, addClickCnt, setBannerHeight }: {
|
|
5
|
+
popup: IBannerTypes[];
|
|
6
|
+
setPopup: (v: IBannerTypes[]) => void;
|
|
7
|
+
addClickCnt: (idx: number) => void;
|
|
8
|
+
setBannerHeight?: SetterOrUpdater<number>;
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
export default PCTopBanner;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import style from './TopBanner.module.css';
|
|
2
|
+
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { isCurrentTimeWithinPopupRange } from '../../lib';
|
|
7
|
+
import useBrowser from '../hook/useBrowser';
|
|
8
|
+
import { Autoplay } from 'swiper/modules';
|
|
9
|
+
const PCTopBanner = ({ popup, setPopup, addClickCnt, setBannerHeight }) => {
|
|
10
|
+
const { width } = useBrowser(true);
|
|
11
|
+
const [swiperKey, setSwiperKey] = useState(0);
|
|
12
|
+
const bannerRef = useRef(null);
|
|
13
|
+
//이미지 패스
|
|
14
|
+
const ImagePath = process.env.NEXT_PUBLIC_S3_URL + '';
|
|
15
|
+
// 배너 높이
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const updateBannerHeight = () => {
|
|
18
|
+
if (bannerRef.current) {
|
|
19
|
+
const height = bannerRef.current.offsetHeight;
|
|
20
|
+
if (setBannerHeight)
|
|
21
|
+
setBannerHeight(height);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
updateBannerHeight();
|
|
25
|
+
if (bannerRef.current && setBannerHeight) {
|
|
26
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
27
|
+
updateBannerHeight();
|
|
28
|
+
});
|
|
29
|
+
resizeObserver.observe(bannerRef.current);
|
|
30
|
+
return () => {
|
|
31
|
+
resizeObserver.disconnect();
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}, [setBannerHeight]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setSwiperKey(prev => prev + 1);
|
|
37
|
+
}, [width]);
|
|
38
|
+
//data.list에서 해당 idx를 삭제하는 함수
|
|
39
|
+
const filterClose = (idx) => {
|
|
40
|
+
const filterData = popup.filter((item) => item.idx !== idx);
|
|
41
|
+
setPopup(filterData);
|
|
42
|
+
};
|
|
43
|
+
//스토리지 저장
|
|
44
|
+
const addCookie = (idx) => {
|
|
45
|
+
//내일 현재시간까지
|
|
46
|
+
const nowDate = new Date();
|
|
47
|
+
const expires = nowDate.setHours(nowDate.getHours() + 24);
|
|
48
|
+
localStorage.setItem(idx + '_CloseTopPop', String(expires));
|
|
49
|
+
};
|
|
50
|
+
// 하루동안 보지않기 (localStorage 저장 + 캐시 무효화)
|
|
51
|
+
const closeForOneDay = (idx) => {
|
|
52
|
+
addCookie(idx);
|
|
53
|
+
filterClose(idx);
|
|
54
|
+
};
|
|
55
|
+
// Link Component rel='nofollow' 적용 유무를 위한 함수
|
|
56
|
+
const validateUrl = (linkUrl) => {
|
|
57
|
+
if (linkUrl.includes('http')) {
|
|
58
|
+
// 해당 링크가 대륜 페이지로 이동하는지 재확인
|
|
59
|
+
if (linkUrl.includes('daeryunlaw')) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
// 대륜 이외 페이지라면 nofollow
|
|
63
|
+
return 'nofollow';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return (<div ref={bannerRef} id={'banner_wrap'} className={popup.length > 0 ? style.header_banner_wrap : ' pointer-events-auto hidden'}>
|
|
70
|
+
<div className={style.header_banner + ' pointer-events-auto'}>
|
|
71
|
+
{popup && popup.filter(item => item.file_type === 'file_pc').length > 0 ? (<Swiper key={swiperKey} autoplay={{ delay: 3000, disableOnInteraction: false }} modules={[Autoplay]} speed={600} loop={popup.filter(item => item.file_type === 'file_pc').length > 1}>
|
|
72
|
+
{popup
|
|
73
|
+
.filter((item) => item.file_type === 'file_pc' &&
|
|
74
|
+
isCurrentTimeWithinPopupRange(item.days, item.startHour, item.startMin, item.endHour, item.endMin))
|
|
75
|
+
.map((item, index) => {
|
|
76
|
+
// {popup.length > 0 ? popup.filter((item: IBannerTypes) => item.file_type === 'file_pc').map((item: IBannerTypes, index: number) => {
|
|
77
|
+
return (<SwiperSlide key={index}>
|
|
78
|
+
<div className={style.header_banner_btn}>
|
|
79
|
+
<button onClick={() => closeForOneDay(item.idx)}>하루동안 보지않기</button>
|
|
80
|
+
<button onClick={() => {
|
|
81
|
+
filterClose(item.idx);
|
|
82
|
+
}}>
|
|
83
|
+
<Image src="/images/banner_btn.webp" alt="하단 팝업 닫기" width={42} height={42}/>
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
<div className={style.banner_block} style={{ background: `#${item.color_code}` }}>
|
|
87
|
+
<Link href={item.pc_link || item.p_link} target={item.link_type} onClick={() => {
|
|
88
|
+
addClickCnt(item.idx);
|
|
89
|
+
}} rel={validateUrl(item.p_link)}>
|
|
90
|
+
<Image src={ImagePath + item.file_path + '/' + item.save_file_name}
|
|
91
|
+
// alt={item.file_alt}
|
|
92
|
+
alt={item.file_alt} width={2000} height={60} quality={85} priority fetchPriority="high"/>
|
|
93
|
+
</Link>
|
|
94
|
+
</div>
|
|
95
|
+
</SwiperSlide>);
|
|
96
|
+
})}
|
|
97
|
+
</Swiper>) : (<></>)}
|
|
98
|
+
</div>
|
|
99
|
+
</div>);
|
|
100
|
+
};
|
|
101
|
+
export default PCTopBanner;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import style from './TopBanner.module.css';
|
|
2
|
+
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { IBannerTypes } from './TopBanner';
|
|
7
|
+
import { SetterOrUpdater } from 'recoil';
|
|
8
|
+
import { isCurrentTimeWithinPopupRange } from '../../lib';
|
|
9
|
+
import useBrowser from '../hook/useBrowser';
|
|
10
|
+
import { Autoplay } from 'swiper/modules';
|
|
11
|
+
|
|
12
|
+
const PCTopBanner = ({
|
|
13
|
+
popup,
|
|
14
|
+
setPopup,
|
|
15
|
+
addClickCnt,
|
|
16
|
+
setBannerHeight
|
|
17
|
+
}: {
|
|
18
|
+
popup: IBannerTypes[];
|
|
19
|
+
setPopup: (v: IBannerTypes[]) => void;
|
|
20
|
+
addClickCnt: (idx: number) => void;
|
|
21
|
+
setBannerHeight?: SetterOrUpdater<number>;
|
|
22
|
+
}) => {
|
|
23
|
+
const { width } = useBrowser(true);
|
|
24
|
+
const [swiperKey, setSwiperKey] = useState(0);
|
|
25
|
+
const bannerRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
|
|
27
|
+
//이미지 패스
|
|
28
|
+
const ImagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
|
|
29
|
+
|
|
30
|
+
// 배너 높이
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const updateBannerHeight = () => {
|
|
33
|
+
if (bannerRef.current) {
|
|
34
|
+
const height = bannerRef.current.offsetHeight;
|
|
35
|
+
if (setBannerHeight) setBannerHeight(height);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
updateBannerHeight();
|
|
39
|
+
|
|
40
|
+
if (bannerRef.current && setBannerHeight) {
|
|
41
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
42
|
+
updateBannerHeight();
|
|
43
|
+
});
|
|
44
|
+
resizeObserver.observe(bannerRef.current);
|
|
45
|
+
return () => {
|
|
46
|
+
resizeObserver.disconnect();
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}, [setBannerHeight]);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setSwiperKey(prev => prev + 1);
|
|
53
|
+
}, [width]);
|
|
54
|
+
|
|
55
|
+
//data.list에서 해당 idx를 삭제하는 함수
|
|
56
|
+
const filterClose = (idx: number) => {
|
|
57
|
+
const filterData = popup.filter((item: IBannerTypes) => item.idx !== idx);
|
|
58
|
+
setPopup(filterData);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//스토리지 저장
|
|
62
|
+
const addCookie = (idx: number) => {
|
|
63
|
+
//내일 현재시간까지
|
|
64
|
+
const nowDate = new Date();
|
|
65
|
+
const expires = nowDate.setHours(nowDate.getHours() + 24);
|
|
66
|
+
localStorage.setItem(idx + '_CloseTopPop', String(expires));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// 하루동안 보지않기 (localStorage 저장 + 캐시 무효화)
|
|
70
|
+
const closeForOneDay = (idx: number) => {
|
|
71
|
+
addCookie(idx);
|
|
72
|
+
filterClose(idx);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Link Component rel='nofollow' 적용 유무를 위한 함수
|
|
76
|
+
const validateUrl = (linkUrl: string) => {
|
|
77
|
+
if (linkUrl.includes('http')) {
|
|
78
|
+
// 해당 링크가 대륜 페이지로 이동하는지 재확인
|
|
79
|
+
if (linkUrl.includes('daeryunlaw')) {
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 대륜 이외 페이지라면 nofollow
|
|
84
|
+
return 'nofollow';
|
|
85
|
+
} else {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
ref={bannerRef}
|
|
93
|
+
id={'banner_wrap'}
|
|
94
|
+
className={popup.length > 0 ? style.header_banner_wrap : ' pointer-events-auto hidden'}
|
|
95
|
+
>
|
|
96
|
+
<div className={style.header_banner + ' pointer-events-auto'}>
|
|
97
|
+
{popup && popup.filter(item => item.file_type === 'file_pc').length > 0 ? (
|
|
98
|
+
<Swiper
|
|
99
|
+
key={swiperKey}
|
|
100
|
+
autoplay={{ delay: 3000, disableOnInteraction: false }}
|
|
101
|
+
modules={[Autoplay]}
|
|
102
|
+
speed={600}
|
|
103
|
+
loop={popup.filter(item => item.file_type === 'file_pc').length > 1}
|
|
104
|
+
>
|
|
105
|
+
{popup
|
|
106
|
+
.filter(
|
|
107
|
+
(item: any) =>
|
|
108
|
+
item.file_type === 'file_pc' &&
|
|
109
|
+
isCurrentTimeWithinPopupRange(
|
|
110
|
+
item.days,
|
|
111
|
+
item.startHour,
|
|
112
|
+
item.startMin,
|
|
113
|
+
item.endHour,
|
|
114
|
+
item.endMin
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
.map((item: IBannerTypes, index: number) => {
|
|
118
|
+
// {popup.length > 0 ? popup.filter((item: IBannerTypes) => item.file_type === 'file_pc').map((item: IBannerTypes, index: number) => {
|
|
119
|
+
return (
|
|
120
|
+
<SwiperSlide key={index}>
|
|
121
|
+
<div className={style.header_banner_btn}>
|
|
122
|
+
<button onClick={() => closeForOneDay(item.idx)}>하루동안 보지않기</button>
|
|
123
|
+
<button
|
|
124
|
+
onClick={() => {
|
|
125
|
+
filterClose(item.idx);
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
<Image
|
|
129
|
+
src="/images/banner_btn.webp"
|
|
130
|
+
alt="하단 팝업 닫기"
|
|
131
|
+
width={42}
|
|
132
|
+
height={42}
|
|
133
|
+
/>
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
<div
|
|
137
|
+
className={style.banner_block}
|
|
138
|
+
style={{ background: `#${item.color_code}` }}
|
|
139
|
+
>
|
|
140
|
+
<Link
|
|
141
|
+
href={item.pc_link || item.p_link}
|
|
142
|
+
target={item.link_type}
|
|
143
|
+
onClick={() => {
|
|
144
|
+
addClickCnt(item.idx);
|
|
145
|
+
}}
|
|
146
|
+
rel={validateUrl(item.p_link)}
|
|
147
|
+
>
|
|
148
|
+
<Image
|
|
149
|
+
src={ImagePath + item.file_path + '/' + item.save_file_name}
|
|
150
|
+
// alt={item.file_alt}
|
|
151
|
+
alt={item.file_alt}
|
|
152
|
+
width={2000}
|
|
153
|
+
height={60}
|
|
154
|
+
quality={85}
|
|
155
|
+
priority
|
|
156
|
+
fetchPriority="high"
|
|
157
|
+
/>
|
|
158
|
+
</Link>
|
|
159
|
+
</div>
|
|
160
|
+
</SwiperSlide>
|
|
161
|
+
);
|
|
162
|
+
})}
|
|
163
|
+
</Swiper>
|
|
164
|
+
) : (
|
|
165
|
+
<></>
|
|
166
|
+
)}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export default PCTopBanner;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import 'swiper/css';
|
|
2
2
|
import { SetterOrUpdater } from 'recoil';
|
|
3
|
+
export interface IBannerTypes {
|
|
4
|
+
color_code: string;
|
|
5
|
+
days: string[];
|
|
6
|
+
start_at: string;
|
|
7
|
+
start_hour: number;
|
|
8
|
+
start_min: number;
|
|
9
|
+
end_at: string;
|
|
10
|
+
end_hour: number;
|
|
11
|
+
end_min: number;
|
|
12
|
+
file_alt: string;
|
|
13
|
+
file_path: string;
|
|
14
|
+
file_type: string;
|
|
15
|
+
idx: number;
|
|
16
|
+
is_show: boolean;
|
|
17
|
+
link_type: string;
|
|
18
|
+
p_link: string;
|
|
19
|
+
p_sort: number;
|
|
20
|
+
save_file_name: string;
|
|
21
|
+
pc_link?: string;
|
|
22
|
+
mobile_link?: string;
|
|
23
|
+
}
|
|
3
24
|
declare const TopBanner: ({ setBannerHeight }: {
|
|
4
25
|
setBannerHeight?: SetterOrUpdater<number>;
|
|
5
26
|
}) => import("react").JSX.Element;
|