Skip to content

Conversation

jcfilben
Copy link
Collaborator

What does this PR do?

Adds a new prop calendar[size].headingSize to the theme. Specifying this prop will override the calendar.heading.level prop and change the calendar to use <Text> instead of <Heading> to display the date and year. This prop also gives the flexibility to specify different font sizes for each calendar size (small, medium, and large).

In addition to this PR I will file a PR on grommet-theme-hpe to opt into this behavior for the hpe theme.

Where should the reviewer start?

What testing has been done on this PR?

Added a jest test and tested by adding a custom theme to calendar stories

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Related to #6637

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Yes, we need to document the new theme prop as well as mention that using calendar[size].headingSize is preferred over calendar.heading.level

Should this PR be mentioned in the release notes?

Yes

Is this change backwards compatible or is it a breaking change?

Backwards compatible

@jcfilben jcfilben requested a review from taysea February 14, 2023 19:19
@taysea
Copy link
Collaborator

taysea commented Feb 15, 2023

I'm wondering if headingSize might be a little misleadinng since it's not actually a Heading -- will people assume that their theme's Heading sizes would be used instead of text?

@jcfilben
Copy link
Collaborator Author

I'm wondering if headingSize might be a little misleadinng since it's not actually a Heading -- will people assume that their theme's Heading sizes would be used instead of text?

Good note, I'll see if I can find a different name for this

@jcfilben
Copy link
Collaborator Author

I'm wondering if headingSize might be a little misleadinng since it's not actually a Heading -- will people assume that their theme's Heading sizes would be used instead of text?

Good note, I'll see if I can find a different name for this

renamed to titleSize

})}
</Heading>
{theme.calendar.heading && theme.calendar[size].titleSize ? (
<Text weight="bold" size={theme.calendar[size].titleSize}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Enforcing bold here might not be the best idea because in v5 of HPE theme, we are leaning away from use of bold in typography. Wondering if we should have theme.calendar[size].title where any text props are supported?

In base.js, the default weight might be bold but then in HPE theme we can override with 500 or whatever is appropriate?

Copy link
Contributor

Choose a reason for hiding this comment

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

good idea!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wondering if we should have theme.calendar[size].title where any text props are supported?

Done in latest commit

@ericsoderberghp ericsoderberghp linked an issue Feb 16, 2023 that may be closed by this pull request
@@ -589,23 +590,36 @@ const Calendar = forwardRef(
return (
<Box direction="row" justify="between" align="center">
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this isn't a <Header />?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed Box to Header in latest commit

year: 'numeric',
})}
</Heading>
{theme.calendar.heading && theme.calendar[size].titleSize ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the check for theme.calendar.heading?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed this extra check in latest commit

</Heading>
{theme.calendar.heading && theme.calendar[size].titleSize ? (
<Text weight="bold" size={theme.calendar[size].titleSize}>
{reference.toLocaleDateString(locale, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're duplicating this code, can we put it in a const variable first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, fixed in latest commit

})}
</Heading>
{theme.calendar.heading && theme.calendar[size].titleSize ? (
<Text weight="bold" size={theme.calendar[size].titleSize}>
Copy link
Contributor

Choose a reason for hiding this comment

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

good idea!

@jcfilben jcfilben changed the title Calendar - add calendar[size].headingSize prop to theme Calendar - add calendar[size].title prop to theme Feb 16, 2023
@jcfilben jcfilben requested a review from taysea February 16, 2023 20:43
Copy link
Collaborator

@taysea taysea left a comment

Choose a reason for hiding this comment

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

LGTM.

@ericsoderberghp ericsoderberghp merged commit c5bb3be into grommet:master Feb 16, 2023
@taysea taysea mentioned this pull request Dec 6, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar - Replace Heading with Text
3 participants