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

Adds UnderlinePanels to drafts/ #4550

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Adds UnderlinePanels to drafts/ #4550

wants to merge 25 commits into from

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented May 1, 2024

Relates to https://github.com/github/primer/issues/3108

This component is visually identical to UnderlineNav. The biggest differences are:

  • These are tabs as behave as such
  • It cannot be used as a controlled component
  • No responsive overflow menu (issue)
Kapture.2024-05-01.at.16.34.03.mp4

Changelog

New

Adds UnderlinePanels component

Changed

Refactors UnderlineNav to share component styles with UnderlinePanels

Removed

Nothing removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

This should more or less behave like PVC's UnderlinePanels

Merge checklist

stylistic tweaks

more stylistic tweaks
Copy link

changeset-bot bot commented May 1, 2024

🦋 Changeset detected

Latest commit: 0f0b58c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot temporarily deployed to storybook-preview-4550 May 2, 2024 18:39 Inactive
@mperrotti mperrotti requested a review from keithamus May 2, 2024 18:39
@mperrotti
Copy link
Contributor Author

Added @keithamus as a reviewer since he's familiar with @github/tab-container-element, which does a lot of the heavy-lifting here.

@mperrotti mperrotti marked this pull request as ready for review May 2, 2024 18:40
@mperrotti mperrotti requested a review from a team as a code owner May 2, 2024 18:40
@github-actions github-actions bot temporarily deployed to storybook-preview-4550 May 2, 2024 18:48 Inactive
Copy link
Contributor

github-actions bot commented May 3, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 89.52 KB (+0.25% 🔺)
packages/react/dist/browser.umd.js 89.74 KB (+0.24% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-4550 May 3, 2024 14:00 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4550 May 3, 2024 14:26 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4550 May 3, 2024 16:25 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4550 May 9, 2024 15:12 Inactive
Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

Reviewed the UnderlineNav intersection and I like the way you extracted the common styles and love the interface as well ✨ Left a naming suggestion and a few minor comments but other than no concern on UnderlineNav 🙌🏻

@@ -7,7 +7,7 @@
"importPath": "@primer/react",
"props": [
{
"name": "afterSelect",
"name": "onSelect",
Copy link
Member

Choose a reason for hiding this comment

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

Ahh must have forgotten to update this, thank you!


Adds UnderlinePanels component. It's like UnderlineNav, but for rendering semantic tabs instead of links.

<!-- Changed components: UnderilnePanels -->
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need the specify the changed components anymore since Primer notifications project is abandoned.

import useLayoutEffect from '../utils/useIsomorphicLayoutEffect'
import {defaultSxProp} from '../utils/defaultSxProp'
import Link from '../Link'
import {UnderlineTab} from '../internal/components/UnderlineTabbedInterface'
Copy link
Member

Choose a reason for hiding this comment

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

How would you feel about renaming this to UnderlineItem? It feels a bit misleading to me have the "tab" in underlinenav.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think UnderlineTab might be clearer since the children behave as role=tab and and role=tabpanel

Copy link
Member

Choose a reason for hiding this comment

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

I am confused. I think this is shared between UnderlineNav and UnderlinePanel, isn't it? And in this file, UnderlineTab doesn't have a role tab or tabpanel - let me know if I am missing something!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I misunderstood your comment! UnderlineItem works great.

Copy link
Member

Choose a reason for hiding this comment

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

No worries!

"name": "UnderlinePanels",
"status": "draft",
"a11yReviewed": false,
"stories": [
Copy link
Member

Choose a reason for hiding this comment

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

I think we can still keep these story ids but we don't actually need to specify. The build script pulls out feature stories by default

${sx};
`

export const StyledUnderlineTabList = styled.ul`
Copy link
Member

Choose a reason for hiding this comment

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

Similar naming suggestion: to make it more generic, how would you feel about renaming this to StyledUnderlineList?

@broccolinisoup
Copy link
Member

I couldn't reproduce the tiny layout shift of UnderlineNav.Item's counters and icons in a real browser, so I updated UnderlineNav snapshots. If anybody can reproduce, I can make more changes and re-update snapshots.

I couldn't reproduce it either 😞

Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

In my initial review, I only focused on the UnderlineNav but this time went over the changes of UnderlinePanel. I left some comments/questions! Looking forward to hearing what you think 🙌🏻

Also I think we should run integration tests at dotcom mainly to make sure we didn't break anything in UnderlineNav

/**
* Whether this is the selected tab
*/
'aria-selected'?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should also add aria-controls attribute to each tab and associate the values to their respective panels. (based on APG Tab Pattern) but also there is not enough support for aria-controls 🤔 What are your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't use aria-controls for other tabs, so I wouldn't introduce it here. For example, we don't attempt setting aria-controls in @github/tab-container-element


export const WithIcons = () => (
<UnderlinePanels aria-label="Tabs with icons">
<UnderlinePanels.Tab icon={CodeIcon}>Code</UnderlinePanels.Tab>
Copy link
Member

Choose a reason for hiding this comment

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

This is nitpick but how about using tab panel examples from dotcom or just tab1, tab2 etc? Because Code, Issues etc are navigational items and I feel we might mislead folks by using our core navigational usages for tab panels examples. Let me know what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great call. Will update.

)

export const WithIconsHiddenOnNarrowScreen = () => (
<UnderlinePanels aria-label="Tabs with icons">
Copy link
Member

Choose a reason for hiding this comment

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

I experience flickering in this story and ot might not be specific to only this story though but not sure why it happens. When I resize a scroll bar (I think?) appears for a hot second and then drops the icons. Sharing a screen recording, let me know what you think

Video preview describes the behaviour I mentioned just above

Rewatch.Screen.Recording.-.2024-05-21.at.4.19.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how we'd get around this and keep the tablist scrollable. This can be something we tackle when/if we introduce the same overflow behavior we have for UnderilneNav.

I wouldn't consider this a blocker, but would you or other reviewers?

Comment on lines 75 to 76
const defaultId = useId()
const parentId = props.id ?? defaultId
Copy link
Member

Choose a reason for hiding this comment

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

I think we can give the custom id as a param to the hook like const parentId = useId(props.id) to make it use the custom one. I find it cleaner that way but totally up to you 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yea I forgot we could do that. Will update.

@mperrotti
Copy link
Contributor Author

Reviewers: I'll be out for 2 weeks. Please merge if this gets approved before I'm back.

@mperrotti
Copy link
Contributor Author

Snapshots need to be updated again since we changed text in stories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants