Skip to content

Improve compatibility with @tailwindcss/typography and @tailwindcss/forms #14221

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

Merged
merged 25 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f00eab1
Fix export
thecrypticace Aug 19, 2024
0baa1fc
Add colors export
thecrypticace Aug 19, 2024
f71147a
Add support for arrays in `objectToAst`
thecrypticace Aug 19, 2024
920c229
Add support for arrays passed to `addUtilities`
thecrypticace Aug 19, 2024
b6a9f2a
Add support for `addComponents` and `matchComponents`
thecrypticace Aug 19, 2024
5590f42
Add support for `prefix` fn
thecrypticace Aug 19, 2024
c6d5a19
Add typography plugin to playground
thecrypticace Aug 19, 2024
4643108
wip
thecrypticace Aug 19, 2024
6d5cbae
Add `tailwindcss/defaultTheme` export
thecrypticace Aug 19, 2024
e00b559
wip
thecrypticace Aug 21, 2024
9be14a0
Support multiple selector keys in `addUtilities`
thecrypticace Aug 21, 2024
88d3497
Handle pseudo-classes/-elements in addUtilities
thecrypticace Aug 21, 2024
5a4a522
Add forms plugin to vite playground
thecrypticace Aug 21, 2024
6b6ec0c
wip
thecrypticace Aug 21, 2024
e157310
wip
thecrypticace Aug 21, 2024
30481df
wip
thecrypticace Aug 21, 2024
2e85672
Add test for addComponents()
philipp-spiess Aug 22, 2024
e4a5e48
Add test for prefix()
philipp-spiess Aug 22, 2024
c8126d6
Add test for multiple selector names and pseudo classes/elements
philipp-spiess Aug 22, 2024
779bb2b
Update default config static properties to match V3
philipp-spiess Aug 22, 2024
885f02e
addUtilities can return an array of declaration objects
philipp-spiess Aug 22, 2024
248851f
Add integration tests for @tailwindcss/typography and @tailwindcss/forms
philipp-spiess Aug 22, 2024
59de5ae
Undo changes to accentColor and fill in createDefaultConfig
philipp-spiess Aug 22, 2024
1c7e429
Revert changes to Vite playground
philipp-spiess Aug 22, 2024
8bfd7c7
Add change log entries
philipp-spiess Aug 22, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add support for `addBase` plugins using the `@plugin` directive ([#14172](https://github.com/tailwindlabs/tailwindcss/pull/14172))
- Add support for the `tailwindcss/plugin` export ([#14173](https://github.com/tailwindlabs/tailwindcss/pull/14173))
- Add support for the `theme()` function in plugins ([#14207](https://github.com/tailwindlabs/tailwindcss/pull/14207))
- Add support for `addComponents`, `matchComponents`, `prefix` plugin APIs ([#14221](https://github.com/tailwindlabs/tailwindcss/pull/14221))
- Add support for `tailwindcss/colors` and `tailwindcss/defaultTheme` exports for use with plugins ([#14221](https://github.com/tailwindlabs/tailwindcss/pull/14221))
- Add support for the `@tailwindcss/typography` and `@tailwindcss/forms` plugins ([#14221](https://github.com/tailwindlabs/tailwindcss/pull/14221))

### Fixed

Expand Down
78 changes: 78 additions & 0 deletions integrations/cli/plugins.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { candidate, css, html, json, test } from '../utils'

test(
'builds the typography plugin utilities',
{
fs: {
'package.json': json`
{
"dependencies": {
"@tailwindcss/typography": "^0.5.14",
"tailwindcss": "workspace:^",
"@tailwindcss/cli": "workspace:^"
}
}
`,
'index.html': html`
<div className="prose">
<h1>Headline</h1>
<p>
Until now, trying to style an article, document, or blog post with Tailwind has been a
tedious task that required a keen eye for typography and a lot of complex custom CSS.
</p>
</div>
`,
'src/index.css': css`
@import 'tailwindcss';
@plugin '@tailwindcss/typography';
`,
},
},
async ({ fs, exec }) => {
await exec('pnpm tailwindcss --input src/index.css --output dist/out.css')

await fs.expectFileToContain('dist/out.css', [
candidate`prose`,
':where(h1):not(:where([class~="not-prose"],[class~="not-prose"] *))',
':where(tbody td, tfoot td):not(:where([class~="not-prose"],[class~="not-prose"] *))',
])
},
)

test(
'builds the forms plugin utilities',
{
fs: {
'package.json': json`
{
"dependencies": {
"@tailwindcss/forms": "^0.5.7",
"tailwindcss": "workspace:^",
"@tailwindcss/cli": "workspace:^"
}
}
`,
'index.html': html`
<input type="text" class="form-input" />
<textarea class="form-textarea"></textarea>
`,
'src/index.css': css`
@import 'tailwindcss';
@plugin '@tailwindcss/forms';
`,
},
},
async ({ fs, exec }) => {
await exec('pnpm tailwindcss --input src/index.css --output dist/out.css')

await fs.expectFileToContain('dist/out.css', [
//
candidate`form-input`,
candidate`form-textarea`,
])
await fs.expectFileNotToContain('dist/out.css', [
//
candidate`form-radio`,
])
},
)
13 changes: 13 additions & 0 deletions integrations/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface TestContext {
read(filePath: string): Promise<string>
glob(pattern: string): Promise<[string, string][]>
expectFileToContain(filePath: string, contents: string | string[]): Promise<void>
expectFileNotToContain(filePath: string, contents: string | string[]): Promise<void>
}
}
type TestCallback = (context: TestContext) => Promise<void> | void
Expand Down Expand Up @@ -289,9 +290,21 @@ export function test(
}
})
},
async expectFileNotToContain(filePath, contents) {
return retryAssertion(async () => {
let fileContent = await this.read(filePath)
for (let content of contents) {
expect(fileContent).not.toContain(content)
}
})
},
},
} satisfies TestContext

config.fs['.gitignore'] ??= txt`
node_modules/
`

for (let [filename, content] of Object.entries(config.fs)) {
await context.fs.write(filename, content)
}
Expand Down
18 changes: 17 additions & 1 deletion packages/tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"require": "./dist/lib.js",
"import": "./src/index.ts"
},
"./colors": {
"require": "./src/compat/colors.cts",
"import": "./src/compat/colors.ts"
},
"./defaultTheme": {
"require": "./src/compat/default-theme.cts",
"import": "./src/compat/default-theme.ts"
},
"./plugin": {
"require": "./src/plugin.cts",
"import": "./src/plugin.ts"
Expand All @@ -49,7 +57,15 @@
},
"./plugin": {
"require": "./dist/plugin.js",
"import": "./src/plugin.mjs"
"import": "./dist/plugin.mjs"
},
"./defaultTheme": {
"require": "./dist/default-theme.js",
"import": "./dist/default-theme.mjs"
},
"./colors": {
"require": "./dist/colors.js",
"import": "./dist/colors.mjs"
},
"./package.json": "./package.json",
"./index.css": "./index.css",
Expand Down
1 change: 1 addition & 0 deletions packages/tailwindcss/src/compat/colors.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./colors.ts').default
Loading