move types. Finish setting zoom buttons

pull/3363/head
Joseph Izang 2 years ago committed by Aniket
parent 18ec9a60c2
commit df77003525
  1. 7
      apps/remix-ide/src/app/plugins/solidity-umlgen.tsx
  2. 43
      libs/remix-ui/solidity-uml-gen/src/lib/solidity-uml-gen.tsx
  3. 16
      libs/remix-ui/solidity-uml-gen/src/types/index.ts

@ -3,7 +3,7 @@ import { ViewPlugin } from '@remixproject/engine-web'
import React from 'react' import React from 'react'
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries // eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { RemixUiSolidityUmlGen } from '@remix-ui/solidity-uml-gen' import { RemixUiSolidityUmlGen } from '@remix-ui/solidity-uml-gen'
import { ISolidityUmlGen } from 'libs/remix-ui/solidity-uml-gen/src/types' import { ISolidityUmlGen, ThemeQualityType, ThemeSummary } from 'libs/remix-ui/solidity-uml-gen/src/types'
import { RemixAppManager } from 'libs/remix-ui/plugin-manager/src/types' import { RemixAppManager } from 'libs/remix-ui/plugin-manager/src/types'
import { concatSourceFiles, getDependencyGraph } from 'libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities' import { concatSourceFiles, getDependencyGraph } from 'libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities'
import { convertUmlClasses2Dot } from 'sol2uml/lib/converterClasses2Dot' import { convertUmlClasses2Dot } from 'sol2uml/lib/converterClasses2Dot'
@ -35,10 +35,6 @@ const themeCollection = [
{ themeName: 'Candy', backgroundColor: '--body-bg', actualHex: '#d5efff'}, { themeName: 'Candy', backgroundColor: '--body-bg', actualHex: '#d5efff'},
] ]
type ThemeQualityType = { name: string, quality: 'light' | 'dark', url: string }
type ThemeSummary = { themeName: string, backgroundColor: string, actualHex: string }
/** /**
* add context menu which will offer download as pdf and download png. * add context menu which will offer download as pdf and download png.
* add menu under the first download button to download * add menu under the first download button to download
@ -189,6 +185,7 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
loading={state.loading} loading={state.loading}
themeSelected={state.currentlySelectedTheme} themeSelected={state.currentlySelectedTheme}
themeName={state.themeName} themeName={state.themeName}
themeCollection={state.themeCollection}
/> />
} }
} }

@ -1,7 +1,7 @@
import { CustomTooltip } from '@remix-ui/helper' import { CustomTooltip } from '@remix-ui/helper'
import React, { Fragment, useEffect, useRef, useState } from 'react' import React, { Fragment, useEffect, useRef, useState } from 'react'
import { TransformComponent, TransformWrapper } from 'react-zoom-pan-pinch' import { TransformComponent, TransformWrapper } from 'react-zoom-pan-pinch'
import { ISolidityUmlGen } from '../types' import { ISolidityUmlGen, ThemeSummary } from '../types'
import './css/solidity-uml-gen.css' import './css/solidity-uml-gen.css'
export interface RemixUiSolidityUmlGenProps { export interface RemixUiSolidityUmlGenProps {
plugin?: ISolidityUmlGen plugin?: ISolidityUmlGen
@ -9,6 +9,7 @@ export interface RemixUiSolidityUmlGenProps {
loading?: boolean loading?: boolean
themeSelected?: string themeSelected?: string
themeName: string themeName: string
themeCollection: ThemeSummary[]
} }
type ButtonAction = { type ButtonAction = {
@ -23,29 +24,8 @@ interface ActionButtonsProps {
buttons: ButtonAction[] buttons: ButtonAction[]
} }
const ActionButtons = ({ buttons }: ActionButtonsProps) => (
<>
{buttons.map(btn => (
<CustomTooltip
key={btn.buttonText}
placement="top"
tooltipText={btn.buttonText}
tooltipId={btn.buttonText}
>
<button
key={btn.buttonText}
className={`btn btn-primary btn-sm rounded-circle ${btn.customcss}`}
disabled={!btn.svgValid}
onClick={btn.action}
>
<i className={`${btn.icon}`}></i>
</button>
</CustomTooltip>
))}
</>
)
export function RemixUiSolidityUmlGen ({ plugin, updatedSvg, loading, themeSelected, themeName }: RemixUiSolidityUmlGenProps) { export function RemixUiSolidityUmlGen ({ updatedSvg, loading }: RemixUiSolidityUmlGenProps) {
const [showViewer, setShowViewer] = useState(false) const [showViewer, setShowViewer] = useState(false)
const [svgPayload, setSVGPayload] = useState<string>('') const [svgPayload, setSVGPayload] = useState<string>('')
const [validSvg, setValidSvg] = useState(false) const [validSvg, setValidSvg] = useState(false)
@ -56,20 +36,6 @@ export function RemixUiSolidityUmlGen ({ plugin, updatedSvg, loading, themeSelec
} }
, [updatedSvg]) , [updatedSvg])
const buttons: ButtonAction[] = [
{
buttonText: 'Download as PDF',
svgValid: () => validSvg,
action: () => console.log('generated!!'),
icon: 'fa fa-file'
},
{
buttonText: 'Download as PNG',
svgValid: () => validSvg,
action: () => console.log('generated!!!'),
icon: 'fa fa-picture-o'
}
]
const encoder = new TextEncoder() const encoder = new TextEncoder()
const data = encoder.encode(updatedSvg) const data = encoder.encode(updatedSvg)
@ -83,7 +49,6 @@ export function RemixUiSolidityUmlGen ({ plugin, updatedSvg, loading, themeSelec
</div> </div>
) )
const Display = () => { const Display = () => {
const invert = themeSelected === 'dark' ? 'invert(0.9)' : 'invert(0)'
return ( return (
<div id="umlImageHolder" className="w-100 px-2 py-2 d-flex"> <div id="umlImageHolder" className="w-100 px-2 py-2 d-flex">
{ validSvg && showViewer ? ( { validSvg && showViewer ? (
@ -96,7 +61,7 @@ export function RemixUiSolidityUmlGen ({ plugin, updatedSvg, loading, themeSelec
<div className="position-absolute bg-transparent rounded p-2" id="buttons" <div className="position-absolute bg-transparent rounded p-2" id="buttons"
style={{ zIndex: 3, top: '10', right: '2em' }} style={{ zIndex: 3, top: '10', right: '2em' }}
> >
<button className="btn btn-outline-info btn-sm rounded-circle mr-1" onClick={() => resetTransform()}> <button className="btn btn-outline-info d-none btn-sm rounded-circle mr-1" onClick={() => resetTransform()}>
<i className="far fa-arrow-to-bottom"></i> <i className="far fa-arrow-to-bottom"></i>
</button> </button>
<button className="btn btn-outline-info btn-sm rounded-circle mr-1" onClick={() => zoomIn()}> <button className="btn btn-outline-info btn-sm rounded-circle mr-1" onClick={() => zoomIn()}>

@ -1,4 +1,5 @@
import { ViewPlugin } from '@remixproject/engine-web' import { ViewPlugin } from '@remixproject/engine-web'
import { customAction } from '@remixproject/plugin-api'
import React from 'react' import React from 'react'
export interface ISolidityUmlGen extends ViewPlugin { export interface ISolidityUmlGen extends ViewPlugin {
@ -6,9 +7,22 @@ export interface ISolidityUmlGen extends ViewPlugin {
currentFile: string currentFile: string
svgPayload: string svgPayload: string
updatedSvg: string updatedSvg: string
currentlySelectedTheme: string
themeName: string
loading: boolean
themeCollection: ThemeSummary[]
showUmlDiagram(path: string, svgPayload: string): void showUmlDiagram(path: string, svgPayload: string): void
updateComponent(state: any): JSX.Element updateComponent(state: any): JSX.Element
setDispatch(dispatch: React.Dispatch<any>): void setDispatch(dispatch: React.Dispatch<any>): void
mangleSvgPayload(svgPayload: string) : Promise<string>
generateCustomAction(action: customAction): Promise<void>
flattenContract (source: any, filePath: string, data: any): Promise<string>
hideSpinner(): void
renderComponent (): void
render(): JSX.Element render(): JSX.Element
} }
export type ThemeQualityType = { name: string, quality: 'light' | 'dark', url: string }
export type ThemeSummary = { themeName: string, backgroundColor: string, actualHex: string }
Loading…
Cancel
Save