import { ReactNode } from 'react' import { SvgNames } from 'src/components/Svg/Svg' import { useIdeContext } from 'src/helpers/hooks/useIdeContext' import { createRemoveUpdate, updateTree } from 'react-mosaic-component' import type { MosaicPath } from 'react-mosaic-component' import Toggle from 'src/components/Toggle' import type { MosaicTree } from 'src/helpers/hooks/useIdeState' interface SidebarConfigType { name: string icon: SvgNames disabled: boolean panel: ReactNode | null } const getPathById = ( tree: MosaicTree, id: string, path: MosaicPath = [] ): MosaicPath => { if (tree.first === id || tree.second === id) { return [...path, tree.first === id ? 'first' : 'second'] } if (typeof tree.first !== 'string' && typeof tree.second !== 'string') { throw new Error('id not found') } try { if (typeof tree.first !== 'string') { return getPathById(tree.first, id, [...path, 'first']) } } catch (error) { throw new Error('id not found') } try { if (typeof tree.second !== 'string') { return getPathById(tree.second, id, [...path, 'second']) } } catch (error) { throw new Error('id not found') } throw new Error('id not found') } export const sidebarTopConfig: SidebarConfigType[] = [ { name: 'Files', icon: 'files', disabled: false, panel: (

Coming Soon


We're working on multi-file support in tandem with the GitHub integration.

), }, { name: 'GitHub', icon: 'github', disabled: false, panel: (

Coming Soon


This integration will allow you to sync a project with a GitHub repo and push changes back to it as a commit!

), }, { name: 'Visibility', icon: 'eye', disabled: true, panel: null, }, ] const DiscordLink = () => ( Discord ) interface settingsConfig { title: string name: string Content: React.FC } const settingsConfig: settingsConfig[] = [ { title: 'Editor', name: 'editor', Content: () => (

Coming Soon


We're building configuration settings for the Viewer pane now. Join us on if you want to lend a hand!

), }, { title: 'Viewer', name: 'viewer', Content: () => (

Coming Soon


We're building configuration settings for the Viewer pane now. Join us on if you want to lend a hand!

), }, { title: 'Console', name: 'console', Content: () => { const { state, thunkDispatch } = useIdeContext() const consolePath = React.useMemo(() => { try { const path = getPathById(state.layout, 'Console') return path } catch (error) { return null } }, [state.layout]) return (
  • ) }, }, ] export const sidebarBottomConfig: SidebarConfigType[] = [ { name: 'Settings', icon: 'gear', disabled: false, panel: , }, ] export const sidebarCombinedConfig = [ ...sidebarTopConfig, ...sidebarBottomConfig, ] function SettingsMenu({ parentName }: { parentName: string }) { const { state, thunkDispatch } = useIdeContext() return (
    {settingsConfig.map(({ name, title, Content }) => (
    { e.preventDefault() thunkDispatch((dispatch) => dispatch({ type: 'settingsButtonClicked', payload: [parentName, name], }) ) }} > {title}
    ))}
    ) }