|  | 
|  | 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 | +import * as React from "react"; | 
|  | 5 | + | 
|  | 6 | +export interface FAQItem { | 
|  | 7 | +  id: string; | 
|  | 8 | +  question: string; | 
|  | 9 | +  answer: string; | 
|  | 10 | +} | 
|  | 11 | + | 
|  | 12 | +export interface FAQAccordionProps { | 
|  | 13 | +  items: FAQItem[]; | 
|  | 14 | +} | 
|  | 15 | + | 
|  | 16 | +export const FAQAccordion: React.FC<FAQAccordionProps> = ({ items }) => { | 
|  | 17 | +  return ( | 
|  | 18 | +    <AccordionWrapper> | 
|  | 19 | +      {items.map((faq, index) => ( | 
|  | 20 | +        <React.Fragment key={faq.id}> | 
|  | 21 | +          <StyledAccordion> | 
|  | 22 | +            <AccordionSummary | 
|  | 23 | +              expandIcon={<ExpandMoreIcon />} | 
|  | 24 | +              aria-controls={`panel${faq.id}-content`} | 
|  | 25 | +              id={`panel${faq.id}-header`} | 
|  | 26 | +            > | 
|  | 27 | +              <Number>{faq.id}</Number> | 
|  | 28 | +              <Question>{faq.question}</Question> | 
|  | 29 | +            </AccordionSummary> | 
|  | 30 | +            <StyledAccordionDetails>{faq.answer}</StyledAccordionDetails> | 
|  | 31 | +          </StyledAccordion> | 
|  | 32 | +          {index !== items.length - 1 && <Divider />} | 
|  | 33 | +        </React.Fragment> | 
|  | 34 | +      ))} | 
|  | 35 | +    </AccordionWrapper> | 
|  | 36 | +  ); | 
|  | 37 | +}; | 
|  | 38 | + | 
|  | 39 | +const AccordionWrapper = styled.div` | 
|  | 40 | +  display: flex; | 
|  | 41 | +  flex-direction: column; | 
|  | 42 | +  border-top: 1px solid ${({ theme }) => theme.palette.primary.dark}; | 
|  | 43 | +  border-bottom: 1px solid ${({ theme }) => theme.palette.primary.dark}; | 
|  | 44 | +`; | 
|  | 45 | + | 
|  | 46 | +const Divider = styled.div` | 
|  | 47 | +  height: 1px; | 
|  | 48 | +  background-color: ${({ theme }) => theme.palette.primary.light}; | 
|  | 49 | +  margin: 0; | 
|  | 50 | +`; | 
|  | 51 | + | 
|  | 52 | +const StyledAccordion = styled(MuiAccordion)` | 
|  | 53 | +  box-shadow: none; | 
|  | 54 | +  border-radius: 0; | 
|  | 55 | +
 | 
|  | 56 | +  &:before { | 
|  | 57 | +    display: none; | 
|  | 58 | +  } | 
|  | 59 | +
 | 
|  | 60 | +  &.MuiAccordion-root { | 
|  | 61 | +    margin: 0; | 
|  | 62 | +
 | 
|  | 63 | +    &:first-of-type { | 
|  | 64 | +      border-top: none; | 
|  | 65 | +    } | 
|  | 66 | +
 | 
|  | 67 | +    &:last-of-type { | 
|  | 68 | +      border-bottom: none; | 
|  | 69 | +    } | 
|  | 70 | +  } | 
|  | 71 | +
 | 
|  | 72 | +  .MuiAccordionSummary-root { | 
|  | 73 | +    padding: 10px 35px; | 
|  | 74 | +    min-height: 60px; | 
|  | 75 | +    max-height: 60px; | 
|  | 76 | +
 | 
|  | 77 | +    .MuiAccordionSummary-content { | 
|  | 78 | +      display: flex; | 
|  | 79 | +      align-items: center; | 
|  | 80 | +      margin: 0; | 
|  | 81 | +    } | 
|  | 82 | +
 | 
|  | 83 | +    &.Mui-expanded { | 
|  | 84 | +      min-height: 60px; | 
|  | 85 | +      max-height: 60px; | 
|  | 86 | +    } | 
|  | 87 | +  } | 
|  | 88 | +`; | 
|  | 89 | + | 
|  | 90 | +const Number = styled.span` | 
|  | 91 | +  font-size: 18px; | 
|  | 92 | +  font-weight: 400; | 
|  | 93 | +`; | 
|  | 94 | + | 
|  | 95 | +const Question = styled.span` | 
|  | 96 | +  font-size: 18px; | 
|  | 97 | +  font-weight: 400; | 
|  | 98 | +  margin-left: 60px; | 
|  | 99 | +`; | 
|  | 100 | + | 
|  | 101 | +const StyledAccordionDetails = styled(AccordionDetails)` | 
|  | 102 | +  background-color: ${({ theme }) => `${theme.palette.primary.light}26`}; // 15% opacity (26 in hex) | 
|  | 103 | +  color: ${({ theme }) => theme.palette.primary.dark}; | 
|  | 104 | +  font-size: 14px; | 
|  | 105 | +  font-weight: 400; | 
|  | 106 | +  padding: 20px 0 20px calc(35px + 18px + 60px); // top right bottom left | 
|  | 107 | +`; | 
0 commit comments