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
feat(tabs): Introduce Tabs component #868
Conversation
Deploy preview for pf-next ready! Built with commit 39e1586 |
7dca75a
to
19f89db
Compare
This is looking good @andybraren But there are a few comments I have. First, to address your questions, yes, I agree that the hover state associated with secondary tabs is too light. @mceledonia can you take a look? Good question about whether we should have a "down" state between hover and selection. Do we have this as a distinct visual state for similar components (buttons for example)? I'll defer to Visual Design here. In comparing the implementation to the visual design, I feel like the border around the tabs is a little heavy. @mceledonia what do you think? Maybe it's just the way the PDF renders but want to make sure the border weight and color is correct. Finally, I'm thinking that the arrow keys should have a hover as well as a selected state. In general, anything that is clickable should have a hover state. |
A few hopefully quick visual changes, good eye @mcarrano . Border color Spacers Primary tab hover state Secondary tab hover state Arrow button hover state Pressed/Down State |
Thank you @mcarrano @mceledonia!
The current pressed/down state is the same as the hover state. I can remove this if we want. I have no idea if this is a possible scenario, but if there's ever a situation where the content of a tab is dependent on JavaScript/React pulling in stuff from elsewhere, some kind of state that indicates that the tab has been clicked but hasn't been populated yet might make sense. My thinking is that if the tab were to immediately switch to the regular unhovered/unclicked state, the user may interpret that as the tab "not working" the way that it should when it's actually just JS being a bit slow. Maybe it's a non-issue. |
Good point @andybraren . We will probably need some type of general "loading" state that can be applied in places like this. @LHinson do we have this in the backlog? If not I can open a new issue for this. |
798de4d
to
c62e2d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @andybraren . Thanks for making all those changes.
The tabs look great! In your original comment, you included this note:
When testing with JAWS, I have noticed that I’m copying the following from the Accessibility chapter in Smashing Book 6, from the section titled “Disabling Background Content”:
I found an example similar to what the author describes in this medium article. P.S. After skimming through the article I mentioned, they suggest that you could effectively hide elements from screen readers using Here are some other comments based on review:
|
@mattnolting will you help review this one as well? |
Thank you for your comments @jgiardino !
|
And updated every example to make use of it.
Box-shadow doesn’t appear in Windows’ high contrast mode, so this switches Tabs to use borders on ::before and ::after pseudo elements to achieve the same result. This change required significant restructuring of the SCSS file.
5f6bfe4
to
87d9e6e
Compare
Setting display: none; and visibility: hidden; has proven to be an effective way to hide scroll buttons from screen readers, so the hidden attribute is no longer necessary.
Removed outdated parts, updated accessibility and usage sections to reflect the latest structure.
I took another look at this. It looks good to me except that didn't we originally have a variant where the width of the tabs scaled to fit their container? I may be mistaken, but just wanted to check @andybraren and @mceledonia . |
Forgot to move the modifier, and adjusted the CSS
@mcarrano "Filled tabs" has been fixed, thank you for spotting that. |
Since we’re keeping sections to the primary example only, including aria-controls in other examples without corresponding sections was invalid.
I was just taking a quick look again at your latest updates, and noticed that you have a Also, a question that would be good to explore in the future is the relationship of the secondary tabs to the primary tabs. Would/should the secondary tabs be included within the tab panel of the primary tab? I think it's totally fine to leave the secondary tabs example as-is for now, and then later revisit it if we find that the react example is using a different html structure. Great job on this one!! |
@jgiardino Agreed, this is one of the last things to fix/figure out. I think @matthewcarleton wants to discuss component structuring with the larger group (should the first element always be the top-level component class?) and we could probably discuss secondary tab location as well. Thanks, and thank you and everyone else who reviewed for helping me fix things. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple more changes and it looks good to me
To keep primary and secondary tabs consistent, primary tabs now use flex rather than inline-flex as well. Also removed some redundant declarations.
Just in case the secondary tabs themselves are not directly adjacent to the primary, they can be contained so long as the modifier is present.
* 'master' of https://github.com/patternfly/patternfly-next: feat(tabs): Introduce Tabs component (#868) fix(progress): moves min-width to apply only to inside measure variant (#940) fix(page): create stacking context of page layout elements with header over the sidebar over the main area (#930)
This is an initial implementation of Tabs that resolves #30. The design spec for tabs is available here.
Implementation notes
The scrollbar isn't hidden. We'll need to discuss this. (EDIT: We did in Firefox doesn't hide scrollbar styles #859. We're keeping the scrollbar.)
The first example includes sample HTML for the
section
s that the tabs would control with the appropriaterole
,id
, andaria-labelledby
attributes. Is this fine? (EDIT: Yes.)CSS notes
The organization of the
SCSS
file could probably be improved. Tabs, secondary tabs, and the hover/focus/active states for each are all kinda interconnected.Some modifiers like
pf-m-tabs-scrollLeftVisible
are highly specific to Tabs so I included "tabs
" in their name. I’m guessing this should be changed to some existing convention? (EDIT: Per @mcoker's recommendation, they're now.pf-m-start
and '.pf-m-end`)Primary tabs need a 3px blue line above them when focused. Removing the existing
border-top
would make the tab’s text jump, soborder-top-color
is changed along with adding a 2pxbox-shadow
to achieve the desired effect. It works, but maybe there's a cleaner way? (EDIT: Yes, using::before
and::after
, which is now implemented)Questions
A parent container is necessary whenever secondary tabs are used in order to position the fixed scroll buttons correctly (see the example). Should this parent container become a requirement, even when secondary tabs aren’t used? (EDIT: This component no longer needs a container. Primary and secondary tabs are now independent, and secondary receives extra styling only when directly adjacent to primary.)
The hover and focus states weren’t fully specified in the design spec. The contrast of secondary tabs when hovered may not meet WCAG AA requirements. (EDIT: Fixed, now they should.)
I’m unsure whether tabs should use the same styling as
.pf-m-current
when focused/clicked, or if they should continue to look like their hover state until JS finishes loading the tab content and addspf-m-current
. If JS ever fails to load the content the tab shouldn't look active, right? (EDIT: The custom focus state has been removed in favor of the eventual universal focus state.)Future notes
Scroll buttons should probably fade in and out when activated, but because
display: none;
is needed to guarantee that they don’t appear to screen readers, adding that animation is a bit tricky.Page 2 of the design spec shows the tab separator stretching past the width of the content area while the tabs themselves stay within it. I’m not quite sure how this would be implemented. (EDIT: Probably some negative margin trickery. It'll be weird.)