Commit 1864622d authored by tom's avatar tom

editor for one file and color fixes

parent 6d8e1324
...@@ -4,6 +4,7 @@ import React from 'react'; ...@@ -4,6 +4,7 @@ import React from 'react';
import type { SmartContract } from 'types/api/contract'; import type { SmartContract } from 'types/api/contract';
import CopyToClipboard from 'ui/shared/CopyToClipboard';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import CodeEditor from 'ui/shared/monaco/CodeEditor'; import CodeEditor from 'ui/shared/monaco/CodeEditor';
import formatFilePath from 'ui/shared/monaco/utils/formatFilePath'; import formatFilePath from 'ui/shared/monaco/utils/formatFilePath';
...@@ -44,11 +45,16 @@ const ContractSourceCode = ({ data, hasSol2Yml, address, isViper, filePath, addi ...@@ -44,11 +45,16 @@ const ContractSourceCode = ({ data, hasSol2Yml, address, isViper, filePath, addi
...(additionalSource || []).map((source) => ({ ...source, file_path: formatFilePath(source.file_path) })) ]; ...(additionalSource || []).map((source) => ({ ...source, file_path: formatFilePath(source.file_path) })) ];
}, [ additionalSource, data, filePath, isViper ]); }, [ additionalSource, data, filePath, isViper ]);
const copyToClipboard = editorData.length === 1 ?
<CopyToClipboard text={ editorData[0].source_code }/> :
null;
return ( return (
<section> <section>
<Flex justifyContent="space-between" alignItems="center" mb={ 3 }> <Flex justifyContent="space-between" alignItems="center" mb={ 3 }>
{ heading } { heading }
{ diagramLink } { diagramLink }
{ copyToClipboard }
</Flex> </Flex>
<CodeEditor data={ editorData }/> <CodeEditor data={ editorData }/>
</section> </section>
......
...@@ -88,6 +88,20 @@ const CodeEditor = ({ data }: Props) => { ...@@ -88,6 +88,20 @@ const CodeEditor = ({ data }: Props) => {
}); });
}, [ data, index ]); }, [ data, index ]);
if (data.length === 1) {
return (
<Box overflow="hidden" borderRadius="md" height="540px">
<MonacoEditor
language="sol"
path={ data[index].file_path }
defaultValue={ data[index].source_code }
options={ EDITOR_OPTIONS }
onMount={ handleEditorDidMount }
/>
</Box>
);
}
return ( return (
<Flex overflow="hidden" borderRadius="md" height="540px" position="relative"> <Flex overflow="hidden" borderRadius="md" height="540px" position="relative">
<Box flexGrow={ 1 }> <Box flexGrow={ 1 }>
......
...@@ -152,26 +152,26 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) = ...@@ -152,26 +152,26 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) =
{ ...buttonProps } { ...buttonProps }
className="codicon codicon-case-sensitive" className="codicon codicon-case-sensitive"
onClick={ setMatchCase.toggle } onClick={ setMatchCase.toggle }
bgColor={ isMatchCase ? themeColors['inputOption.activeBackground'] : 'transparent' } bgColor={ isMatchCase ? themeColors['custom.inputOption.activeBackground'] : 'transparent' }
_hover={{ bgColor: isMatchCase ? themeColors['inputOption.activeBackground'] : themeColors['inputOption.hoverBackground'] }} _hover={{ bgColor: isMatchCase ? themeColors['custom.inputOption.activeBackground'] : themeColors['custom.inputOption.hoverBackground'] }}
title="Match Case" title="Match Case"
aria-label="Match Case" aria-label="Match Case"
/> />
<Box <Box
{ ...buttonProps } { ...buttonProps }
className="codicon codicon-whole-word" className="codicon codicon-whole-word"
bgColor={ isMatchWholeWord ? themeColors['inputOption.activeBackground'] : 'transparent' } bgColor={ isMatchWholeWord ? themeColors['custom.inputOption.activeBackground'] : 'transparent' }
onClick={ setMatchWholeWord.toggle } onClick={ setMatchWholeWord.toggle }
_hover={{ bgColor: isMatchWholeWord ? themeColors['inputOption.activeBackground'] : themeColors['inputOption.hoverBackground'] }} _hover={{ bgColor: isMatchWholeWord ? themeColors['custom.inputOption.activeBackground'] : themeColors['custom.inputOption.hoverBackground'] }}
title="Match Whole Word" title="Match Whole Word"
aria-label="Match Whole Word" aria-label="Match Whole Word"
/> />
<Box <Box
{ ...buttonProps } { ...buttonProps }
className="codicon codicon-regex" className="codicon codicon-regex"
bgColor={ isMatchRegex ? themeColors['inputOption.activeBackground'] : 'transparent' } bgColor={ isMatchRegex ? themeColors['custom.inputOption.activeBackground'] : 'transparent' }
onClick={ setMatchRegex.toggle } onClick={ setMatchRegex.toggle }
_hover={{ bgColor: isMatchRegex ? themeColors['inputOption.activeBackground'] : themeColors['inputOption.hoverBackground'] }} _hover={{ bgColor: isMatchRegex ? themeColors['custom.inputOption.activeBackground'] : themeColors['custom.inputOption.hoverBackground'] }}
title="Use Regular Expression" title="Use Regular Expression"
aria-label="Use Regular Expression" aria-label="Use Regular Expression"
/> />
......
...@@ -48,7 +48,7 @@ const CodeEditorSearchResultItem = ({ lineContent, filePath, onClick, startLineN ...@@ -48,7 +48,7 @@ const CodeEditorSearchResultItem = ({ lineContent, filePath, onClick, startLineN
_hover={{ bgColor: themeColors['list.hoverBackground'] }} _hover={{ bgColor: themeColors['list.hoverBackground'] }}
> >
<span>{ lineContent.slice(start, startColumn - 1) }</span> <span>{ lineContent.slice(start, startColumn - 1) }</span>
<chakra.span bgColor={ themeColors['editor.findMatchHighlightBackground'] }> <chakra.span bgColor={ themeColors['custom.findMatchHighlightBackground'] }>
{ lineContent.slice(startColumn - 1, endColumn - 1) } { lineContent.slice(startColumn - 1, endColumn - 1) }
</chakra.span> </chakra.span>
<span>{ lineContent.slice(endColumn - 1) }</span> <span>{ lineContent.slice(endColumn - 1) }</span>
......
...@@ -69,7 +69,7 @@ const CodeEditorTab = ({ isActive, path, onClick, onClose, isCloseDisabled, tabs ...@@ -69,7 +69,7 @@ const CodeEditorTab = ({ isActive, path, onClick, onClose, isCloseDisabled, tabs
opacity={ isCloseDisabled ? 0.3 : 1 } opacity={ isCloseDisabled ? 0.3 : 1 }
visibility={ isActive ? 'visible' : 'hidden' } visibility={ isActive ? 'visible' : 'hidden' }
color={ themeColors['icon.foreground'] } color={ themeColors['icon.foreground'] }
_hover={{ bgColor: isCloseDisabled ? 'transparent' : themeColors['inputOption.hoverBackground'] }} _hover={{ bgColor: isCloseDisabled ? 'transparent' : themeColors['custom.inputOption.hoverBackground'] }}
/> />
</Flex> </Flex>
); );
......
...@@ -28,7 +28,7 @@ const CoderEditorCollapseButton = ({ onClick, label, isDisabled, isCollapsed }: ...@@ -28,7 +28,7 @@ const CoderEditorCollapseButton = ({ onClick, label, isDisabled, isCollapsed }:
content: isCollapsed ? '"\\eb95"' : '"\\eac5"', content: isCollapsed ? '"\\eb95"' : '"\\eac5"',
}} }}
_hover={{ _hover={{
bgColor: themeColors['inputOption.hoverBackground'], bgColor: themeColors['custom.inputOption.hoverBackground'],
}} }}
onClick={ onClick } onClick={ onClick }
cursor="pointer" cursor="pointer"
......
...@@ -4,7 +4,6 @@ export const light = { ...@@ -4,7 +4,6 @@ export const light = {
rules: [], rules: [],
colors: { colors: {
'editor.background': '#f5f5f6', 'editor.background': '#f5f5f6',
'editor.findMatchHighlightBackground': 'rgba(234, 92, 0, 0.33)',
'tab.activeBackground': '#f5f5f6', 'tab.activeBackground': '#f5f5f6',
'tab.inactiveBackground': 'rgb(236, 236, 236)', 'tab.inactiveBackground': 'rgb(236, 236, 236)',
...@@ -14,12 +13,9 @@ export const light = { ...@@ -14,12 +13,9 @@ export const light = {
'icon.foreground': '#616161', 'icon.foreground': '#616161',
'input.foreground': 'rgb(97, 97, 97)', 'input.foreground': '#616161',
'input.background': '#fff', 'input.background': '#fff',
'inputOption.activeBackground': 'rgba(0, 144, 241, 0.2)',
'inputOption.hoverBackground': 'rgba(184, 184, 184, 0.31)',
'list.hoverBackground': 'rgba(16, 17, 18, 0.08)', // blackAlpha.200 'list.hoverBackground': 'rgba(16, 17, 18, 0.08)', // blackAlpha.200
'list.inactiveSelectionBackground': '#e4e6f1', 'list.inactiveSelectionBackground': '#e4e6f1',
...@@ -30,6 +26,11 @@ export const light = { ...@@ -30,6 +26,11 @@ export const light = {
'sideBar.background': '#eee', 'sideBar.background': '#eee',
focusBorder: '#0090f1', focusBorder: '#0090f1',
// not able to use rgba for standard variables, so we use custom prefix here
'custom.findMatchHighlightBackground': 'rgba(234,92,0,0.33)',
'custom.inputOption.activeBackground': 'rgba(0, 144, 241, 0.2)',
'custom.inputOption.hoverBackground': 'rgba(184, 184, 184, 0.31)',
} as const, } as const,
}; };
...@@ -39,7 +40,6 @@ export const dark = { ...@@ -39,7 +40,6 @@ export const dark = {
rules: [], rules: [],
colors: { colors: {
'editor.background': '#1a1b1b', 'editor.background': '#1a1b1b',
'editor.findMatchHighlightBackground': 'rgba(234, 92, 0, 0.33)',
'tab.activeBackground': '#1a1b1b', // black 'tab.activeBackground': '#1a1b1b', // black
'tab.inactiveBackground': 'rgb(45, 45, 45)', 'tab.inactiveBackground': 'rgb(45, 45, 45)',
...@@ -49,11 +49,8 @@ export const dark = { ...@@ -49,11 +49,8 @@ export const dark = {
'icon.foreground': '#616161', 'icon.foreground': '#616161',
'input.foreground': 'rgb(204, 204, 204)', 'input.foreground': '#cccccc',
'input.background': 'rgb(60, 60, 60)', 'input.background': '#3c3c3c',
'inputOption.activeBackground': 'rgba(0, 127, 212, 0.4)',
'inputOption.hoverBackground': 'rgba(90, 93, 94, 0.31)',
'list.hoverBackground': 'rgba(255, 255, 255, 0.08)', // whiteAlpha.200 'list.hoverBackground': 'rgba(255, 255, 255, 0.08)', // whiteAlpha.200
'list.inactiveSelectionBackground': '#37373d', 'list.inactiveSelectionBackground': '#37373d',
...@@ -65,5 +62,10 @@ export const dark = { ...@@ -65,5 +62,10 @@ export const dark = {
'sideBar.background': '#222', 'sideBar.background': '#222',
focusBorder: '#007fd4', focusBorder: '#007fd4',
// not able to use rgba for standard variables, so we use custom prefix here
'custom.findMatchHighlightBackground': 'rgba(234,92,0,0.33)',
'custom.inputOption.activeBackground': 'rgba(0, 127, 212, 0.4)',
'custom.inputOption.hoverBackground': 'rgba(90, 93, 94, 0.31)',
} as const, } as const,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment