Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak update button position and visibility in component editor #673

Merged
merged 5 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/toolpad-app/src/components/SplitPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const WrappedSplitPane = React.forwardRef<
// Some sensible defaults
minSize={20}
maxSize={-20}
style={{
position: 'relative',
Copy link
Member

@Janpot Janpot Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, makes sense. Perhaps it could make a bit more sense on the paneStyle instead, since that's the exact rectangle we want that editor to size to? (Not 100% sure that will work, didn't test)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my initial though too, I tried it but it seems that paneStyle is responsible for other components so I had to use style

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so it's the whole splitpane sizing badly. I'm a bit concerned that this will mess up existing splitpane usage. Perhaps it's safer to keep it absolute and have it size against its parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked and we have 5 places where we use it:

  1. Component editor - all seems to look ok ✅
  2. Page editor - it's rendered also without an issue ✅

image

  1. Three places in QueryEditor - all seem to look still ok ✅

image

Should I still change it to absolute? I'm worried that having it as absolute will bite us back in future usecases the same way and we will either have to sprinkle relative position on parent everywhere we use SplitPane or we will still end up doing it globally 🤔

}}
paneStyle={{
display: 'block',
// Prevent the content from stretching the Panel out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,9 @@ function CodeComponentEditorContent({ codeComponentNode }: CodeComponentEditorCo
return (
<React.Fragment>
<Stack sx={{ height: '100%' }}>
<Toolbar sx={{ mt: 2 }}>
<Toolbar sx={{ mt: 2, mb: 2 }}>
<NodeNameEditor node={codeComponentNode} sx={{ maxWidth: 300 }} />
</Toolbar>
<Toolbar>
<Button disabled={allChangesAreCommitted} onClick={handleSave}>
Update
</Button>
</Toolbar>
<Box flex={1}>
<SplitPane split="vertical" allowResize size="50%">
<TypescriptEditor
Expand All @@ -170,6 +165,15 @@ function CodeComponentEditorContent({ codeComponentNode }: CodeComponentEditorCo
<CanvasFrame ref={frameRef} title="Code component sandbox" onLoad={onLoad} />
</SplitPane>
</Box>
<Toolbar
sx={{
justifyContent: 'end',
}}
>
<Button disabled={allChangesAreCommitted} onClick={handleSave} variant="contained">
Update
</Button>
</Toolbar>
</Stack>
{iframeLoaded && frameDocument
? ReactDOM.createPortal(
Expand Down