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

feat(Details): Add summary subcomponent #5015

Conversation

francinelucca
Copy link
Member

@francinelucca francinelucca commented Sep 24, 2024

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

Adds Details.Summary subcomponent that can be used within Details for the summary and adds summary prop to Details component which will render the supplied node within the new Details.Summary subcomponent. Also adds a default "See Details" summary value to be rendered to improve accessibility in case authors fail to supply one.

Changelog

New

  • Adds Details.Summary subcomponent
  • Adds tests for new Details.Summary subcomponent

Changed

  • Updates Details.docs.json to include data for new Details.Summary subcomponent and its props
  • Use new Details.Summary subcomponent in Details story
  • Refactor Details component to render a default Details.Summary if one hasn't been supplied by author
  • Rewrite Details component export to include new Details.Summary subcomponent
  • Update Details tests to use new Details.Summary subcomponent

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

  • Verify no visual/behavioral regressions in deploy preview Details story
  • All tests should pass sniff test and CI

Merge checklist

Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: e6ce3b3

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

@francinelucca francinelucca added the staff Author is a staff member label Sep 24, 2024
@github-actions github-actions bot temporarily deployed to storybook-preview-5015 September 24, 2024 15:38 Inactive
Copy link
Contributor

github-actions bot commented Sep 24, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.94 KB (+0.19% 🔺)
packages/react/dist/browser.umd.js 98.25 KB (+0.21% 🔺)

@francinelucca francinelucca changed the title fix(Details): Add summary prop and subcomponent feat(Details): Add summary prop and subcomponent Sep 24, 2024
@github-actions github-actions bot temporarily deployed to storybook-preview-5015 September 24, 2024 18:48 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-5015 September 24, 2024 19:01 Inactive
@francinelucca francinelucca marked this pull request as ready for review September 24, 2024 21:01
@francinelucca francinelucca requested a review from a team as a code owner September 24, 2024 21:01
Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

This is really good and thorough work!

Mostly clarifying questions, 1 suggestion

<Details summary="test summary" data-testid="details">
<Details.Summary>custom summary</Details.Summary>
content
</Details>,
Copy link
Member

Choose a reason for hiding this comment

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

(non blocker) Should this also be a dev warning? example of warning

Copy link
Member Author

Choose a reason for hiding this comment

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

superseeded by bac525a

)

expect(queryByText('See Details')).toBeNull()
expect(getByTestId('summary')).toBeInTheDocument()
Copy link
Member

Choose a reason for hiding this comment

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

(just a note) TIL you can't getByRole('summary'), it's inferred as a button instead!

}
]
}
]
Copy link
Member

@siddharthkp siddharthkp Oct 2, 2024

Choose a reason for hiding this comment

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

(blocking) summary prop is missing from docs.

Curious, should we prefer adding just 1 approach instead of both <Details summary> and <Details.Summary>? To me, <Details.Summary> feels like the closest replacement for <summary>, which feels complete.

Would like to hear your thoughts on the 2 approaches though!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thought about this and I agree with you. I think originally I was going for the "maximize ease-of-use" approach but in hindsight this might be confusing and adds extra complexity with having to support the intersection of both strategies (Re: your comment here).

Going to refactor to just introduce Details.Summary and render a default one if one isn't present, that feels right-er to me as well.
Wondering, do you think that would warrant a warning as well? (The use case where a Details component is used but neither Details.Summary nor a native summary is present within the children).

@@ -12,7 +12,7 @@ export const Default: StoryFn<typeof Details> = () => {
const {getDetailsProps} = useDetails({closeOnOutsideClick: true})
return (
<Details {...getDetailsProps()}>
<Button as="summary">See Details</Button>
<Details.Summary as={Button}>See Details</Details.Summary>
Copy link
Member

Choose a reason for hiding this comment

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

Couple noob questions here:

  1. Assuming this renders a <button>, is that still accessible with <details>?
  2. Just checking, does this also support ButtonProps like size=small and variant=primary`?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Note sure what accessible with details means 😅, here's how/what it renders:
image is there some specific behavior you want me to test for here?
  1. Had to fiddle with the types a little but yeah those work:
image image

…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
@francinelucca francinelucca added 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 labels Oct 23, 2024
…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Great!

…does-not-provide-appropriate-structure-by-default
@primer-integration
Copy link

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

@jonrohan jonrohan requested a review from siddharthkp October 31, 2024 21:44
@francinelucca francinelucca removed the request for review from siddharthkp October 31, 2024 21:47
@jonrohan jonrohan dismissed siddharthkp’s stale review October 31, 2024 21:47

Changes addressed

@francinelucca francinelucca added this pull request to the merge queue Oct 31, 2024
Merged via the queue into main with commit 1473c26 Oct 31, 2024
43 checks passed
@francinelucca francinelucca deleted the francinelucca/fix/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default branch October 31, 2024 21:54
@primer primer bot mentioned this pull request Oct 31, 2024
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 staff Author is a staff member status: review needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants