import { useContext, useState, useEffect } from 'react'
import { ModalContext } from 'shared/context/modal-context.mjs'
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
import { CloseIcon } from 'shared/components/icons.mjs'
import { MobileMenubarContext } from 'shared/context/mobile-menubar-context.mjs'
import { shownHeaderSelector } from 'shared/components/wrappers/header.mjs'
/**
* A component to display menu buttons and actions in mobile.
* Draws its contents from items added to the {@link MobileMenubarContext}
* @returns
*/
export const MobileMenubar = () => {
const { setModal, clearModal, modalContent } = useContext(ModalContext)
const { menus, actions } = useContext(MobileMenubarContext)
const [selectedModal, setSelectedModal] = useState(false)
// get the content of the selected modal because this is what will be changing if there are updates
const selectedMenu = menus[selectedModal]
// when the content changes, or the selection changes
useEffect(() => {
// there's no selected modal, we're in the clear
if (!selectedModal) return
// generate a new modal with the content
const Modal = () => {
const closeModal = () => {
setSelectedModal(false)
clearModal()
}
return (