Skip to content

Add arrangement solution to the component library #13

@huyenltnguyen

Description

@huyenltnguyen

Describe the issue

During freeCodeCamp/freeCodeCamp#52092, I found that the ui-components buttons don't automatically space out when they stack on top of each other, and the library also doesn't have a prop or a component to handle this sort of arrangement.

Comparison:

Bootstrap ui-components
Screenshot 2023-12-19 at 18 30 11 Screenshot 2023-12-19 at 18 29 59

To unblock the migration, I temporarily used the Spacer component in /learn to manually add a gap between the buttons (see freeCodeCamp/freeCodeCamp#52577).

Solution

Some approaches off the top of my head:

  1. Mimic Bootstrap implementation and add spacing logic to the Button component
  2. Build a new component component in ui-components that handles layout arrangement, including direction (vertical and horizontal) and content spacing

My thoughts:
I'm personally against (1). I think atomic components such as Button should be made as dumb as possible, and they shouldn't be aware of their layout context to compute their styles.

That leaves me with option (2). I would call this new component Container as the described responsibilities fit the name. However, we already have a Container component in ui-components, which at the moment is just a wrapper that controls width and pads its content. So we would need to either find a new name for this component or update Container to support these capabilities.

References

How Bootstrap handles the button spacing: https://github.com/twbs/bootstrap/blob/f17f882df292b29323f1e1da515bd16f326cee4a/less/buttons.less#L156-L159

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: discussingUnder discussion threads. Closed as stale after 60 days of inactivity.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions