From 8bca9baf3cb371eb45023eb986b8730e21cf728c Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Mon, 25 Oct 2021 20:56:35 +0200 Subject: feat(web): show lint status on lint button --- language-web/src/main/js/editor/EditorButtons.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'language-web/src/main/js/editor/EditorButtons.tsx') diff --git a/language-web/src/main/js/editor/EditorButtons.tsx b/language-web/src/main/js/editor/EditorButtons.tsx index 9622475c..bd843dfe 100644 --- a/language-web/src/main/js/editor/EditorButtons.tsx +++ b/language-web/src/main/js/editor/EditorButtons.tsx @@ -1,16 +1,35 @@ +import type { Diagnostic } from '@codemirror/lint'; import { observer } from 'mobx-react-lite'; import Stack from '@mui/material/Stack'; import ToggleButton from '@mui/material/ToggleButton'; import ToggleButtonGroup from '@mui/material/ToggleButtonGroup'; import CheckIcon from '@mui/icons-material/Check'; +import ErrorIcon from '@mui/icons-material/Error'; import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered'; +import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import RedoIcon from '@mui/icons-material/Redo'; import SearchIcon from '@mui/icons-material/Search'; import UndoIcon from '@mui/icons-material/Undo'; +import WarningIcon from '@mui/icons-material/Warning'; import React from 'react'; import { useRootStore } from '../RootStore'; +// Exhastive switch as proven by TypeScript. +// eslint-disable-next-line consistent-return +function getLintIcon(severity: Diagnostic['severity'] | null) { + switch (severity) { + case 'error': + return ; + case 'warning': + return ; + case 'info': + return ; + case null: + return ; + } +} + export const EditorButtons = observer(() => { const { editorStore } = useRootStore(); @@ -61,10 +80,10 @@ export const EditorButtons = observer(() => { editorStore.toggleLintPanel()} - aria-label="Show errors and warnings" + aria-label={`${editorStore.errorCount} errors, ${editorStore.warningCount} warnings, ${editorStore.infoCount} info`} value="show-lint-panel" > - + {getLintIcon(editorStore.highestDiagnosticLevel)} -- cgit v1.2.3-70-g09d2