fix_using_abstract_panel

AbstractPanel
yann300 3 years ago
parent 97c0603a4a
commit 68cb1f8bff
  1. 18
      apps/remix-ide/src/app/components/hidden-panel.js
  2. 12
      apps/remix-ide/src/app/components/main-panel.js
  3. 21
      apps/remix-ide/src/app/components/panel.js
  4. 5
      apps/remix-ide/src/app/components/side-panel.js
  5. 12
      libs/remix-ui/abstract-panel/.babelrc
  6. 18
      libs/remix-ui/abstract-panel/.eslintrc.json
  7. 7
      libs/remix-ui/abstract-panel/README.md
  8. 4
      libs/remix-ui/abstract-panel/package.json
  9. 1
      libs/remix-ui/abstract-panel/src/index.ts
  10. 16
      libs/remix-ui/abstract-panel/src/lib/abstract-panel-hoc.tsx
  11. 16
      libs/remix-ui/abstract-panel/src/lib/remix-ui-abstract-panel.module.css
  12. 22
      libs/remix-ui/abstract-panel/src/lib/remix-ui-abstract-panel.tsx
  13. 20
      libs/remix-ui/abstract-panel/tsconfig.json
  14. 13
      libs/remix-ui/abstract-panel/tsconfig.lib.json
  15. 110
      libs/remix-ui/main-panel/src/lib/remix-ui-main-panel.tsx
  16. 4
      libs/remix-ui/side-panel/src/lib/remix-ui-side-panel.tsx
  17. 3
      nx.json
  18. 1
      tsconfig.base.json
  19. 18
      workspace.json

@ -1,7 +1,7 @@
import React from 'react' // eslint-disable-line
import { AbstractPanel } from './panel'
import * as packageJson from '../../../../../package.json'
const csjs = require('csjs-inject')
const yo = require('yo-yo')
const css = csjs`
.pluginsContainer {
@ -20,12 +20,20 @@ const profile = {
export class HiddenPanel extends AbstractPanel {
constructor () {
super(profile)
this.container = document.createElement('div')
}
render () {
return yo`
<div class=${css.pluginsContainer}>
${this.view}
</div>`
return this.container
}
renderComponent () {
return ReactDOM.render(
<div class={css.pluginsContainer}>
{this.element}
</div>
,
this.container
)
}
}

@ -21,6 +21,10 @@ export class MainPanel extends AbstractPanel {
this.config = config
}
onActivation () {
this.renderComponent()
}
focus (name) {
this.emit('focusChanged', name)
super.focus(name)
@ -30,6 +34,12 @@ export class MainPanel extends AbstractPanel {
addView (profile, view) {
super.addView(profile, view)
view.style.height = '100%'
this.renderComponent()
}
removeView (profile) {
super.removeView(profile)
this.renderComponent()
}
onActivation () {
@ -43,7 +53,7 @@ export class MainPanel extends AbstractPanel {
renderComponent () {
ReactDOM.render(
<RemixUiMainPanel
plugin={this}
plugin={this} contents={this.contents}
/>,
this.mainelement
)

@ -1,6 +1,4 @@
import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom'
import { RemixUiAbstractPanel } from '@remix-ui/abstract-panel' // eslint-disable-line
import { EventEmitter } from 'events'
const EventManager = require('../../lib/events')
import { HostPlugin } from '@remixproject/engine-web' // eslint-disable-line
@ -13,11 +11,6 @@ export class AbstractPanel extends HostPlugin {
this.event = new EventManager()
this.contents = {}
this.active = undefined
this.element = document.createElement('div')
}
onActivation () {
this.renderComponent()
}
addView (profile, view) {
@ -32,8 +25,6 @@ export class AbstractPanel extends HostPlugin {
this.contents[profile.name] = view
this.contents[profile.name].style.display = 'none'
this.element.appendChild(this.contents[profile.name])
this.renderComponent()
}
removeView (profile) {
@ -49,9 +40,7 @@ export class AbstractPanel extends HostPlugin {
remove (name) {
const el = this.contents[name]
delete this.contents[name]
if (el) el.parentElement.removeChild(el)
if (name === this.active) this.active = undefined
this.renderComponent()
}
/**
@ -64,7 +53,6 @@ export class AbstractPanel extends HostPlugin {
if (this.active) {
this.contents[this.active].style.display = 'none'
}
console.log({ name, active: this.active, contents: this.contents })
this.contents[name].style.display = 'flex'
this.contents[name].style.paddingTop = '20%'
this.contents[name].style.flexDirection = 'column'
@ -75,13 +63,4 @@ export class AbstractPanel extends HostPlugin {
focus (name) {
this.showContent(name)
}
renderComponent () {
ReactDOM.render(
<RemixUiAbstractPanel
plugin={this}
/>,
this.element
)
}
}

@ -18,9 +18,7 @@ export class SidePanel extends AbstractPanel {
constructor (appManager, verticalIcons) {
super(sidePanel)
this.appManager = appManager
// this.sideelement = this.element
this.sideelement = document.createElement('div')
this.element = this.sideelement
this.verticalIcons = verticalIcons
// Toggle content
@ -60,6 +58,7 @@ export class SidePanel extends AbstractPanel {
super.removeView(profile)
this.emit('pluginDisabled', profile.name)
this.verticalIcons.unlinkContent(profile)
this.renderComponent()
}
addView (profile, view) {
@ -84,7 +83,7 @@ export class SidePanel extends AbstractPanel {
renderComponent () {
ReactDOM.render(
<RemixUiSidePanel
plugin={this}
plugin={this} contents={this.contents}
/>
,
this.sideelement

@ -1,12 +0,0 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}

@ -1,18 +0,0 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

@ -1,7 +0,0 @@
# remix-ui-abstract-panel
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test remix-ui-abstract-panel` to execute the unit tests via [Jest](https://jestjs.io).

@ -1,4 +0,0 @@
{
"name": "@remix-ui/abstract-panel",
"version": "0.0.1"
}

@ -1 +0,0 @@
export * from './lib/remix-ui-abstract-panel';

@ -1,16 +0,0 @@
import React from 'react'
function AbstractPanelHOC (WrappedComponent: any) {
return (WrappedComponent: any) => {
const WithAbstractPanel = (props: any) => {
return (
<WrappedComponent
{...props}
/>
)
}
return WithAbstractPanel;
}
}
export default AbstractPanelHOC

@ -1,16 +0,0 @@
.plugins {
height: 100%;
}
.plugItIn {
display : none;
height : 100%;
}
.plugItIn > div {
overflow-y : auto;
overflow-x : hidden;
height : 100%;
width : 100%;
}
.plugItIn.active {
display : block;
}

@ -1,22 +0,0 @@
import React, { useEffect, useState } from 'react' // eslint-disable-line
import './remix-ui-abstract-panel.module.css';
import parse from 'html-react-parser'
/* eslint-disable-next-line */
export interface RemixUiAbstractPanelProps {
reactView: any,
plugin: any
}
export function RemixUiAbstractPanel(props: RemixUiAbstractPanelProps) {
const [loading, setLoading] = useState(false);
return (
<div id="plugins">
</div>
)
}
export default RemixUiAbstractPanel;

@ -1,20 +0,0 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

@ -1,13 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": ["node"]
},
"files": [
"../../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../../node_modules/@nrwl/react/typings/image.d.ts"
],
"exclude": ["**/*.spec.ts", "**/*.spec.tsx"],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}

