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

fix(tab-title): tabs center when set to layout='center' #7026

Merged
merged 13 commits into from
May 26, 2023

Conversation

Elijbet
Copy link
Contributor

@Elijbet Elijbet commented May 24, 2023

Related Issue: #7025

Summary

Enhancement to tab-title to make it optionally closable introduced structural changes that caused a regression in the tab alignment when centered.

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label May 24, 2023
@Elijbet Elijbet marked this pull request as ready for review May 25, 2023 00:16
@Elijbet Elijbet requested a review from a team as a code owner May 25, 2023 00:16
@Elijbet Elijbet added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label May 25, 2023
@@ -7,7 +7,9 @@
:host([layout="center"]) {
@apply my-0 mx-5 text-center;
flex-basis: theme("spacing.48");
margin: auto;
.content {
@apply m-auto;
Copy link
Contributor

Choose a reason for hiding this comment

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

given that there's no difference between margin: auto and @apply m-auto I'd recommend using margin: auto it's more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we're using tailwind for now, it makes sense to stick to tailwind classes if they are available, for consistency. This is what we've been doing so far. Also, overlapping uses of tailwind and regular css props might create oversight doubling use of both by accident.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, lets keep tailwind for now for consistency. Hopefully we can remove tailwind in the future.

@macandcheese
Copy link
Contributor

macandcheese commented May 25, 2023

Can we add some additional screenshot tests for some more specific pre-configured cases like centered + closable, closable + bordered + centered, to hopefully catch some of these?

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

👍

@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 25, 2023
@jcfranco jcfranco added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 25, 2023
@Elijbet
Copy link
Contributor Author

Elijbet commented May 25, 2023

Can we add some additional screenshot tests for some more specific pre-configured cases like centered + closable, closable + bordered + centered, to hopefully catch some of these?

Adding these tests revealed some mismatch with the centering with regards to Figma. There are various ways to center text/icon and the x button within a tab, as discussed with @macandcheese.

We were wondering what to prioritize: matching the Figma design to make it absolutely centered (but with variable padding to offset for added close button width), or making sure the text/icon is centered between the edge of the tab and the close button. I've applied the latter for your review @SkyeSeitz @ashetland

@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 25, 2023
Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

🦭 Seal of approval! ☑️ 👍 💯 👏

@@ -7,7 +7,9 @@
:host([layout="center"]) {
@apply my-0 mx-5 text-center;
flex-basis: theme("spacing.48");
margin: auto;
.content {
@apply m-auto;
Copy link
Member

Choose a reason for hiding this comment

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

Agreed, lets keep tailwind for now for consistency. Hopefully we can remove tailwind in the future.

@@ -190,11 +192,21 @@
}
}

:host([closable]) {
.content {
padding-inline-start: 1.5rem;
Copy link
Member

Choose a reason for hiding this comment

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

@alisonailea @Elijbet are there any tokens we can use as values for these paddings?f

Copy link
Member

Choose a reason for hiding this comment

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

If this padding should be referenced from theme()/tailwind we could do it as a followup.

Copy link
Contributor Author

@Elijbet Elijbet May 25, 2023

Choose a reason for hiding this comment

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

Let me see what design says about the centering approach in general (will determine the padding amount) and yeah that would be the next question.

@SkyeSeitz
Copy link

SkyeSeitz commented May 26, 2023

Let's prioritize absolutely centering the Tab Titles with variable padding to offset for added close button width.

small x-button offset: 24px; core.sizing.9
medium x-button offset: 24px; core.sizing.9
large x-button offset: 32px; core.sizing.11

Secondly, I would propose truncating the text when it reaches 8px away from the x-button at all scales. Not sure if this is in scope for this particular issue, though, but this is a better behavior than the current wrapping.
image

@Elijbet
Copy link
Contributor Author

Elijbet commented May 26, 2023

Secondly, I would propose truncating the text when it reaches 8px away from the x-button at all scales. Not sure if this is in scope for this particular issue, though, but this is a better behavior than the current wrapping.

I'll open a separate issue for the truncation, as it would need to have the tooltip applied for sighted users, just like the truncated button does.

@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 26, 2023
@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 26, 2023
@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 26, 2023
@Elijbet Elijbet added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 26, 2023
:host([layout="center"][closable]) {
.content {
padding-inline-start: 32px; //28px button width + 0.25rem padding
}
Copy link
Contributor Author

@Elijbet Elijbet May 26, 2023

Choose a reason for hiding this comment

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

Can I get guidance on how to implement tokens here?
eg. padding-inline-start: var(--core-sizing-11);
This doesn't seem to take any effect.

Or is it something we could do as a follow-up like you said earlier @driskull?

@alisonailea @jcfranco

Copy link
Member

Choose a reason for hiding this comment

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

@Elijbet this is good for the release. Can you open an issue to address this by using our design tokens/tailwind for this padding? Ideally both the button width and padding should be tied to variables.

@Elijbet Elijbet merged commit 0bd677b into master May 26, 2023
@Elijbet Elijbet deleted the elijbet/7025-fix-tab-title-regression-center-layout branch May 26, 2023 15:43
@github-actions github-actions bot added this to the 1.4.1 May patch - Bugs only milestone May 26, 2023
Elijbet added a commit that referenced this pull request May 27, 2023
…he width of `tab-nav` (#7047)

**Related Issue:** #7025 

## Summary

Follow-up to fix to #7026.

Centered `tabs` should spread the `tab-titles` evenly to extend across
the entire width of `tab-nav`, as opposed to `inline tab-titles` that
only justify against the start of `tab-nav` width.

Added coverage for both `centeredTabsAreEvenlyJustifiedAcrossNavWidth`
and `inlineTabsJustifyAgainstTheStartOfTheNavWidth`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants