Merge pull request #1742 from ethereum/editorColors

Editor colors
pull/1778/head
Liana Husikyan 3 years ago committed by GitHub
commit 2be317f0f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/remix-ide-e2e/src/tests/generalSettings.test.ts
  2. 7
      apps/remix-ide/src/app/editor/editor.js
  3. 1
      apps/remix-ide/src/assets/css/themes/remix-black_undtds.css
  4. 1
      apps/remix-ide/src/assets/css/themes/remix-candy_ikhg4m.css
  5. 2
      apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css
  6. 5
      apps/remix-ide/src/assets/css/themes/remix-light_powaqg.css
  7. 1
      apps/remix-ide/src/assets/css/themes/remix-midcentury_hrzph3.css
  8. 128
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  9. 41
      libs/remix-ui/editor/src/lib/syntax.ts
  10. 165
      package-lock.json

@ -147,7 +147,7 @@ const remixIdeThemes = {
},
light: {
primary: '#007aa6',
secondary: '#a8b3bc',
secondary: '#b3bcc483',
success: '#32ba89',
info: '#007aa6',
warning: '#c97539',

@ -82,7 +82,7 @@ class Editor extends Plugin {
ReactDOM.render(
<EditorUI
editorAPI={this.api}
theme={this.currentTheme}
themeType={this.currentThemeType}
currentFile={this.currentFile}
sourceAnnotationsPerFile={this.sourceAnnotationsPerFile}
markerPerFile={this.markerPerFile}
@ -107,13 +107,12 @@ class Editor extends Plugin {
this.clearAllDecorationsFor(name)
})
const translateTheme = (theme) => this._themes[theme.name === 'Dark' ? 'remixDark' : theme.quality]
this.on('theme', 'themeLoaded', (theme) => {
this.currentTheme = translateTheme(theme)
this.currentThemeType = theme.quality
this.renderComponent()
})
try {
this.currentTheme = translateTheme(await this.call('theme', 'currentTheme'))
this.currentThemeType = (await this.call('theme', 'currentTheme')).quality
} catch (e) {
console.log('unable to select the theme ' + e.message)
}

@ -21,6 +21,7 @@
--danger: #823a3a;
--light: #1f2020;
--dark: #1a1a1a;
--text: #babbcc;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;

@ -20,6 +20,7 @@
--danger: #f80b0b;
--light: #fff;
--dark: #645fb5;
--text: #11556c;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;

@ -21,6 +21,8 @@
--danger: #b84040;
--light: #2a2c3f;
--dark: #222336;
--text: #babbcc;
--text-background: #222336;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;

@ -1,7 +1,7 @@
:root {
--blue: #007bff;
--indigo: #6610f2;
--purple: #6f42c1;
--purple: #d145a7;
--pink: #e83e8c;
--red: #dc3545;
--orange: #fd7e14;
@ -13,13 +13,14 @@
--gray: #6c757d;
--gray-dark: #343a40;
--primary: #007aa6;
--secondary: #a8b3bc;
--secondary: #b3bcc483;
--success: #32ba89;
--info: #007aa6;
--warning: #c97539;
--danger: #b84040;
--light: #fff;
--dark: #f8fafe;
--text: #3b445e;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;

@ -20,6 +20,7 @@
--danger: #E64F29;
--light: #eeede9;
--dark: #01414E;
--text: #11556c;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;

@ -47,7 +47,7 @@ type sourceMarkerMap = {
/* eslint-disable-next-line */
export interface EditorUIProps {
activated: boolean
theme: string
themeType: string
currentFile: string
sourceAnnotationsPerFile: sourceAnnotationMap
markerPerFile: sourceMarkerMap
@ -60,7 +60,7 @@ export interface EditorUIProps {
plugin: {
on: (plugin: string, event: string, listener: any) => void
}
editorAPI:{
editorAPI: {
findMatches: (uri: string, value: string) => any
getFontSize: () => number,
getValue: (uri: string) => string
@ -78,38 +78,122 @@ export const EditorUI = (props: EditorUIProps) => {
const [editorModelsState, dispatch] = useReducer(reducerActions, initialState)
const defineAndSetDarkTheme = (monaco) => {
const formatColor = (name) => {
let color = window.getComputedStyle(document.documentElement).getPropertyValue(name).trim()
if (color.length === 4) {
color = color.concat(color.substr(1))
}
return color
}
const defineAndSetTheme = (monaco) => {
const themeType = props.themeType === 'dark' ? 'vs-dark' : 'vs'
const themeName = props.themeType === 'dark' ? 'remix-dark' : 'remix-light'
// see https://microsoft.github.io/monaco-editor/playground.html#customizing-the-appearence-exposed-colors
const lightColor = window.getComputedStyle(document.documentElement).getPropertyValue('--light').trim()
const infoColor = window.getComputedStyle(document.documentElement).getPropertyValue('--info').trim()
const darkColor = window.getComputedStyle(document.documentElement).getPropertyValue('--dark').trim()
const grayColor = window.getComputedStyle(document.documentElement).getPropertyValue('--gray-dark').trim()
monaco.editor.defineTheme('remix-dark', {
base: 'vs-dark',
const lightColor = formatColor('--light')
const infoColor = formatColor('--info')
const darkColor = formatColor('--dark')
const secondaryColor = formatColor('--secondary')
const textColor = formatColor('--text') || darkColor
const textbackground = formatColor('--text-background') || lightColor
const blueColor = formatColor('--blue')
const successColor = formatColor('--success')
const warningColor = formatColor('--warning')
const yellowColor = formatColor('--yellow')
const pinkColor = formatColor('--pink')
const locationColor = '#9e7e08'
const purpleColor = formatColor('--purple')
const dangerColor = formatColor('--danger')
monaco.editor.defineTheme(themeName, {
base: themeType,
inherit: true, // can also be false to completely replace the builtin rules
rules: [
{ background: darkColor.replace('#', '') },
{ token: 'keyword.external', foreground: infoColor }
{ foreground: textColor.replace('#', '') },
// global variables
{ token: 'keyword.abi', foreground: blueColor },
{ token: 'keyword.block', foreground: blueColor },
{ token: 'keyword.bytes', foreground: blueColor },
{ token: 'keyword.msg', foreground: blueColor },
{ token: 'keyword.tx', foreground: blueColor },
// global functions
{ token: 'keyword.assert', foreground: blueColor },
{ token: 'keyword.require', foreground: blueColor },
{ token: 'keyword.revert', foreground: blueColor },
{ token: 'keyword.blockhash', foreground: blueColor },
{ token: 'keyword.keccak256', foreground: blueColor },
{ token: 'keyword.sha256', foreground: blueColor },
{ token: 'keyword.ripemd160', foreground: blueColor },
{ token: 'keyword.ecrecover', foreground: blueColor },
{ token: 'keyword.addmod', foreground: blueColor },
{ token: 'keyword.mulmod', foreground: blueColor },
{ token: 'keyword.selfdestruct', foreground: blueColor },
{ token: 'keyword.type ', foreground: blueColor },
{ token: 'keyword.gasleft', foreground: blueColor },
// specials
{ token: 'keyword.super', foreground: infoColor },
{ token: 'keyword.this', foreground: infoColor },
// for state variables
{ token: 'keyword.constants', foreground: warningColor },
{ token: 'keyword.override', foreground: warningColor },
{ token: 'keyword.immutable', foreground: warningColor },
// data location
{ token: 'keyword.memory', foreground: locationColor },
{ token: 'keyword.storage', foreground: locationColor },
{ token: 'keyword.calldata', foreground: locationColor },
// // forf functions and modifiers
{ token: 'keyword.virtual', foreground: purpleColor },
// // for Events
{ token: 'keyword.indexed', foreground: yellowColor },
{ token: 'keyword.anonymous', foreground: yellowColor },
// // for functions
{ token: 'keyword.external', foreground: successColor },
{ token: 'keyword.internal', foreground: successColor },
{ token: 'keyword.private', foreground: successColor },
{ token: 'keyword.public', foreground: successColor },
{ token: 'keyword.view', foreground: successColor },
{ token: 'keyword.pure', foreground: successColor },
{ token: 'keyword.payable', foreground: successColor },
{ token: 'keyword.nonpayable', foreground: successColor },
// Errors
{ token: 'keyword.Error', foreground: dangerColor },
{ token: 'keyword.Panic', foreground: dangerColor },
// special functions
{ token: 'keyword.fallback', foreground: pinkColor },
{ token: 'keyword.receive', foreground: pinkColor },
{ token: 'keyword.constructor', foreground: pinkColor }
],
colors: {
'editor.background': darkColor,
// see https://code.visualstudio.com/api/references/theme-color for more settings
'editor.background': textbackground,
'editorSuggestWidget.background': lightColor,
'editorSuggestWidget.selectedBackground': lightColor,
'editorSuggestWidget.highlightForeground': infoColor,
'editor.lineHighlightBorder': lightColor,
'editor.lineHighlightBackground': grayColor,
'editorGutter.background': lightColor
'editor.lineHighlightBorder': secondaryColor,
'editor.lineHighlightBackground': textbackground === darkColor ? lightColor : secondaryColor,
'editorGutter.background': lightColor,
'minimap.background': lightColor
}
})
monacoRef.current.editor.setTheme('remix-dark')
monacoRef.current.editor.setTheme(themeName)
}
useEffect(() => {
if (!monacoRef.current) return
if (props.theme === 'remix-dark') {
defineAndSetDarkTheme(monacoRef.current)
} else monacoRef.current.editor.setTheme(props.theme)
}, [props.theme])
defineAndSetTheme(monacoRef.current)
})
const setAnnotationsbyFile = (uri) => {
if (props.sourceAnnotationsPerFile[uri]) {
@ -236,9 +320,7 @@ export const EditorUI = (props: EditorUIProps) => {
function handleEditorDidMount (editor) {
editorRef.current = editor
if (props.theme === 'remix-dark') {
defineAndSetDarkTheme(monacoRef.current)
} else monacoRef.current.editor.setTheme(props.theme)
defineAndSetTheme(monacoRef.current)
reducerListener(props.plugin, dispatch, monacoRef.current, editorRef.current, props.events)
props.events.onEditorMounted()
editor.onMouseUp((e) => {
@ -270,7 +352,7 @@ export const EditorUI = (props: EditorUIProps) => {
language={editorModelsState[props.currentFile] ? editorModelsState[props.currentFile].language : 'text'}
onMount={handleEditorDidMount}
beforeMount={handleEditorWillMount}
options= { { glyphMargin: true } }
options={{ glyphMargin: true }}
/>
)
}

@ -1214,21 +1214,58 @@ export const language = {
'ufixed240x16',
'ufixed248x8',
'event',
'emit',
'enum',
'let',
'mapping',
'private',
'public',
'external',
'internal',
'indexed',
'anonymous',
'isOwner',
'view',
'pure',
'inherited',
'storage',
'memory',
'virtual',
'calldata',
'override',
'abstract',
'payable',
'nonpayable',
'constants',
'immutable',
'assert',
'require',
'revert',
'blockhash',
'keccak256',
'sha256',
'ripemd160',
'ecrecover',
'addmod',
'mulmod',
'selfdestruct',
'type',
'gasleft',
'abi',
'block',
'bytes',
'msg',
'tx',
'Error',
'Panic',
'exceptions',
'true',
'false',
'var',
'import',
'constant',
'fallback',
'receive',
'if',
'else',
'for',
@ -1245,7 +1282,9 @@ export const language = {
'new',
'is',
'this',
'super'
'super',
'try',
'catch'
],
operators: [

165
package-lock.json generated

@ -579,6 +579,171 @@
"requires": {
"@babel/helper-create-class-features-plugin": "^7.16.0",
"@babel/helper-plugin-utils": "^7.14.5"
},
"dependencies": {
"@babel/code-frame": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.0.tgz",
"integrity": "sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==",
"requires": {
"@babel/highlight": "^7.16.0"
}
},
"@babel/generator": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.16.0.tgz",
"integrity": "sha512-RR8hUCfRQn9j9RPKEVXo9LiwoxLPYn6hNZlvUOR8tSnaxlD0p0+la00ZP9/SnRt6HchKr+X0fO2r8vrETiJGew==",
"requires": {
"@babel/types": "^7.16.0",
"jsesc": "^2.5.1",
"source-map": "^0.5.0"
}
},
"@babel/helper-annotate-as-pure": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.0.tgz",
"integrity": "sha512-ItmYF9vR4zA8cByDocY05o0LGUkp1zhbTQOH1NFyl5xXEqlTJQCEJjieriw+aFpxo16swMxUnUiKS7a/r4vtHg==",
"requires": {
"@babel/types": "^7.16.0"
}
},
"@babel/helper-create-class-features-plugin": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.16.0.tgz",
"integrity": "sha512-XLwWvqEaq19zFlF5PTgOod4bUA+XbkR4WLQBct1bkzmxJGB0ZEJaoKF4c8cgH9oBtCDuYJ8BP5NB9uFiEgO5QA==",
"requires": {
"@babel/helper-annotate-as-pure": "^7.16.0",
"@babel/helper-function-name": "^7.16.0",
"@babel/helper-member-expression-to-functions": "^7.16.0",
"@babel/helper-optimise-call-expression": "^7.16.0",
"@babel/helper-replace-supers": "^7.16.0",
"@babel/helper-split-export-declaration": "^7.16.0"
}
},
"@babel/helper-function-name": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.0.tgz",
"integrity": "sha512-BZh4mEk1xi2h4HFjWUXRQX5AEx4rvaZxHgax9gcjdLWdkjsY7MKt5p0otjsg5noXw+pB+clMCjw+aEVYADMjog==",
"requires": {
"@babel/helper-get-function-arity": "^7.16.0",
"@babel/template": "^7.16.0",
"@babel/types": "^7.16.0"
}
},
"@babel/helper-get-function-arity": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.0.tgz",
"integrity": "sha512-ASCquNcywC1NkYh/z7Cgp3w31YW8aojjYIlNg4VeJiHkqyP4AzIvr4qx7pYDb4/s8YcsZWqqOSxgkvjUz1kpDQ==",
"requires": {
"@babel/types": "^7.16.0"
}
},
"@babel/helper-hoist-variables": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.0.tgz",
"integrity": "sha512-1AZlpazjUR0EQZQv3sgRNfM9mEVWPK3M6vlalczA+EECcPz3XPh6VplbErL5UoMpChhSck5wAJHthlj1bYpcmg==",
"requires": {
"@babel/types": "^7.16.0"
}
},
"@babel/helper-member-expression-to-functions": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.16.0.tgz",
"integrity": "sha512-bsjlBFPuWT6IWhl28EdrQ+gTvSvj5tqVP5Xeftp07SEuz5pLnsXZuDkDD3Rfcxy0IsHmbZ+7B2/9SHzxO0T+sQ==",
"requires": {
"@babel/types": "^7.16.0"
}
},
"@babel/helper-optimise-call-expression": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.0.tgz",
"integrity": "sha512-SuI467Gi2V8fkofm2JPnZzB/SUuXoJA5zXe/xzyPP2M04686RzFKFHPK6HDVN6JvWBIEW8tt9hPR7fXdn2Lgpw==",
"requires": {
"@babel/types": "^7.16.0"
}
},
"@babel/helper-replace-supers": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.0.tgz",
"integrity": "sha512-TQxuQfSCdoha7cpRNJvfaYxxxzmbxXw/+6cS7V02eeDYyhxderSoMVALvwupA54/pZcOTtVeJ0xccp1nGWladA==",
"requires": {
"@babel/helper-member-expression-to-functions": "^7.16.0",
"@babel/helper-optimise-call-expression": "^7.16.0",
"@babel/traverse": "^7.16.0",
"@babel/types": "^7.16.0"
}
},
"@babel/helper-split-export-declaration": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.0.tgz",
"integrity": "sha512-0YMMRpuDFNGTHNRiiqJX19GjNXA4H0E8jZ2ibccfSxaCogbm3am5WN/2nQNj0YnQwGWM1J06GOcQ2qnh3+0paw==",
"requires": {
"@babel/types": "^7.16.0"
}
},
"@babel/highlight": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.0.tgz",
"integrity": "sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g==",
"requires": {
"@babel/helper-validator-identifier": "^7.15.7",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
}
},
"@babel/parser": {
"version": "7.16.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.3.tgz",
"integrity": "sha512-dcNwU1O4sx57ClvLBVFbEgx0UZWfd0JQX5X6fxFRCLHelFBGXFfSz6Y0FAq2PEwUqlqLkdVjVr4VASEOuUnLJw=="
},
"@babel/template": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.0.tgz",
"integrity": "sha512-MnZdpFD/ZdYhXwiunMqqgyZyucaYsbL0IrjoGjaVhGilz+x8YB++kRfygSOIj1yOtWKPlx7NBp+9I1RQSgsd5A==",
"requires": {
"@babel/code-frame": "^7.16.0",
"@babel/parser": "^7.16.0",
"@babel/types": "^7.16.0"
}
},
"@babel/traverse": {
"version": "7.16.3",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.3.tgz",
"integrity": "sha512-eolumr1vVMjqevCpwVO99yN/LoGL0EyHiLO5I043aYQvwOJ9eR5UsZSClHVCzfhBduMAsSzgA/6AyqPjNayJag==",
"requires": {
"@babel/code-frame": "^7.16.0",
"@babel/generator": "^7.16.0",
"@babel/helper-function-name": "^7.16.0",
"@babel/helper-hoist-variables": "^7.16.0",
"@babel/helper-split-export-declaration": "^7.16.0",
"@babel/parser": "^7.16.3",
"@babel/types": "^7.16.0",
"debug": "^4.1.0",
"globals": "^11.1.0"
}
},
"@babel/types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.0.tgz",
"integrity": "sha512-PJgg/k3SdLsGb3hhisFvtLOw5ts113klrpLuIPtCJIU+BB24fqq6lf8RWqKJEjzqXR9AEH1rIb5XTqwBHB+kQg==",
"requires": {
"@babel/helper-validator-identifier": "^7.15.7",
"to-fast-properties": "^2.0.0"
}
},
"debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
"integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
"requires": {
"ms": "2.1.2"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"@babel/plugin-proposal-class-static-block": {

Loading…
Cancel
Save