@ -1,117 +1,17 @@
import React, { useEffect, useState } from 'react' // eslint-disable-line
import React, { useEffect, useState, useRef } from 'react' // eslint-disable-line
import './remix-ui-main-panel.module.css';
/* eslint-disable-next-line */
export interface RemixUiMainPanelProps {
plugin: any
contents: [any]
}
export const RemixUiMainPanel = (props: RemixUiMainPanelProps) => {
const [invertNumber, setInvertNumber] = useState(0)
const handlePluginCall = (pluginName: string) => {
props.plugin.call('menuicons', 'select', pluginName)
props.plugin.call(pluginName, pluginName, '')
}
const dom = useRef(null)
return (
<div data-id="landingPageHomeContainer" className="homeContainer d-flex" style={{ height: "100%", width: "100%", border: "0px", display: "block" }}>
<div className="mainContent_2A2Ew bg-light">
<div className="d-flex justify-content-between">
<div className="d-flex flex-column">
<div className="border-bottom d-flex justify-content-between clearfix py-3 mb-4">
<div className="mx-4 w-100 d-flex">
<img src="assets/img/guitarRemiCroped.webp" className="m-4 logoImg_2A2Ew" style={{ filter: `invert(${invertNumber})`}}/>
<audio id="remiAudio" src="assets/audio/remiGuitar-single-power-chord-A-minor.wav"></audio>
<div className="w-80 pl-5 ml-5">
<h5 className="mb-1">Quicklinks</h5>
<a target="__blank" href="https://medium.com/remix-ide/migrating-files-to-workspaces-8e34737c751c?source=friends_link&amp;sk=b75cfd9093aa23c78be13cce49e4a5e8" className="text_2A2Ew mr-1">Guide</a>for migrating the old File System
<p className="font-weight-bold mb-0 py-1">Migration tools:</p>
<li className="pl-1">
<span className="pl-0"><u className="text_2A2Ew pr-1">Basic migration</u></span>
</li>
<li className="pl-1"><u className="text_2A2Ew pr-1">Download all Files</u> as a backup zip</li>
<li className="pl-1"><u className="text_2A2Ew pr-1">Restore files</u>from backup zip</li>
<p className="font-weight-bold mb-0 mt-2">Help:</p>
<div className="d-flex flex-column mt-1 pl-0"><a target="__blank" href="https://gitter.im/ethereum/remix" className="text_2A2Ew mx-1">Gitter channel</a> <a target="__blank" href="https://github.com/ethereum/remix-project/issues" className="text_2A2Ew mx-1">Report on Github</a></div>
</div>
</div>
</div>
<div data-id="landingPageHpSections" className="row hpSections_2A2Ew mx-4">
<div className="ml-3">
<div className="plugins mb-5">
<h4>Featured Plugins</h4>
<div className="d-flex flex-row pt-2">
<button data-id="landingPageStartSolidity" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center envButton_2A2Ew" onClick = {() => handlePluginCall('solidity') }>
<img src="assets/img/solidityLogo.webp" className="m-2 align-self-center envLogo_2A2Ew text-dark" alt='Solidity' style={{ filter: `invert(${invertNumber})` }}/>
<label className="text-uppercase text-dark cursorStyle_2A2Ew">Solidity</label>
</button>
<button data-id="landingPageStartSolidity" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center envButton_2A2Ew" onClick={() => handlePluginCall('optimism-compiler') }>
<img id="optimismLogo" src="assets/img/optimismLogo.webp" className="m-2 align-self-center envLogo_2A2Ew" style={{ filter: `invert(${invertNumber})` }}/>
<label className="text-uppercase text-dark cursorStyle_2A2Ew">Optimism</label>
</button>
<button data-id="landingPageStartSolidity" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center envButton_2A2Ew" onClick={() => handlePluginCall('LearnEth') }>
<img id="learnEthLogo" src="assets/img/learnEthLogo.webp" className="m-2 align-self-center envLogo_2A2Ew" style={{ filter: `invert(${invertNumber})` }}/>
<label className="text-uppercase text-dark cursorStyle_2A2Ew">LearnEth</label>
</button>
<button data-id="landingPageStartSolidity" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center envButton_2A2Ew" onClick={() => handlePluginCall('solhint') }>
<img id="solhintLogo" src="assets/img/solhintLogo.png" className="m-2 align-self-center envLogo_2A2Ew" style={{ filter: `invert(${invertNumber})` }}/>
<label className="text-uppercase text-dark cursorStyle_2A2Ew">Solhint linter</label>
</button><button data-id="landingPageStartSolidity" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center envButton_2A2Ew" onClick={() => handlePluginCall('source-verification') }>
<img id="sourcifyLogo" src="assets/img/sourcifyLogo.webp" className="m-2 align-self-center envLogo_2A2Ew" style={{ filter: `invert(${invertNumber})` }}/>
<label className="text-uppercase text-dark cursorStyle_2A2Ew">Sourcify</label>
</button>
<button data-id="landingPageStartSolidity" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center envButton_2A2Ew" onClick={() => handlePluginCall('pluginManager') }>
<img id="moreLogo" src="assets/img/moreLogo.webp" className="m-2 align-self-center envLogo_2A2Ew" style={{ filter: `invert(${invertNumber})` }}/>
<label className="text-uppercase text-dark cursorStyle_2A2Ew">More</label>
</button>
</div>
</div>
<div className="d-flex">
<div className="file">
<h4>File</h4>
<p className="mb-1"><i className="mr-1 far fa-file"></i> <span className="ml-1 mb-1 text_2A2Ew">New File</span></p>
<p className="mb-1"><i className="mr-1 far fa-file-alt"></i> <label className="ml-1 labelIt_2A2Ew bigLabelSize_2A2Ew text_2A2Ew">Open Files <input title="open file" type="file" multiple /></label></p>
<p className="mb-1"><i className="far fa-hdd"></i> <span className="ml-1 text_2A2Ew">Connect to Localhost</span></p>
<p className="mt-3 mb-0"><label>LOAD FROM:</label></p>
<div className="btn-group"><button data-id="landingPageImportFromGistButton" className="btn mr-1 btn-secondary">Gist</button><button className="btn mx-1 btn-secondary">GitHub</button><button className="btn mx-1 btn-secondary">Ipfs</button><button className="btn mx-1 btn-secondary">https</button></div>
{/* <!-- end of btn-group --> */}
</div>
{/* <!-- end of div.file --> */}
<div className="ml-4 pl-4">
<h4>Resources</h4>
<p className="mb-1"><i className="mr-1 fas fa-book"></i> <a target="__blank" href="https://remix-ide.readthedocs.io/en/latest/#" className="text_2A2Ew">Documentation</a></p>
<p className="mb-1"><i className="mr-1 fab fa-gitter"></i> <a target="__blank" href="https://gitter.im/ethereum/remix" className="text_2A2Ew">Gitter channel</a></p>
<p className="mb-1"><img id="remixHhomeWebsite" src="assets/img/remixLogo.webp" className="mr-1 image_2A2Ew" style={{ filter: `invert(${invertNumber})` }}/><a target="__blank" href="https://remix-project.org" className="text_2A2Ew">Featuring website</a></p>
<p className="mb-1"><i className="fab fa-ethereum image_2A2Ew"></i> <span className="text_2A2Ew">Old experience</span></p>
</div>
</div>
</div>
</div>
{/* <!-- end of hpSections --> */}
</div>
<div className="d-flex flex-column rightPanel_2A2Ew">
<div id="remixIDEMediaPanelsTitle" className="d-flex pr-3 py-2 align-self-end"><button id="remixIDEHomeTwitterbtn" className="btn-info p-2 m-1 border rounded-circle mediaBadge_2A2Ew fab fa-twitter"></button><button id="remixIDEHomeMediumbtn" className="btn-danger p-2 m-1 border rounded-circle mediaBadge_2A2Ew fab fa-medium"></button></div>
<div id="remixIDEMediaPanels" className="mr-3 d-flex bg-light panels_2A2Ew">
<div id="remixIDE_MediumBlock" className="p-2 mx-0 mb-0 d-none remixHomeMedia_2A2Ew" style={{ maxHeight: "514px" }}>
<div id="medium-widget" className="p-3 media_2A2Ew">
<div id="retainable-rss-embed" data-rss="https://medium.com/feed/remix-ide" data-maxcols="1" data-layout="grid" data-poststyle="external" data-readmore="More..." data-buttonclassName="btn mb-3" data-offset="-100"> -</div>
</div>
</div>
<div id="remixIDE_TwitterBlock" className="p-2 mx-0 mb-0 d-none remixHomeMedia_2A2Ew" style={{ maxHeight: "514px" }}>
<div className="px-2 media_2A2Ew">
<a data-width="350" data-theme="dark" data-chrome="nofooter noheader transparent" data-tweet-limit="8" href="https://twitter.com/EthereumRemix" className="twitter-timeline"></a>
{/* <script async="async" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> */}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div className="pluginsContainer" data-id="mainPanelPluginsContainer" id='mainPanelPluginsContainer-id' ref={dom} >
</div>
)
}

