-
Notifications
You must be signed in to change notification settings - Fork 50
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
[Team23] 프론트엔드 UI 완성 #45
Changes from all commits
c75cc1d
8e42c5f
1c99905
ccfab6b
ac9082b
27cd014
24fae61
c3b9535
7c86069
70a202a
e2b8c6e
e3e19fe
2a35a71
487e287
2c0ee6d
add6642
81b3fce
e2b8e11
3a3dfa5
f2a1cc1
00242f4
4858938
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import styled from 'styled-components'; | ||
import theme from '../utils/styles/theme.js'; | ||
import theme from '../componentUtils/styles/theme.js'; | ||
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. 참고로 전 util하면 유용한 JS 코드만 있어야 할 것 같은 편견이 있네요. |
||
import { CenterContainer } from './styles/common.jsx'; | ||
|
||
const Price = ({ product }) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import styled from "styled-components"; | ||
import theme from "../styles/theme"; | ||
import { BUTTON_TYPE } from "../variables.js"; | ||
import { Button } from "../styles/common"; | ||
import { BUTTON_TYPE } from "../../../utils/variables"; | ||
|
||
const IconButton = ({ type, fn, disabled = false }) => { | ||
const IconButton = ({ type, fn, disabled = false, margin = 0 }) => { | ||
return ( | ||
<StyledIconButton type={type} onClick={fn} disabled={disabled}> | ||
<StyledIconButton type={type} onClick={fn} disabled={disabled} margin={margin}> | ||
{BUTTON_TYPE[type]} | ||
</StyledIconButton> | ||
); | ||
}; | ||
|
||
const StyledIconButton = styled(Button)` | ||
cursor: pointer; | ||
color: ${(props) => | ||
props.disabled || props.type === "SEARCH" ? props.theme.colors.lightGray : props.theme.colors.darkGray}; | ||
color: ${(props) => { | ||
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. 여기서도 destructuring을 사용하시죠. props가 자주 쓰이고 있네요. |
||
if (props.type === "CLOSE") return props.theme.colors.white; | ||
if (props.disabled || props.type === "SEARCH") return props.theme.colors.lightGray; | ||
return props.theme.colors.darkGray; | ||
}}; | ||
font-size: ${({ type }) => (type === "UP" || type === "DOWN" ? theme.fontSizes.M : "30px")}; | ||
margin: ${({ margin }) => `${margin}px`}; | ||
`; | ||
|
||
export default IconButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import styled from "styled-components"; | ||
// import theme from "../styles/theme.js"; | ||
import Price from "../Price"; | ||
import Label from "../Label"; | ||
import { CenterContainer, LabelList, StyledDescription, StyledTitle } from "../styles/common.jsx"; | ||
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. 이 아이들이 common.jsx 에 있는 이유는 뭔가요? 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. 여러군데에서 사용하기 때문입니다! 조건이 있다면 최소 두군데 이상에서 동일한 스타일이 적용될때.. 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. 여러군데에서 사용되는 스타일 컴포넌트를 모아두었습니다. 조건이라한다면 최소 두 군데 이상에서 사용된다는 점..? |
||
import { useState } from "react"; | ||
import Modal from "../modal/Modal.jsx"; | ||
import ModalCard from "../modal/ModalCard.jsx"; | ||
import { URLS } from "../../../utils/variables.js"; | ||
import IconButton from "../button/IconButton.jsx"; | ||
import Thumbnail from "./Thumbnail"; | ||
|
||
// const mockImage = "https://recipe1.ezmember.co.kr/cache/recipe/2020/09/23/5e308abb30b00ecb9c1b9b398db5b4451.jpg"; | ||
|
||
const Card = ({ product, cardSize, margin = 0, type, onModal }) => { | ||
const [modalState, setModalState] = useState(false); | ||
const [detail, setDetail] = useState({}); | ||
|
||
const requestProductDetailInfo = async () => { | ||
const data = await fetch(URLS.base + `detail/${product.detail_hash}`); | ||
const json = await data.json(); | ||
setDetail({ ...json.data }); | ||
setModalState(true); | ||
Comment on lines
+20
to
+23
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 ( | ||
<> | ||
<StyledLi cardSize={cardSize} margin={margin} onClick={requestProductDetailInfo}> | ||
<Thumbnail {...{ product, cardSize, type }} /> | ||
<StyledTitle>{product.title}</StyledTitle> | ||
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. 담번엔 Styled를 붙이지 말아보세요. 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. 넵...! |
||
<StyledDescription>{product.description}</StyledDescription> | ||
<Price product={product} /> | ||
<LabelList>{product.badge && product.badge.map((e) => <Label badgeName={e} />)}</LabelList> | ||
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. 요 문법을 활용해보세요. https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Optional_chaining |
||
</StyledLi> | ||
<Modal> | ||
{modalState && ( | ||
<ModalBackground> | ||
<ModalContainer> | ||
<ModalCard product={{ ...product, ...detail }} /> | ||
<IconButton type="CLOSE" fn={() => setModalState(false)} margin={10} /> | ||
</ModalContainer> | ||
</ModalBackground> | ||
)} | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
const StyledLi = styled.li` | ||
width: ${(props) => props.cardSize}; | ||
margin: 0 ${(props) => props.margin}px; | ||
list-style: none; | ||
`; | ||
|
||
const ModalBackground = styled(CenterContainer)` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
background: rgba(0, 0, 0, 0.4); | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const ModalContainer = styled.div` | ||
display: flex; | ||
align-items: flex-start; | ||
position: absolute; | ||
left: 50%; | ||
transform: translateX(-48%); | ||
`; | ||
|
||
export default Card; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { CenterContainer } from "../styles/common"; | ||
import styled from "styled-components"; | ||
|
||
const mockImage = "https://recipe1.ezmember.co.kr/cache/recipe/2020/09/23/5e308abb30b00ecb9c1b9b398db5b4451.jpg"; | ||
|
||
const Thumbnail = ({ product, cardSize, type }) => { | ||
return ( | ||
<StyledThumbnail> | ||
<HoverLayer cardSize={cardSize}> | ||
<DeliveryTypeList> | ||
{product.delivery_type.reduce((acc, val, index, array) => { | ||
acc.push( | ||
<p> | ||
{val} | ||
{index < array.length - 1 && <Divider />} | ||
</p> | ||
); | ||
return acc; | ||
}, [])} | ||
Comment on lines
+11
to
+19
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. reduce 활용도 좋죠. |
||
</DeliveryTypeList> | ||
</HoverLayer> | ||
<StyledImg cardSize={cardSize} src={type === "베스트" ? mockImage : product.image} alt="card-image" /> | ||
</StyledThumbnail> | ||
); | ||
}; | ||
|
||
export default Thumbnail; | ||
|
||
const StyledThumbnail = styled.div` | ||
position: relative; | ||
`; | ||
|
||
const HoverLayer = styled(CenterContainer)` | ||
color: ${(props) => props.theme.colors.white}; | ||
opacity: 0; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: ${(props) => props.cardSize}; | ||
height: ${(props) => props.cardSize}; | ||
border-radius: ${(props) => props.theme.borders.radius}; | ||
font-size: ${(props) => props.theme.fontSizes.XL}; | ||
font-weight: bold; | ||
|
||
&:hover { | ||
background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)); | ||
opacity: 1; | ||
} | ||
`; | ||
|
||
const DeliveryTypeList = styled.div``; | ||
|
||
const Divider = styled.div` | ||
border: 1px solid ${(props) => props.theme.colors.white}; | ||
width: 90px; | ||
margin: 16px 0; | ||
`; | ||
|
||
const StyledImg = styled.img` | ||
border-radius: ${(props) => props.theme.borders.radius}; | ||
margin-bottom: 16px; | ||
width: ${(props) => props.cardSize}; | ||
height: ${(props) => props.cardSize}; | ||
`; |
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.
오썸~