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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add support for addComponents and matchComponents
  • Loading branch information
thecrypticace committed Aug 21, 2024
commit b6a9f2af93c34cb8ce94178cbbf470bee9ecb8b4
30 changes: 29 additions & 1 deletion packages/tailwindcss/src/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ export type PluginAPI = {
modifiers: 'any' | Record<string, string>
}>,
): void

addComponents(utilities: Record<string, CssInJs> | Record<string, CssInJs>[], options?: {}): void
matchComponents(
utilities: Record<string, (value: string, extra: { modifier: string | null }) => CssInJs>,
options?: Partial<{
type: string | string[]
supportsNegativeValues: boolean
values: Record<string, string> & {
__BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined
}
modifiers: 'any' | Record<string, string>
}>,
): void

theme(path: string, defaultValue?: any): any
}

Expand All @@ -45,7 +59,7 @@ function buildPluginApi(
ast: AstNode[],
resolvedConfig: { theme?: Record<string, any> },
): PluginAPI {
return {
let api: PluginAPI = {
addBase(css) {
ast.push(rule('@layer base', objectToAst(css)))
},
Expand Down Expand Up @@ -215,12 +229,26 @@ function buildPluginApi(
}
},

addComponents(components, options) {
this.addUtilities(components)
},

matchComponents(components, options) {
this.matchUtilities(components)
},

theme: createThemeFn(
designSystem,
() => resolvedConfig.theme ?? {},
(value) => value,
),
}

// Bind these functions so they can use `this`
api.addComponents = api.addComponents.bind(api)
api.matchComponents = api.matchComponents.bind(api)

return api
}

export type CssInJs = { [key: string]: string | CssInJs | CssInJs[] }
Expand Down