@ -5,6 +5,7 @@ import './remix-ui-side-panel.module.css';
/* eslint-disable-next-line */
export interface RemixUiSidePanelProps {
plugin: any
contents: any
}
export function RemixUiSidePanel(props: RemixUiSidePanelProps) {
@ -68,6 +69,9 @@ export function RemixUiSidePanel(props: RemixUiSidePanelProps) {
zIndex: "999",
}} >
{renderHeader()}
<div className="pluginsContainer">
{props.contents}
</div>
</section>
);
}

@ -142,9 +142,6 @@
"remix-ui-main-panel": {
"tags": []
},
"remix-ui-abstract-panel": {
"tags": []
},
"remix-ui-side-panel": {
"tags": []
}

@ -69,7 +69,6 @@
"@remix-ui/helper": ["libs/remix-ui/helper/src/index.ts"],
"@remix-ui/vertical-icons-panel": ["libs/remix-ui/vertical-icons-panel/src/index.ts"],
"@remix-ui/main-panel": ["libs/remix-ui/main-panel/src/index.ts"],
"@remix-ui/abstract-panel": ["libs/remix-ui/abstract-panel/src/index.ts"],
"@remix-ui/side-panel": ["libs/remix-ui/side-panel/src/index.ts"]
}
},

@ -1150,24 +1150,6 @@
}
}
},
"remix-ui-abstract-panel": {
"root": "libs/remix-ui/abstract-panel",
"sourceRoot": "libs/remix-ui/abstract-panel/src",
"projectType": "library",
"architect": {
"lint": {
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"tsConfig": ["libs/remix-ui/abstract-panel/tsconfig.lib.json"],
"exclude": [
"**/node_modules/**",
"!libs/remix-ui/abstract-panel/**/*"
]
}
}
}
},
"remix-ui-side-panel": {
"root": "libs/remix-ui/side-panel",
"sourceRoot": "libs/remix-ui/side-panel/src",

Loading…
Cancel
Save