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

Merged
merged 51 commits into from
Feb 24, 2025
Merged

Add expand to NavList #4686

merged 51 commits into from
Feb 24, 2025

Conversation

TylerJDev
Copy link
Member

@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

Sorry, something went wrong.

Copy link

changeset-bot bot commented Jun 19, 2024

🦋 Changeset detected

Latest commit: d22f63f

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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@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
@TylerJDev TylerJDev requested a review from hectahertz February 13, 2025 16:45
@github-actions github-actions bot requested a deployment to storybook-preview-4686 February 21, 2025 14:18 Abandoned

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@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 👍

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
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.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 24, 2025
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@github-actions github-actions bot removed the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 24, 2025
@TylerJDev TylerJDev merged commit 6b137a4 into main Feb 24, 2025
44 checks passed
@TylerJDev TylerJDev deleted the add-expand-to-navlist branch February 24, 2025 22:20
@primer primer bot mentioned this pull request Feb 24, 2025
hectahertz pushed a commit that referenced this pull request Mar 20, 2025
* Add expand to `NavList`

* Improved semantics

* Remove styles

* Add extra story

* Add unit test coverage

* Add Group unit test coverage

* Add e2e test coverage

* Add expanded to groups

* Fix import

* Change structure

* Update stories, add ref

* Update tests, add focus target

* Add changeset

* Remove `GroupContent`

* Update to use context

* Add useRef usage

* Change name to `NavList.ShowMoreItem`

* Update docs

* test(vrt): update snapshots

* Update .changeset/many-rivers-deny.md

Co-authored-by: Josh Black <joshblack@github.com>

* Address some feedback

* Memoize id value

* Update w/ new prop `Pages` based on suggestion from Primer patterns

* test(vrt): update snapshots

* Remove story

* Remove story test

* Remove the correct story

* Add condition for css modules feature flag

* Update tests, docs, add ternary

* Only allow for `Item` in `ShowMoreItem`

* Fix lint issue

* Add dependencies

* Remove comment

* Add data API

* Some clean up for `NavList`

* More clean up

* Use `useMemo` instead

* Update docs

* Fix tests

* Remove auto-import

* Add `key` to story

* PR review feedback

* Type check

* Update packages/react/src/NavList/NavList.tsx

Co-authored-by: Josh Black <joshblack@github.com>

---------

Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com>
Co-authored-by: TylerJDev <TylerJDev@users.noreply.github.com>
Co-authored-by: Josh Black <joshblack@github.com>
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.

None yet

4 participants