Skip to content

Add expand to NavList - #4686

Merged
TylerJDev merged 51 commits into
mainfrom
add-expand-to-navlist
Feb 24, 2025
Merged

Add expand to NavList#4686
TylerJDev merged 51 commits into
mainfrom
add-expand-to-navlist

Conversation

@TylerJDev

@TylerJDevTylerJDev commented Jun 19, 2024

Copy link
Copy Markdown
Member

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

Closeshttps://github.com/github/primer/issues/2637

Proposed API

Basic example:

exportconstWithExpand=()=>{constitems=[{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.Itemhref="#"aria-current="page">
Item 1
</NavList.Item><NavList.Itemhref="#">Item 2</NavList.Item><NavList.Itemhref="#">Item 3</NavList.Item><NavList.GroupExpandlabel="Show more"items={items}/></NavList>)}

Multiple expands:

exportconstExpandWithPages=()=>{constitems=[{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.Itemhref="#"aria-current="page">
Item 1
</NavList.Item><NavList.Itemhref="#">Item 2</NavList.Item><NavList.Itemhref="#">Item 3</NavList.Item><NavList.GroupExpandpages={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

@changeset-bot

changeset-botBot commented Jun 19, 2024

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactMinor

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-actionsBot commented Jun 19, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js106.02 KB (+0.24% 🔺)
packages/react/dist/browser.umd.js106.33 KB (+0.15% 🔺)

@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 19, 2024 19:32 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 19, 2024 19:49 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 19, 2024 20:15 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 20, 2024 15:42 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 21, 2024 18:24 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 21, 2024 19:26 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 25, 2024 12:33 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 June 25, 2024 13:10 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4686 February 4, 2025 21:50 Inactive
trailingVisual?: Icon | string
leadingVisual?: Icon | string
trailingAction?: ActionListTrailingActionProps
'data-expand-focus-target'?: string

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
MemberAuthor

@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! 😁

Comment threadpackages/react/src/NavList/NavList.tsx Outdated
Comment threadpackages/react/src/NavList/NavList.tsx Outdated
Comment threadpackages/react/src/NavList/NavList.tsx Outdated
Comment threadpackages/react/src/NavList/NavList.tsx Outdated
Comment threadpackages/react/src/NavList/NavList.tsx Outdated

@joshblackjoshblack left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@primer-integration

Copy link
Copy Markdown

🟢 golden-jobs completed with status success.

@github-actions

Copy link
Copy Markdown
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!

@primerprimerBot mentioned this pull request Feb 24, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passingChanges 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

@TylerJDev@joshblack@lesliecdubs@khiga8