2024-03-22 17:12:14 +01:00
|
|
|
import { run, html, css } from '../util/run'
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
test('font-size utilities can include a default line-height', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [{ raw: html`<div class="text-md text-sm text-lg"></div>` }],
|
|
|
|
|
theme: {
|
|
|
|
|
fontSize: {
|
|
|
|
|
sm: '12px',
|
|
|
|
|
md: ['16px', '24px'],
|
|
|
|
|
lg: ['20px', '28px'],
|
2020-04-05 14:07:30 -04:00
|
|
|
},
|
2024-03-22 17:12:14 +01:00
|
|
|
},
|
|
|
|
|
}
|
2020-04-05 14:07:30 -04:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchCss(css`
|
|
|
|
|
.text-lg {
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
line-height: 28px;
|
|
|
|
|
}
|
|
|
|
|
.text-md {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
`)
|
2021-05-05 15:23:32 +02:00
|
|
|
})
|
2024-03-22 17:12:14 +01:00
|
|
|
})
|
2020-08-06 15:42:52 -04:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
test('font-size utilities can include a default letter-spacing', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [{ raw: html`<div class="text-md text-sm text-lg"></div>` }],
|
|
|
|
|
theme: {
|
|
|
|
|
fontSize: {
|
|
|
|
|
sm: '12px',
|
|
|
|
|
md: ['16px', { letterSpacing: '-0.01em' }],
|
|
|
|
|
lg: ['20px', { letterSpacing: '-0.02em' }],
|
2020-08-06 15:42:52 -04:00
|
|
|
},
|
2024-03-22 17:12:14 +01:00
|
|
|
},
|
|
|
|
|
}
|
2020-08-06 15:42:52 -04:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchCss(css`
|
|
|
|
|
.text-lg {
|
|
|
|
|
letter-spacing: -0.02em;
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
}
|
|
|
|
|
.text-md {
|
|
|
|
|
letter-spacing: -0.01em;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
`)
|
2021-05-05 15:23:32 +02:00
|
|
|
})
|
2024-03-22 17:12:14 +01:00
|
|
|
})
|
2020-08-06 15:42:52 -04:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
test('font-size utilities can include a default line-height and letter-spacing', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [{ raw: html`<div class="text-md text-sm text-lg"></div>` }],
|
|
|
|
|
theme: {
|
|
|
|
|
fontSize: {
|
|
|
|
|
sm: '12px',
|
|
|
|
|
md: ['16px', { lineHeight: '24px', letterSpacing: '-0.01em' }],
|
|
|
|
|
lg: ['20px', { lineHeight: '28px', letterSpacing: '-0.02em' }],
|
2020-08-06 15:42:52 -04:00
|
|
|
},
|
2024-03-22 17:12:14 +01:00
|
|
|
},
|
|
|
|
|
}
|
2020-08-06 15:42:52 -04:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchCss(css`
|
|
|
|
|
.text-lg {
|
|
|
|
|
letter-spacing: -0.02em;
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
line-height: 28px;
|
|
|
|
|
}
|
|
|
|
|
.text-md {
|
|
|
|
|
letter-spacing: -0.01em;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
`)
|
2021-05-05 15:23:32 +02:00
|
|
|
})
|
2024-03-22 17:12:14 +01:00
|
|
|
})
|
2022-07-05 05:01:06 +08:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
test('font-size utilities can include a font-weight', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [{ raw: html`<div class="text-md text-sm text-lg"></div>` }],
|
|
|
|
|
theme: {
|
|
|
|
|
fontSize: {
|
|
|
|
|
sm: '12px',
|
|
|
|
|
md: ['16px', { lineHeight: '24px', fontWeight: 500 }],
|
|
|
|
|
lg: ['20px', { lineHeight: '28px', fontWeight: 'bold' }],
|
2022-07-05 05:01:06 +08:00
|
|
|
},
|
2024-03-22 17:12:14 +01:00
|
|
|
},
|
|
|
|
|
}
|
2022-07-05 05:01:06 +08:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchCss(css`
|
|
|
|
|
.text-lg {
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
line-height: 28px;
|
|
|
|
|
}
|
|
|
|
|
.text-md {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
`)
|
2022-07-05 05:01:06 +08:00
|
|
|
})
|
2024-03-22 17:12:14 +01:00
|
|
|
})
|
2023-02-08 17:39:43 +01:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
test('font-size utilities can include a line-height modifier', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [
|
|
|
|
|
{
|
|
|
|
|
raw: html`<div class="text-sm md:text-base">
|
|
|
|
|
<div class="text-sm/6 md:text-base/7"></div>
|
|
|
|
|
<div class="text-sm/[21px] md:text-base/[33px]"></div>
|
|
|
|
|
<div class="text-[13px]/6 md:text-[19px]/8"></div>
|
|
|
|
|
<div class="text-[17px]/[23px] md:text-[21px]/[29px]"></div>
|
|
|
|
|
<div class="text-sm/999 md:text-base/000"></div>
|
|
|
|
|
</div>`,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
theme: {
|
|
|
|
|
fontSize: {
|
|
|
|
|
sm: ['12px', '20px'],
|
|
|
|
|
base: ['16px', '24px'],
|
2023-02-08 17:39:43 +01:00
|
|
|
},
|
2024-03-22 17:12:14 +01:00
|
|
|
lineHeight: {
|
|
|
|
|
6: '24px',
|
|
|
|
|
7: '28px',
|
|
|
|
|
8: '32px',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2023-02-08 17:39:43 +01:00
|
|
|
|
2024-03-22 17:12:14 +01:00
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchCss(css`
|
|
|
|
|
.text-\[13px\]\/6 {
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
.text-\[17px\]\/\[23px\] {
|
|
|
|
|
font-size: 17px;
|
|
|
|
|
line-height: 23px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
line-height: 20px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm\/6 {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
|
|
|
|
.text-sm\/\[21px\] {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
line-height: 21px;
|
|
|
|
|
}
|
|
|
|
|
@media (min-width: 768px) {
|
|
|
|
|
.md\:text-\[19px\]\/8 {
|
|
|
|
|
font-size: 19px;
|
|
|
|
|
line-height: 32px;
|
|
|
|
|
}
|
|
|
|
|
.md\:text-\[21px\]\/\[29px\] {
|
|
|
|
|
font-size: 21px;
|
|
|
|
|
line-height: 29px;
|
|
|
|
|
}
|
|
|
|
|
.md\:text-base {
|
|
|
|
|
font-size: 16px;
|
2023-02-08 17:39:43 +01:00
|
|
|
line-height: 24px;
|
|
|
|
|
}
|
2024-03-22 17:12:14 +01:00
|
|
|
.md\:text-base\/7 {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 28px;
|
2023-02-08 17:39:43 +01:00
|
|
|
}
|
2024-03-22 17:12:14 +01:00
|
|
|
.md\:text-base\/\[33px\] {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 33px;
|
2023-02-08 17:39:43 +01:00
|
|
|
}
|
2024-03-22 17:12:14 +01:00
|
|
|
}
|
|
|
|
|
`)
|
2023-02-08 17:39:43 +01:00
|
|
|
})
|
2022-11-22 09:37:07 -05:00
|
|
|
})
|