Skip to content

Commit

Permalink
Revert "Add support for configuring default font-variation-settings
Browse files Browse the repository at this point in the history
… for a `font-family` (#10515)"

This reverts commit 8bd2846.
  • Loading branch information
RobinMalfait committed Feb 8, 2023
1 parent 1668a54 commit 6740372
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 405 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add logical properties support for inline direction ([#10166](https://github.com/tailwindlabs/tailwindcss/pull/10166))
- Add `hyphens` utilities ([#10071](https://github.com/tailwindlabs/tailwindcss/pull/10071))
- [Oxide] Use `lightningcss` for nesting and vendor prefixes in PostCSS plugin ([#10399](https://github.com/tailwindlabs/tailwindcss/pull/10399))
- Add support for configuring default `font-variation-settings` for a `font-family` ([#10034](https://github.com/tailwindlabs/tailwindcss/pull/10034), [#10515](https://github.com/tailwindlabs/tailwindcss/pull/10515))

### Fixed

Expand Down
5 changes: 1 addition & 4 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -1915,16 +1915,13 @@ export let corePlugins = {
font: (value) => {
let [families, options = {}] =
Array.isArray(value) && isPlainObject(value[1]) ? value : [value]
let { fontFeatureSettings, fontVariationSettings } = options
let { fontFeatureSettings } = options

return {
'font-family': Array.isArray(families) ? families.join(', ') : families,
...(fontFeatureSettings === undefined
? {}
: { 'font-feature-settings': fontFeatureSettings }),
...(fontVariationSettings === undefined
? {}
: { 'font-variation-settings': fontVariationSettings }),
}
},
},
Expand Down
2 changes: 0 additions & 2 deletions src/css/preflight.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
*/

html {
Expand All @@ -33,7 +32,6 @@ html {
tab-size: 4; /* 3 */
font-family: theme('fontFamily.sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); /* 4 */
font-feature-settings: theme('fontFamily.sans[1].fontFeatureSettings', normal); /* 5 */
font-variation-settings: theme('fontFamily.sans[1].fontVariationSettings', normal); /* 6 */
}

/*
Expand Down
66 changes: 0 additions & 66 deletions tests/evaluateTailwindFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,72 +591,6 @@ crosscheck(({ stable, oxide }) => {
})
})

test('font-family values are retrieved without font-variation-settings', () => {
let input = css`
.heading-1 {
font-family: theme('fontFamily.sans');
}
.heading-2 {
font-family: theme('fontFamily.serif');
}
.heading-3 {
font-family: theme('fontFamily.mono');
}
`

let output = css`
.heading-1 {
font-family: Inter;
}
.heading-2 {
font-family: Times, serif;
}
.heading-3 {
font-family: Menlo, monospace;
}
`

return run(input, {
theme: {
fontFamily: {
sans: ['Inter', { fontVariationSettings: '"opsz" 32' }],
serif: [['Times', 'serif'], { fontVariationSettings: '"opsz" 32' }],
mono: ['Menlo, monospace', { fontVariationSettings: '"opsz" 32' }],
},
},
}).then((result) => {
expect(result.css).toMatchCss(output)
expect(result.warnings().length).toBe(0)
})
})

test('font-variation-settings values can be retrieved', () => {
let input = css`
.heading {
font-family: theme('fontFamily.sans');
font-variation-settings: theme('fontFamily.sans[1].fontVariationSettings');
}
`

let output = css`
.heading {
font-family: Inter;
font-variation-settings: 'opsz' 32;
}
`

return run(input, {
theme: {
fontFamily: {
sans: ['Inter', { fontVariationSettings: "'opsz' 32" }],
},
},
}).then((result) => {
expect(result.css).toMatchCss(output)
expect(result.warnings().length).toBe(0)
})
})

test('font-family values are joined when an array', () => {
let input = css`
.element {
Expand Down
40 changes: 0 additions & 40 deletions tests/plugins/fontFamily.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,43 +98,3 @@ crosscheck(() => {
})
})
})

test('font-variation-settings can be provided when families are defined as a string', () => {
let config = {
content: [{ raw: html`<div class="font-sans"></div>` }],
theme: {
fontFamily: {
sans: ['Inter, sans-serif', { fontVariationSettings: '"opsz" 32' }],
},
},
}

return run('@tailwind utilities', config).then((result) => {
expect(result.css).toMatchCss(`
.font-sans {
font-family: Inter, sans-serif;
font-variation-settings: "opsz" 32;
}
`)
})
})

test('font-variation-settings can be provided when families are defined as an array', () => {
let config = {
content: [{ raw: html`<div class="font-sans"></div>` }],
theme: {
fontFamily: {
sans: [['Inter', 'sans-serif'], { fontVariationSettings: '"opsz" 32' }],
},
},
}

return run('@tailwind utilities', config).then((result) => {
expect(result.css).toMatchCss(`
.font-sans {
font-family: Inter, sans-serif;
font-variation-settings: "opsz" 32;
}
`)
})
})
Loading

0 comments on commit 6740372

Please sign in to comment.