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

Ensure font-size utilities with none modifier works e.g.: text-sm/none #15921

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

RobinMalfait
Copy link
Member

This PR fixes an issue where classes such as text-sm/none don't work as expected. The reason for this is that leading-none is the only hardcoded leading utility and is not coming from the @theme. This means that text-sm/none tries to do a lookup for none but it won't resolve.

This PR fixes that by allowing none as a modifier.

While working on this, I noticed that text-sm/none did generate CSS:

.text-sm\/none {
  font-size: var(--text-sm);
}

Notice that the line-height is missing. This means that any modifier that can't be resolved doesn't get the line-height set, but it will generate CSS. In this case, no CSS should have been generated.

Otherwise, all of these generate CSS which will only bloat your CSS and won't
work as expected. E.g.: text-sm/foo, text-sm/bar, and text-sm/baz:

.text-sm\/bar {
  font-size: var(--text-sm);
}
.text-sm\/baz {
  font-size: var(--text-sm);
}
.text-sm\/foo {
  font-size: var(--text-sm);
}

Fixes: #15911

@RobinMalfait RobinMalfait requested a review from a team as a code owner January 27, 2025 12:31
If you used `text-sm/foobar`, then this would generate:

```css
.text-sm\/foobar {
  font-size: var(--text-sm);
}
```

Even if the `/foobar` is not really used. This fixes that by ensuring
that if a modifier is used, but doesn't resolve, that it does not
generate any CSS.
`leading-none` is a hardcoded value, and is not coming from the
`@theme`. This means that this is the only modifier value you can't use
with a `text-*` utility. E.g.: `text-sm/none` will not have a
`line-height: 1;` attached.
Copy link
Member

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Nice!

@RobinMalfait RobinMalfait merged commit f1221b3 into next Jan 27, 2025
5 checks passed
@RobinMalfait RobinMalfait deleted the fix/issue-15911 branch January 27, 2025 13:10
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.

Font size / line height shorthand doesn't apply line-height when leading value is none
2 participants