@daeryun/dr_components 1.2.21 → 1.2.23

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.
@@ -52,7 +52,7 @@ const ChatButton = ({ isOpen, onClick, apiVersion, isMobile = false, hashValue =
52
52
  }
53
53
  }, [hashValue]);
54
54
  return (<button aria-label="채팅 상담 열기" onClick={handleClick} style={{
55
- bottom: bannerHeight > 0 && (!isScrollTop || width >= 1024)
55
+ bottom: bannerHeight > 0
56
56
  ? width >= 1024
57
57
  ? `${bannerHeight + 20}px`
58
58
  : `${bannerHeight + 78}px`
@@ -68,7 +68,7 @@ const ChatButton: React.FC<ChatButtonProps> = ({
68
68
  onClick={handleClick}
69
69
  style={{
70
70
  bottom:
71
- bannerHeight > 0 && (!isScrollTop || width >= 1024)
71
+ bannerHeight > 0
72
72
  ? width >= 1024
73
73
  ? `${bannerHeight + 20}px`
74
74
  : `${bannerHeight + 78}px`
@@ -25,10 +25,10 @@ viewState, onHistoryClick, isAuthenticated, historyList }) => {
25
25
  };
26
26
  return (<div className={`${isMobile ? '' : ''} flex h-[56px] w-full items-center justify-between border-b border-gray-200 px-[16px] `}>
27
27
  {viewState === 'conversation' ? (<button type="button" className={`relative flex flex-col items-center justify-center`} onClick={handleHistoryClick}>
28
- <Image src={HistoryIcon} alt="히스토리" width={20} height={20}/>
28
+ <Image src={HistoryIcon} alt="Chat Conversation Header History Icon" width={20} height={20}/>
29
29
  <span className="h-[10px] text-[10px] font-[700] leading-[100%] tracking-[-0.04%]">히스토리</span>
30
30
  <div className={`${isNewBadge ? 'opacity-100' : 'opacity-0'} absolute -right-[4px] -top-[1px]`}>
31
- <Image src={HistoryNewbadge} alt="뉴 히스토리 뱃지" width={12} height={12}/>
31
+ <Image src={HistoryNewbadge} alt="Chat Conversation Header New History Badge" width={12} height={12}/>
32
32
  </div>
33
33
  </button>) : (<button className={`flex h-[28px] w-[28px] items-center justify-center `} aria-label="이전" onClick={handleBackClick}>
34
34
  <Image src={PrevIcon} alt="이전" width={28} height={28}/>
@@ -68,10 +68,15 @@ const ChatConversationHeader = ({
68
68
  className={`relative flex flex-col items-center justify-center`}
69
69
  onClick={handleHistoryClick}
70
70
  >
71
- <Image src={HistoryIcon} alt="히스토리" width={20} height={20} />
71
+ <Image src={HistoryIcon} alt="Chat Conversation Header History Icon" width={20} height={20} />
72
72
  <span className="h-[10px] text-[10px] font-[700] leading-[100%] tracking-[-0.04%]">히스토리</span>
73
73
  <div className={`${isNewBadge ? 'opacity-100' : 'opacity-0'} absolute -right-[4px] -top-[1px]`}>
74
- <Image src={HistoryNewbadge} alt="뉴 히스토리 뱃지" width={12} height={12} />
74
+ <Image
75
+ src={HistoryNewbadge}
76
+ alt="Chat Conversation Header New History Badge"
77
+ width={12}
78
+ height={12}
79
+ />
75
80
  </div>
76
81
  </button>
77
82
  ) : (
@@ -30,7 +30,7 @@ const NavigationFooter = ({ activeView, onHomeClick, onHistoryClick, historyList
30
30
  {isHundredOver ? '99+' : unreadCount}
31
31
  </span>) : null;
32
32
  })()}
33
- <Image src={History} alt="히스토리" width={32} height={32}/>
33
+ <Image src={History} alt="Footer History Icon" width={32} height={32}/>
34
34
  {/* <History width={32} height={32} /> */}
35
35
  <span className={`dr_talk_subtitle_small2 ${activeView === 'history'
36
36
  ? 'text-drTalkCrimson'
@@ -78,7 +78,7 @@ const NavigationFooter: React.FC<NavigationFooterProps> = ({
78
78
  </span>
79
79
  ) : null;
80
80
  })()}
81
- <Image src={History} alt="히스토리" width={32} height={32} />
81
+ <Image src={History} alt="Footer History Icon" width={32} height={32} />
82
82
  {/* <History width={32} height={32} /> */}
83
83
  <span
84
84
  className={`dr_talk_subtitle_small2 ${
@@ -197,7 +197,7 @@ const Daeryuntalk = ({ tel = '1800-7905', centerCode = 'CT0000', bannerHeight =
197
197
  <DaeryuntalkToastProvider>
198
198
  <ViewportHandler isMobile={isMobile} isDisable={!isOpen || !isMobile}/>
199
199
  <DaeryuntalkProvider propsTel={tel} isMobile={isMobile} onClose={closeModal} centerCode={currentCenterCode || ''} isOpen={isOpen}>
200
- {isMobile ? (isOpen || !currentCenterCode ? null : (<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat}/>)) : !currentCenterCode ? null : (<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat} bannerHeight={bannerHeight}/>)}
200
+ {isMobile ? (isOpen || !currentCenterCode ? null : (<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat} bannerHeight={bannerHeight}/>)) : !currentCenterCode ? null : (<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat} bannerHeight={bannerHeight}/>)}
201
201
  <ChatWidget isOpen={hashValue ? true : isOpen} isMobile={isMobile} onClose={closeModal} hashValue={hashValue} setHashValue={setHashValue} animationState={animationState} isMobileSafari={isMobileSafari} androidViewportHeight={androidViewportHeight} isMobileAndroid={isMobileAndroid}/>
202
202
  </DaeryuntalkProvider>
203
203
  </DaeryuntalkToastProvider>
@@ -17,11 +17,7 @@ type DaeryuntalkProps = {
17
17
  bannerHeight?: number;
18
18
  };
19
19
 
20
- const Daeryuntalk: React.FC<DaeryuntalkProps> = ({
21
- tel = '1800-7905',
22
- centerCode = 'CT0000',
23
- bannerHeight = 0
24
- }) => {
20
+ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905', centerCode = 'CT0000', bannerHeight = 0 }) => {
25
21
  const [isOpen, setIsOpen] = useState(false);
26
22
  const [isMobile, setIsMobile] = useState(false);
27
23
  const [isMobileSafari, setIsMobileSafari] = useState(false); // ios + 모바일
@@ -250,6 +246,7 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({
250
246
  isMobile={isMobile}
251
247
  hashValue={hashValue}
252
248
  onClick={toggleChat}
249
+ bannerHeight={bannerHeight}
253
250
  />
254
251
  )
255
252
  ) : !currentCenterCode ? null : (
@@ -25,7 +25,7 @@ viewState, onHistoryClick, isAuthenticated, historyList }) => {
25
25
  };
26
26
  return (<div className={`${isMobile ? '' : ''} flex h-[56px] w-full items-center justify-between border-b border-gray-200 px-[16px] `}>
27
27
  {viewState === 'conversation' ? (<button type="button" className={`relative flex flex-col items-center justify-center`} onClick={handleHistoryClick}>
28
- <Image src={HistoryIcon} alt="히스토리" width={20} height={20}/>
28
+ <Image src={HistoryIcon} alt="Chat Conversation Header History Icon" width={20} height={20}/>
29
29
  <span className="h-[10px] text-[10px] font-[700] leading-[100%] tracking-[-0.04%]">히스토리</span>
30
30
  <div className={`${isNewBadge ? 'opacity-100' : 'opacity-0'} absolute -right-[4px] -top-[1px]`}>
31
31
  <Image src={HistoryNewbadge} alt="뉴 히스토리 뱃지" width={12} height={12}/>
@@ -68,7 +68,7 @@ const ChatConversationHeader = ({
68
68
  className={`relative flex flex-col items-center justify-center`}
69
69
  onClick={handleHistoryClick}
70
70
  >
71
- <Image src={HistoryIcon} alt="히스토리" width={20} height={20} />
71
+ <Image src={HistoryIcon} alt="Chat Conversation Header History Icon" width={20} height={20} />
72
72
  <span className="h-[10px] text-[10px] font-[700] leading-[100%] tracking-[-0.04%]">히스토리</span>
73
73
  <div className={`${isNewBadge ? 'opacity-100' : 'opacity-0'} absolute -right-[4px] -top-[1px]`}>
74
74
  <Image src={HistoryNewbadge} alt="뉴 히스토리 뱃지" width={12} height={12} />
@@ -30,7 +30,7 @@ const NavigationFooter = ({ activeView, onHomeClick, onHistoryClick, historyList
30
30
  {isHundredOver ? '99+' : unreadCount}
31
31
  </span>) : null;
32
32
  })()}
33
- <Image src={History} alt="히스토리" width={32} height={32}/>
33
+ <Image src={History} alt="Navigation Footer History Icon" width={32} height={32}/>
34
34
  {/* <History width={32} height={32} /> */}
35
35
  <span className={`dr_talk_subtitle_small2 ${activeView === 'history'
36
36
  ? 'text-drTalkCrimson'
@@ -78,7 +78,7 @@ const NavigationFooter: React.FC<NavigationFooterProps> = ({
78
78
  </span>
79
79
  ) : null;
80
80
  })()}
81
- <Image src={History} alt="히스토리" width={32} height={32} />
81
+ <Image src={History} alt="Navigation Footer History Icon" width={32} height={32} />
82
82
  {/* <History width={32} height={32} /> */}
83
83
  <span
84
84
  className={`dr_talk_subtitle_small2 ${
@@ -20,6 +20,7 @@ import { DateTime } from 'luxon';
20
20
  import classNames from 'classnames';
21
21
  import Link from 'next/link';
22
22
  import useBrowser from '../hook/useBrowser';
23
+ import { usePathname, useRouter } from 'next/navigation';
23
24
  // 팝업 컴포넌트 스토리북 확인용 더미 데이터
24
25
  // const POPUP_DUMMY: IBannerTypes[] = [
25
26
  // {
@@ -88,6 +89,8 @@ const TopBanner = ({ setBannerHeight }) => {
88
89
  const ImagePath = process.env.NEXT_PUBLIC_S3_URL + '';
89
90
  const { width } = useBrowser();
90
91
  const bannerRef = useRef(null);
92
+ const router = useRouter();
93
+ const pathname = usePathname();
91
94
  //팝업 리스트
92
95
  const [popup, setPopup] = useState([]);
93
96
  const addClickCnt = (idx) => {
@@ -104,18 +107,67 @@ const TopBanner = ({ setBannerHeight }) => {
104
107
  gcTime: Infinity,
105
108
  staleTime: Infinity
106
109
  });
110
+ useEffect(() => {
111
+ if (typeof window === 'undefined')
112
+ return; // SSR 보호 ●
113
+ const sourceData = popupData || [];
114
+ if (sourceData.length > 0) {
115
+ setPopup(filterBannerData(sourceData));
116
+ }
117
+ }, [router, pathname, popupData]);
118
+ const filterBannerData = (data) => {
119
+ const kstDateTime = DateTime.now().setZone('Asia/Seoul');
120
+ const nowDate = Number(kstDateTime.year + '' + zeroMaker(kstDateTime.month) + '' + zeroMaker(kstDateTime.day));
121
+ const nowTime = Number(zeroMaker(kstDateTime.hour) + zeroMaker(kstDateTime.minute));
122
+ const weekday = kstDateTime.weekdayShort + '';
123
+ const currentPath = pathname.split('?')[0].split('#')[0]; // 현재 경로 (쿼리/해시 제거)
124
+ const dateData = data.filter((item) => findDate(item, 'start') <= nowDate &&
125
+ findDate(item, 'end') >= nowDate &&
126
+ findDays(item, weekday) &&
127
+ findTime(item, nowTime));
128
+ return dateData.filter((item) => {
129
+ // localStorage로 닫힌 배너 제외
130
+ if (localStorage.getItem(item.idx + '_CloseTopPop') &&
131
+ Number(localStorage.getItem(item.idx + '_CloseTopPop')) > new Date().getTime()) {
132
+ return false;
133
+ }
134
+ // 현재 경로와 배너 링크 비교
135
+ // PC인 경우: pc_link 또는 p_link 확인
136
+ // 모바일인 경우: mobile_link 또는 p_link 확인
137
+ const bannerLink = width > 900 ? item.pc_link || item.p_link : item.mobile_link || item.p_link;
138
+ // 링크가 없으면 표시
139
+ if (!bannerLink) {
140
+ return true;
141
+ }
142
+ // 배너 링크에서 경로 부분만 추출
143
+ // 전체 URL인 경우 (https://www.daeryunlaw.com/relief) 경로 부분만 추출
144
+ // 상대 경로인 경우 (/relief) 그대로 사용
145
+ let bannerPath = bannerLink.split('?')[0].split('#')[0]; // 쿼리/해시 제거
146
+ // http:// 또는 https://로 시작하는 전체 URL인 경우 경로 부분만 추출
147
+ if (bannerPath.startsWith('http://') || bannerPath.startsWith('https://')) {
148
+ try {
149
+ const url = new URL(bannerPath);
150
+ bannerPath = url.pathname;
151
+ }
152
+ catch (_a) {
153
+ // URL 파싱 실패 시 그대로 사용
154
+ }
155
+ }
156
+ // 경로가 /로 시작하지 않으면 /를 추가
157
+ if (bannerPath && !bannerPath.startsWith('/')) {
158
+ bannerPath = '/' + bannerPath;
159
+ }
160
+ // 경로 끝의 슬래시 제거하여 정규화 (예: /relief/ → /relief)
161
+ bannerPath = bannerPath.replace(/\/$/, '');
162
+ const normalizedCurrentPath = currentPath.replace(/\/$/, '');
163
+ // 정확히 일치하는 경우에만 배너를 표시하지 않음
164
+ // 예: 배너 링크가 /relief이고 현재 경로가 /relief일 때만 숨김
165
+ return normalizedCurrentPath !== bannerPath;
166
+ });
167
+ };
107
168
  useEffect(() => {
108
169
  if (popupData) {
109
- const kstDateTime = DateTime.now().setZone('Asia/Seoul');
110
- const nowDate = Number(kstDateTime.year + '' + zeroMaker(kstDateTime.month) + '' + zeroMaker(kstDateTime.day));
111
- const nowTime = Number(zeroMaker(kstDateTime.hour) + zeroMaker(kstDateTime.minute));
112
- const weekday = kstDateTime.weekdayShort + '';
113
- const dateData = popupData.filter(item => findDate(item, 'start') <= nowDate &&
114
- findDate(item, 'end') >= nowDate &&
115
- findDays(item, weekday) &&
116
- findTime(item, nowTime));
117
- setPopup(dateData.filter(item => !(localStorage.getItem(item.idx + '_CloseTopPop') &&
118
- Number(localStorage.getItem(item.idx + '_CloseTopPop')) > new Date().getTime())));
170
+ setPopup(filterBannerData(popupData));
119
171
  }
120
172
  }, [popupData]);
121
173
  // 테스트 로직, 스토리북으로 확인할 때만 활성화 (useQuery는 주석하고)
@@ -82,13 +82,14 @@
82
82
  .header_banner_m_btn {
83
83
  display: flex;
84
84
  width: 100%;
85
+ height: 35px;
85
86
  }
86
87
  .header_banner_m_btn button {
87
88
  width: 50%;
88
89
  padding: 4px 0;
89
90
  color: #fff;
90
91
  background: #0a1932;
91
- font-size: 12px;
92
+ font-size: 14px;
92
93
  cursor: pointer;
93
94
  }
94
95
  .header_banner_m_btn button:nth-child(2) {
@@ -100,6 +101,12 @@
100
101
  .header_banner_m .banner_block_m a img {
101
102
  max-height: 120px !important;
102
103
  }
104
+ .header_banner_m_btn {
105
+ height: 30px;
106
+ }
107
+ .header_banner_m_btn button {
108
+ font-size: 12px;
109
+ }
103
110
  }
104
111
  /*header_banner 20230322 end*/
105
112
 
@@ -13,6 +13,7 @@ import classNames from 'classnames';
13
13
  import Link from 'next/link';
14
14
  import useBrowser from '../hook/useBrowser';
15
15
  import { SetterOrUpdater } from 'recoil';
16
+ import { usePathname, useRouter } from 'next/navigation';
16
17
 
17
18
  //배너타입
18
19
  interface IBannerTypes {
@@ -102,6 +103,8 @@ const TopBanner = ({ setBannerHeight }: { setBannerHeight?: SetterOrUpdater<numb
102
103
  const ImagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
103
104
  const { width } = useBrowser();
104
105
  const bannerRef = useRef<HTMLDivElement>(null);
106
+ const router = useRouter();
107
+ const pathname = usePathname();
105
108
 
106
109
  //팝업 리스트
107
110
  const [popup, setPopup] = useState<IBannerTypes[]>([]);
@@ -121,30 +124,84 @@ const TopBanner = ({ setBannerHeight }: { setBannerHeight?: SetterOrUpdater<numb
121
124
  gcTime: Infinity,
122
125
  staleTime: Infinity
123
126
  });
127
+
128
+ useEffect(() => {
129
+ if (typeof window === 'undefined') return; // SSR 보호 ●
130
+
131
+ const sourceData = popupData || [];
132
+
133
+ if (sourceData.length > 0) {
134
+ setPopup(filterBannerData(sourceData));
135
+ }
136
+ }, [router, pathname, popupData]);
137
+
138
+ const filterBannerData = (data: any[]) => {
139
+ const kstDateTime = DateTime.now().setZone('Asia/Seoul');
140
+ const nowDate = Number(kstDateTime.year + '' + zeroMaker(kstDateTime.month) + '' + zeroMaker(kstDateTime.day));
141
+ const nowTime = Number(zeroMaker(kstDateTime.hour) + zeroMaker(kstDateTime.minute));
142
+ const weekday = kstDateTime.weekdayShort + '';
143
+ const currentPath = pathname.split('?')[0].split('#')[0]; // 현재 경로 (쿼리/해시 제거)
144
+
145
+ const dateData = data.filter(
146
+ (item: any) =>
147
+ findDate(item, 'start') <= nowDate &&
148
+ findDate(item, 'end') >= nowDate &&
149
+ findDays(item, weekday) &&
150
+ findTime(item, nowTime)
151
+ );
152
+
153
+ return dateData.filter((item: IBannerTypes) => {
154
+ // localStorage로 닫힌 배너 제외
155
+ if (
156
+ localStorage.getItem(item.idx + '_CloseTopPop') &&
157
+ Number(localStorage.getItem(item.idx + '_CloseTopPop')) > new Date().getTime()
158
+ ) {
159
+ return false;
160
+ }
161
+
162
+ // 현재 경로와 배너 링크 비교
163
+ // PC인 경우: pc_link 또는 p_link 확인
164
+ // 모바일인 경우: mobile_link 또는 p_link 확인
165
+ const bannerLink = width > 900 ? item.pc_link || item.p_link : item.mobile_link || item.p_link;
166
+
167
+ // 링크가 없으면 표시
168
+ if (!bannerLink) {
169
+ return true;
170
+ }
171
+
172
+ // 배너 링크에서 경로 부분만 추출
173
+ // 전체 URL인 경우 (https://www.daeryunlaw.com/relief) 경로 부분만 추출
174
+ // 상대 경로인 경우 (/relief) 그대로 사용
175
+ let bannerPath = bannerLink.split('?')[0].split('#')[0]; // 쿼리/해시 제거
176
+
177
+ // http:// 또는 https://로 시작하는 전체 URL인 경우 경로 부분만 추출
178
+ if (bannerPath.startsWith('http://') || bannerPath.startsWith('https://')) {
179
+ try {
180
+ const url = new URL(bannerPath);
181
+ bannerPath = url.pathname;
182
+ } catch {
183
+ // URL 파싱 실패 시 그대로 사용
184
+ }
185
+ }
186
+
187
+ // 경로가 /로 시작하지 않으면 /를 추가
188
+ if (bannerPath && !bannerPath.startsWith('/')) {
189
+ bannerPath = '/' + bannerPath;
190
+ }
191
+
192
+ // 경로 끝의 슬래시 제거하여 정규화 (예: /relief/ → /relief)
193
+ bannerPath = bannerPath.replace(/\/$/, '');
194
+ const normalizedCurrentPath = currentPath.replace(/\/$/, '');
195
+
196
+ // 정확히 일치하는 경우에만 배너를 표시하지 않음
197
+ // 예: 배너 링크가 /relief이고 현재 경로가 /relief일 때만 숨김
198
+ return normalizedCurrentPath !== bannerPath;
199
+ });
200
+ };
201
+
124
202
  useEffect(() => {
125
203
  if (popupData) {
126
- const kstDateTime = DateTime.now().setZone('Asia/Seoul');
127
- const nowDate = Number(
128
- kstDateTime.year + '' + zeroMaker(kstDateTime.month) + '' + zeroMaker(kstDateTime.day)
129
- );
130
- const nowTime = Number(zeroMaker(kstDateTime.hour) + zeroMaker(kstDateTime.minute));
131
- const weekday = kstDateTime.weekdayShort + '';
132
- const dateData = popupData.filter(
133
- item =>
134
- findDate(item, 'start') <= nowDate &&
135
- findDate(item, 'end') >= nowDate &&
136
- findDays(item, weekday) &&
137
- findTime(item, nowTime)
138
- );
139
- setPopup(
140
- dateData.filter(
141
- item =>
142
- !(
143
- localStorage.getItem(item.idx + '_CloseTopPop') &&
144
- Number(localStorage.getItem(item.idx + '_CloseTopPop')) > new Date().getTime()
145
- )
146
- )
147
- );
204
+ setPopup(filterBannerData(popupData));
148
205
  }
149
206
  }, [popupData]);
150
207