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

[v4] Add font-stretch utilities #13153

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `font-stretch` utilities ([#13153](https://github.com/tailwindlabs/tailwindcss/pull/13153))

### Fixed

- Don't error on `@apply` with leading/trailing whitespace ([#13144](https://github.com/tailwindlabs/tailwindcss/pull/13144))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,25 @@ exports[`getClassList 1`] = `
"font-medium",
"font-normal",
"font-semibold",
"font-stretch-100",
"font-stretch-105",
"font-stretch-110",
"font-stretch-125",
"font-stretch-150",
"font-stretch-200",
"font-stretch-50",
"font-stretch-75",
"font-stretch-90",
"font-stretch-95",
"font-stretch-condensed",
"font-stretch-expanded",
"font-stretch-extra-condensed",
"font-stretch-extra-expanded",
"font-stretch-normal",
"font-stretch-semi-condensed",
"font-stretch-semi-expanded",
"font-stretch-ultra-condensed",
"font-stretch-ultra-expanded",
"font-thin",
"forced-color-adjust-auto",
"forced-color-adjust-none",
Expand Down
1 change: 1 addition & 0 deletions packages/tailwindcss/src/property-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export default [
'font-weight',
'text-transform',
'font-style',
'font-stretch',
'font-variant-numeric',
'line-height',
'letter-spacing',
Expand Down
20 changes: 20 additions & 0 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8788,6 +8788,26 @@ test('font-style', () => {
expect(run(['-italic', '-not-italic'])).toEqual('')
})

test('font-stretch', () => {
expect(run(['font-stretch-ultra-expanded', 'font-stretch-50', 'font-stretch-200']))
.toMatchInlineSnapshot(`
".font-stretch-200 {
font-stretch: 200%;
}

.font-stretch-50 {
font-stretch: 50%;
}

.font-stretch-ultra-expanded {
font-stretch: ultra-expanded;
}"
`)
expect(
run(['font-stretch', 'font-stretch-20', 'font-stretch-400', 'font-stretch-potato']),
).toEqual('')
})

test('text-decoration-line', () => {
expect(run(['underline', 'overline', 'line-through', 'no-underline'])).toMatchInlineSnapshot(`
".line-through {
Expand Down
26 changes: 26 additions & 0 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,32 @@ export function createUtilities(theme: Theme) {
staticUtility('line-through', [['text-decoration-line', 'line-through']])
staticUtility('no-underline', [['text-decoration-line', 'none']])

staticUtility('font-stretch-normal', [['font-stretch', 'normal']])
staticUtility('font-stretch-ultra-condensed', [['font-stretch', 'ultra-condensed']])
staticUtility('font-stretch-extra-condensed', [['font-stretch', 'extra-condensed']])
staticUtility('font-stretch-condensed', [['font-stretch', 'condensed']])
staticUtility('font-stretch-semi-condensed', [['font-stretch', 'semi-condensed']])
staticUtility('font-stretch-semi-expanded', [['font-stretch', 'semi-expanded']])
staticUtility('font-stretch-expanded', [['font-stretch', 'expanded']])
staticUtility('font-stretch-extra-expanded', [['font-stretch', 'extra-expanded']])
staticUtility('font-stretch-ultra-expanded', [['font-stretch', 'ultra-expanded']])
functionalUtility('font-stretch', {
themeKeys: [],
handleBareValue: ({ value }) => {
let num = Number(value)
// Only 50-200% (inclusive) are valid:
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
if (Number.isNaN(num) || num < 50 || num > 200) return null
return `${value}%`
},
handle: (value) => [decl('font-stretch', value)],
})
suggest('font-stretch', () => [
{
values: ['50', '75', '90', '95', '100', '105', '110', '125', '150', '200'],
},
])

colorUtility('placeholder', {
themeKeys: ['--background-color', '--color'],
handle: (value) => [
Expand Down
Loading