primer / react

An implementation of GitHub's Primer Design System using React
https://primer.style/guides/react
MIT License
3.02k stars 520 forks source link

Add expand to `NavList` #4686

Open TylerJDev opened 1 week ago

TylerJDev commented 1 week ago

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

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

Proposed API

Basic example:

<NavList>
  <NavList.Item href="#" aria-current="page">Item 1</NavList.Item>
  <NavList.Item href="#">Item 2</NavList.Item>
  <NavList.Expand label="Show more">
    <NavList.Item href="#">Item 3</NavList.Item>
    <NavList.Item href="#">Item 4</NavList.Item>
  </NavList.Expand>
</NavList>

Multiple expands:

<NavList>
  <NavList.Item href="#" aria-current="page">Item 1</NavList.Item>
  <NavList.Item href="#">Item 2</NavList.Item>
  <NavList.Expand label="Show more">
    <NavList.Item href="#">Item 3</NavList.Item>
    <NavList.Item href="#">Item 4</NavList.Item>
    <NavList.Expand label="Show more">
      <NavList.Item href="#">Item 5</NavList.Item>
      <NavList.Item href="#">Item 6</NavList.Item>
     </NavList.Expand>
  </NavList.Expand>
</NavList>

Group example (storybook)

Changelog

New

Rollout strategy

Testing & Reviewing

Merge checklist

changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: 3c0c94259decd22eba88563430eae274031c46e8

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[bot] commented 1 week ago

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 91.16 KB (+0.22% 🔺)
packages/react/dist/browser.umd.js 91.51 KB (+0.3% 🔺)
TylerJDev commented 4 days ago

Questions for reviewers!

TylerJDev commented 4 days ago

Would love any and all reviews from the team! This PR is serving mainly as a proposal to the NavList API, to add a new pattern/component. :grin:

Cc: @primer/engineer-reviewers

joshblack commented 1 day ago

Should we rename expand with something else

I'd love to try and come up with a descriptive name but it's definitely challenging 🤔 Maybe we could use NavList.ShowMoreItem to align with PVC? Which I think has the method: with_show_more_item