Skip to content

Commit

Permalink
๐ŸŽจ Publish(#83): ์ƒ์ ํŽ˜์ด์ง€ ํผ๋ธ”๋ฆฌ์‹ฑ
Browse files Browse the repository at this point in the history
  • Loading branch information
rhehfl committed Dec 8, 2024
1 parent 8fd7f50 commit 64ee2c0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 63 deletions.
17 changes: 12 additions & 5 deletions src/features/store/styles.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Item from '@type/Item';
import styled, { css } from 'styled-components';

export const StoreItemWrapper = styled.div<{ $query: string }>`
export const StoreItemWrapper = styled.div<{ $category: Item['category'] }>`
margin: 18px 0 27px 0;
display: grid;
grid-template-columns: repeat(4, 144px);
grid-template-rows: repeat(2, 125px);
gap: 21px 19px;
${({ $query }) =>
$query === 'ํ”„๋กœํ•„' &&
${({ $category }) =>
$category === 'profile' &&
css`
grid-template-columns: repeat(3, 180px);
grid-template-rows: repeat(1, 217px);
Expand Down Expand Up @@ -48,9 +49,15 @@ export const ItemLabel = styled.label`
line-height: 16px; /* 160% */
letter-spacing: 0.2px;
`;
export const ItemImage = styled.img`
export const ItemImage = styled.img<{ $category: Item['category'] }>`
width: 125px;
height: 70px;
${({ $category }) =>
$category === 'profile' &&
css`
width: 160px;
height: 160px;
`}
`;
export const PaginationDiv = styled.div`
width: 276px;
Expand Down Expand Up @@ -95,7 +102,7 @@ export const StoreCartListWrapper = styled.div`
`;

export const PlaceLabel = styled.label`
margin-bottom: 26px;
margin: 28px 0 26px 0;
text-align: center;
display: block;
width: 142.001px;
Expand Down
54 changes: 27 additions & 27 deletions src/features/store/ui/CartList.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
import { getImageUrl } from '@utils/getImageUrl';
import * as S from '../styles';
const testItem = [
import Item from '@type/Item';
const testItem: Item[] = [
{
id: 1,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
name: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
image: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
cost: 500,
category: 'accessories',
},
{
id: 2,
label: 'ํ•ด์  ์˜์ƒ',
img: 'ํ•ด์ -์˜์ƒ.svg',
place: '1000',
name: 'ํ•ด์  ์˜์ƒ',
image: 'ํ•ด์ -์˜์ƒ.svg',
cost: 1000,
category: 'clothes',
},
{
id: 3,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
name: 'ํ•ด์ดˆ์˜ ์Šต๊ฒฉ',
image: 'ํ•ด์ดˆ์˜-์Šต๊ฒฉ.svg',
cost: 500,
category: 'profile',
},
{
id: 4,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
},
{
id: 5,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
name: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
image: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
cost: 500,
category: 'color',
},
];
interface CartListProps {
query: string;
}
export default function CartList({ query }: CartListProps) {

export default function CartList() {
return (
<>
<S.StoreCartListWrapper>
{testItem.map(item => (
<S.StoreItem key={item.id}>
<S.ItemLabel>{item.label}</S.ItemLabel>
<S.ItemImage src={getImageUrl(item.img)} />
<S.ItemLabel>{item.place} Point</S.ItemLabel>
<S.ItemLabel>{item.name}</S.ItemLabel>
<S.ItemImage
$category={item.category}
src={getImageUrl(item.image)}
/>
<S.ItemLabel>{item.cost} Point</S.ItemLabel>
</S.StoreItem>
))}
<S.PlaceLabel>์ด 1500ํฌ์ธํŠธ</S.PlaceLabel>
</S.StoreCartListWrapper>
<S.PlaceLabel>์ด 1500ํฌ์ธํŠธ</S.PlaceLabel>
</>
);
}
47 changes: 26 additions & 21 deletions src/features/store/ui/ItemContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
import { getImageUrl } from '@/utils/getImageUrl';
import * as S from '../styles';
import { useState } from 'react';
const testItem = [
import Item from '@type/Item';
const testItem: Item[] = [
{
id: 1,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
category: 'hat',
name: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
image: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
cost: 500,
category: 'accessories',
},
{
id: 2,
label: 'ํ•ด์  ์˜์ƒ',
img: 'ํ•ด์ -์˜์ƒ.svg',
place: '1000',
category: 'top',
name: 'ํ•ด์  ์˜์ƒ',
image: 'ํ•ด์ -์˜์ƒ.svg',
cost: 1000,
category: 'clothes',
},
{
id: 3,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
category: 'accessories',
name: 'ํ•ด์ดˆ์˜ ์Šต๊ฒฉ',
image: 'ํ•ด์ดˆ์˜-์Šต๊ฒฉ.svg',
cost: 500,
category: 'profile',
},
{
id: 4,
label: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
img: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
place: '500',
name: 'ํ•ด์  ๋ฒ ๋ ˆ๋ชจ',
image: 'ํ•ด์ -๋ฒ ๋ ˆ๋ชจ.svg',
cost: 500,
category: 'color',
},
];

interface ItemContainerProps {
query: string;
query: Item['category'];
}
export default function ItemContainer({ query }: ItemContainerProps) {
//์Šคํƒ€์ผ๋ง์„ ์œ„ํ•จ ์ถ”ํ›„ ์ˆ˜์ • ์˜ˆ์ •
const [currentPage, setCurrentPage] = useState<number>();
return (
<>
<S.StoreItemWrapper $query={query}>
<S.StoreItemWrapper $category={query}>
{testItem.map(item => (
<S.StoreItem key={item.id}>
<S.ItemLabel>{item.label}</S.ItemLabel>
<S.ItemImage src={getImageUrl(item.img)} />
<S.ItemLabel>{item.place} Point</S.ItemLabel>
<S.ItemLabel>{item.name}</S.ItemLabel>
<S.ItemImage
$category={item.category}
src={getImageUrl(item.image)}
/>
<S.ItemLabel>{item.cost} Point</S.ItemLabel>
</S.StoreItem>
))}
</S.StoreItemWrapper>
Expand Down
37 changes: 27 additions & 10 deletions src/pages/store/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,27 @@ import ItemContainer from '@features/store/ui/ItemContainer';
import CartList from '@features/store/ui/CartList';
import MyCharacter from '@features/user/ui/MyCharacter';
import ProfileImage from '@features/user/ui/ProfileImage';
const buttonLabelList = ['์˜์ƒ', '์•…์„ธ์‚ฌ๋ฆฌ', 'ํ”„๋กœํ•„', '์ƒ‰์ƒ'] as const;
import Item from '@type/Item';
const buttonList: { label: string; name: Item['category'] }[] = [
{
label: '์˜์ƒ',
name: 'clothes',
},
{
label: '์•…์„ธ์‚ฌ๋ฆฌ',
name: 'accessories',
},
{
label: 'ํ”„๋กœํ•„',
name: 'profile',
},
{
label: '์ƒ‰์ƒ',
name: 'color',
},
];
export default function Store() {
const [itemQuery, setItemQuery] =
useState<(typeof buttonLabelList)[number]>('์˜์ƒ');
const [itemQuery, setItemQuery] = useState<Item['category']>('clothes');
return (
<>
<globalS.Wrapper>
Expand All @@ -23,7 +40,7 @@ export default function Store() {
<Header />
<S.CartListWrapper>
<S.Label>์žฅ๋ฐ”๊ตฌ๋‹ˆ</S.Label>
<CartList query={itemQuery} />
<CartList />
</S.CartListWrapper>
</globalS.RightSection>
</globalS.Wrapper>
Expand All @@ -33,17 +50,17 @@ export default function Store() {
<S.Button>๋‚ด๊ฐ€ ๊ตฌ๋งคํ•œ ์•„์ดํ…œ</S.Button>
<S.Button>์ดˆ๊ธฐํ™”</S.Button>
</div>
{itemQuery === 'ํ”„๋กœํ•„' ? <ProfileImage /> : <MyCharacter />}
{itemQuery === 'profile' ? <ProfileImage /> : <MyCharacter />}
</S.MyCharacterSection>
<S.StoreItemListSection>
<S.FilterListContainer>
{buttonLabelList.map(label => (
{buttonList.map(item => (
<S.FilterButton
key={label}
onClick={() => setItemQuery(label)}
$isSelect={itemQuery === label}
key={item.name}
onClick={() => setItemQuery(item.name)}
$isSelect={itemQuery === item.name}
>
{label}
{item.label}
</S.FilterButton>
))}
</S.FilterListContainer>
Expand Down
8 changes: 8 additions & 0 deletions src/types/Item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
interface Item {
id: number;
name: string;
cost: number;
image: string;
category: 'clothes' | 'accessories' | 'profile' | 'color';
}
export default Item;

0 comments on commit 64ee2c0

Please sign in to comment.