Skip to content

Static factory methods for common layout configurations #8490

@stefanuebe

Description

@stefanuebe

Describe your motivation

Currently, VerticalLayout and HorizontalLayout constructors behave in a certain way, that is not always useful. In the same time, they are often used multiple times as children of another component, where their default configuration is not suitable

  • VerticalLayout comes with default padding, which leads to immense indents, when applied to every nested instance
  • HorizontalLayout always aligns on top, which is not suitable, when used for input fields with labels plus buttons

The solution for that is, to instantiate the object, assign it to a local var, apply the changes (no padding, align centered or on baseline), but that always takes additional code, which seems like unnecessary boilerplate.

Describe the solution you'd like

Vertical- and horizontal layout should provide some common configuration methods, so that they can be used in an easier manner, without breaking existing code.

For instance:

VerticalLayout - all these come without padding (which should be documented)

  • of(Components...) // simple alternative for the normal constructor
  • stretched(Components...) // align-items: stretched
  • centered(Components...) // align-items: centered (not sure if really a common case)

HorizontlLayout

  • of(Components...) // not sure if needed, since the normal HorizontalLayout has no padding
  • centered(Components...) // align-items: stretched)
  • baselined(Components...) // align-items: baseline)

Describe alternatives you've considered

Creating my own "Components" factory class, but this is something, that needs to be repeated for every project or using some 3rd party addon, that provides a fluent api.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions