From 928d053a72cb96010b6611486b2c1caf397b2827 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 20 Nov 2021 11:13:33 -0600 Subject: tweak display of options/yaml --- .../src/components/System/Options/CodeEditor.js | 19 ++++++++++++++++ src/web/src/components/System/Options/Edit.js | 25 +++++++++------------- src/web/src/components/System/Options/View.js | 22 +++++++------------ src/web/src/components/System/System.css | 6 ++++++ 4 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 src/web/src/components/System/Options/CodeEditor.js (limited to 'src') diff --git a/src/web/src/components/System/Options/CodeEditor.js b/src/web/src/components/System/Options/CodeEditor.js new file mode 100644 index 00000000..77867a12 --- /dev/null +++ b/src/web/src/components/System/Options/CodeEditor.js @@ -0,0 +1,19 @@ +import React from 'react'; + +import CodeMirror from '@uiw/react-codemirror'; +import { StreamLanguage } from '@codemirror/stream-parser'; +import { yaml } from '@codemirror/legacy-modes/mode/yaml'; +import { defaultHighlightStyle } from '@codemirror/highlight'; + +const CodeEditor = ({ value, onChange = () => {}, ...rest}) => { + return ( + onChange(value)} + { ...rest} + /> + ); +} + +export default CodeEditor; \ No newline at end of file diff --git a/src/web/src/components/System/Options/Edit.js b/src/web/src/components/System/Options/Edit.js index dfcb0072..0092279a 100644 --- a/src/web/src/components/System/Options/Edit.js +++ b/src/web/src/components/System/Options/Edit.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Button, Icon, Message } from 'semantic-ui-react'; -import CodeEditor from '@uiw/react-textarea-code-editor'; +import CodeEditor from './CodeEditor'; import { getYaml, validateYaml, updateYaml } from '../../../lib/options'; import PlaceholderSegment from '../../Shared/PlaceholderSegment'; @@ -56,20 +56,15 @@ const Edit = ({ cancelAction }) => { return ( <> - update(e.target.value)} - padding={10} - style={{ - border: '1px solid #d4d4d5', - backgroundColor: 'rgb(250, 250, 250)', - fontSize: '1em', - fontFamily: 'ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace', - overflow: 'auto', - height: yamlError ? 'calc(100vh - 316px)' : 'calc(100vh - 254px)' - }} - /> +
+ update(value)} + /> +
{yamlError && {yamlError}}
diff --git a/src/web/src/components/System/Options/View.js b/src/web/src/components/System/Options/View.js index 980a90d8..61651f8d 100644 --- a/src/web/src/components/System/Options/View.js +++ b/src/web/src/components/System/Options/View.js @@ -2,7 +2,7 @@ import React from 'react'; import yaml from 'yaml'; import { Icon, Button } from 'semantic-ui-react'; -import CodeEditor from '@uiw/react-textarea-code-editor'; +import CodeEditor from './CodeEditor'; const View = ({ options, editAction }) => { const { remoteConfiguration } = options; @@ -14,19 +14,13 @@ const View = ({ options, editAction }) => { return ( <> - +
+ +
{remoteConfiguration ? : diff --git a/src/web/src/components/System/System.css b/src/web/src/components/System/System.css index 3a930667..23f05221 100644 --- a/src/web/src/components/System/System.css +++ b/src/web/src/components/System/System.css @@ -36,4 +36,10 @@ .footer-buttons { margin-top: 14px; text-align: right; +} + +.code-container { + border: 1px solid #d4d4d5; + overflow: auto; + height: calc(100vh - 254px); } \ No newline at end of file -- cgit v1.2.3