Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Revert: inlining drop-shadow(…) values
We updated the drop shadow values to have a single shadow instead of
multiple values which allows us to keep using the `var(…)` instead of
inlining it.

The caveat is that if you define a custom drop shadow that contains
multiple values then that won't be valid CSS because the two (or more)
drop shadows will be wrapped in a `drop-shadow(shadow-1, shadow-2, …)`
  • Loading branch information
RobinMalfait committed Nov 21, 2024
commit 8fb8137af60668b2efd95d5094fb080a0352c5a5
4 changes: 2 additions & 2 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13694,7 +13694,7 @@ test('filter', async () => {
}

.drop-shadow {
--tw-drop-shadow: drop-shadow(0 1px 2px #0000001a) drop-shadow(0 1px 1px #0000000f);
--tw-drop-shadow: drop-shadow(var(--drop-shadow));
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

Expand All @@ -13704,7 +13704,7 @@ test('filter', async () => {
}

.drop-shadow-xl {
--tw-drop-shadow: drop-shadow(0 20px 13px #00000008) drop-shadow(0 8px 5px #00000014);
--tw-drop-shadow: drop-shadow(var(--drop-shadow-xl));
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

Expand Down
21 changes: 5 additions & 16 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ export function createUtilities(theme: Theme) {
supportsNegative?: boolean
supportsFractions?: boolean
themeKeys?: ThemeKey[]
inlineThemeValues?: boolean
defaultValue?: string | null
handleBareValue?: (value: NamedUtilityValue) => string | null
handleNegativeBareValue?: (value: NamedUtilityValue) => string | null
Expand All @@ -276,24 +275,15 @@ export function createUtilities(theme: Theme) {
value =
desc.defaultValue !== undefined
? desc.defaultValue
: desc.inlineThemeValues
? theme.resolveValue(null, desc.themeKeys ?? [])
: theme.resolve(null, desc.themeKeys ?? [])
: theme.resolve(null, desc.themeKeys ?? [])
} else if (candidate.value.kind === 'arbitrary') {
if (candidate.modifier) return
value = candidate.value.value
} else {
if (desc.inlineThemeValues) {
value = theme.resolveValue(
candidate.value.fraction ?? candidate.value.value,
desc.themeKeys ?? [],
)
} else {
value = theme.resolve(
candidate.value.fraction ?? candidate.value.value,
desc.themeKeys ?? [],
)
}
value = theme.resolve(
candidate.value.fraction ?? candidate.value.value,
desc.themeKeys ?? [],
)

// Automatically handle things like `w-1/2` without requiring `1/2` to
// exist as a theme value.
Expand Down Expand Up @@ -3483,7 +3473,6 @@ export function createUtilities(theme: Theme) {
])
functionalUtility('drop-shadow', {
themeKeys: ['--drop-shadow'],
inlineThemeValues: true,
handle: (value) => [
filterProperties(),
decl(
Expand Down