-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
"Grid" drag and drop interactive layouts #14321
Conversation
--grid-mobile-row-end, | ||
round(up, calc(var(--default-height) / var(--row-size) + 1)) | ||
) | ||
); |
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.
Yes, I'm actually using CSS here to calculate default sizes and then round it to get a valid integer to use later for CSS grid column/row positions.
@@ -650,6 +664,7 @@ | |||
data-name={name} | |||
data-icon={icon} | |||
data-parent={$component.id} | |||
use:gridLayout={gridMetadata} |
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.
Most of the new metadata required to use this feature is handled by this new svelte action. This keeps it all nicely scoped inside one file and means we don't need to make this core Component file any more complicated than it already is.
… padding, remove row and column settings
this looks really neat ! |
Closing in favour of #14360. |
Description
This PR adds a new way to lay out your components - a drag and drop grid system. This makes it easier, faster and more intuitive to design your screens.
I'd really appreciate it if you could give this a try on the feature branch - all feedback is welcome.
Some of these videos are now outdated - please use the feature branch for the most up to date code.
How to use grid layout
Grid layout can be used in 2 ways: either on your screen as a whole, or in any container.
To change your screen or container to grid layout, use the new action button setting setting:
Grid layout basics
Any components put inside a grid container or screen can be resized using anchors on all corners and sides:
Screen.Recording.2024-08-05.at.19.03.57.mov
They can be moved around by dragging:
Screen.Recording.2024-08-05.at.19.04.31.mov
Some components take up the full size that you specify, like the table in the videos above, but this doesn't make sense for all components. Take a button for example - you wouldn't want your button to ever be that size. Components like this instead are positioned inside the bounds you define, and can be aligned whatever way you want:
Screen.Recording.2024-08-05.at.19.06.28.mov
Designing for mobile
The biggest limitation of drag and drop layout systems (especially compared to Budibase's normal layout system) is the lack of responsiveness - i.e. they don't automatically work on mobile.
To solve this, the new grid layout system "remembers" the position and size of your components for both large (desktop/tablet) and small (mobile) previews. So to design a screen for mobile, just swap to the mobile preview and move your components around to design the screen as you want on mobile.
Here's a quick example of building a very basic screen:
Screen.Recording.2024-08-05.at.19.13.59.mov
A few other clarifications about how this feature works:
Addresses
For plugin authors
When adding a component inside grids, we use metadata defined in the manifest to determine how big a component should initially be, and what way it should be laid out.
The
size
key is used to define what size (in pixels) an instance of your component should be by default. Please use a reasonably small size here. If this is undefined, we will use 200x200. For our table component for example, we use:The
grid
key defines how your component should be aligned when used inside a grid. There are 2 properties -hAlign
for horizontal alignment andvAlign
for vertical alignment. Each of these can be eitherstart
,center
,end
or stretch and behaves exactly like their CSS flexbox equivalents. The defaults arestretch
horizontally andstart
vertically. These can be controlled by the end user in the settings bar rendered in the preview. The one exception to this is if you specifystretch
for both. In that case, the user will not see the settings in the bar and the component will always fill the space, like for our table component.Here's an example of how this metadata looks for our form block:
Other stuff
Launchcontrol
Added a new way to lay out your components - a drag and drop grid system. This makes it easier, faster and more intuitive to design your screens.
Feature branch env
Feature Branch Link