-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE] refactor: 홈 화면 변경 #628
Changes from 18 commits
bee3e61
4d029d2
af8a065
17506a4
7632b12
a40e10b
2d521ae
f193e59
bf3a3da
09e534e
61e167c
fb3d02d
ec48d4f
89ff622
9231ee5
ed8d19e
6794cba
a85ed74
24020c2
3b5d86d
8c7c436
16b8edd
f9b371b
d6b0b9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import CategoryItem from './CategoryItem'; | ||
|
||
const meta: Meta<typeof CategoryItem> = { | ||
title: 'common/CategoryItem', | ||
component: CategoryItem, | ||
args: { | ||
name: '즉석 식품', | ||
image: 'https://tqklhszfkvzk6518638.cdn.ntruss.com/product/8801771029052.jpg', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CategoryItem>; | ||
|
||
export const Default: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Button } from '@fun-eat/design-system'; | ||
import styled from 'styled-components'; | ||
|
||
interface CategoryItemProps { | ||
name: string; | ||
image: string; | ||
} | ||
|
||
const CategoryItem = ({ name, image }: CategoryItemProps) => { | ||
return ( | ||
<CategoryItemContainer variant="transparent"> | ||
<ImageWrapper> | ||
<img src={image} width={60} height={60} alt="카테고리" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alt에 {name}카테고리로 하는건 어떨까요?? |
||
</ImageWrapper> | ||
<CategoryName>{name}</CategoryName> | ||
</CategoryItemContainer> | ||
); | ||
}; | ||
|
||
export default CategoryItem; | ||
|
||
const CategoryItemContainer = styled(Button)` | ||
width: 60px; | ||
height: 100px; | ||
text-align: center; | ||
`; | ||
|
||
const ImageWrapper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 10px; | ||
background: ${({ theme }) => theme.colors.white}; | ||
|
||
img { | ||
width: 100%; | ||
height: auto; | ||
object-fit: cover; | ||
} | ||
`; | ||
|
||
const CategoryName = styled.p` | ||
margin-top: 10px; | ||
font-weight: 600; | ||
font-size: 0.8rem; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import CategoryList from './CategoryList'; | ||
|
||
const meta: Meta<typeof CategoryList> = { | ||
title: 'common/CategoryList', | ||
component: CategoryList, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CategoryList>; | ||
|
||
export const Default: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import styled from 'styled-components'; | ||
|
||
import CategoryItem from '../CategoryItem/CategoryItem'; | ||
|
||
import { MENU_IMAGES, MENU_NAME, STORE_IMAGES, STORE_NAMES } from '@/constants'; | ||
|
||
const MENU_LENGTH = 5; | ||
const STORE_LENGTH = 4; | ||
|
||
const CategoryList = () => { | ||
const menuList = Array.from({ length: MENU_LENGTH }, (_, index) => ({ | ||
name: MENU_NAME[index], | ||
image: MENU_IMAGES[index], | ||
})); | ||
|
||
const storeList = Array.from({ length: STORE_LENGTH }, (_, index) => ({ | ||
name: STORE_NAMES[index], | ||
image: STORE_IMAGES[index], | ||
})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 상수니까 컴포넌트 위로 빼주세요! |
||
|
||
return ( | ||
<CategoryListContainer> | ||
<MenuListWrapper> | ||
{menuList.map((menu, index) => ( | ||
<CategoryItem key={`menuItem-${index}`} name={menu.name} image={menu.image} /> | ||
))} | ||
</MenuListWrapper> | ||
<StoreListWrapper> | ||
{storeList.map((menu, index) => ( | ||
<CategoryItem key={`storeItem-${index}`} name={menu.name} image={menu.image} /> | ||
))} | ||
</StoreListWrapper> | ||
</CategoryListContainer> | ||
); | ||
}; | ||
|
||
export default CategoryList; | ||
|
||
const CategoryListContainer = styled.div` | ||
overflow-x: auto; | ||
overflow-y: hidden; | ||
|
||
@media screen and (min-width: 500px) { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
&::-webkit-scrollbar { | ||
display: none; | ||
} | ||
`; | ||
|
||
const MenuListWrapper = styled.div` | ||
display: flex; | ||
gap: 20px; | ||
`; | ||
|
||
const StoreListWrapper = styled.div` | ||
display: flex; | ||
gap: 20px; | ||
`; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import CategoryTab from './CategoryTab'; | ||
|
||
const meta: Meta<typeof CategoryTab> = { | ||
title: 'common/CategoryTab', | ||
component: CategoryTab, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CategoryTab>; | ||
|
||
export const FoodCategory: Story = { | ||
args: { | ||
tabVariant: 'food', | ||
}, | ||
}; | ||
|
||
export const StoreCategory: Story = { | ||
args: { | ||
tabVariant: 'store', | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,23 +8,17 @@ import { MoreButton } from '@/components/Common'; | |
import { PATH } from '@/constants/path'; | ||
import { useCategoryContext } from '@/hooks/context'; | ||
import { useInfiniteProductsQuery } from '@/hooks/queries/product'; | ||
import displaySlice from '@/utils/displaySlice'; | ||
|
||
interface PBProductListProps { | ||
isHomePage?: boolean; | ||
} | ||
|
||
const PBProductList = ({ isHomePage }: PBProductListProps) => { | ||
const PBProductList = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 덜어낸거 👍👍👍 |
||
const { categoryIds } = useCategoryContext(); | ||
|
||
const { data: pbProductListResponse } = useInfiniteProductsQuery(categoryIds.store); | ||
const pbProducts = pbProductListResponse.pages.flatMap((page) => page.products); | ||
const pbProductsToDisplay = displaySlice(isHomePage, pbProducts, 10); | ||
|
||
return ( | ||
<> | ||
<PBProductListContainer> | ||
{pbProductsToDisplay.map((pbProduct) => ( | ||
{pbProducts.map((pbProduct) => ( | ||
<li key={pbProduct.id}> | ||
<Link as={RouterLink} to={`${PATH.PRODUCT_LIST}/store/${pbProduct.id}`}> | ||
<PBProductItem pbProduct={pbProduct} /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿!