feat: added ResponsiveGrid component

This commit is contained in:
wonderlandpark 2021-03-03 14:25:09 +09:00
parent 0916cc335a
commit 84af82938a
8 changed files with 37 additions and 22 deletions

View File

@ -28,7 +28,7 @@ const BotCard = ({ manage = false, bot }: BotProps): JSX.Element => {
<Link href={makeBotURL(bot)}> <Link href={makeBotURL(bot)}>
<a className='cursor-pointer'> <a className='cursor-pointer'>
<div className='flex h-44'> <div className='flex h-44'>
<div className='w-2/3'> <div className='w-3/5'>
<div className='flex justify-start'> <div className='flex justify-start'>
<DiscordAvatar <DiscordAvatar
size={128} size={128}
@ -46,7 +46,7 @@ const BotCard = ({ manage = false, bot }: BotProps): JSX.Element => {
<h1 className='mb-3 text-left text-2xl font-bold truncate'>{bot.name}</h1> <h1 className='mb-3 text-left text-2xl font-bold truncate'>{bot.name}</h1>
</div> </div>
</div> </div>
<div className='grid grid-cols-1 pr-5 py-5 w-1/3 h-0'> <div className='grid grid-cols-1 pr-5 py-5 w-2/5 h-0'>
<Tag <Tag
text={ text={
<> <>

View File

@ -0,0 +1,9 @@
import { ReactNode } from 'react'
const ResponsiveGrid = ({ children }:{ children: ReactNode }):JSX.Element => {
return <div className='grid gap-x-4 grid-rows-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 mt-10 -mb-10'>
{children}
</div>
}
export default ResponsiveGrid

View File

@ -10,6 +10,7 @@ import NotFound from 'pages/404'
const Hero = dynamic(() => import('@components/Hero')) const Hero = dynamic(() => import('@components/Hero'))
const Advertisement = dynamic(() => import('@components/Advertisement')) const Advertisement = dynamic(() => import('@components/Advertisement'))
const SEO = dynamic(() => import('@components/SEO')) const SEO = dynamic(() => import('@components/SEO'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const BotCard = dynamic(() => import('@components/BotCard')) const BotCard = dynamic(() => import('@components/BotCard'))
const Container = dynamic(() => import('@components/Container')) const Container = dynamic(() => import('@components/Container'))
const Paginator = dynamic(() => import('@components/Paginator')) const Paginator = dynamic(() => import('@components/Paginator'))
@ -22,11 +23,11 @@ const Category: NextPage<CategoryProps> = ({ data, query }) => {
<Container> <Container>
<Advertisement /> <Advertisement />
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-20'> <ResponsiveGrid>
{ {
data.data.map(bot => <BotCard key={bot.id} bot={bot} /> ) data.data.map(bot => <BotCard key={bot.id} bot={bot} /> )
} }
</div> </ResponsiveGrid>
<Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname={`/categories/${query.category}`} /> <Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname={`/categories/${query.category}`} />
<Advertisement /> <Advertisement />
</Container> </Container>

View File

@ -5,10 +5,11 @@ import { BotList } from '@types'
import * as Query from '@utils/Query' import * as Query from '@utils/Query'
import LongButton from '@components/LongButton' import LongButton from '@components/LongButton'
const Advertisement = dynamic(()=> import('@components/Advertisement')) const Advertisement = dynamic(() => import('@components/Advertisement'))
const Container = dynamic(()=> import('@components/Container')) const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const BotCard = dynamic(()=> import('@components/BotCard')) const Container = dynamic(() => import('@components/Container'))
const Paginator = dynamic(()=> import('@components/Paginator')) const BotCard = dynamic(() => import('@components/BotCard'))
const Paginator = dynamic(() => import('@components/Paginator'))
const Hero = dynamic(() => import('@components/Hero')) const Hero = dynamic(() => import('@components/Hero'))
const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => { const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
@ -21,32 +22,32 @@ const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
<i className='far fa-heart mr-3 text-pink-600' /> <i className='far fa-heart mr-3 text-pink-600' />
</h1> </h1>
<p className='text-base'> !</p> <p className='text-base'> !</p>
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-10 -mb-10'> <ResponsiveGrid>
{ {
votes.data.map(bot=> <BotCard key={bot.id} bot={bot} />) votes.data.map(bot=> <BotCard key={bot.id} bot={bot} />)
} }
</div> </ResponsiveGrid>
<Paginator totalPage={votes.totalPage} currentPage={votes.currentPage} pathname='/list/votes' /> <Paginator totalPage={votes.totalPage} currentPage={votes.currentPage} pathname='/list/votes' />
<Advertisement /> <Advertisement />
<h1 className='text-3xl font-bold mt-20 mb-2'> <h1 className='text-3xl font-bold mt-20 mb-2'>
<i className='far fa-star mr-3 text-yellow-500' /> <i className='far fa-star mr-3 text-yellow-500' />
</h1> </h1>
<p className='text-base'> .</p> <p className='text-base'> .</p>
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-10'> <ResponsiveGrid>
{ {
newBots.data.slice(0, 4).map(bot=> <BotCard key={bot.id} bot={bot} />) newBots.data.slice(0, 4).map(bot=> <BotCard key={bot.id} bot={bot} />)
} }
</div> </ResponsiveGrid>
<LongButton href='/list/new' center></LongButton> <LongButton href='/list/new' center></LongButton>
<h1 className='text-3xl font-bold mb-2'> <h1 className='text-3xl font-bold mb-2'>
<i className='fa fa-check mr-3 mt-10 text-green-500' /> <i className='fa fa-check mr-3 mt-10 text-green-500' />
</h1> </h1>
<p className='text-base'>KOREANBOTS에서 !!</p> <p className='text-base'>KOREANBOTS에서 !!</p>
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-10'> <ResponsiveGrid>
{ {
trusted.data.slice(0, 4).map(bot=> <BotCard key={bot.id} bot={bot} />) trusted.data.slice(0, 4).map(bot=> <BotCard key={bot.id} bot={bot} />)
} }
</div> </ResponsiveGrid>
<Advertisement /> <Advertisement />
</Container> </Container>
</> </>

View File

@ -9,6 +9,7 @@ const Advertisement = dynamic(() => import('@components/Advertisement'))
const SEO = dynamic(() => import('@components/SEO')) const SEO = dynamic(() => import('@components/SEO'))
const BotCard = dynamic(() => import('@components/BotCard')) const BotCard = dynamic(() => import('@components/BotCard'))
const Container = dynamic(() => import('@components/Container')) const Container = dynamic(() => import('@components/Container'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const New:NextPage<NewProps> = ({ data }) => { const New:NextPage<NewProps> = ({ data }) => {
return <> return <>
@ -16,11 +17,11 @@ const New:NextPage<NewProps> = ({ data }) => {
<SEO title='새로운 봇' description='최근에 추가된 봇들입니다!' /> <SEO title='새로운 봇' description='최근에 추가된 봇들입니다!' />
<Container> <Container>
<Advertisement /> <Advertisement />
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-20'> <ResponsiveGrid>
{ {
data.data.map(bot => <BotCard key={bot.id} bot={bot} /> ) data.data.map(bot => <BotCard key={bot.id} bot={bot} /> )
} }
</div> </ResponsiveGrid>
<Advertisement /> <Advertisement />
</Container> </Container>
</> </>

View File

@ -13,6 +13,7 @@ const Hero = dynamic(() => import('@components/Hero'))
const Advertisement = dynamic(() => import('@components/Advertisement')) const Advertisement = dynamic(() => import('@components/Advertisement'))
const SEO = dynamic(() => import('@components/SEO')) const SEO = dynamic(() => import('@components/SEO'))
const BotCard = dynamic(() => import('@components/BotCard')) const BotCard = dynamic(() => import('@components/BotCard'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const Container = dynamic(() => import('@components/Container')) const Container = dynamic(() => import('@components/Container'))
const Paginator = dynamic(() => import('@components/Paginator')) const Paginator = dynamic(() => import('@components/Paginator'))
@ -24,11 +25,11 @@ const Votes:NextPage<VotesProps> = ({ data }) => {
<SEO title='하트 랭킹' description='하트를 많이 받은 봇들의 순위입니다!'/> <SEO title='하트 랭킹' description='하트를 많이 받은 봇들의 순위입니다!'/>
<Container> <Container>
<Advertisement /> <Advertisement />
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-20'> <ResponsiveGrid>
{ {
data.data.map(bot => <BotCard key={bot.id} bot={bot} /> ) data.data.map(bot => <BotCard key={bot.id} bot={bot} /> )
} }
</div> </ResponsiveGrid>
<Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname='/list/votes' /> <Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname='/list/votes' />
<Advertisement /> <Advertisement />
</Container> </Container>

View File

@ -14,6 +14,7 @@ const Advertisement = dynamic(() => import('@components/Advertisement'))
const SEO = dynamic(() => import('@components/SEO')) const SEO = dynamic(() => import('@components/SEO'))
const BotCard = dynamic(() => import('@components/BotCard')) const BotCard = dynamic(() => import('@components/BotCard'))
const Container = dynamic(() => import('@components/Container')) const Container = dynamic(() => import('@components/Container'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const Paginator = dynamic(() => import('@components/Paginator')) const Paginator = dynamic(() => import('@components/Paginator'))
const Search:NextPage<SearchProps> = ({ data, query }) => { const Search:NextPage<SearchProps> = ({ data, query }) => {
@ -29,11 +30,11 @@ const Search:NextPage<SearchProps> = ({ data, query }) => {
<Advertisement /> <Advertisement />
{ !data || data.data.length === 0 ? <h1 className='text-3xl font-bold text-center py-20'> .</h1> : { !data || data.data.length === 0 ? <h1 className='text-3xl font-bold text-center py-20'> .</h1> :
<> <>
<div className='grid gap-x-4 2xl:grid-cols-4 md:grid-cols-2 mt-20'> <ResponsiveGrid>
{ {
data.data.map(bot => <BotCard key={bot.id} bot={bot} /> ) data.data.map(bot => <BotCard key={bot.id} bot={bot} /> )
} }
</div> </ResponsiveGrid>
<Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname={`/search?q=${query.q}`} /> <Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname={`/search?q=${query.q}`} />
</> </>
} }

View File

@ -15,6 +15,7 @@ const SEO = dynamic(() => import('@components/SEO'))
const DiscordAvatar = dynamic(() => import('@components/DiscordAvatar')) const DiscordAvatar = dynamic(() => import('@components/DiscordAvatar'))
const Divider = dynamic(() => import('@components/Divider')) const Divider = dynamic(() => import('@components/Divider'))
const BotCard = dynamic(() => import('@components/BotCard')) const BotCard = dynamic(() => import('@components/BotCard'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const Tag = dynamic(() => import('@components/Tag')) const Tag = dynamic(() => import('@components/Tag'))
const Advertisement = dynamic(() => import('@components/Advertisement')) const Advertisement = dynamic(() => import('@components/Advertisement'))
const Tooltip = dynamic(() => import('@components/Tooltip')) const Tooltip = dynamic(() => import('@components/Tooltip'))
@ -83,11 +84,11 @@ const Users: NextPage<UserProps> = ({ data }) => {
</div> </div>
<Divider /> <Divider />
<h2 className='mt-8 text-3xl font-bold'> </h2> <h2 className='mt-8 text-3xl font-bold'> </h2>
<div className='grid gap-x-4 mt-20 2xl:grid-cols-4 md:grid-cols-2'> <ResponsiveGrid>
{(data.bots as Bot[]).map((bot: Bot) => ( {(data.bots as Bot[]).map((bot: Bot) => (
<BotCard key={bot.id} bot={bot} /> <BotCard key={bot.id} bot={bot} />
))} ))}
</div> </ResponsiveGrid>
<Advertisement /> <Advertisement />
</Container> </Container>
) )