Skip to content

Rebrand - Create typography.scss stylesheet - #51116

Merged
kelbyhawn merged 14 commits into
stagingfrom
rebrand-typography-stylesheet
Apr 11, 2023
Merged

Rebrand - Create typography.scss stylesheet#51116
kelbyhawn merged 14 commits into
stagingfrom
rebrand-typography-stylesheet

Conversation

@kelbyhawn

@kelbyhawn kelbyhawn commented Apr 4, 2023

Copy link
Copy Markdown
Contributor

Create a typography.scss stylesheet that can be imported on other stylesheets to maintain typographic consistency across Dashboard and Pegasus sites.

  • Includes heading, paragraph, and caption styles
  • Intended to work/get imported similarly to the font.scss and color.scss files
  • Introduces mixins to style semantic tags, and also creates identical classes for use on other elements if needed.
    • Includes the use of heading classes to allow for semantic headings to be styled as needed
    • This allows for better accessibility (see this comment and comments in file for more info)

Note: I replaced some instances already in use w/ the new pattern in this PR.

Asana task: https://app.asana.com/0/0/1204195827611852

@kelbyhawn
kelbyhawn requested a review from levadadenys April 5, 2023 16:09

@levadadenys levadadenys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love the way you organised shared/css/typography.scss ! Thank you!
Have only one comment, other than that everything LGTM!

Comment thread shared/css/typography.scss Outdated
// ----------------------------------------

// Mixins are used to maintain accessible heading hierarchy when design
// calls for a different style (semantic h3, h5 styling).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, here comes the only question I have.
Is this really a good idea? (semantic h3, h5 styling). Why can't we use h5 for h5 styling? I would say that it's and anti pattern and we should avoid it. (Correct me if I'm wrong)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is the result of some discussion we've been having, on how to maintain accessible heading structure in cases where we want non-standard font sizes for the heading. it's important for users who navigate a page via screenreader that headings correctly represent the document structure. here's a copy of a message i wrote a while back, that hopefully provides some context:

Just to clarify, the distinction we want to make is between heading style (e.g. font-size) and heading tag (e.g. <h1>). We might be using an H2 inside a modal and want it to have smaller text than normal, so style it as an H3.

In terms of both accessibility and semantic appropriateness, we should consider the following as rules, though breaking them isn't always technically a violation of WCAG standards:

  • All heading levels should be appropriately ordered, so an H1 is always above other heading tags in the HTML, H2s are under it, etc, without ever skipping levels.
  • While a page can have multiple H1s, it should not, and an H1 should represent the page title. (Some exceptions exist, like using H1s inside an iframe, or in standalone components like a modal.)
  • Headings should only be used to describe the contents of a section. If we want larger text that does not describe a section beneath it, we should style the text without making it a heading.

Kelby suggested some options, like the mixins we use in Pegasus, Bootstrap's class styles, and some combinations of the two.

This page has some additional info and resources: https://www.w3.org/TR/2012/NOTE-WCAG20-TECHS-20120103/H42.html.

Darin also shared another article:

This article has some best practices for headings that I think are great - but I link to it because of the section on "headings in components" about halfway through the article.

@kelbyhawn kelbyhawn Apr 6, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing this extra context @rshipp!

@levadadenys good question about the class names — Bootstrap uses .h1, etc classes, and Molly found that Semantic UI React uses size labels (see here) like huge, tiny.

I chose these class names (heading-lg, etc) since they matched the breakpoints.scss size naming convention, but am 100% on board to change them if we think a different pattern is better!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just updated the refactored typography.scss file after @levadadenys suggested making mixins and classes for each element 🙌

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the context and the article, now I understand. +1 to using classNames

@rshipp rshipp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thank you for doing this!

@kelbyhawn
kelbyhawn requested a review from a team April 6, 2023 16:57

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great!

@levadadenys levadadenys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot all for the deeper context! Synced up with Kelby, everything LGTM!

@kelbyhawn kelbyhawn Apr 7, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@levadadenys I made a few updates this morning to this file — can you take another look?

  • Added the color, font, and barlow imports just in case this gets used somewhere where they aren't being imported.
  • Refactored the p styles a bit
  • Added em styles

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!
The only thing I would change is put @include statements in the begining of mixin/style scope in order to prevent styles from parent scope being overriden by the styles from included scope.
So this:

@mixin body-one {
  font-family: $gotham-regular, sans-serif;
  font-size: 1em;
  @include paragraph-common
}

I would make like this:

@mixin body-one {
  @include paragraph-common
  font-family: $gotham-regular, sans-serif;
  font-size: 1em;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done 👍 Excellent feedback, thank you!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!
The only thing I would change is put @include statements in the begining of mixin/style scope in order to prevent styles from parent scope being overriden by the styles from included scope.
So this:

@mixin body-one {
  font-family: $gotham-regular, sans-serif;
  font-size: 1em;
  @include paragraph-common
}

I would make like this:

@mixin body-one {
  @include paragraph-common
  font-family: $gotham-regular, sans-serif;
  font-size: 1em;
}

@kelbyhawn
kelbyhawn merged commit aaba02b into staging Apr 11, 2023
@kelbyhawn
kelbyhawn deleted the rebrand-typography-stylesheet branch April 11, 2023 18:01
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.

4 participants