-
Notifications
You must be signed in to change notification settings - Fork 6
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
DSD-1613: Pattern for string or JSX element values for component title/headingText props #1453
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…to allow JSX.Element types
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.
Overall, this looks great, but there are a few things that need to be cleaned up. Please see my comments.
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.
Looks good!
@oliviawongnyc @jackiequach can you please review this when you get a chance. |
@@ -21,7 +21,7 @@ export interface AlphabetFilterProps { | |||
/** Value used to set the text for a `Text` component that will be displayed above the letter buttons. */ | |||
descriptionText?: string | JSX.Element; | |||
/** Value used to set the text for a `Heading` component. */ | |||
headingText?: string; | |||
headingText?: string | JSX.Element; |
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.
Should a warning be logged when a non-Heading component is passed?
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.
Hmm yes...
@@ -21,7 +21,7 @@ export interface AlphabetFilterProps { | |||
/** Value used to set the text for a `Text` component that will be displayed above the letter buttons. */ | |||
descriptionText?: string | JSX.Element; | |||
/** Value used to set the text for a `Heading` component. */ |
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.
Update docstring to reflect changes (similarly for the other components).
src/components/List/List.mdx
Outdated
@@ -71,6 +74,30 @@ list renders `dt` and `dd` elements. | |||
|
|||
<Canvas of={ListStories.DescriptionList} /> | |||
|
|||
## Description List with Custom Headings |
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.
Add link to TOC.
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.
Making this a level 3 subheading so not adding it to TOC and removing the other one that was a level 2.
…TML heading elements are passed
@jackiequach good points. I updated the comment docstring. |
// If the user passed in an HTML heading element, just use that. | ||
// They will not get any DS styling. | ||
updatedTitle = title; | ||
console.warn( |
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.
@jackiequach @bigfishdesign13 I am logging two warnings:
1 - one where an HTML heading element is passed,
2 - one for non-DS Heading
or HTML heading elements are passed.
The wording could be better. What do you think? Also added tests for these.
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.
These are very relevant warning messages. I just made some suggetions for the wording.
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.
Looks good to me!
// They will not get any DS styling. | ||
updatedTitle = title; | ||
console.warn( | ||
"NYPL Reservoir useDSHeading: An HTML heading element was passed " + |
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.
I think the message could use a little clarification.
An HTML heading element was passed for the `title` or `headingText` prop in a Reservoir component. The heading will render without DS-specific styling.
src/hooks/useDSHeading.tsx
Outdated
); | ||
} else { | ||
console.warn( | ||
"NYPL Reservoir useDSHeading: A DS `Heading` component or an HTML " + |
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.
Similarly...
NYPL Reservoir useDSHeading: An unsupported heading element was passed to the `title` or `headingText` prop in a Reservoir component, so that component's title will not be rendered. Instead, a DS `Heading` component or an HTML heading element should be passed.
Fixes JIRA ticket DSD-1613
This PR does the following:
JSX.Element
type values into their"title"
prop:List
,NewsletterSignup
,JSX.Element
type values into their"headingText"
prop:AlphabetFilter
,AudioPlayer
,ComponentWrapper
,SearchBar
,VideoPlayer
Notification
component to acceptJSX.Element
type values into its"notificationHeading"
prop.StructuredContent
component to acceptJSX.Element
type values into its"headingText"
and"calloutText"
props.useDSHeading
React hook to make the updates above easier to implement.How has this been tested?
Locally in Storybook.
Accessibility concerns or updates
h2
could clash in an app's heading hierarchy.Checklist:
Front End Review: