HasSidebar.js (1857B)
1 import LoginButton from '../../components/Loginbutton' 2 import { useUserStore } from '../../state/User' 3 import { useState, useEffect } from '@wordpress/element' 4 // import { useGlobalStore } from '../../state/GlobalState' 5 // import { __ } from '@wordpress/i18n' 6 // import { useTemplatesStore } from '../../state/Templates' 7 8 export default function HasSidebar({ children }) { 9 const apiKey = useUserStore(state => state.apiKey) 10 const [canLogInOut, setCanInLogOut] = useState(false) 11 // const setActiveTemplate = useTemplatesStore(state => state.setActive) 12 // const openGuide = () => { 13 // useGlobalStore.setState({ 14 // currentPage: 'guide-start', 15 // }) 16 // setActiveTemplate({}) 17 // } 18 useEffect(() => { 19 setCanInLogOut(!apiKey.length || window.location.search.indexOf('DEVMODE') > -1) 20 }, [apiKey]) 21 return <> 22 <aside className="flex-shrink-0 sm:pl-12 py-0 sm:py-6 relative"> 23 <div className="sm:w-56 lg:w-72 sticky flex flex-col lg:h-full">{children[0]}</div> 24 <div className="hidden sm:flex flex-col absolute bottom-0 bg-white mb-4 w-72 text-left space-y-4"> 25 <div className="border-t border-gray-300 flex divide-x"> 26 {/* <button 27 type="button" 28 className="components-button inline-block flex-1 text-center hover:bg-gray-100" 29 onClick={openGuide}> 30 {__('Welcome Guide', 'extendify-sdk')} 31 </button> */} 32 {canLogInOut && <LoginButton/>} 33 </div> 34 </div> 35 </aside> 36 <main 37 id="extendify-templates" 38 // tabIndex="0" 39 className="w-full smp:l-12 sm:pt-6 h-full overflow-hidden"> 40 {children[1]} 41 </main> 42 </> 43 }