From 6047d534fd9e27bfa1da23451ae7c931fdcd55c4 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:52:16 +0100 Subject: [PATCH] add support for `svh`, `lvh` and dvh` scale values --- src/lib/default-config.ts | 40 ++++++++++++++++++++++++++--- tests/tailwind-css-versions.test.ts | 4 +++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/lib/default-config.ts b/src/lib/default-config.ts index a29892df..10b6cd83 100644 --- a/src/lib/default-config.ts +++ b/src/lib/default-config.ts @@ -581,7 +581,21 @@ export function getDefaultConfig() { * Width * @see https://tailwindcss.com/docs/width */ - w: [{ w: ['auto', 'min', 'max', 'fit', isArbitraryValue, spacing] }], + w: [ + { + w: [ + 'auto', + 'min', + 'max', + 'fit', + 'svw', + 'lvw', + 'dvw', + isArbitraryValue, + spacing, + ], + }, + ], /** * Min-Width * @see https://tailwindcss.com/docs/min-width @@ -611,17 +625,35 @@ export function getDefaultConfig() { * Height * @see https://tailwindcss.com/docs/height */ - h: [{ h: [isArbitraryValue, spacing, 'auto', 'min', 'max', 'fit'] }], + h: [ + { + h: [ + isArbitraryValue, + spacing, + 'auto', + 'min', + 'max', + 'fit', + 'svh', + 'lvh', + 'dvh', + ], + }, + ], /** * Min-Height * @see https://tailwindcss.com/docs/min-height */ - 'min-h': [{ 'min-h': ['min', 'max', 'fit', isLength, isArbitraryValue] }], + 'min-h': [ + { 'min-h': ['min', 'max', 'fit', 'svh', 'lvh', 'dvh', isLength, isArbitraryValue] }, + ], /** * Max-Height * @see https://tailwindcss.com/docs/max-height */ - 'max-h': [{ 'max-h': [isArbitraryValue, spacing, 'min', 'max', 'fit'] }], + 'max-h': [ + { 'max-h': [isArbitraryValue, spacing, 'min', 'max', 'fit', 'svh', 'lvh', 'dvh'] }, + ], // Typography /** * Font Size diff --git a/tests/tailwind-css-versions.test.ts b/tests/tailwind-css-versions.test.ts index c4e7c697..91d85a21 100644 --- a/tests/tailwind-css-versions.test.ts +++ b/tests/tailwind-css-versions.test.ts @@ -34,3 +34,7 @@ test('supports Tailwind CSS v3.3 features', () => { expect(twMerge('content-normal content-center content-stretch')).toBe('content-stretch') expect(twMerge('whitespace-nowrap whitespace-break-spaces')).toBe('whitespace-break-spaces') }) + +test('supports Tailwind CSS v3.4 features', () => { + expect(twMerge('h-svh h-dvh w-svw w-dvw')).toBe('h-dvh w-dvw') +})