ui: scratchpad: allow close left main pane (#405)

pull/386/head
无限UCW 2 years ago committed by GitHub
parent 9b92b47656
commit ac289ae955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,10 +97,12 @@ export default function ScratchpadContainer() {
</div>
<SplitPane
defaultSize={ui.main.size}
minSize={250}
size={ui.main.size}
minSize={ui.activePage !== null ? 250 : 0}
split="vertical"
primary="second"
primary="first"
onChange={(size) => handleChangeSize('main', size)}
allowResize={ui.activePage !== null}
>
<div className="scratchpad__problem">
{Object.keys(pages).map((key) => {

@ -4,6 +4,7 @@ import i18n from 'vj/utils/i18n';
export default function reducer(state = {
main: {
size: '50%',
savedSize: '50%',
},
pretest: {
visible: ['default', 'fileio'].includes(UiContext.pdoc.config?.type)
@ -120,9 +121,22 @@ export default function reducer(state = {
};
}
case 'SCRATCHPAD_SWITCH_TO_PAGE': {
let newPage = action.payload;
let { size } = state.main;
if (newPage === state.activePage) {
newPage = null;
(size as any) = 0;
} else if (state.activePage === null) {
size = state.main.savedSize;
}
return {
...state,
activePage: action.payload,
main: {
...state.main,
size,
savedSize: state.main.size,
},
activePage: newPage,
};
}
default:

Loading…
Cancel
Save