Skip to content

Commit 4416cb5

Browse files
feat: 카테고리 태그 더보기/접기 기능 (#675)
* feat: implement collapse/expand UI for category tags * chore: add cursor-pointer --------- Co-authored-by: SKINMAKER <[email protected]>
1 parent 8ab5e43 commit 4416cb5

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

components/Hero.tsx

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import dynamic from 'next/dynamic'
21
import { NextSeo } from 'next-seo'
2+
import dynamic from 'next/dynamic'
3+
import { useState } from 'react'
34

45
import {
56
botCategories,
@@ -13,6 +14,7 @@ const Tag = dynamic(() => import('@components/Tag'))
1314
const Search = dynamic(() => import('@components/Search'))
1415

1516
const Hero: React.FC<HeroProps> = ({ type = 'all', header, description }) => {
17+
const [showAllCategories, setShowAllCategories] = useState(false)
1618
const link = `/${type}/categories`
1719
return (
1820
<>
@@ -110,32 +112,36 @@ const Hero: React.FC<HeroProps> = ({ type = 'all', header, description }) => {
110112
bigger
111113
href={type === 'bots' ? '/bots/list/votes' : '/servers/list/votes'}
112114
/>
113-
{(type === 'bots' ? botCategories : serverCategories).slice(0, 4).map((t) => (
114-
<Tag
115-
key={t}
116-
text={
117-
<>
118-
<i
119-
className={(type === 'bots' ? botCategoryIcon : serverCategoryIcon)[t]}
120-
/>{' '}
121-
{t}
122-
</>
123-
}
124-
dark
125-
bigger
126-
href={`${link}/${t}`}
127-
/>
128-
))}
115+
{(type === 'bots' ? botCategories : serverCategories)
116+
.slice(0, showAllCategories ? undefined : 4)
117+
.map((t) => (
118+
<Tag
119+
key={t}
120+
text={
121+
<>
122+
<i
123+
className={(type === 'bots' ? botCategoryIcon : serverCategoryIcon)[t]}
124+
/>{' '}
125+
{t}
126+
</>
127+
}
128+
dark
129+
bigger
130+
href={`${link}/${t}`}
131+
/>
132+
))}
129133
<Tag
130134
key='tag'
135+
className='cursor-pointer'
131136
text={
132137
<>
133-
<i className='fas fa-tag' /> 카테고리 더보기
138+
<i className='fas fa-tag' />{' '}
139+
{showAllCategories ? '간략히 보기' : '카테고리 더보기'}
134140
</>
135141
}
136142
dark
137143
bigger
138-
href={link}
144+
onClick={() => setShowAllCategories(!showAllCategories)}
139145
/>
140146
</>
141147
)}

0 commit comments

Comments
 (0)