Skip to content

Commit

Permalink
Persist component panel size (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored Jun 25, 2022
1 parent 09e231e commit 479def3
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as appDom from '../../../appDom';
import ComponentCatalog from './ComponentCatalog';
import NotFoundEditor from '../NotFoundEditor';
import usePageTitle from '../../../utils/usePageTitle';
import useLocalStorageState from '../../../utils/useLocalStorageState';

const classes = {
renderPanel: 'Toolpad_RenderPanel',
Expand All @@ -34,9 +35,21 @@ interface PageEditorContentProps {

function PageEditorContent({ appId, node }: PageEditorContentProps) {
usePageTitle(`${node.attributes.title.value} | Toolpad editor`);

const [splitDefaultSize, setSplitDefaultSize] = useLocalStorageState<number>(
`editor/${appId}/component-panel-split`,
300,
);

return (
<PageEditorProvider key={node.id} appId={appId} nodeId={node.id}>
<SplitPane allowResize split="vertical" defaultSize={300} primary="second">
<SplitPane
allowResize
split="vertical"
defaultSize={splitDefaultSize}
onChange={(newSize) => setSplitDefaultSize(newSize)}
primary="second"
>
<PageEditorRoot>
<ComponentCatalog />
<RenderPanel className={classes.renderPanel} />
Expand Down

0 comments on commit 479def3

Please sign in to comment.