Skip to content
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

Grafana/ui: Unify flex shorthand props #77768

Merged
merged 3 commits into from
Nov 7, 2023
Merged

Conversation

Clarity-89
Copy link
Contributor

@Clarity-89 Clarity-89 commented Nov 7, 2023

Currently, the API between the Stack and Box components is inconsistent: Stack supports a flexGrow prop, while Box has a grow prop, which is then used to set the value of the flex shorthand property. Beyond this inconsistency, assigning only the grow value as the complete value of flex sets the shrink and basis implicitly. While this approach works fine in most cases, it creates some edge cases that are not immediately obvious. For instance, by setting flex: 1 on the element, flex-basis is set to 0, and this value will overwrite any width value on the component should we add those in the future (flex-basis, unless set to auto, has precedence over width). For this reason, it is better to be explicit when setting flex values.

What is this feature?

  • Unify the flex shorthand props across Box and Stack components.
  • Enable passing individual flex props (grow, shrink and basis) as well as the shorthand flex prop.
  • Move common types to a separate file.
  • Make the Stack story not to be internal-only.

Why do we need this feature?

Consistent API across the layout components.

Which issue(s) does this PR fix?:

Part of ##76516

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@Clarity-89 Clarity-89 added this to the 10.3.x milestone Nov 7, 2023
@Clarity-89 Clarity-89 self-assigned this Nov 7, 2023
@Clarity-89 Clarity-89 requested review from a team as code owners November 7, 2023 07:57
@Clarity-89 Clarity-89 requested review from dprokop, kaydelaney and eledobleefe and removed request for a team November 7, 2023 07:57
Copy link
Contributor

@JoaoSilvaGrafana JoaoSilvaGrafana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@Clarity-89 Clarity-89 merged commit e286a3a into main Nov 7, 2023
32 checks passed
@Clarity-89 Clarity-89 deleted the grafana-ui/unify-flex-props branch November 7, 2023 15:45
@aangelisc aangelisc modified the milestones: 10.3.x, 10.2.3 Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants