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

[Empty States] Make description and title optional #2744

Closed
Supamiu opened this issue Apr 18, 2024 · 2 comments · Fixed by #2774
Closed

[Empty States] Make description and title optional #2744

Supamiu opened this issue Apr 18, 2024 · 2 comments · Fixed by #2774
Labels
🔨 Technical Doesn't affect the output (refactor, dependencies update, cleaning, etc.)
Milestone

Comments

@Supamiu
Copy link
Contributor

Supamiu commented Apr 18, 2024

Problem

In some empty states, we may want just a description or just a title, but at the moment, both of them are required, which means we end up with one of them still present inside the DOM but empty, with all the style applied to it (use case described by @fbasmaison-lucca)

Possible solutions

The ideal solution would be to have "at least one of them required" but that's not possible with the current tooling that Angular exposes regarding Inputs. Our solution would be to make both of them optional and rely on devs to see that if they don't provide any, well the component is empty and makes no sense.

@Supamiu Supamiu added the 🔨 Technical Doesn't affect the output (refactor, dependencies update, cleaning, etc.) label Apr 18, 2024
@fbasmaison-lucca
Copy link
Contributor

fbasmaison-lucca commented Apr 22, 2024

The solution I chose in CSS so far is to use :empty and hide them.

%hide-empty {
  &:empty {
    display: none;
  }
}

.emptyState-content-heading {
  []
  @extend %hide-empty;
  []
}

.emptyState-actions,
.emptyState-content-text p {
  @extend %hide-empty;
}

@fbasmaison-lucca
Copy link
Contributor

fbasmaison-lucca commented May 3, 2024

Would it be relevant to reset the paragraph’s bottom margin, and instead apply it to the buttons’s wrapper if they exist? This would:

  • avoid having to overwrite the component to delete the extraneous margin if there is no action,
  • avoid having to add a margin to add spacing for the buttons if there is no description.

Something along these lines?

.emptyState-content-description {
  margin-bottom: 0;
}

* + .emptyState-actions {
  margin-top: var(--pr-t-spacings-200);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Technical Doesn't affect the output (refactor, dependencies update, cleaning, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants