diff --git a/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx b/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx index 75857ced56..7cc304f754 100644 --- a/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx +++ b/apps/remix-ide/src/app/plugins/solidity-umlgen.tsx @@ -24,32 +24,32 @@ const profile = { events: [], } -const themeCollection = [ - { themeName: 'HackerOwl', backgroundColor: '#011628', textColor: '#babbcc', - shapeColor: '#8694a1',fillColor: '#011C32'}, - { themeName: 'Cerulean', backgroundColor: '#ffffff', textColor: '#343a40', - shapeColor: '#343a40',fillColor: '#f8f9fa'}, - { themeName: 'Cyborg', backgroundColor: '#060606', textColor: '#adafae', - shapeColor: '#adafae', fillColor: '#222222'}, - { themeName: 'Dark', backgroundColor: '#222336', textColor: '#babbcc', - shapeColor: '#babbcc',fillColor: '#2a2c3f'}, - { themeName: 'Flatly', backgroundColor: '#ffffff', textColor: '#343a40', - shapeColor: '#7b8a8b',fillColor: '#ffffff'}, - { themeName: 'Black', backgroundColor: '#1a1a1a', textColor: '#babbcc', - shapeColor: '#b5b4bc',fillColor: '#1f2020'}, - { themeName: 'Light', backgroundColor: '#eef1f6', textColor: '#3b445e', - shapeColor: '#343a40',fillColor: '#ffffff'}, - { themeName: 'Midcentury', backgroundColor: '#DBE2E0', textColor: '#11556c', - shapeColor: '#343a40',fillColor: '#eeede9'}, - { themeName: 'Spacelab', backgroundColor: '#ffffff', textColor: '#343a40', - shapeColor: '#333333', fillColor: '#eeeeee'}, - { themeName: 'Candy', backgroundColor: '#d5efff', textColor: '#11556c', - shapeColor: '#343a40',fillColor: '#fbe7f8' }, - { themeName: 'Violet', backgroundColor: '#f1eef6', textColor: '#3b445e', - shapeColor: '#343a40',fillColor: '#f8fafe' }, - { themeName: 'Unicorn', backgroundColor: '#f1eef6', textColor: '#343a40', - shapeColor: '#343a40',fillColor: '#f8fafe' }, -] +// const themeCollection = [ +// { themeName: 'HackerOwl', backgroundColor: '#011628', textColor: '#babbcc', +// shapeColor: '#8694a1',fillColor: '#011C32'}, +// { themeName: 'Cerulean', backgroundColor: '#ffffff', textColor: '#343a40', +// shapeColor: '#343a40',fillColor: '#f8f9fa'}, +// { themeName: 'Cyborg', backgroundColor: '#060606', textColor: '#adafae', +// shapeColor: '#adafae', fillColor: '#222222'}, +// { themeName: 'Dark', backgroundColor: '#222336', textColor: '#babbcc', +// shapeColor: '#babbcc',fillColor: '#2a2c3f'}, +// { themeName: 'Flatly', backgroundColor: '#ffffff', textColor: '#343a40', +// shapeColor: '#7b8a8b',fillColor: '#ffffff'}, +// { themeName: 'Black', backgroundColor: '#1a1a1a', textColor: '#babbcc', +// shapeColor: '#b5b4bc',fillColor: '#1f2020'}, +// { themeName: 'Light', backgroundColor: '#eef1f6', textColor: '#3b445e', +// shapeColor: '#343a40',fillColor: '#ffffff'}, +// { themeName: 'Midcentury', backgroundColor: '#DBE2E0', textColor: '#11556c', +// shapeColor: '#343a40',fillColor: '#eeede9'}, +// { themeName: 'Spacelab', backgroundColor: '#ffffff', textColor: '#343a40', +// shapeColor: '#333333', fillColor: '#eeeeee'}, +// { themeName: 'Candy', backgroundColor: '#d5efff', textColor: '#11556c', +// shapeColor: '#343a40',fillColor: '#fbe7f8' }, +// { themeName: 'Violet', backgroundColor: '#f1eef6', textColor: '#3b445e', +// shapeColor: '#343a40',fillColor: '#f8fafe' }, +// { themeName: 'Unicorn', backgroundColor: '#f1eef6', textColor: '#343a40', +// shapeColor: '#343a40',fillColor: '#f8fafe' }, +// ] /** * add context menu which will offer download as pdf and download png. @@ -81,8 +81,8 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen { this.currentlySelectedTheme = '' this.themeName = '' - this.themeCollection = themeCollection - this.activeTheme = themeCollection.find(t => t.themeName === 'Dark') + + this.activeTheme = {} as ThemeSummary this.appManager = appManager this.element = document.createElement('div') this.element.setAttribute('id', 'sol-uml-gen') @@ -127,35 +127,15 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen { private handleThemeChange() { this.on('theme', 'themeChanged', async (theme) => { this.currentlySelectedTheme = theme.quality - const themeQuality: ThemeQualityType = await this.call('theme', 'currentTheme') - themeCollection.forEach((theme) => { - if (theme.themeName === themeQuality.name) { - this.themeDark = theme.backgroundColor - this.activeTheme = theme - const umlDot = convertUmlClasses2Dot(this.umlClasses, false, { backColor: this.activeTheme.backgroundColor, textColor: this.activeTheme.textColor, shapeColor: this.activeTheme.shapeColor, fillColor: this.activeTheme.fillColor }) - this.updatedSvg = vizRenderStringSync(umlDot) - this.renderComponent() - } - }) + this.activeTheme = theme + this.themeDark = theme.backgroundColor + const umlDot = convertUmlClasses2Dot(this.umlClasses, false, { backColor: this.activeTheme.backgroundColor, textColor: this.activeTheme.textColor, shapeColor: this.activeTheme.shapeColor, fillColor: this.activeTheme.fillColor }) + this.updatedSvg = vizRenderStringSync(umlDot) + this.renderComponent() await this.call('tabs', 'focus', 'solidityumlgen') }) } - async mangleSvgPayload(svgPayload: string) : Promise { - const parser = new DOMParser() - const themeQuality: ThemeQualityType = await this.call('theme', 'currentTheme') - const parsedDocument = parser.parseFromString(svgPayload, 'image/svg+xml') - const element = parsedDocument.getElementsByTagName('svg') - themeCollection.forEach((theme) => { - if (theme.themeName === themeQuality.name) { - parsedDocument.documentElement.setAttribute('style', `background-color: var(${this.getThemeCssVariables('--body-bg')})`) - element[0].setAttribute('fill', theme.backgroundColor) - } - }) - const stringifiedSvg = new XMLSerializer().serializeToString(parsedDocument) - return stringifiedSvg - } - onDeactivation(): void { this.off('solidity', 'compilationFinished') } diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index 6d3e248a93..4ff7c2b0d1 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -72,7 +72,9 @@ export class ThemeModule extends Plugin { * @return {{ name: string, quality: string, url: string }} - The active theme */ currentTheme () { - return this.themes[this.active] + const current = this.themes[this.active] + console.log({ current }) + return current } /** Returns all themes as an array */ diff --git a/libs/remix-ui/solidity-uml-gen/src/types/index.ts b/libs/remix-ui/solidity-uml-gen/src/types/index.ts index 210b9c6066..4359302642 100644 --- a/libs/remix-ui/solidity-uml-gen/src/types/index.ts +++ b/libs/remix-ui/solidity-uml-gen/src/types/index.ts @@ -16,7 +16,6 @@ export interface ISolidityUmlGen extends ViewPlugin { showUmlDiagram(path: string, svgPayload: string): void updateComponent(state: any): JSX.Element setDispatch(dispatch: React.Dispatch): void - mangleSvgPayload(svgPayload: string) : Promise generateCustomAction(action: customAction): Promise flattenContract (source: any, filePath: string, data: any): Promise hideSpinner(): void @@ -27,5 +26,5 @@ export interface ISolidityUmlGen extends ViewPlugin { export type ThemeQualityType = { name: string, quality: 'light' | 'dark', url: string } -export type ThemeSummary = { themeName: string, backgroundColor: string, textColor?: string, -shapeColor?: string, fillColor?: string } \ No newline at end of file +export type ThemeSummary = { name: string, quality: 'light' | 'dark', url: string, backgroundColor: string, textColor?: string, +shapeColor?: string, fillColor?: string }