Skip to content

Commit

Permalink
Allows fallback values in plugin API helpers (#8762)
Browse files Browse the repository at this point in the history
* Update types to allow for fallback property values in add/matchUtilities/Components/etc…

* Update changelog
  • Loading branch information
thecrypticace committed Jul 1, 2022
1 parent c47e666 commit d4f1f15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Allows fallback values in plugin API helpers ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))

## [3.1.4] - 2022-06-21

Expand Down
11 changes: 6 additions & 5 deletions types/config.d.ts
Expand Up @@ -12,6 +12,7 @@ interface RecursiveKeyValuePair<K extends keyof any = string, V = string> {
[key: string]: V | RecursiveKeyValuePair<K, V>
}
type ResolvableTo<T> = T | ((utils: PluginUtils) => T)
type CSSRuleObject = RecursiveKeyValuePair<string, string | string[]>

interface PluginUtils {
colors: DefaultColors
Expand Down Expand Up @@ -242,15 +243,15 @@ type ValueType =
export interface PluginAPI {
// for registering new static utility styles
addUtilities(
utilities: RecursiveKeyValuePair | RecursiveKeyValuePair[],
utilities: CSSRuleObject | CSSRuleObject[],
options?: Partial<{
respectPrefix: boolean
respectImportant: boolean
}>
): void
// for registering new dynamic utility styles
matchUtilities<T>(
utilities: KeyValuePair<string, (value: T) => RecursiveKeyValuePair>,
utilities: KeyValuePair<string, (value: T) => CSSRuleObject>,
options?: Partial<{
respectPrefix: boolean
respectImportant: boolean
Expand All @@ -261,15 +262,15 @@ export interface PluginAPI {
): void
// for registering new static component styles
addComponents(
components: RecursiveKeyValuePair | RecursiveKeyValuePair[],
components: CSSRuleObject | CSSRuleObject[],
options?: Partial<{
respectPrefix: boolean
respectImportant: boolean
}>
): void
// for registering new dynamic component styles
matchComponents<T>(
components: KeyValuePair<string, (value: T) => RecursiveKeyValuePair>,
components: KeyValuePair<string, (value: T) => CSSRuleObject>,
options?: Partial<{
respectPrefix: boolean
respectImportant: boolean
Expand All @@ -279,7 +280,7 @@ export interface PluginAPI {
}>
): void
// for registering new base styles
addBase(base: RecursiveKeyValuePair | RecursiveKeyValuePair[]): void
addBase(base: CSSRuleObject | CSSRuleObject[]): void
// for registering custom variants
addVariant(name: string, definition: string | string[] | (() => string) | (() => string)[]): void
// for looking up values in the user’s theme configuration
Expand Down

0 comments on commit d4f1f15

Please sign in to comment.