@daeryun/dr_components 0.4.75 → 0.4.76

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.
@@ -4,11 +4,12 @@ import { Title } from './Title';
4
4
  import { ILawyerTypes, IListPagesType, IListTypes } from './integrateType';
5
5
  import { ViewMore } from './ViewMore';
6
6
  import mobile from 'is-mobile';
7
- import { useRouter } from 'next/navigation';
7
+ import { useRouter, useSearchParams } from 'next/navigation';
8
8
  import Link from 'next/link';
9
9
  import Image from 'next/image';
10
10
  import style from './index.module.css';
11
11
  import Mark from '../../Mark/Mark';
12
+ import { searchColorLawyerText } from '../../common/integrate';
12
13
 
13
14
  const Lawyer = (props: {
14
15
  isMobileSize: boolean | null;
@@ -156,7 +157,13 @@ const LawyerContainer = (props: {
156
157
  isPro?: boolean; // true 일 시 특수분야 전문가
157
158
  }) => {
158
159
  const { item, lawyerImagePath, selectedFilter = '', onClickTel, isPro = false } = props;
159
- const router = useRouter();
160
+ const searchParams = useSearchParams();
161
+ const [search, setSearch] = useState<string>('');
162
+
163
+ useEffect(() => {
164
+ const searchQuery = searchParams.get('search');
165
+ setSearch(searchQuery ? String(searchQuery) : '');
166
+ }, [searchParams]);
160
167
 
161
168
  if (!isPro) {
162
169
  return (
@@ -164,7 +171,8 @@ const LawyerContainer = (props: {
164
171
  <div className={'flex w-[95%] flex-col sm:w-[80%]'}>
165
172
  <Link
166
173
  href={{
167
- pathname: '/lawyer/' + item.id
174
+ pathname: '/lawyer/' + item.id,
175
+ query: search != '' ? { integrate_search: search } : {}
168
176
  }}
169
177
  tabIndex={-1}
170
178
  >
@@ -205,7 +213,8 @@ const LawyerContainer = (props: {
205
213
  <div className={'m-3 flex h-full flex-col justify-between'}>
206
214
  <Link
207
215
  href={{
208
- pathname: '/lawyer/' + item.id
216
+ pathname: '/lawyer/' + item.id,
217
+ query: search != '' ? { integrate_search: search } : {}
209
218
  }}
210
219
  >
211
220
  <span>
@@ -215,7 +224,7 @@ const LawyerContainer = (props: {
215
224
  'my-2 text-[20px] font-[700] tracking-[-1.6px] sm:text-[25px] lg:text-[32px]'
216
225
  }
217
226
  >
218
- {item.name}
227
+ {searchColorLawyerText(item.name, search)}
219
228
  </p>
220
229
  <Image
221
230
  draggable={'false'}
@@ -228,7 +237,7 @@ const LawyerContainer = (props: {
228
237
  </div>
229
238
 
230
239
  <p className={'text-[16px] font-[600] tracking-[-1px] text-[#454545] lg:text-[22px]'}>
231
- {item.code}
240
+ {searchColorLawyerText(item.code, search)}
232
241
  </p>
233
242
 
234
243
  {item.position ? (
@@ -237,7 +246,7 @@ const LawyerContainer = (props: {
237
246
  ' bg-[#F7FBFF] py-1 text-[14px] font-[600] tracking-[-1px] text-[#454545] lg:text-[18px]'
238
247
  }
239
248
  >
240
- {item.position}
249
+ {searchColorLawyerText(item.position, search)}
241
250
  </p>
242
251
  ) : (
243
252
  <div className={'h-[35px] max-lg:hidden'}></div>
@@ -254,8 +263,8 @@ const LawyerContainer = (props: {
254
263
  }
255
264
  >
256
265
  {item.group_career.length > 32
257
- ? item.group_career.replace(',', ', ')
258
- : item.group_career.replace(',', '\n')}
266
+ ? searchColorLawyerText(item.group_career.replace(',', ', '), search)
267
+ : searchColorLawyerText(item.group_career.replace(',', '\n'), search)}
259
268
  </p>
260
269
  ) : (
261
270
  <p
@@ -267,9 +276,13 @@ const LawyerContainer = (props: {
267
276
  : 'text-[14px] lg:text-[18px] '
268
277
  }whitespace-pre-wrap mt-[11px] font-medium leading-tight tracking-[-1px] text-[#143F79] max-lg:mb-[5px]`}
269
278
  >
270
- <span className="font-[800] max-sm:hidden">{item.ability}</span>
279
+ <span className="font-[800] max-sm:hidden">
280
+ {searchColorLawyerText(item.ability, search)}
281
+ </span>
271
282
  <span className="font-[800] sm:hidden">
272
- {item.ability.length > 29 ? item.ability.split('\n').join(', ') : item.ability}
283
+ {item.ability.length > 29
284
+ ? searchColorLawyerText(item.ability.split('\n').join(', '), search)
285
+ : searchColorLawyerText(item.ability, search)}
273
286
  </span>
274
287
  </p>
275
288
  )}
@@ -282,7 +295,10 @@ const LawyerContainer = (props: {
282
295
  aria-label={item.name + '변호사에게 전화하기 ' + item.tel}
283
296
  >
284
297
  <p className={'text-[14px] font-[600] max-xs:text-[12px] lg:text-[18px]'}>
285
- T. <span className={'font-[800] text-[#6e6e6e] underline'}>{item.tel}</span>
298
+ T.{' '}
299
+ <span className={'font-[800] text-[#6e6e6e] underline'}>
300
+ {searchColorLawyerText(item.tel, search)}
301
+ </span>
286
302
  </p>
287
303
  </Link>
288
304
  ) : (
@@ -315,10 +331,13 @@ const LawyerContainer = (props: {
315
331
  'mt-3 line-clamp-1 text-ellipsis text-[14px] font-medium text-[#6e6e6e] lg:text-[18px]'
316
332
  }
317
333
  >
318
- {item.careers
319
- .replaceAll(',', '')
320
- .replace('일반소송', '민사')
321
- .replace('중재', '손해배상')}
334
+ {searchColorLawyerText(
335
+ item.careers
336
+ .replaceAll(',', '')
337
+ .replace('일반소송', '민사')
338
+ .replace('중재', '손해배상'),
339
+ search
340
+ )}
322
341
  전문
323
342
  </p>
324
343
  </div>
@@ -333,7 +352,8 @@ const LawyerContainer = (props: {
333
352
  return (
334
353
  <Link
335
354
  href={{
336
- pathname: '/lawyer/' + item.id
355
+ pathname: '/lawyer/' + item.id,
356
+ query: search != '' ? { integrate_search: search } : {}
337
357
  }}
338
358
  key={item.id}
339
359
  className={'flex justify-center'}
@@ -354,7 +374,7 @@ const LawyerContainer = (props: {
354
374
  <div className={'m-3'}>
355
375
  <div className={'flex items-center justify-between'}>
356
376
  <p className={'my-2 text-[20px] font-[800] tracking-[-1.6px] sm:text-[28px]'}>
357
- {item.name}
377
+ {searchColorLawyerText(item.name, search)}
358
378
  </p>
359
379
  <Image
360
380
  draggable={'false'}
@@ -365,7 +385,9 @@ const LawyerContainer = (props: {
365
385
  height={40}
366
386
  />
367
387
  </div>
368
- <p className={'text-lg font-[600] tracking-[-1.1px] text-[#454545]'}>{item.code}</p>
388
+ <p className={'text-lg font-[600] tracking-[-1.1px] text-[#454545]'}>
389
+ {searchColorLawyerText(item.code, search)}
390
+ </p>
369
391
  </div>
370
392
  </div>
371
393
  </div>
@@ -1,90 +1,31 @@
1
1
  'use client';
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  import React, { useEffect, useState } from 'react';
12
- import { useRouter } from 'next/navigation';
13
3
  import { useSearchParams } from 'next/navigation';
14
4
  import Link from 'next/link';
15
5
  import { tabTypes } from '../../common/integrate';
16
6
  const MenuTab = ({ search, searchDoneRef, setChoiceTabValue, totalCount, count }) => {
17
- const router = useRouter();
18
7
  const [tab, setTab] = useState('');
19
8
  const searchParams = useSearchParams();
20
9
  const querySearch = searchParams.get('search');
21
10
  const queryTab = searchParams.get('tab');
22
- const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
23
- yield router.push(`/integrate?search=${querySearch}&tab=${event.target.value}`);
24
- });
25
- const onClickEvent = (tab, search) => __awaiter(void 0, void 0, void 0, function* () {
26
- yield router.push(`/integrate?search=${querySearch}&tab=${tab}`);
27
- });
28
11
  useEffect(() => {
29
12
  setTab(String(queryTab));
30
13
  setChoiceTabValue === null || setChoiceTabValue === void 0 ? void 0 : setChoiceTabValue(queryTab ? String(queryTab) : '전체'); // 부모에게 tab button value 넘겨주는 setState
31
14
  }, [searchParams]);
32
- return (<>
33
- <div className={'mx-auto w-full max-sm:hidden '}>
34
- <Link href={tab !== '전체'
35
- ? `/integrate?search=${querySearch}&tab=전체`
36
- : `/integrate?search=${querySearch}&tab=${tab}`} ref={searchDoneRef} className={`
37
- ${totalCount < 1 ? 'hidden' : ''}
38
- ${tab === '전체' ? ' bg-[#285FA7] text-[#fff] ' : 'bg-[#F8F8F8] '}
39
- mt-12 flex h-[56px] cursor-pointer items-center justify-center rounded-[30px] text-center font-semibold sm:h-[50px] sm:w-[155px]
40
- sm:text-[16px] lg:w-[165px] lg:text-[17px] `} onKeyDown={e => {
41
- var _a, _b;
42
- if (e.key === 'Enter') {
43
- if (tab === '전체') {
44
- (_b = (_a = document.getElementById('integrate-result')) === null || _a === void 0 ? void 0 : _a.querySelector('a')) === null || _b === void 0 ? void 0 : _b.focus();
45
- }
46
- }
47
- }} aria-label={'전체 ' +
48
- totalCount.toLocaleString() +
49
- '개의 검색결과 보기 ' +
50
- `${tab === '전체' ? '선택된 메뉴입니다.' : ''}`}>
51
- 전체 ({totalCount.toLocaleString()})
52
- </Link>
53
- <div className={'mb-16 mt-3 flex-col flex-wrap gap-2 sm:flex sm:w-auto sm:flex-row'}>
54
- {tabTypes.map(item => {
55
- return (<TabButton key={item.value} tab={tab} count={
56
- // @ts-ignore
57
- count[String(item.value)]} title={item.tab} type={item.value} onClickEvent={onClickEvent} search={search}/>);
58
- })}
59
- </div>
60
- </div>
61
- {/*모바일*/}
62
- <div className={"relative after:absolute after:right-[2em] after:top-[1.2em] after:h-[10px] after:w-[10px] after:rotate-[135deg] after:border-r-[2px] after:border-t-[2px] after:border-[#fff] after:content-[''] sm:hidden"}>
63
- <select onChange={handleChange} aria-label={'search-tab'} className="z-9 relative my-10 block w-full appearance-none rounded-[30px] border border-gray-400 bg-[#285FA7] px-6 py-3 text-[18px] font-[800] text-[#fff] hover:border-gray-500 sm:hidden">
64
- <option value="전체">
65
- 전체
66
- {`(${totalCount.toLocaleString()})`}
67
- </option>
68
-
69
- {tabTypes.map(t => {
70
- // @ts-ignore
71
- const tabNum = count[t.value];
72
- return (tabNum > 0 && (<option value={t.value} key={t.value}>
73
- {t.tab} {`(${tabNum.toLocaleString()})`}
74
- </option>));
15
+ return (<div className={'mb-[106px] mt-20 grid h-full w-full grid-cols-8 max-xl:grid-cols-4 max-lg:my-[60px] max-sm:my-10 max-sm:grid-cols-2'}>
16
+ {[{ tab: '전체', etab: 'All', value: '전체' }, ...tabTypes].map(item => {
17
+ return (<Link ref={searchDoneRef} href={`/integrate?search=${querySearch}&tab=${item.value}`} key={item.value} className={'flex h-[62px] w-full items-center justify-center text-[20px] leading-none tracking-[-0.7px] max-3xl:text-[18px] max-md:text-[16px] max-sm:h-[40px] max-sm:text-[14px] ' +
18
+ (tab === item.value
19
+ ? 'bg-[#29579C] font-[800] text-[#FFFFFF] '
20
+ : 'border border-solid border-[#E9E9E9] bg-[#F7F7F7] font-[500] text-[#949494] ')}>
21
+ {item.value} (
22
+ {item.value != '전체'
23
+ ? //@ts-ignore
24
+ count[String(item.value)].toLocaleString()
25
+ : totalCount.toLocaleString()}
26
+ )
27
+ </Link>);
75
28
  })}
76
- </select>
77
- </div>
78
- </>);
79
- };
80
- const TabButton = (props) => {
81
- const searchParams = useSearchParams();
82
- const buttonClass = 'block flex items-center justify-center sm:w-[155px] sm:text-[16px] lg:w-[165px] lg:text-[17px] text-center cursor-pointer font-semibold rounded-[30px] h-[56px] ';
83
- const { tab, count, type, title, onClickEvent, search } = props;
84
- const querySearch = searchParams.get('search');
85
- return (<Link href={`/integrate?search=${querySearch}&tab=${type}`} className={`${tab === type ? ' bg-[#285FA7] text-[#fff] ' : ' bg-[#F8F8F8] '} ${buttonClass} ${count < 1 ? 'hidden' : ''}`}>
86
- {`${title}`}
87
- {` (${count.toLocaleString()})`}
88
- </Link>);
29
+ </div>);
89
30
  };
90
31
  export default MenuTab;
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { RefObject, useEffect, useRef, useState } from 'react';
4
- import { useRouter } from 'next/navigation';
3
+ import React, { RefObject, useEffect, useState } from 'react';
5
4
  import { useSearchParams } from 'next/navigation';
6
5
  import Link from 'next/link';
7
6
  import { tabTypes } from '../../common/integrate';
@@ -23,20 +22,11 @@ interface TabProps {
23
22
  }
24
23
 
25
24
  const MenuTab = ({ search, searchDoneRef, setChoiceTabValue, totalCount, count }: TabProps) => {
26
- const router = useRouter();
27
25
  const [tab, setTab] = useState<string>('');
28
26
  const searchParams = useSearchParams();
29
27
  const querySearch = searchParams.get('search');
30
28
  const queryTab = searchParams.get('tab');
31
29
 
32
- const handleChange = async (event: React.ChangeEvent<HTMLSelectElement>) => {
33
- await router.push(`/integrate?search=${querySearch}&tab=${event.target.value}`);
34
- };
35
-
36
- const onClickEvent = async (tab: any, search: any) => {
37
- await router.push(`/integrate?search=${querySearch}&tab=${tab}`);
38
- };
39
-
40
30
  useEffect(() => {
41
31
  setTab(String(queryTab));
42
32
 
@@ -44,115 +34,34 @@ const MenuTab = ({ search, searchDoneRef, setChoiceTabValue, totalCount, count }
44
34
  }, [searchParams]);
45
35
 
46
36
  return (
47
- <>
48
- <div className={'mx-auto w-full max-sm:hidden '}>
49
- <Link
50
- href={
51
- tab !== '전체'
52
- ? `/integrate?search=${querySearch}&tab=전체`
53
- : `/integrate?search=${querySearch}&tab=${tab}`
54
- }
55
- ref={searchDoneRef}
56
- className={`
57
- ${totalCount < 1 ? 'hidden' : ''}
58
- ${tab === '전체' ? ' bg-[#285FA7] text-[#fff] ' : 'bg-[#F8F8F8] '}
59
- mt-12 flex h-[56px] cursor-pointer items-center justify-center rounded-[30px] text-center font-semibold sm:h-[50px] sm:w-[155px]
60
- sm:text-[16px] lg:w-[165px] lg:text-[17px] `}
61
- onKeyDown={e => {
62
- if (e.key === 'Enter') {
63
- if (tab === '전체') {
64
- document.getElementById('integrate-result')?.querySelector('a')?.focus();
65
- }
66
- }
67
- }}
68
- aria-label={
69
- '전체 ' +
70
- totalCount.toLocaleString() +
71
- '개의 검색결과 보기 ' +
72
- `${tab === '전체' ? '선택된 메뉴입니다.' : ''}`
73
- }
74
- >
75
- 전체 ({totalCount.toLocaleString()})
76
- </Link>
77
- <div className={'mb-16 mt-3 flex-col flex-wrap gap-2 sm:flex sm:w-auto sm:flex-row'}>
78
- {tabTypes.map(item => {
79
- return (
80
- <TabButton
81
- key={item.value}
82
- tab={tab}
83
- count={
84
- // @ts-ignore
85
- count[String(item.value)]
86
- }
87
- title={item.tab}
88
- type={item.value}
89
- onClickEvent={onClickEvent}
90
- search={search}
91
- />
92
- );
93
- })}
94
- </div>
95
- </div>
96
- {/*모바일*/}
97
- <div
98
- className={
99
- "relative after:absolute after:right-[2em] after:top-[1.2em] after:h-[10px] after:w-[10px] after:rotate-[135deg] after:border-r-[2px] after:border-t-[2px] after:border-[#fff] after:content-[''] sm:hidden"
100
- }
101
- >
102
- <select
103
- onChange={handleChange}
104
- aria-label={'search-tab'}
105
- className="z-9 relative my-10 block w-full appearance-none rounded-[30px] border border-gray-400 bg-[#285FA7] px-6 py-3 text-[18px] font-[800] text-[#fff] hover:border-gray-500 sm:hidden"
106
- >
107
- <option value="전체">
108
- 전체
109
- {`(${totalCount.toLocaleString()})`}
110
- </option>
111
-
112
- {tabTypes.map(t => {
113
- // @ts-ignore
114
- const tabNum = count[t.value];
115
-
116
- return (
117
- tabNum > 0 && (
118
- <option value={t.value} key={t.value}>
119
- {t.tab} {`(${tabNum.toLocaleString()})`}
120
- </option>
121
- )
122
- );
123
- })}
124
- </select>
125
- </div>
126
- </>
127
- );
128
- };
129
-
130
- interface ITabButtonTypes {
131
- tab: string;
132
- count: number;
133
- type: string;
134
- title: string;
135
- onClickEvent: (type: string, search: any) => Promise<void>;
136
- search: any;
137
- }
138
-
139
- const TabButton = (props: ITabButtonTypes) => {
140
- const searchParams = useSearchParams();
141
- const buttonClass =
142
- 'block flex items-center justify-center sm:w-[155px] sm:text-[16px] lg:w-[165px] lg:text-[17px] text-center cursor-pointer font-semibold rounded-[30px] h-[56px] ';
143
- const { tab, count, type, title, onClickEvent, search } = props;
144
- const querySearch = searchParams.get('search');
145
-
146
- return (
147
- <Link
148
- href={`/integrate?search=${querySearch}&tab=${type}`}
149
- className={`${tab === type ? ' bg-[#285FA7] text-[#fff] ' : ' bg-[#F8F8F8] '} ${buttonClass} ${
150
- count < 1 ? 'hidden' : ''
151
- }`}
37
+ <div
38
+ className={
39
+ 'mb-[106px] mt-20 grid h-full w-full grid-cols-8 max-xl:grid-cols-4 max-lg:my-[60px] max-sm:my-10 max-sm:grid-cols-2'
40
+ }
152
41
  >
153
- {`${title}`}
154
- {` (${count.toLocaleString()})`}
155
- </Link>
42
+ {[{ tab: '전체', etab: 'All', value: '전체' }, ...tabTypes].map(item => {
43
+ return (
44
+ <Link
45
+ ref={searchDoneRef}
46
+ href={`/integrate?search=${querySearch}&tab=${item.value}`}
47
+ key={item.value}
48
+ className={
49
+ 'flex h-[62px] w-full items-center justify-center text-[20px] leading-none tracking-[-0.7px] max-3xl:text-[18px] max-md:text-[16px] max-sm:h-[40px] max-sm:text-[14px] ' +
50
+ (tab === item.value
51
+ ? 'bg-[#29579C] font-[800] text-[#FFFFFF] '
52
+ : 'border border-solid border-[#E9E9E9] bg-[#F7F7F7] font-[500] text-[#949494] ')
53
+ }
54
+ >
55
+ {item.value} (
56
+ {item.value != '전체'
57
+ ? //@ts-ignore
58
+ count[String(item.value)].toLocaleString()
59
+ : totalCount.toLocaleString()}
60
+ )
61
+ </Link>
62
+ );
63
+ })}
64
+ </div>
156
65
  );
157
66
  };
158
67