mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: scratchpad: allow close left main pane (#405)
This commit is contained in:
1 parent
9b92b47656
commit
ac289ae955
2 files changed
+19
-3
No files matched your search
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user