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

Fix: Line-height across the app for H1, H2, H3, H4 #1610

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

machikoyasuda
Copy link
Member

@machikoyasuda machikoyasuda commented Aug 2, 2023

fixes #1573

Line-height should always be a unitless value. https://developer.mozilla.org/en-US/docs/Web/CSS/line-height#values Do not use rems, pixels for line-height.

What this PR does

  • Applies new line-height to h1, h2, h3, h4
  • H1-H3 are 1.3
  • H4 is 1.2
  • These values are the same across Desktop and Mobile.

Steps I took to run through this PR

  1. Confirm on Figma that H1, H2, H3, H4 now have different line-height values from the standard body line height.
  2. Confirm that the --bs-body-line-height variable is correct, set at 1.5, and applied to all the places it should.
  3. Create a new variable: --heading-line-height of value 1.3.
  4. Create a new variable: --h4-line-height of value 1.2. H4 is only used in one spot in the whole app, and that is for the Agency Selector modal, specifically, the name of the transit agency. The 1.2 value allows for the transit agency name to be tighter.
  5. Apply the --heading-line-height to H1, H2, H3
  6. Apply --h4-line-height outlier exception to H4.
  7. Deleted the custom code setting .card .card-title's line-height, which is an H4, to fall back and use the H4 line-height.
  8. Audit the CSS file for any other line-height declarations and make sure they're correct/appropriate.
  9. Confirm local vs. dev site vs. Figma for desktop and mobile headlines

Is this even noticeable? Yes.

Modal titles on Mobile

Side-by-side comparison of Figma, this PR and the Dev site for modal titles. Modal titles on Dev have a line-height of 1.5, and now, with this PR, they are tightened to 1.3.
image

Index/Agency Index on Desktop

Total height of the H1 and H2 types are tighter now
image

2-line Headlines on Desktop

image

@github-actions github-actions bot added front-end HTML/CSS/JavaScript and Django templates deployment-dev [auto] Changes that will trigger a deploy if merged to dev labels Aug 2, 2023
@machikoyasuda machikoyasuda self-assigned this Aug 2, 2023
@machikoyasuda machikoyasuda added this to the Veterans milestone Aug 2, 2023
@machikoyasuda machikoyasuda marked this pull request as ready for review August 2, 2023 21:38
@machikoyasuda machikoyasuda requested a review from a team as a code owner August 2, 2023 21:38
@machikoyasuda
Copy link
Member Author

machikoyasuda commented Aug 2, 2023

@srhhnry How does this change look to you?

Here's my comment summarizing my findings for both line-height and letter-spacing: #1600 (comment)

This PR deals exclusively with line-height. I decided to get that one out first since it's simpler than letter-spacing.

Comment on lines +207 to 211
/* H4 */
/* Desktop only: Used for Agency Selector card, agency name */
h4 {
line-height: var(--h4-line-height);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

One could argue we should be declaring the H4 font sizes here, but I opted not to for this PR. I did add that comment, thought, that it's only used on Agency Selector card title. Next time we do use the H4, it can be refactored.

Copy link
Member

Choose a reason for hiding this comment

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

I get that you're defining line-height on h4 because the Agency Selector card title is the only place we actually use an h4 element. And here you're saying that, by the same reasoning, we could also define all the styles for the Agency Selector card title on h4.

I want to note that this is slightly different than what Figma says, since the Style Guide has h4 with a certain font-size, line-height, etc. and the Components page has the Agency Selector Cards with a certain font-size, line-height, etc.

This is fine though since this code change gives us the net-effect we want and, as you noted,

Next time we do use the H4, it can be refactored.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea the next Letter-Spacing PR will apply the h4 letter-spacing styles to this h4, and then the Agency Selector's H4 will get those styles.

And we know we're gonna refactor the entire modal layout/includes after #1444 this ticket for SBMTD, we can revisit how the h4 on the modal is constructed and styled more thoroughly then.

Comment on lines +207 to 211
/* H4 */
/* Desktop only: Used for Agency Selector card, agency name */
h4 {
line-height: var(--h4-line-height);
}
Copy link
Member

Choose a reason for hiding this comment

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

I get that you're defining line-height on h4 because the Agency Selector card title is the only place we actually use an h4 element. And here you're saying that, by the same reasoning, we could also define all the styles for the Agency Selector card title on h4.

I want to note that this is slightly different than what Figma says, since the Style Guide has h4 with a certain font-size, line-height, etc. and the Components page has the Agency Selector Cards with a certain font-size, line-height, etc.

This is fine though since this code change gives us the net-effect we want and, as you noted,

Next time we do use the H4, it can be refactored.

@machikoyasuda machikoyasuda merged commit 0998a99 into dev Aug 3, 2023
10 checks passed
@machikoyasuda machikoyasuda deleted the fix/type-line-height branch August 3, 2023 16:04
@srhhnry
Copy link
Member

srhhnry commented Aug 3, 2023

Late on this comment but line height looks fine to me from that screenshot.

@machikoyasuda
Copy link
Member Author

Awesome thank you @srhhnry. This PR is merged into dev, which means the changes are live and available to test out here dev-benefits.calitp.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment-dev [auto] Changes that will trigger a deploy if merged to dev front-end HTML/CSS/JavaScript and Django templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix line-height for headlines
4 participants