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

DSD-1613: Pattern for string or JSX element values for component title/headingText props #1453

Merged
merged 16 commits into from
Nov 27, 2023

Conversation

EdwinGuzman
Copy link
Member

@EdwinGuzman EdwinGuzman commented Oct 30, 2023

Fixes JIRA ticket DSD-1613

This PR does the following:

  • Updates the following components to accept JSX.Element type values into their "title" prop: List, NewsletterSignup,
  • Updates the following components to accept JSX.Element type values into their "headingText" prop: AlphabetFilter, AudioPlayer, ComponentWrapper, SearchBar, VideoPlayer
  • Updates the Notification component to accept JSX.Element type values into its "notificationHeading" prop.
  • Updates the StructuredContent component to accept JSX.Element type values into its "headingText" and "calloutText" props.
  • Adds a new useDSHeading React hook to make the updates above easier to implement.

How has this been tested?

Locally in Storybook.

Accessibility concerns or updates

  • Should help potential issues where the default, hardcoded h2 could clash in an app's heading hierarchy.

Checklist:

  • I have updated the Storybook documentation accordingly.
  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.

Front End Review:

  • Review the Vercel preview deployment once it is ready.

@vercel
Copy link

vercel bot commented Oct 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nypl-design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 10:14pm

@EdwinGuzman EdwinGuzman added the In Progress Tickets or PRs that are being worked on. PRs marked as In Progress should not be merged. label Oct 30, 2023
@EdwinGuzman EdwinGuzman changed the title WIP: Dsd 1613/pattern for title DSD-1613: Pattern for string or JSX element values for component title/headingText props Nov 7, 2023
@EdwinGuzman EdwinGuzman added Needs Review Pull requests that are ready for peer review. and removed In Progress Tickets or PRs that are being worked on. PRs marked as In Progress should not be merged. labels Nov 7, 2023
Copy link
Collaborator

@bigfishdesign13 bigfishdesign13 left a 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.

src/components/NewsletterSignup/NewsletterSignup.mdx Outdated Show resolved Hide resolved
src/components/NewsletterSignup/NewsletterSignup.mdx Outdated Show resolved Hide resolved
src/components/List/List.tsx Show resolved Hide resolved
src/components/NewsletterSignup/NewsletterSignup.mdx Outdated Show resolved Hide resolved
src/components/Notification/Notification.mdx Outdated Show resolved Hide resolved
@bigfishdesign13 bigfishdesign13 added the Changes Requested Pull requests where changes have been requested in peer review. label Nov 8, 2023
@EdwinGuzman EdwinGuzman removed the Changes Requested Pull requests where changes have been requested in peer review. label Nov 9, 2023
Copy link
Collaborator

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

@bigfishdesign13 bigfishdesign13 added Ship It Pull requests that have been reviewed and approved. and removed Needs Review Pull requests that are ready for peer review. labels Nov 9, 2023
@EdwinGuzman
Copy link
Member Author

@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;
Copy link
Collaborator

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?

Copy link
Member Author

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. */
Copy link
Collaborator

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).

@@ -71,6 +74,30 @@ list renders `dt` and `dd` elements.

<Canvas of={ListStories.DescriptionList} />

## Description List with Custom Headings
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add link to TOC.

Copy link
Member Author

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.

@EdwinGuzman
Copy link
Member Author

@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(
Copy link
Member Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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

// They will not get any DS styling.
updatedTitle = title;
console.warn(
"NYPL Reservoir useDSHeading: An HTML heading element was passed " +
Copy link
Collaborator

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.

);
} else {
console.warn(
"NYPL Reservoir useDSHeading: A DS `Heading` component or an HTML " +
Copy link
Collaborator

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. 

@EdwinGuzman EdwinGuzman merged commit 639b867 into development Nov 27, 2023
4 checks passed
@EdwinGuzman EdwinGuzman deleted the DSD-1613/pattern-for-title branch January 31, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ship It Pull requests that have been reviewed and approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants