mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
37 lines
932 B
TypeScript
37 lines
932 B
TypeScript
|
import { createTheme } from '@uiw/codemirror-themes'
|
||
|
import { json } from '@codemirror/lang-json'
|
||
|
|
||
|
export function checkJson(text: string) {
|
||
|
try {
|
||
|
JSON.parse(text)
|
||
|
return true
|
||
|
} catch (error) {
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
declare type Theme = 'light' | 'dark'
|
||
|
export const oceanTheme = (marketTheme: Theme, field) => {
|
||
|
let textColor = 'var(--font-color-text)'
|
||
|
if (
|
||
|
(field.name === 'files[0].abi' ||
|
||
|
field.name === 'services[0].files[0].abi') &&
|
||
|
!checkJson(field.value)
|
||
|
) {
|
||
|
textColor = 'var(--brand-alert-red)'
|
||
|
}
|
||
|
|
||
|
return createTheme({
|
||
|
theme: marketTheme,
|
||
|
settings: {
|
||
|
background: 'var(--background-content)',
|
||
|
foreground: textColor,
|
||
|
selection: 'var(--background-highlight)',
|
||
|
lineHighlight: 'transparent',
|
||
|
gutterBackground: 'var(--background-body)',
|
||
|
gutterForeground: 'var(--font-color-text)'
|
||
|
},
|
||
|
styles: []
|
||
|
})
|
||
|
}
|
||
|
export const extensions = [json()]
|