From 1e2dbea7cc10ebd6d8aedea988ccc4f7ad030b4f Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 11 Oct 2021 11:46:09 +0100 Subject: [PATCH 01/84] create vertical icons panel react lib --- .eslintrc.json | 35 +++++++ libs/remix-ui/vertical-icons-panel/.babelrc | 12 +++ .../vertical-icons-panel/.eslintrc.json | 18 ++++ libs/remix-ui/vertical-icons-panel/README.md | 7 ++ .../vertical-icons-panel/src/index.ts | 1 + .../remix-ui-vertical-icons-panel.module.css | 0 .../src/lib/remix-ui-vertical-icons-panel.tsx | 16 ++++ .../vertical-icons-panel/tsconfig.json | 20 ++++ .../vertical-icons-panel/tsconfig.lib.json | 13 +++ nx.json | 15 +-- package.json | 4 + tsconfig.base.json | 5 +- workspace.json | 93 ++++++++++++++++--- 13 files changed, 215 insertions(+), 24 deletions(-) create mode 100644 .eslintrc.json create mode 100644 libs/remix-ui/vertical-icons-panel/.babelrc create mode 100644 libs/remix-ui/vertical-icons-panel/.eslintrc.json create mode 100644 libs/remix-ui/vertical-icons-panel/README.md create mode 100644 libs/remix-ui/vertical-icons-panel/src/index.ts create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.module.css create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/tsconfig.json create mode 100644 libs/remix-ui/vertical-icons-panel/tsconfig.lib.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..06cc47d9a2 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,35 @@ +{ + "root": true, + "ignorePatterns": ["**/*"], + "plugins": ["@nrwl/nx"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": { + "@nrwl/nx/enforce-module-boundaries": [ + "error", + { + "enforceBuildableLibDependency": true, + "allow": [], + "depConstraints": [ + { + "sourceTag": "*", + "onlyDependOnLibsWithTags": ["*"] + } + ] + } + ] + } + }, + { + "files": ["*.ts", "*.tsx"], + "extends": ["plugin:@nrwl/nx/typescript"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "extends": ["plugin:@nrwl/nx/javascript"], + "rules": {} + } + ] +} diff --git a/libs/remix-ui/vertical-icons-panel/.babelrc b/libs/remix-ui/vertical-icons-panel/.babelrc new file mode 100644 index 0000000000..ccae900be4 --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nrwl/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/remix-ui/vertical-icons-panel/.eslintrc.json b/libs/remix-ui/vertical-icons-panel/.eslintrc.json new file mode 100644 index 0000000000..50e59482cf --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/remix-ui/vertical-icons-panel/README.md b/libs/remix-ui/vertical-icons-panel/README.md new file mode 100644 index 0000000000..3d01813d07 --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/README.md @@ -0,0 +1,7 @@ +# remix-ui-vertical-icons-panel + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test remix-ui-vertical-icons-panel` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/remix-ui/vertical-icons-panel/src/index.ts b/libs/remix-ui/vertical-icons-panel/src/index.ts new file mode 100644 index 0000000000..5024f5ff7a --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/src/index.ts @@ -0,0 +1 @@ +export * from './lib/remix-ui-vertical-icons-panel'; diff --git a/libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.module.css b/libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.module.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx b/libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx new file mode 100644 index 0000000000..e7980c0939 --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx @@ -0,0 +1,16 @@ +import './remix-ui-vertical-icons-panel.module.css'; + +/* eslint-disable-next-line */ +export interface RemixUiVerticalIconsPanelProps {} + +export function RemixUiVerticalIconsPanel( + props: RemixUiVerticalIconsPanelProps +) { + return ( +
+

Welcome to remix-ui-vertical-icons-panel!

+
+ ); +} + +export default RemixUiVerticalIconsPanel; diff --git a/libs/remix-ui/vertical-icons-panel/tsconfig.json b/libs/remix-ui/vertical-icons-panel/tsconfig.json new file mode 100644 index 0000000000..8bd701c578 --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/tsconfig.json @@ -0,0 +1,20 @@ +{ + "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" + } + ] +} diff --git a/libs/remix-ui/vertical-icons-panel/tsconfig.lib.json b/libs/remix-ui/vertical-icons-panel/tsconfig.lib.json new file mode 100644 index 0000000000..b560bc4dec --- /dev/null +++ b/libs/remix-ui/vertical-icons-panel/tsconfig.lib.json @@ -0,0 +1,13 @@ +{ + "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"] +} diff --git a/nx.json b/nx.json index 9f4c399b8e..aa46ad3fc7 100644 --- a/nx.json +++ b/nx.json @@ -1,5 +1,4 @@ { - "npmScope": "remix-project", "implicitDependencies": { "workspace.json": "*", "package.json": { @@ -11,6 +10,7 @@ ".eslintrc": "*", "nx.json": "*" }, + "npmScope": "remix-project", "tasksRunnerOptions": { "default": { "runner": "@nrwl/workspace/tasks-runners/default", @@ -130,19 +130,14 @@ "remix-ui-editor": { "tags": [] }, - "remix-ui-helper": { + "remix-ui-helper": { + "tags": [] + }, + "remix-ui-vertical-icons-panel": { "tags": [] }, "remix-ui-tabs": { "tags": [] } - }, - "targetDependencies": { - "build": [ - { - "target": "build", - "projects": "dependencies" - } - ] } } diff --git a/package.json b/package.json index 4cd3cb70db..5a6030a591 100644 --- a/package.json +++ b/package.json @@ -161,6 +161,7 @@ "chokidar": "^2.1.8", "color-support": "^1.1.3", "commander": "^2.20.3", + "core-js": "^3.6.5", "deep-equal": "^1.0.1", "document-register-element": "1.13.1", "ethereumjs-util": "^7.0.10", @@ -261,8 +262,11 @@ "eslint-config-prettier": "^6.11.0", "eslint-config-standard": "^14.1.1", "eslint-plugin-import": "2.20.2", + "eslint-plugin-jsx-a11y": "6.4.1", "eslint-plugin-node": "11.1.0", "eslint-plugin-promise": "4.2.1", + "eslint-plugin-react": "7.23.1", + "eslint-plugin-react-hooks": "4.2.0", "eslint-plugin-standard": "4.0.1", "events": "^3.0.0", "execr": "^1.0.1", diff --git a/tsconfig.base.json b/tsconfig.base.json index c0f4b6f093..c87af8611e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -66,7 +66,10 @@ "@remix-ui/plugin-manager": ["libs/remix-ui/plugin-manager/src/index.ts"], "@remix-ui/editor": ["libs/remix-ui/editor/src/index.ts"], "@remix-ui/tabs": ["libs/remix-ui/tabs/src/index.ts"], - "@remix-ui/helper": ["libs/remix-ui/helper/src/index.ts"] + "@remix-ui/helper": ["libs/remix-ui/helper/src/index.ts"], + "@remix-ui/vertical-icons-panel": [ + "libs/remix-ui/vertical-icons-panel/src/index.ts" + ] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index 217c170d9d..04972f329f 100644 --- a/workspace.json +++ b/workspace.json @@ -1,5 +1,71 @@ { "version": 1, + "cli": { + "defaultCollection": "@nrwl/react" + }, + "defaultProject": "remix-ide", + "schematics": { + "@nrwl/workspace": { + "library": { + "linter": "eslint" + } + }, + "@nrwl/cypress": { + "cypress-project": { + "linter": "eslint" + } + }, + "@nrwl/react": { + "application": { + "style": "css", + "linter": "eslint", + "babel": true + }, + "component": { + "style": "css" + }, + "library": { + "style": "css", + "linter": "eslint" + } + }, + "@nrwl/next": { + "application": { + "linter": "eslint" + } + }, + "@nrwl/web": { + "application": { + "linter": "eslint" + } + }, + "@nrwl/node": { + "application": { + "linter": "eslint" + }, + "library": { + "linter": "eslint" + } + }, + "@nrwl/nx-plugin": { + "plugin": { + "linter": "eslint" + } + }, + "@nrwl/nest": { + "application": { + "linter": "eslint" + } + }, + "@nrwl/express": { + "application": { + "linter": "eslint" + }, + "library": { + "linter": "eslint" + } + } + }, "projects": { "remix-ide": { "root": "apps/remix-ide", @@ -1106,19 +1172,20 @@ "linter": "eslint" } }, - "@nrwl/nest": { - "application": { - "linter": "eslint" - } - }, - "@nrwl/express": { - "application": { - "linter": "eslint" - }, - "library": { - "linter": "eslint" + "remix-ui-vertical-icons-panel": { + "root": "libs/remix-ui/vertical-icons-panel", + "sourceRoot": "libs/remix-ui/vertical-icons-panel/src", + "projectType": "library", + "architect": { + "lint": { + "builder": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [ + "libs/remix-ui/vertical-icons-panel/**/*.{ts,tsx,js,jsx}" + ] + } + } } } - }, - "defaultProject": "remix-ide" + } } From 851e0dd59d1aa7240adbdac2246aa441cbd4d985 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 11 Oct 2021 13:43:57 +0100 Subject: [PATCH 02/84] update components and setttings --- .../src/app/components/vertical-icons.js | 204 ++------- libs/remix-ui/vertical-icons-panel/.babelrc | 12 +- .../vertical-icons-panel/.eslintrc.json | 35 +- .../remix-ui/vertical-icons-panel/.prettierrc | 5 + .../src/lib/components/BasicLogo.tsx | 14 + .../src/lib/components/Home.tsx | 26 ++ .../src/lib/components/Icon.tsx | 114 +++++ .../src/lib/components/OtherIcons.tsx | 15 + .../src/lib/components/Settings.tsx | 15 + .../src/lib/remix-ui-vertical-icons-panel.css | 109 +++++ .../remix-ui-vertical-icons-panel.module.css | 0 .../src/lib/remix-ui-vertical-icons-panel.tsx | 422 +++++++++++++++++- .../src/lib/vertical-icons-context-menu.tsx | 113 +++++ .../vertical-icons-panel/tsconfig.json | 3 +- .../vertical-icons-panel/tsconfig.lib.json | 3 +- .../types/vertical-icons-panel.d.ts | 112 +++++ package-lock.json | 57 ++- 17 files changed, 1041 insertions(+), 218 deletions(-) create mode 100644 libs/remix-ui/vertical-icons-panel/.prettierrc create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/components/BasicLogo.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/components/Home.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/components/Icon.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/components/OtherIcons.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/components/Settings.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.css delete mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.module.css create mode 100644 libs/remix-ui/vertical-icons-panel/src/lib/vertical-icons-context-menu.tsx create mode 100644 libs/remix-ui/vertical-icons-panel/types/vertical-icons-panel.d.ts diff --git a/apps/remix-ide/src/app/components/vertical-icons.js b/apps/remix-ide/src/app/components/vertical-icons.js index 54b77f9720..8ecd2a50ac 100644 --- a/apps/remix-ide/src/app/components/vertical-icons.js +++ b/apps/remix-ide/src/app/components/vertical-icons.js @@ -1,13 +1,18 @@ import * as packageJson from '../../../../../package.json' +// eslint-disable-next-line no-unused-vars import { basicLogo } from '../ui/svgLogo' +import ReactDOM from 'react-dom' +import React from 'react' // eslint-disable-line +// eslint-disable-next-line no-unused-vars +import { RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel' var yo = require('yo-yo') var csjs = require('csjs-inject') var helper = require('../../lib/helper') const globalRegistry = require('../../global/registry') -const contextMenu = require('../ui/contextMenu') +// const contextMenu = require('../ui/contextMenu') const { Plugin } = require('@remixproject/engine') const EventEmitter = require('events') -let VERTICALMENU_HANDLE +// let VERTICALMENU_HANDLE const profile = { name: 'menuicons', @@ -23,23 +28,39 @@ export class VerticalIcons extends Plugin { super(profile) this.events = new EventEmitter() this.appManager = appManager + this.htmlElement = document.createElement('div') + this.htmlElement.setAttribute('id', 'icon-panel') this.icons = {} this.iconKind = {} this.iconStatus = {} + this.defaultProfile = profile + this.targetProfileForChange = {} + this.targetProfileForRemoval = {} + this.registry = globalRegistry + } + + renderComponent () { + ReactDOM.render( + , + this.htmlElement) + } - const themeModule = globalRegistry.get('themeModule').api - themeModule.events.on('themeChanged', (theme) => { - this.onThemeChanged(theme.quality) - }) + onActivation () { + this.renderComponent() } linkContent (profile) { if (!profile.icon) return - this.addIcon(profile) + if (!profile.kind) profile.kind = 'none' + this.targetProfileForChange[profile.name] = profile this.listenOnStatus(profile) + this.renderComponent() } unlinkContent (profile) { + this.targetProfileForRemoval = profile this.removeIcon(profile) } @@ -60,55 +81,6 @@ export class VerticalIcons extends Plugin { this.on(profile.name, 'statusChanged', this.iconStatus[profile.name]) } - /** - * Add an icon to the map - * @param {ModuleProfile} profile The profile of the module - */ - addIcon ({ kind, name, icon, displayName, tooltip, documentation }) { - let title = (tooltip || displayName || name) - title = title.replace(/^\w/, c => c.toUpperCase()) - this.icons[name] = yo` -
- ${name} -
` - this.iconKind[kind || 'none'].appendChild(this.icons[name]) - } - - /** - * resolve a classes list for @arg key - * @param {Object} key - * @param {Object} type - */ - resolveClasses (key, type) { - let classes = css.status - switch (key) { - case 'succeed': - classes += ' fas fa-check-circle text-' + type + ' ' + css.statusCheck - break - case 'edited': - classes += ' fas fa-sync text-' + type + ' ' + css.statusCheck - break - case 'loading': - classes += ' fas fa-spinner text-' + type + ' ' + css.statusCheck - break - case 'failed': - classes += ' fas fa-exclamation-triangle text-' + type + ' ' + css.statusCheck - break - default: { - classes += ' badge badge-pill badge-' + type - } - } - return classes - } - /** * Set a new status for the @arg name * @param {String} name @@ -137,7 +109,7 @@ export class VerticalIcons extends Plugin { const title = helper.checkSpecialChars(status.title) ? '' : status.title el.appendChild(yo`