-
Notifications
You must be signed in to change notification settings - Fork 315
Refactor h1 and h2 to use Typography component where relevant. #11037
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
Refactor h1 and h2 to use Typography component where relevant. #11037
Conversation
Build files for cc0abb5 have been deleted. |
Size Change: +4.91 kB (+0.22%) Total Size: 2.22 MB ℹ️ View Unchanged
|
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.
Thanks @benbowler, usage of the Typography
component is almost there, but it seems there is an implementation part that has been missed from the IB
Search for <h1 and <h2 across the codebase and replace it by using Typography component, and passing as prop with value of h1 and h2 respectively
Mainly the "passing as
prop with value of h1 and h2 respectively". We should use as
prop to mark the heading tags correctly, for h1
would be <Typography as="h1" {...}>{...}</Typography>
etc.
You can see example of a full usage in the stories file
site-kit-wp/assets/js/components/Typography.stories.js
Lines 52 to 54 in 7d0a6a2
<Typography as="h1" size="large" type="display"> | |
Typography | |
</Typography> |
Let's include the missing prop to the implemented Typography
components
As to the regard of not replacing headings with Typography
in the stories and tests, not sure there is a specific reason we would omit it there, as referenced above, this is already implemented in the Typography.stories.js
file. We should replace usage of hardcoded headings completely with the Typography
file in the JS
files (components, jest tests, storybook stories)
…replace-headings-with-typography-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.
Thanks @benbowler looks much better. Just one more thing to check
…replace-headings-with-typography-component.
…replace-headings-with-typography-component.
…replace-headings-with-typography-component.
…replace-headings-with-typography-component.
Note that E2E tests started failing consistently here, not sure why because the changes are unrelated, however I added timeouts to allow the |
…replace-headings-with-typography-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.
Thanks @benbowler LGTM
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 few questions here, but looks good 👍🏻
<h2 className="googlesitekit-heading-3 googlesitekit-setup-module__title"> | ||
<Typography | ||
as="h3" | ||
className="googlesitekit-setup-module__title" | ||
size="small" | ||
type="headline" | ||
> |
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.
Why the change in heading hierarchy here? This used to be an <h2>
.
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 because it was an h2 with the class googlesitekit-heading-3
- I suppose we could keep as="h2"
but the other props as "small" / "headine" to style like it should be. Does that make more sense?
There were a few like this in the codebase where h2s were styled as h3s.
@@ -13,7 +13,7 @@ exports[`AdminMenuTooltip should render when isTooltipVisible is true and track | |||
class="googlesitekit-tooltip-body" | |||
> | |||
<h2 | |||
class="googlesitekit-tooltip-title" | |||
class="googlesitekit-typography googlesitekit-tooltip-title googlesitekit-typography--title googlesitekit-typography--medium" | |||
> | |||
Test Title | |||
</h2> |
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.
Why not use the <Typography>
component here too? It would allow us to better test (with snapshots) the output of the component, and might as well use it everywhere we would in production 🤔
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 the snapshot of the Joyride > Step component which does use the Typography component:
site-kit-wp/assets/js/components/Stepper/Step.js
Lines 33 to 40 in 049b702
<Typography | |
as="h2" | |
className="googlesitekit-stepper__step-title" | |
size="medium" | |
type="title" | |
> | |
{ title } | |
</Typography> |
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.
OMG 🤦🏻
My bad for missing that 😅
<h2 className="googlesitekit-heading-3 googlesitekit-setup-module__title"> | ||
<Typography | ||
as="h3" |
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.
Why the change here to H3? 🤔
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.
As above.
…replace-headings-with-typography-component.
Summary
Addresses issue:
h1
andh2
headings with newTypography
component #10905Relevant technical choices
I had to make a few decisions here to refactor title appropriately extending on the IB.
Firstly, I did not refactor the following:
h1
site-kit-wp/assets/js/components/ReportError.stories.js
Line 93 in b21d94c
h2
I found that the following titles used
h2
tags but using thegooglesitekit-heading-3
class so these should be refactored to theh3
style typography component as part of this ticket:assets/js/components/legacy-setup/search-console.js
assets/js/components/legacy-setup/site-verification.js
assets/js/modules/ads/components/setup/SetupMain.js
assets/js/modules/ads/components/setup/SetupMainPAX.js
assets/js/modules/adsense/components/common/AdSenseConnectCTA/Content.js
assets/js/modules/adsense/components/setup/SetupMain.js
assets/js/modules/analytics-4/components/setup/SetupMain.js
assets/js/modules/reader-revenue-manager/components/setup/SetupMain.js
assets/js/modules/sign-in-with-google/components/setup/SetupMain.js
I did this by setting these to
size=small
andas='h3'
.Other changes:
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist