-
Notifications
You must be signed in to change notification settings - Fork 563
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
feat(Details): Add summary subcomponent #5015
Conversation
🦋 Changeset detectedLatest commit: e6ce3b3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
size-limit report 📦
|
There was a problem hiding this 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>, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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!
} | ||
] | ||
} | ||
] |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple noob questions here:
- Assuming this renders a
<button>
, is that still accessible with<details>
? - Just checking, does this also support ButtonProps like
size=small
and variant=primary`?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
There was a problem hiding this 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
👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/349552 |
Closes https://github.com/github/primer/issues/3518
Adds
Details.Summary
subcomponent that can be used withinDetails
for the summary and addssummary
prop toDetails
component which will render the supplied node within the newDetails.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
Details.Summary
subcomponentDetails.Summary
subcomponentChanged
Details.docs.json
to include data for newDetails.Summary
subcomponent and its propsDetails.Summary
subcomponent inDetails
storyDetails
component to render a defaultDetails.Summary
if one hasn't been supplied by authorDetails
component export to include newDetails.Summary
subcomponentDetails
tests to use newDetails.Summary
subcomponentRollout strategy
Testing & Reviewing
Details
storyMerge checklist