Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new set of utilities for the
font-variant-numeric
property:normal-nums
font-variant-numeric
tonormal
ordinal
ordinal
featureslashed-zero
slashed-zero
featurelining-nums
lining-nums
featureoldstyle-nums
oldstyle-nums
featureproportional-nums
proportional-nums
featuretabular-nums
tabular-nums
featurediagonal-fractions
diagonal-fractions
featurestacked-fractions
stacked-fractions
featureThe exciting thing about how these are implemented is that they are composable in your HTML, so you can enable multiple
font-variant-numeric
features by adding multiple classes:The
normal-nums
class can be used to reset things, usually used at a particular breakpoint:By default, only
responsive
variants are enabled for this new core plugin.Design details
This was pretty challenging to implement and only works thanks to a magical tip from @davidkpiano. Here's what the CSS looks like:
The general idea here is that we build the actual
font-variant-numeric
property value out of CSS custom properties, and we use this incredible hack of setting a custom property to an empty comment to make it possible to provide a no-op default value for every "slot" in the final property value.I've had to use
/*!*/
rather than/**/
because most CSS minifiers will strip comments that don't start with a!
.Any properties that are incompatible with each other are assigned to the same CSS custom property, so the slots we are filling look like this:
...where every slot on its own is optional.
So magical.