-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [FEAT] 상품 소개, 리뷰 탭으로 변경 * [ui] 주문 탭 반응형
- Loading branch information
1 parent
f634bbf
commit a665923
Showing
5 changed files
with
118 additions
and
41 deletions.
There are no files selected for viewing
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,8 @@ | ||
// 상품 소개 | ||
export default function Introduction({ introductionImageUrl }) { | ||
return introductionImageUrl ? ( | ||
<img src={introductionImageUrl} alt="상품 정보" style={{ width: "100%" }} /> | ||
) : ( | ||
<div style={{ textAlign: "center" }}>상품 정보가 없습니다</div> | ||
); | ||
} |
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,103 @@ | ||
import { Box, Tabs, Tab } from "@mui/material"; | ||
import PropTypes from "prop-types"; | ||
import { useState } from "react"; | ||
import Review from "./review/Review"; | ||
import Introduction from "./Introduction"; | ||
import styled from "styled-components"; | ||
|
||
const OrderTabBox = styled(Box)` | ||
margin: 0 200px; | ||
@media screen and (max-width: 768px) { | ||
margin: 0; | ||
} | ||
`; | ||
|
||
function TabPanel(props) { | ||
const { children, value, index, ...other } = props; | ||
|
||
return ( | ||
<div | ||
role="tabpanel" | ||
hidden={value !== index} | ||
id={`product-tabpanel-${index}`} | ||
aria-labelledby={`product-tab-${index}`} | ||
{...other} | ||
> | ||
{value === index && <Box sx={{ p: 3 }}>{children}</Box>} | ||
</div> | ||
); | ||
} | ||
|
||
TabPanel.propTypes = { | ||
children: PropTypes.node, | ||
index: PropTypes.number.isRequired, | ||
value: PropTypes.number.isRequired, | ||
}; | ||
|
||
function a11yProps(index) { | ||
return { | ||
id: `product-tab-${index}`, | ||
"aria-controls": `product-tabpanel-${index}`, | ||
}; | ||
} | ||
|
||
export default function OrderTab({ introductionImageUrl }) { | ||
const [value, setValue] = useState(0); | ||
|
||
const handleChange = (event, newValue) => { | ||
setValue(newValue); | ||
}; | ||
|
||
const tabConfigs = [ | ||
{ | ||
value: "intro", | ||
label: "상품 소개", | ||
content: <Introduction introductionImageUrl={introductionImageUrl} />, | ||
}, | ||
{ | ||
value: "review", | ||
label: "리뷰", | ||
content: <Review />, | ||
}, | ||
]; | ||
|
||
return ( | ||
<OrderTabBox> | ||
<Box | ||
sx={{ | ||
borderBottom: 1, | ||
borderColor: "divider", | ||
}} | ||
> | ||
<Tabs | ||
sx={{ mt: 7 }} | ||
value={value} | ||
onChange={handleChange} | ||
aria-label="basic tabs example" | ||
centered | ||
> | ||
{tabConfigs.map((t, i, arr) => { | ||
return ( | ||
<Tab | ||
key={i} | ||
sx={{ | ||
fontSize: 18, | ||
fontWeight: "bold", | ||
}} | ||
label={t.label} | ||
{...a11yProps(i)} | ||
/> | ||
); | ||
})} | ||
</Tabs> | ||
</Box> | ||
{tabConfigs.map((t, i, arr) => { | ||
return ( | ||
<TabPanel key={i} value={value} index={i}> | ||
{t.content} | ||
</TabPanel> | ||
); | ||
})} | ||
</OrderTabBox> | ||
); | ||
} |
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
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