diff --git a/apps/remix-ide/src/app/components/hidden-panel.tsx b/apps/remix-ide/src/app/components/hidden-panel.tsx index bfdff5a11a..ba5fd4f59c 100644 --- a/apps/remix-ide/src/app/components/hidden-panel.tsx +++ b/apps/remix-ide/src/app/components/hidden-panel.tsx @@ -15,6 +15,7 @@ const profile = { export class HiddenPanel extends AbstractPanel { el: HTMLElement + dispatch: React.Dispatch = () => {} constructor () { super(profile) this.el = document.createElement('div') @@ -27,11 +28,17 @@ export class HiddenPanel extends AbstractPanel { this.renderComponent() } - render () { - return this.el + render (state: any) { + return
} plugins={state.plugins}/>
+ } + + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch } renderComponent () { - ReactDOM.render(} plugins={this.plugins}/>, this.el) + this.dispatch({ + plugins: this.plugins, + }) } } diff --git a/apps/remix-ide/src/app/components/side-panel.tsx b/apps/remix-ide/src/app/components/side-panel.tsx index b5e9dcd3df..610653f205 100644 --- a/apps/remix-ide/src/app/components/side-panel.tsx +++ b/apps/remix-ide/src/app/components/side-panel.tsx @@ -17,6 +17,7 @@ const sidePanel = { export class SidePanel extends AbstractPanel { sideelement: any + dispatch: React.Dispatch = () => {} constructor() { super(sidePanel) this.sideelement = document.createElement('section') @@ -78,11 +79,17 @@ export class SidePanel extends AbstractPanel { this.renderComponent() } - render() { - return this.sideelement + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch + } + + render(state: any) { + return
} plugins={state.plugins} />
} renderComponent() { - ReactDOM.render(} plugins={this.plugins} />, this.sideelement) + this.dispatch({ + plugins: this.plugins + }) } } diff --git a/apps/remix-ide/src/app/components/vertical-icons.tsx b/apps/remix-ide/src/app/components/vertical-icons.tsx index eea114b637..a55dd5a7d4 100644 --- a/apps/remix-ide/src/app/components/vertical-icons.tsx +++ b/apps/remix-ide/src/app/components/vertical-icons.tsx @@ -20,6 +20,7 @@ export class VerticalIcons extends Plugin { events: EventEmitter htmlElement: HTMLDivElement icons: Record = {} + dispatch: React.Dispatch = () => {} constructor () { super(profile) this.events = new EventEmitter() @@ -46,12 +47,15 @@ export class VerticalIcons extends Plugin { ...divived.filter((value) => { return !value.isRequired }) ] - ReactDOM.render( - , - this.htmlElement) + this.dispatch({ + verticalIconsPlugin: this, + icons: sorted + }) + + } + + setDispatch (dispatch: React.Dispatch) { + this.dispatch = dispatch } onActivation () { @@ -107,7 +111,10 @@ export class VerticalIcons extends Plugin { this.events.emit('toggleContent', name) } - render () { - return this.htmlElement + render (state: any) { + return
} } diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx index 6845ce88b1..97b9fbec81 100644 --- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react' +import React, { useContext, useEffect, useRef, useState } from 'react' import './style/remix-app.css' import { RemixUIMainPanel } from '@remix-ui/panel' import MatomoDialog from './components/modals/matomo' @@ -8,6 +8,7 @@ import { AppProvider } from './context/provider' import AppDialogs from './components/modals/dialogs' import DialogViewPlugin from './components/modals/dialogViewPlugin' import { AppContext } from './context/context' +import { RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel' interface IRemixAppUi { app: any @@ -17,31 +18,10 @@ const RemixApp = (props: IRemixAppUi) => { const [appReady, setAppReady] = useState(false) const [hideSidePanel, setHideSidePanel] = useState(false) const sidePanelRef = useRef(null) - const mainPanelRef = useRef(null) const iconPanelRef = useRef(null) const hiddenPanelRef = useRef(null) useEffect(() => { - if (sidePanelRef.current) { - if (props.app.sidePanel) { - sidePanelRef.current.appendChild(props.app.sidePanel.render()) - } - } - if (mainPanelRef.current) { - if (props.app.mainview) { - mainPanelRef.current.appendChild(props.app.mainview.render()) - } - } - if (iconPanelRef.current) { - if (props.app.menuicons) { - iconPanelRef.current.appendChild(props.app.menuicons.render()) - } - } - if (hiddenPanelRef.current) { - if (props.app.hiddenPanel) { - hiddenPanelRef.current.appendChild(props.app.hiddenPanel.render()) - } - } async function activateApp () { props.app.themeModule.initTheme(() => { setAppReady(true) @@ -54,6 +34,11 @@ const RemixApp = (props: IRemixAppUi) => { } }, []) + + useEffect(() => { + console.log(props.app.menuicons) + }, [props.app.menuicons]) + function setListeners () { props.app.sidePanel.events.on('toggle', () => { setHideSidePanel(prev => { @@ -73,9 +58,6 @@ const RemixApp = (props: IRemixAppUi) => { } const components = { - iconPanel:
, - sidePanel:
, - mainPanel:
, hiddenPanel:
} @@ -93,18 +75,46 @@ const RemixApp = (props: IRemixAppUi) => {
- {components.iconPanel} - {components.sidePanel} +
+
- {components.hiddenPanel} +
) } +interface IViewPluginUI { + plugin: any +} + +export const ViewPluginUI = (props: IViewPluginUI) => { + + const [state, setState] = useState(null) + + useEffect(() => { + console.log(props.plugin) + if(props.plugin.setDispatch){ + props.plugin.setDispatch(setState) + } + }, []) + + useEffect(() => { + console.log(state) + }, [state]) + + return ( + <>{state? + props.plugin.render(state) + :<> + } + ) +} + + export default RemixApp