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 NavList.GroupHeading component #5106

Merged
merged 10 commits into from
Oct 22, 2024
Merged

Adds NavList.GroupHeading component #5106

merged 10 commits into from
Oct 22, 2024

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented Oct 10, 2024

We needed linked group headings when developing the new Primer docs. Instead of faking it by using ActionList.GroupHeading, we discussed updating the NavList API to allow rendering NavList.Group headings using NavList.GroupHeading instead of the more restrictive title prop: <NavList.Group title="Group title">

This was discussed in a weekly Primer patterns/API working sesh on Sept 24 2024 (notes)

The NavList group headings would be styled exactly the same except when they're hovered. The first group heading in this image is being hovered.
NavList with the first group heading hovered

Changelog

Adds NavList.GroupHeading component

New

NavList.GroupHeading component

Changed

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

Merge checklist

@mperrotti mperrotti requested a review from a team as a code owner October 10, 2024 17:57
Copy link

changeset-bot bot commented Oct 10, 2024

🦋 Changeset detected

Latest commit: 5765a19

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

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@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 Oct 10, 2024
Copy link
Contributor

github-actions bot commented Oct 10, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.02 KB (+0.12% 🔺)
packages/react/dist/browser.umd.js 97.35 KB (+0.11% 🔺)

@github-actions github-actions bot temporarily deployed to storybook-preview-5106 October 10, 2024 18:00 Inactive
Copy link
Contributor

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

The NavList group headings would be styled exactly the same except when they're hovered. The first group heading in this image is being hovered.

I'm seeing some different styles in the heading between the "With Group" and "With Group Heading Links" stories (mainly the color), wondering if that's intended :
image
image

Also wondering what would happen if a user used this in alongside the title prop (and if we even care to cover/prevent for that use case)

const GroupHeading: React.FC<NavListGroupHeadingProps> = ({sx: sxProp = defaultSxProp, ...rest}) => {
return (
<ActionList.GroupHeading
as="h3"
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) optional suggestion:
from line 285:

TODO: API update to give flexibility to NavList.Group title's heading level

Maybe this is a good opportunity to do that here? (take as as a prop that defaults to h3 and can be overriden if necessary). We could then use this same component for the title prop instead of ActionList.GroupHeading as well 🤔

Wouldn't make the title's prop heading level itself configurable, but might offer an alternative manually through the new GroupHeading

@mperrotti
Copy link
Contributor Author

I'm seeing some different styles in the heading between the "With Group" and "With Group Heading Links" stories (mainly the color), wondering if that's intended

This is an intentional style change we decided to make last week.


Also wondering what would happen if a user used this in alongside the title prop (and if we even care to cover/prevent for that use case)

Great question! I'll look into this and add some guards to prevent undesired results.

Comment on lines +304 to +313
sx={merge<SxProp['sx']>(
{
'> a {': {
color: 'var(--fgColor-default)',
textDecoration: 'inherit',
':hover': {textDecoration: 'underline'},
},
},
sxProp,
)}
Copy link
Member

Choose a reason for hiding this comment

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

Do we still want to use sx here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it possible to use regular CSS for component styling in PRC yet?

Copy link
Member

Choose a reason for hiding this comment

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

If you're adding new styles I think it's safe to go directly to CSS modules. The risk is entirely around the fact that there could be other styles in dotcom relying on the existing sx styling architecture.

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but we should consider if we want to use sx or not.

Copy link
Contributor

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🚀

@mperrotti mperrotti added this pull request to the merge queue Oct 22, 2024
Merged via the queue into main with commit 851c857 Oct 22, 2024
43 checks passed
@mperrotti mperrotti deleted the mp/navlist-groupheading branch October 22, 2024 20:05
@primer primer bot mentioned this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants