import { h, Fragment } from 'preact'; import { useState } from 'preact/hooks'; import PropTypes from 'prop-types'; import { MobileDrawer } from '@crayons/MobileDrawer'; import { Button } from '@crayons/Button'; const OverflowIcon = () => ( ); const CheckIcon = () => ( ); /** * Renders a page heading with a button which activates a with a list of the given navigation links. * * @param {object} props * @param {number} headingLevel The level of heading to render as the page title (e.g. 1-6) * @param {string} navigationTitle The title to be used for the navigation element (e.g. 'Feed timeframes') * @param {Array} navigationLinks An array of navigationLink objects to display * * @example * */ export const MobileDrawerNavigation = ({ headingLevel, navigationTitle, navigationLinks, }) => { const [isDrawerOpen, setIsDrawerOpen] = useState(false); const currentPage = navigationLinks.find((item) => item.isCurrentPage); const Heading = `h${headingLevel}`; return (
{currentPage.displayName}
{isDrawerOpen && ( setIsDrawerOpen(false)} > )}
); }; MobileDrawerNavigation.propTypes = { headingLevel: PropTypes.oneOf([1, 2, 3, 4, 5, 6]).isRequired, navigationTitle: PropTypes.string.isRequired, navigationLinks: PropTypes.arrayOf( PropTypes.shape({ url: PropTypes.string, isCurrentPage: PropTypes.bool, displayName: PropTypes.string, }), ).isRequired, };