From 6a864e2c7c7f5e17f99e64b3fe442404d88860db Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 28 Oct 2022 11:46:13 +0100 Subject: [PATCH] add custom tooltip to solidity-compiler --- .../src/lib/components/custom-tooltip.tsx | 2 +- .../helper/src/types/customtooltip.ts | 2 +- .../search/src/lib/components/Find.tsx | 2 +- .../src/lib/compiler-container.tsx | 121 +++++++++--------- .../src/lib/contract-selection.tsx | 47 +++---- 5 files changed, 76 insertions(+), 98 deletions(-) diff --git a/libs/remix-ui/helper/src/lib/components/custom-tooltip.tsx b/libs/remix-ui/helper/src/lib/components/custom-tooltip.tsx index 515944c4d2..302dfb1a95 100644 --- a/libs/remix-ui/helper/src/lib/components/custom-tooltip.tsx +++ b/libs/remix-ui/helper/src/lib/components/custom-tooltip.tsx @@ -12,7 +12,7 @@ export function CustomTooltip({ children, placement, tooltipId, tooltipClasses, placement={placement} overlay={ - {tooltipText} + {typeof tooltipText === 'string' ? ({tooltipText}) : (tooltipText)} } > diff --git a/libs/remix-ui/helper/src/types/customtooltip.ts b/libs/remix-ui/helper/src/types/customtooltip.ts index 1b71376bfb..05178ebe08 100644 --- a/libs/remix-ui/helper/src/types/customtooltip.ts +++ b/libs/remix-ui/helper/src/types/customtooltip.ts @@ -6,6 +6,6 @@ export type CustomTooltipType = { placement?: Placement, tooltipId?: string, tooltipClasses?:string, - tooltipText: string, + tooltipText: string | JSX.Element, tooltipTextClasses?: string } \ No newline at end of file diff --git a/libs/remix-ui/search/src/lib/components/Find.tsx b/libs/remix-ui/search/src/lib/components/Find.tsx index 529cb7667d..dd39d0a1c6 100644 --- a/libs/remix-ui/search/src/lib/components/Find.tsx +++ b/libs/remix-ui/search/src/lib/components/Find.tsx @@ -1,5 +1,5 @@ import { CustomTooltip } from '@remix-ui/helper' -import React, { useContext, useEffect, useRef, useState } from 'react' +import React, { useContext, useEffect, useState } from 'react' import { SearchContext } from '../context/context' export const Find = () => { diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 1ea42d038a..7fcccfb4ad 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -2,11 +2,10 @@ import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint import semver from 'semver' import { CompilerContainerProps } from './types' import { ConfigurationSettings } from '@remix-project/remix-lib-ts' -import { checkSpecialChars, extractNameFromKey } from '@remix-ui/helper' +import { checkSpecialChars, CustomTooltip, extractNameFromKey } from '@remix-ui/helper' import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity' import { compilerReducer, compilerInitialState } from './reducers/compiler' import { resetEditorMode, listenToEvents } from './actions/compiler' -import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line import { getValidLanguage } from '@remix-project/remix-solidity' import { CopyToClipboard } from '@remix-ui/clipboard' import { configFileContent } from './compilerConfiguration' @@ -725,26 +724,22 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
- - {"Add a custom compiler with URL"} - - } + tooltipId="promptCompilerTooltip" + tooltipClasses="text-nowrap" + tooltipText={"Add a custom compiler with URL"} > promptCompiler()}> - - + - {"See compiler license"} - - } + tooltipId="showCompilerTooltip" + tooltipClasses="text-nowrap" + tooltipText={"See compiler license"} > showCompilerLicense()}> - + - - Learn how to use Hardhat Compilation - - }> + Learn how to use Hardhat Compilation} + > - +
} @@ -791,13 +787,14 @@ export const CompilerContainer = (props: CompilerContainerProps) => { - - Learn how to use Truffle Compilation - - }> + Learn how to use Truffle Compilation} + > - +
} @@ -820,19 +817,17 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
- - {'Language specification available from Compiler >= v0.5.7'} - - } + tooltipId="compilerLabelTooltip" + tooltipClasses="text-nowrap" + tooltipText={{'Language specification available from Compiler >= v0.5.7'}} > - +
@@ -863,21 +858,19 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
- {(!showFilePathInput && state.useFileConfiguration) && - + tooltipId="configfileTooltip" + tooltipClasses="text-nowrap" + tooltipText={ Click to open the config file - - - } + } > { } : async () => { await openFile() }} className="py-2 remixui_compilerConfigPath" >{configFilePath === '' ? 'No file selected.' : configFilePath} - } + } {(!showFilePathInput && !state.useFileConfiguration) && {configFilePath}} {
} + > {} Compile {typeof state.compiledFileName === 'string' ? extractNameFromKey(state.compiledFileName) || '' : ''} - +
} + > Compile and Run script - + - -
+
Choose the script to execute right after compilation by adding the `dev-run-script` natspec tag, as in:
                     
@@ -947,11 +941,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
                     
                   
Click to know more -
- - }> +
} + > - + '@custom:dev-run-script file_path'} direction='top'> {/* Copy to Clipboard */}