Skip to content

Commit

Permalink
Merge pull request #32 from team-nabi/NABI-59
Browse files Browse the repository at this point in the history
🎉 ItemListPage 컴포넌트 UI 완성
  • Loading branch information
doggopawer authored Nov 3, 2023
2 parents 2d055a8 + 6f766a1 commit e80f52a
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 4 deletions.
6 changes: 5 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {
images: {
domains: ['cdn.cetizen.com'],
},
}

module.exports = nextConfig
4 changes: 4 additions & 0 deletions public/images/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/filter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions src/app/(root)/(routes)/items/components/Item-list/ItemList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import Image from 'next/image'
import TradeStateCard from '@/components/domain/card/trade-state-card'
import Assets from '@/config/assets'
import { Item } from '@/types'
import SearchInput from '../search-input'

const list = [
{
_id: 1, // 내려줄 때 리스트 순서
cardId: 1,
cardTitle: '아이폰 16 팝니다',
itemName: '아이폰 16',
createdAt: '2023-11-01T08:08:00',
modifiedAt: '2023-11-01T08:08:00',
dibCount: 19,
priceRange: '10000-50000',
image:
'https://cdn.cetizen.com/CDN/market/market_large_crop/202203/20220318/220318152808_1_2913635.jpg',
tradeState: 'impossible',
},
{
_id: 2, // 내려줄 때 리스트 순서
cardId: 1,
cardTitle: '아이폰 16 팝니다',
itemName: '아이폰 16',
createdAt: '2023-11-01T08:08:00',
modifiedAt: '2023-11-01T08:08:00',
dibCount: 19,
priceRange: '10000-50000',
image:
'https://cdn.cetizen.com/CDN/market/market_large_crop/202203/20220318/220318152808_1_2913635.jpg',
tradeState: 'impossible',
},
{
_id: 3, // 내려줄 때 리스트 순서
cardId: 1,
cardTitle: '아이폰 16 팝니다',
itemName: '아이폰 16',
createdAt: '2023-11-01T08:08:00',
modifiedAt: '2023-11-01T08:08:00',
dibCount: 19,
priceRange: '10000-50000',
image:
'https://cdn.cetizen.com/CDN/market/market_large_crop/202203/20220318/220318152808_1_2913635.jpg',
tradeState: 'impossible',
},
]

const ItemList = () => {
return (
<div>
<div className="h-9 flex justify-between items-center mb-6">
<SearchInput placeholder="찾으시는 물품을 입력해주세요." />
<div className="h-6 flex gap-2">
<Image src={Assets.filterIcon} alt="필터 아이콘" />{' '}
<div className="flex">필터</div>
</div>
</div>
<div>
{list.map((item: Item) => (
<TradeStateCard key={item._id} item={item} className="mb-6" />
))}
</div>
</div>
)
}
export default ItemList
3 changes: 3 additions & 0 deletions src/app/(root)/(routes)/items/components/Item-list/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ItemList from './ItemList'

export default ItemList
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'
import Input from '@/components/ui/Input'
import { InputProps } from '@/components/ui/Input/Input'

const SearchInput = ({ ...props }: InputProps) => {
return (
<div className="relative w-4/5">
<Input {...props} />
<div className="absolute right-3 top-2.5 pointer-events-none">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5 text-gray-400"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fillRule="evenodd"
d="M9 16a7 7 0 100-14 7 7 0 000 14zm0 1a8 8 0 100-16 8 8 0 000 16zm5.293-11.293a1 1 0 00-1.414-1.414l-4 4a1 1 0 001.414 1.414l4-4z"
clipRule="evenodd"
/>
</svg>
</div>
</div>
)
}

SearchInput.displayName = 'SearchInput'

export default SearchInput
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SearchInput from './SearchInput'

export default SearchInput
16 changes: 16 additions & 0 deletions src/app/(root)/(routes)/items/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FunctionComponent } from 'react'
import PageTitle from '@/components/domain/page-title'
import ItemList from './components/Item-list'

interface ItemListPageProps {}

const ItemListPage: FunctionComponent<ItemListPageProps> = ({}) => {
return (
<div>
<PageTitle title="물건 목록" />
<ItemList />
</div>
)
}

export default ItemListPage
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Item } from '@/types'

type TradeStateCardProps = {
item: Item
className: string
}
type TradeStateMap = {
[key: string]: {
Expand All @@ -23,6 +24,7 @@ type TradeStateMap = {

const TradeStateCard = ({
item: { image, cardTitle, tradeState, itemName, priceRange, createdAt },
className,
}: TradeStateCardProps) => {
const tradeStateMap: TradeStateMap = {
possible: {
Expand All @@ -36,7 +38,7 @@ const TradeStateCard = ({
}

return (
<Card size={'sm'}>
<Card size={'sm'} className={className}>
<CardFlex
direction={'row'}
justify={'start'}
Expand Down
19 changes: 19 additions & 0 deletions src/components/domain/page-title/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Image from 'next/image'
import Assets from '@/config/assets'

const PageTitle = ({ title }: { title: string }) => {
return (
<div className="flex grid items-center justify-between w-full grid-cols-3 h-8 my-4">
<Image
src={Assets.arrowLeftIcon}
alt="이전 아이콘"
className="flex justify-start items-center"
/>
<h2 className="flex justify-center items-center text-xl font-bold">
{title}
</h2>
<div></div>
</div>
)
}
export default PageTitle
3 changes: 3 additions & 0 deletions src/components/domain/page-title/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PageTitle from './PageTitle'

export default PageTitle
3 changes: 2 additions & 1 deletion src/components/ui/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Trade: Story = {
return (
<TradeStateCard
item={{
_id: 1, // 내려줄 때 리스트 순서
_id: 1,
cardId: 1,
cardTitle: '아이폰 16 팝니다',
itemName: '아이폰 16',
Expand All @@ -101,6 +101,7 @@ export const Trade: Story = {
'https://cdn.cetizen.com/CDN/market/market_large_crop/202203/20220318/220318152808_1_2913635.jpg',
tradeState: 'impossible',
}}
className={''}
/>
)
},
Expand Down
4 changes: 4 additions & 0 deletions src/config/assets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ArrowLeftIcon from '/public/images/arrow-left.svg'
import AlarmIcon from '/public/images/bell.svg'
import FilterIcon from '/public/images/filter.svg'
import GoogleIcon from '/public/images/google.png'
import KakaoIcon from '/public/images/kakao.png'
import Logo from '/public/images/logo.svg'
Expand All @@ -7,6 +9,8 @@ import XIcon from '/public/images/x-icon.svg'

const Assets = {
menuIcon: MenuIcon,
arrowLeftIcon: ArrowLeftIcon,
filterIcon: FilterIcon,
alarmIcon: AlarmIcon,
googleIcon: GoogleIcon,
kakaoIcon: KakaoIcon,
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface Item {
dibCount: number
priceRange: string
image: string
tradeState: 'possible' | 'impossible'
tradeState: string
}

0 comments on commit e80f52a

Please sign in to comment.