-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9802c4
commit 1b7f635
Showing
7 changed files
with
45,727 additions
and
9,918 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useEffect, useState } from 'react'; | ||
import Card from '../utils/Card'; | ||
|
||
const CarouselSection = (props) => { | ||
const [products, setProducts] = useState([]); | ||
|
||
useEffect(() => { | ||
fetch( | ||
'https://h3rb9c0ugl.execute-api.ap-northeast-2.amazonaws.com/develop/baminchan/main' | ||
) | ||
.then((response) => response.json()) | ||
.then((result) => setProducts(result.body)) | ||
.then((error) => console.log('error', error)); | ||
}, []); | ||
|
||
return ( | ||
<ul> | ||
{products.map((product) => ( | ||
<Card key={product.detail_hash} product={product} cardSize={'medium'} /> | ||
))} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default CarouselSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const MainPage = (props) => <></>; | ||
import CarouselSection from './CarouselSection'; | ||
|
||
const MainPage = (props) => <CarouselSection />; | ||
|
||
export default MainPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import styled from 'styled-components'; | ||
import theme from './constant'; | ||
|
||
const Card = ({ product, cardSize }) => { | ||
return ( | ||
<CardContainer cardSize={cardSize}> | ||
<img src={product.image} alt="card-image" /> | ||
<CardInfoContainer> | ||
<div className="title"> | ||
<span>{product.title}</span> | ||
</div> | ||
<div className="description"> | ||
<span>{product.description}</span> | ||
</div> | ||
<Price product={product} /> | ||
</CardInfoContainer> | ||
</CardContainer> | ||
); | ||
}; | ||
|
||
const Price = ({ product }) => { | ||
const isOnSale = !!product.n_price; | ||
if (!isOnSale) { | ||
return <FinalPriceSpan>{product.s_price}</FinalPriceSpan>; | ||
} | ||
return ( | ||
<div className="price"> | ||
<FinalPriceSpan>{product.n_price}</FinalPriceSpan> | ||
<OriginalPriceSpan>{product.s_price}</OriginalPriceSpan> | ||
</div> | ||
); | ||
}; | ||
|
||
// ============================= ● Styled components ● ============================= | ||
|
||
const CardContainer = styled.li` | ||
width: ${(props) => (props.cardSize === 'medium' ? '308px' : '384px')}; | ||
img { | ||
border-radius: ${theme.borders.radius}; | ||
margin-bottom: 16px; | ||
width: ${(props) => (props.cardSize === 'medium' ? '308px' : '384px')}; | ||
} | ||
`; | ||
|
||
const CardInfoContainer = styled.div` | ||
.title { | ||
font-size: ${theme.fontSizes.S}; | ||
color: ${theme.colors.darkGray}; | ||
} | ||
.description { | ||
font-size: ${theme.fontSizes.XS}; | ||
color: ${theme.colors.gray}; | ||
margin: 8px 0px; | ||
} | ||
.price { | ||
display: flex; | ||
align-items: center; | ||
} | ||
`; | ||
|
||
const FinalPriceSpan = styled.span` | ||
font-size: ${theme.fontSizes.L}; | ||
font-weight: bold; | ||
margin-right: 8px; | ||
`; | ||
|
||
const OriginalPriceSpan = styled.span` | ||
font-size: ${theme.fontSizes.XS}; | ||
text-decoration: line-through; | ||
color: ${theme.colors.lightGray}; | ||
`; | ||
|
||
export default Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* { | ||
box-sizing: border-box; | ||
list-style: none; | ||
} |
Oops, something went wrong.