|
| 1 | +import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; |
| 2 | +import { Accordion as MuiAccordion, AccordionDetails, AccordionSummary } from "@mui/material"; |
| 3 | +import styled from "@emotion/styled"; |
| 4 | + |
| 5 | +const MOCK_FAQ = [ |
| 6 | + { |
| 7 | + id: "01", |
| 8 | + question: "후원사 신청시 여러 후원 등급에 중복 신청도 가능한가요?", |
| 9 | + answer: "네, 중복 신청 가능합니다. 다만 최종 선정시에는 하나의 등급만 선택하셔야 합니다.", |
| 10 | + }, |
| 11 | + { |
| 12 | + id: "02", |
| 13 | + question: "후원사 선정 방법이 궁금합니다. 선착순인가요?", |
| 14 | + answer: |
| 15 | + "후원사 선정은 신청 순서와 함께 파이콘 한국의 후원사 선정 기준에 따라 진행됩니다. 자세한 사항은 후원사 안내 페이지를 참고해 주세요.", |
| 16 | + }, |
| 17 | + { |
| 18 | + id: "03", |
| 19 | + question: "후원사 등록이 정상적으로 진행되었는지 확인 방법이 있나요?", |
| 20 | + answer: |
| 21 | + "후원사 등록 완료 후 자동으로 확인 이메일이 발송됩니다. 만약 확인 이메일을 받지 못하셨다면 [email protected]로 문의해 주시기 바랍니다.", |
| 22 | + }, |
| 23 | +]; |
| 24 | + |
| 25 | +export default function Accordion() { |
| 26 | + return ( |
| 27 | + <AccordionWrapper> |
| 28 | + {MOCK_FAQ.map((faq, index) => ( |
| 29 | + <> |
| 30 | + <StyledAccordion key={faq.id}> |
| 31 | + <AccordionSummary |
| 32 | + expandIcon={<ExpandMoreIcon />} |
| 33 | + aria-controls={`panel${faq.id}-content`} |
| 34 | + id={`panel${faq.id}-header`} |
| 35 | + > |
| 36 | + <Number>{faq.id}</Number> |
| 37 | + <Question>{faq.question}</Question> |
| 38 | + </AccordionSummary> |
| 39 | + <StyledAccordionDetails>{faq.answer}</StyledAccordionDetails> |
| 40 | + </StyledAccordion> |
| 41 | + {index !== MOCK_FAQ.length - 1 && <Divider />} |
| 42 | + </> |
| 43 | + ))} |
| 44 | + </AccordionWrapper> |
| 45 | + ); |
| 46 | +} |
| 47 | + |
| 48 | +const AccordionWrapper = styled.div` |
| 49 | + display: flex; |
| 50 | + flex-direction: column; |
| 51 | +`; |
| 52 | + |
| 53 | +const Divider = styled.div` |
| 54 | + height: 1px; |
| 55 | + background-color: ${({ theme }) => theme.palette.primary.light}; |
| 56 | +`; |
| 57 | + |
| 58 | +const StyledAccordion = styled(MuiAccordion)` |
| 59 | + box-shadow: none; |
| 60 | +
|
| 61 | + &:before { |
| 62 | + display: none; |
| 63 | + } |
| 64 | +
|
| 65 | + &.MuiAccordion-root { |
| 66 | + margin: 0; |
| 67 | + } |
| 68 | +
|
| 69 | + .MuiAccordionSummary-root { |
| 70 | + padding: 10px 35px; |
| 71 | + min-height: 60px; |
| 72 | + max-height: 60px; |
| 73 | +
|
| 74 | + .MuiAccordionSummary-content { |
| 75 | + display: flex; |
| 76 | + align-items: center; |
| 77 | + margin: 0; |
| 78 | + } |
| 79 | +
|
| 80 | + &.Mui-expanded { |
| 81 | + min-height: 60px; |
| 82 | + max-height: 60px; |
| 83 | + } |
| 84 | + } |
| 85 | +`; |
| 86 | + |
| 87 | +const Number = styled.span` |
| 88 | + font-size: 18px; |
| 89 | + font-weight: 400; |
| 90 | +`; |
| 91 | + |
| 92 | +const Question = styled.span` |
| 93 | + font-size: 18px; |
| 94 | + font-weight: 400; |
| 95 | + margin-left: 60px; |
| 96 | +`; |
| 97 | + |
| 98 | +const StyledAccordionDetails = styled(AccordionDetails)` |
| 99 | + background-color: ${({ theme }) => `${theme.palette.primary.light}26`}; // 15% opacity (26 in hex) |
| 100 | + color: ${({ theme }) => theme.palette.primary.dark}; |
| 101 | + font-size: 14px; |
| 102 | + font-weight: 400; |
| 103 | + padding: 20px 0 20px calc(35px + 18px + 60px); // top right bottom left |
| 104 | +`; |
0 commit comments