easyblockshq / easyblocks

The open-source visual builder framework.
https://easyblocks.io
GNU Affero General Public License v3.0
241 stars 33 forks source link

Feature: pass class names to the placeholderAppearence prop in component type fields #48

Closed timoconnellaus closed 1 month ago

timoconnellaus commented 1 month ago

Motiviation: the placeholder is currently pretty rigid with the ability to set height, width or aspect ratio. But when the parent container's shape is dynamic it's not possible to automatically grow / shrink the placeholder to fill the parent

Solution: ability to pass class names to the component - this allows for tailwind to be used to style the placeholder

Perhaps this could even be expanded to completely replace the placeholders styling

{
  type: "component-collection",
  prop: "data",
  label: "List Items",
  accepts: ["icon-and-text"],
  placeholderAppearance: {
    classNames: "h-full w-full"
  },
}
r00dY commented 1 month ago

You can leave width and height as undefined and make the parent component have display: grid.

It works because:

  1. width and height set to undefined mean that in CSS they're gonna be auto.
  2. auto fills the parent if the parent uses grid layout.

For many reasons Easyblocks prefers grid/flex over width: 100% / height: 100% styling. When I have a free moment I'll add a note to the docs about that because it's a recurring question and is not easy to explain quickly.

That being said, the idea of providing custom component for Placeholder is a very good one!

timoconnellaus commented 1 month ago

Thank you. That worked perfectly