AccordionsItem.jsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import {
  3. Accordion,
  4. AccordionDetails,
  5. AccordionSummary,
  6. Typography,
  7. useMediaQuery}
  8. from "@mui/material";
  9. import {useState} from "react";
  10. import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
  11. export const AccordionsItem = ({id, title, content}) => {
  12. const matches = useMediaQuery('(max-width:768px)')
  13. const [expanded, setExpanded] = useState(false)
  14. const handleChange = (panel) => (event, isExpanded) => {
  15. setExpanded(isExpanded ? panel : false)
  16. }
  17. return (
  18. <Accordion
  19. expanded={expanded === id}
  20. onChange={handleChange(id)}
  21. sx={{padding: matches ? '10px' : "20px"}}
  22. >
  23. <AccordionSummary
  24. expandIcon={<ExpandMoreIcon />}
  25. aria-controls="panel1a-content"
  26. id="panel1a-header"
  27. >
  28. <Typography
  29. variant={matches ? 'body1' : 'h5'}
  30. letterSpacing='3px'
  31. >
  32. { title.toUpperCase() || 'title' }
  33. </Typography>
  34. </AccordionSummary>
  35. <AccordionDetails>
  36. <Typography
  37. variant='body1'
  38. color='#616161'
  39. lineHeight='1.7em'
  40. fontWeight='300'
  41. >
  42. { content || 'content' }
  43. </Typography>
  44. </AccordionDetails>
  45. </Accordion>
  46. )
  47. }