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

Add expand to NavList #4686

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

Add expand to NavList #4686

wants to merge 50 commits into from

Conversation

TylerJDev
Copy link
Collaborator

@TylerJDev TylerJDev commented Jun 19, 2024

Adds new component NavList.ShowMoreItem, allows native support for "expanding" content within a NavList.

Closes https://github.com/github/primer/issues/2637

Proposed API

Basic example:

export const WithExpand = () => {
  const items = [
    {href: '#', text: 'Item 4'},
    {href: '#', text: 'Item 5'},
    {href: '#', text: 'Item 6'},
    {href: '#', text: 'Item 7'},
    {href: '#', text: 'Item 8'},
    {href: '#', text: 'Item 9'},
  ]

  return (
    <NavList>
      <NavList.Item href="#" aria-current="page">
        Item 1
      </NavList.Item>
      <NavList.Item href="#">Item 2</NavList.Item>
      <NavList.Item href="#">Item 3</NavList.Item>
      <NavList.GroupExpand label="Show more" items={items} />
    </NavList>
  )
}

Multiple expands:

export const ExpandWithPages = () => {
  const items = [
    {href: '#', text: 'Item 4'},
    {href: '#', text: 'Item 5'},
    {href: '#', text: 'Item 6'},
    {href: '#', text: 'Item 7'},
    {href: '#', text: 'Item 8'},
    {href: '#', text: 'Item 9'},
  ]

  return (
    <NavList>
      <NavList.Item href="#" aria-current="page">
        Item 1
      </NavList.Item>
      <NavList.Item href="#">Item 2</NavList.Item>
      <NavList.Item href="#">Item 3</NavList.Item>
      <NavList.GroupExpand pages={2} label="Show more" items={items} />
    </NavList>
  )
}

Group example (storybook)

Changelog

New

  • Adds new component NavList.ShowMoreItem

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

Merge checklist

Copy link

changeset-bot bot commented Jun 19, 2024

🦋 Changeset detected

Latest commit: c94d612

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

Copy link
Contributor

github-actions bot commented Jun 19, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 106.02 KB (+0.24% 🔺)
packages/react/dist/browser.umd.js 106.33 KB (+0.15% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 19, 2024 19:32 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 19, 2024 19:49 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 19, 2024 20:15 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 20, 2024 15:42 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 21, 2024 18:24 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 21, 2024 19:26 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 25, 2024 12:33 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 June 25, 2024 13:10 Inactive
trailingVisual?: Icon | string
leadingVisual?: Icon | string
trailingAction?: ActionListTrailingActionProps
'data-expand-focus-target'?: string
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would love to not have to express this in GroupItems, as we don't want consumers adding this data-* attribute themselves. The only reason I have it here is so TS doesn't yell at me for adding it in itemArr['data-expand-focus-target'] = focusTarget.

Comment on lines +440 to +441
const teamEnabled = useFeatureFlag('primer_react_css_modules_team')
const staffEnabled = useFeatureFlag('primer_react_css_modules_staff')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Have to utilize this to account for both ActionList and NavList FFs.

@TylerJDev TylerJDev requested a review from joshblack February 12, 2025 15:36
@TylerJDev
Copy link
Collaborator Author

@joshblack, should be ready for another review! I moved towards the data API that you suggested, and it seems to work great! Let me know if you have any suggestions or ways to improve it! 😁

@github-actions github-actions bot requested a deployment to storybook-preview-4686 February 21, 2025 14:18 Abandoned
@github-actions github-actions bot requested a deployment to storybook-preview-4686 February 21, 2025 14:28 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-4686 February 21, 2025 14:41 Inactive
@TylerJDev TylerJDev requested a review from joshblack February 21, 2025 14:48
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Congrats on putting this together! Just left a comment but approving since it's non-blocking 👍

Co-authored-by: Josh Black <joshblack@github.com>
@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/363691

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Feb 21, 2025
@primer-integration
Copy link

🟢 golden-jobs completed with status success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants