From cecbb24cc39ed9e2ef62a93f489b270f33ce2167 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 11 Oct 2021 13:43:57 +0100 Subject: [PATCH] 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`