-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
Fix and improve resizing in editor (incl. Add Spacer component) #2818
Conversation
handleScreenUpdate(); | ||
}, []); | ||
|
||
React.useEffect(() => { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
@@ -816,6 +817,21 @@ export function moveNode<Parent extends AppDomNode, Child extends AppDomNode>( | |||
return setNodeParent(dom, node, parent.id, parentProp, parentIndex); | |||
} | |||
|
|||
export function spreadNode<Child extends AppDomNode>(dom: AppDom, node: Child) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an action in the editor causes a column of elements to be inside the page root, for example, we can spread the contents of the column on the page root directly and get rid of the column element.
element: ElementType, | ||
isPageChild = false, | ||
): ElementType | ElementType[] { | ||
if (isPageChild && element.component === PAGE_COLUMN_COMPONENT_ID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gets rid of page columns inside the page root too, I saw it in a few apps already and it's unnecessary / shouldn't ever happen.
@@ -205,7 +204,8 @@ export default createBuiltin(Chart, { | |||
loadingProp: 'loading', | |||
loadingPropSource: ['data'], | |||
errorProp: 'error', | |||
resizableHeightProp: 'height', | |||
defaultLayoutHeight: 360, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New interface that should be simpler.
Any component is vertically resizable, but we can set a default and minimum height for specific components.
1f0c05f
to
1a40eaa
Compare
const hintPosition = rect.y > HUD_HEIGHT ? HINT_POSITION_TOP : HINT_POSITION_BOTTOM; | ||
const { nodeId: pageNodeId, viewState } = usePageEditorState(); | ||
|
||
const { nodes: nodesInfo } = viewState; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
@@ -1195,6 +1193,8 @@ function RenderedNodeContent({ node, childNodeGroups, Component }: RenderedNodeC | |||
display: 'flex', | |||
alignItems: boundLayoutProps.verticalAlign, | |||
justifyContent: boundLayoutProps.horizontalAlign, | |||
height: node.layout?.height ?? componentConfig.defaultLayoutHeight, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Element heights are controlled in the boxes that wrap components instead of the components themselves.
@apedroferreira Can you also add a demo video that demonstrates the new features? |
I've added 3 demos to the description, hopefully it helps! |
Looking good:
|
Yeah, it's because the default height of the data grid changed, I probably changed it to be a multiple of the resizing intervals.
Yeah I just didn't want to delete it right away from this PR but we had discussed not having it and it just being created automatically... As we're not sure about it I don't mind removing it and seeing what we come up with later if we come back to this, I guess it's better than introducing something we might not plan to keep. I'll remove it from the PR if you don't disagree.
Nope, not in this version of them. Again I guess that I can remove it for now anyway. |
I'm fine with keeping it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impressive
This reverts commit 6e1e06c.
I've tried to bring back this old PR so we can merge it instead of just closing, it's a bit large though... The Spacer component could be separated.
Improves resizing and allows for more control over spacing in the editor overall:
resizableHeightProp
, make it possible to set adefaultLayoutHeight
andminimumLayoutHeight
for each component. This means that all components can be resized using the same system, but for now to avoid bugs I've kept the old resizing behavior: only charts and data grid are resizable, and only from the bottom border. This way no new bugs are introduced until we find solutions for some issues in the UX, but this new system is already there.Spacer component demo:
Screen.Recording.2024-02-23.at.16.48.11.mov
Column spread demo:
Screen.Recording.2024-02-23.at.16.48.55.mov
Improved resizing demo (all components would be resizable + could be resized from top border, but this feature shown here is commented out for now as it still has some poor UX to improve in some scenarios):
Screen.Recording.2024-02-23.at.16.50.40.mov