import React, { useState } from 'react' import PropTypes from 'prop-types' import classNames from 'classnames' import slugify from '@sindresorhus/slugify' import Link from './link' import classes from '../styles/accordion.module.sass' const Accordion = ({ title, id, expanded, children }) => { const anchorId = id || slugify(title) const [isExpanded, setIsExpanded] = useState(expanded) const contentClassNames = classNames(classes.content, { [classes.hidden]: !isExpanded, }) const iconClassNames = classNames({ [classes.hidden]: isExpanded, }) return (

{children}
) } Accordion.defaultProps = { expanded: false, } Accordion.propTypes = { title: PropTypes.string, id: PropTypes.string, children: PropTypes.node.isRequired, } export default Accordion