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

Set all type style properties explicitly #294

Merged
merged 4 commits into from
Jul 24, 2023

Conversation

joelamb
Copy link
Contributor

@joelamb joelamb commented Jul 14, 2023

Because CSS properties such as font-weight are inherited, if a parent element sets a type style that sets a medium font weight and a child sets a style that doesn't set font weight, but is expecting normal weight, then the child will render with an unexpected medium font weight.

The same goes for text-rendering, letter-spacing and font-family, so all properties need to be explicitly set for all type styles.

@changeset-bot
Copy link

changeset-bot bot commented Jul 14, 2023

🦋 Changeset detected

Latest commit: 60e5d86

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 14, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 60e5d86
Status: ✅  Deploy successful!
Preview URL: https://031c4adf.tailwind-toucan-base.pages.dev
Branch Preview URL: https://jl-explicit-type-style-prope.tailwind-toucan-base.pages.dev

View logs

@joelamb joelamb force-pushed the jl-explicit-type-style-properties branch 3 times, most recently from 04df5dc to e3341cf Compare July 17, 2023 14:56
@joelamb joelamb requested review from nicolechung and ynotdraw July 17, 2023 14:59
"@tailwind-toucan-base": patch
---

chore: set all type style properties explicitly
Copy link
Contributor

Choose a reason for hiding this comment

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

Asking @ynotdraw here: Should this actually be a BREAKING change (minor? major?) because while this is the "correct" thing to do, it also can cause visual breaking changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think a breaking change here may be safest/most valid. Especially due to:

if a parent element sets a type style that sets a medium font weight and a child sets a style that doesn't set font weight, but is expecting normal weight, then the child will render with an unexpected medium font weight.

(Also this changeset name is hilarious - spicy-mice-speak.md 🌶️ 🐭 🗣️ 😂)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changeset updated

Copy link

Choose a reason for hiding this comment

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

spicy-mouse-steak 🤤

let geometricPrecision = { textRendering: 'geometricPrecision' };
let underline = { textDecoration: 'underline' };

// geometricPrecision text rendering makes it appear slightly
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation! Do we want a "this is what we want for Toucan" at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel that's implicit since we've included it, so not sure it needs that addition.

letterSpacing: theme('letterSpacing.normal'),
lineHeight: theme('lineHeight.8'),
textDecoration: 'initial',
textRendering: 'geometricPrecision',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are some of these geometricPrecision and some are initial?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh nevermind I see that this was there from before.

@nicolechung
Copy link
Contributor

preview

Sorta, but not exactly related:

  1. I read through the code but it's a bit unclear how the preview is made for font-sizes
  2. That being said, it would be nice to have a font-styles preview because as you can see
    a) font-weight is not included here with font-sizes
    b) seems like the tailwind classes are not used, just a style applied to the font-size

@@ -82,6 +82,7 @@
"volta": {
"node": "18.16.1",
"yarn": "1.22.19",
"npm": "9.8.0"
"npm": "9.8.0",
"pnpm": "7.32.5"
Copy link
Contributor

@ynotdraw ynotdraw Jul 17, 2023

Choose a reason for hiding this comment

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

I think we can probably have only node and pnpm under here, as it looks like we aren't using yarn or npm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

"@tailwind-toucan-base": patch
---

chore: set all type style properties explicitly
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think a breaking change here may be safest/most valid. Especially due to:

if a parent element sets a type style that sets a medium font weight and a child sets a style that doesn't set font weight, but is expecting normal weight, then the child will render with an unexpected medium font weight.

(Also this changeset name is hilarious - spicy-mice-speak.md 🌶️ 🐭 🗣️ 😂)

pin [email protected] in line with other CS repositories
@joelamb joelamb force-pushed the jl-explicit-type-style-properties branch from b5d68dc to 40cd1d4 Compare July 24, 2023 09:41
@joelamb joelamb requested review from nicolechung and ynotdraw July 24, 2023 10:26
@joelamb joelamb changed the title chore: set all type style properties explicitly Set all type style properties explicitly Jul 24, 2023
@joelamb joelamb requested a review from clintcs July 24, 2023 12:35
Copy link
Contributor

@ynotdraw ynotdraw left a comment

Choose a reason for hiding this comment

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

🎉

@joelamb joelamb force-pushed the jl-explicit-type-style-properties branch from dcae615 to f83f092 Compare July 24, 2023 12:48
@@ -8,13 +8,11 @@ module.exports = (fontSizes) =>
});

Copy link

@clintcs clintcs Jul 24, 2023

Choose a reason for hiding this comment

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

A comment explaining why certain properties are set to initial would be helpful, I think. Readers will otherwise spend a second wondering before assuming.

Also, not a big deal, but why initial instead of the desired value? The effect is the same. But setting, say, text-rendering to auto is a more explicit and saves the reader a moment's time.

Copy link
Contributor Author

@joelamb joelamb Jul 24, 2023

Choose a reason for hiding this comment

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

I went with initial over auto to convey the concept that this is not setting a value, but would have the effect of 'un-setting' any inherited value. Will add a comment to that effect, but leave it as initial rather than auto

joelamb added 3 commits July 24, 2023 16:11
Because CSS properties such as font-weight are inherited,
if a parent element sets a type style that sets a medium font weight
and a child sets a style that doesn't set font weight, but is expecting
normal weight, then the child will render with an unexpected medium
font weight.

The same goes for text-rendering, letter-spacing and font-family, so
all properties need to be explicitly set for all type styles.
@joelamb joelamb force-pushed the jl-explicit-type-style-properties branch from f83f092 to 60e5d86 Compare July 24, 2023 15:12
@joelamb joelamb merged commit f9f53e5 into main Jul 24, 2023
@joelamb joelamb deleted the jl-explicit-type-style-properties branch July 24, 2023 15:41
@github-actions github-actions bot mentioned this pull request Jul 25, 2023
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