diff --git a/subprojects/frontend/src/PaneButtons.tsx b/subprojects/frontend/src/PaneButtons.tsx index 0c265709..d41bf219 100644 --- a/subprojects/frontend/src/PaneButtons.tsx +++ b/subprojects/frontend/src/PaneButtons.tsx @@ -12,7 +12,9 @@ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup'; import { alpha, styled } from '@mui/material/styles'; import { observer } from 'mobx-react-lite'; +import Tooltip from './Tooltip'; import type ThemeStore from './theme/ThemeStore'; +import type { SelectedPane } from './theme/ThemeStore'; const PaneButtonGroup = styled(ToggleButtonGroup, { name: 'PaneButtons-Group', @@ -82,6 +84,42 @@ const PaneButtonGroup = styled(ToggleButtonGroup, { }; }); +const PaneButton = observer(function PaneButton({ + themeStore, + value, + label, + icon, + hideLabel, +}: { + themeStore: ThemeStore; + value: SelectedPane; + label: string; + icon: React.ReactNode; + hideLabel: boolean; +}): JSX.Element { + const button = ( + { + if (event.shiftKey || event.ctrlKey) { + themeStore.setSelectedPane(value, event.shiftKey); + } else { + themeStore.togglePane(value); + } + }} + > + {icon} + {!hideLabel && label} + + ); + return hideLabel ? ( + {button} + ) : ( + button + ); +}); + function PaneButtons({ themeStore, hideLabel, @@ -89,53 +127,33 @@ function PaneButtons({ themeStore: ThemeStore; hideLabel?: boolean; }): JSX.Element { + const hideLabelOrDefault = hideLabel ?? false; return ( - { - if (event.shiftKey || event.ctrlKey) { - themeStore.setSelectedPane('code'); - } else { - themeStore.toggleCode(); - } - }} - > - - {!hideLabel && 'Code'} - - } + hideLabel={hideLabelOrDefault} + /> + { - if (event.shiftKey || event.ctrlKey) { - themeStore.setSelectedPane('graph', event.shiftKey); - } else { - themeStore.toggleGraph(); - } - }} - > - - {!hideLabel && 'Graph'} - - } + hideLabel={hideLabelOrDefault} + /> + { - if (event.shiftKey || event.ctrlKey) { - themeStore.setSelectedPane('table', event.shiftKey); - } else { - themeStore.toggleTable(); - } - }} - > - - {!hideLabel && 'Table'} - + label="Table" + icon={} + hideLabel={hideLabelOrDefault} + /> ); } diff --git a/subprojects/frontend/src/editor/SearchToolbar.tsx b/subprojects/frontend/src/editor/SearchToolbar.tsx index a2a16ce7..3ee01327 100644 --- a/subprojects/frontend/src/editor/SearchToolbar.tsx +++ b/subprojects/frontend/src/editor/SearchToolbar.tsx @@ -17,12 +17,13 @@ import Stack from '@mui/material/Stack'; import TextField from '@mui/material/TextField'; import ToggleButton from '@mui/material/ToggleButton'; import Toolbar from '@mui/material/Toolbar'; -import Tooltip from '@mui/material/Tooltip'; import { styled } from '@mui/material/styles'; import { observer } from 'mobx-react-lite'; import { useCallback, useState } from 'react'; import { useResizeDetector } from 'react-resize-detector'; +import Tooltip from '../Tooltip'; + import type SearchPanelStore from './SearchPanelStore'; const DimLabel = styled(FormControlLabel)(({ theme }) => ({ @@ -131,26 +132,22 @@ export default observer(function SearchToolbar({ rowGap={0.5} > - - searchPanelStore.findPrevious()} - color="inherit" - > - - - + searchPanelStore.findPrevious()} + color="inherit" + > + + - - searchPanelStore.findNext()} - color="inherit" - > - - - + searchPanelStore.findNext()} + color="inherit" + > + + { this.systemDarkMode = event.matches; }); - makeAutoObservable(this); + makeAutoObservable(this, { + isShowing: false, + }); } get darkMode(): boolean { @@ -57,6 +59,35 @@ export default class ThemeStore { } } + togglePane(pane: SelectedPane) { + switch (pane) { + case 'code': + this.toggleCode(); + break; + case 'graph': + this.toggleGraph(); + break; + case 'table': + this.toggleTable(); + break; + default: + throw new Error(`Unknown pane: ${String(pane)}`); + } + } + + isShowing(pane: SelectedPane): boolean { + switch (pane) { + case 'code': + return this.showCode; + case 'graph': + return this.showGraph; + case 'table': + return this.showTable; + default: + throw new Error(`Unknown pane: ${String(pane)}`); + } + } + toggleCode(): void { if (!this.showGraph && !this.showTable) { return;