From 9d5f9a70101bcc75f05dc59a3d4dc2d368106b5f Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Sat, 8 Jun 2024 16:14:23 +0200 Subject: [PATCH] fix(Tabs): align `link` variant left when vertical --- src/theme/tabs.ts | 10 ++-- .../__snapshots__/Tabs.spec.ts.snap | 48 +++++++++---------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/theme/tabs.ts b/src/theme/tabs.ts index 4b626196..26643f67 100644 --- a/src/theme/tabs.ts +++ b/src/theme/tabs.ts @@ -5,7 +5,7 @@ export default (options: Required) => ({ root: 'flex items-center gap-2', list: 'relative flex p-1 group', indicator: 'absolute transition-[translate,width] duration-200', - trigger: ['relative inline-flex items-center justify-center shrink-0 data-[state=inactive]:text-gray-500 dark:data-[state=inactive]:text-gray-400 hover:data-[state=inactive]:text-gray-700 dark:hover:data-[state=inactive]:text-gray-200 font-medium rounded-md disabled:cursor-not-allowed disabled:opacity-75 focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus:outline-none', options.transitions && 'transition-colors'], + trigger: ['relative inline-flex items-center shrink-0 data-[state=inactive]:text-gray-500 dark:data-[state=inactive]:text-gray-400 hover:data-[state=inactive]:text-gray-700 dark:hover:data-[state=inactive]:text-gray-200 font-medium rounded-md disabled:cursor-not-allowed disabled:opacity-75 focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus:outline-none', options.transitions && 'transition-colors'], content: 'focus:outline-none w-full', leadingIcon: 'shrink-0', leadingAvatar: 'shrink-0', @@ -33,10 +33,11 @@ export default (options: Required) => ({ horizontal: { root: 'flex-col', list: 'w-full', - indicator: 'left-0 w-[--radix-tabs-indicator-size] translate-x-[--radix-tabs-indicator-position]' + indicator: 'left-0 w-[--radix-tabs-indicator-size] translate-x-[--radix-tabs-indicator-position]', + trigger: 'justify-center' }, vertical: { - list: 'flex-col items-center', + list: 'flex-col', indicator: 'top-0 h-[--radix-tabs-indicator-size] translate-y-[--radix-tabs-indicator-position]' } }, @@ -85,7 +86,8 @@ export default (options: Required) => ({ orientation: 'vertical', variant: 'pill', class: { - indicator: 'inset-x-1' + indicator: 'inset-x-1', + list: 'items-center' } }, { orientation: 'vertical', diff --git a/test/components/__snapshots__/Tabs.spec.ts.snap b/test/components/__snapshots__/Tabs.spec.ts.snap index 026d44c4..79928d8d 100644 --- a/test/components/__snapshots__/Tabs.spec.ts.snap +++ b/test/components/__snapshots__/Tabs.spec.ts.snap @@ -3,7 +3,7 @@ exports[`Tabs > renders with class correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -14,7 +14,7 @@ exports[`Tabs > renders with class correctly 1`] = ` exports[`Tabs > renders with color black correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -25,7 +25,7 @@ exports[`Tabs > renders with color black correctly 1`] = ` exports[`Tabs > renders with color green correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -36,7 +36,7 @@ exports[`Tabs > renders with color green correctly 1`] = ` exports[`Tabs > renders with color primary correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -47,7 +47,7 @@ exports[`Tabs > renders with color primary correctly 1`] = ` exports[`Tabs > renders with color red correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -58,7 +58,7 @@ exports[`Tabs > renders with color red correctly 1`] = ` exports[`Tabs > renders with color white correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -69,7 +69,7 @@ exports[`Tabs > renders with color white correctly 1`] = ` exports[`Tabs > renders with content slot correctly 1`] = ` "
-
+
Content slot
@@ -80,7 +80,7 @@ exports[`Tabs > renders with content slot correctly 1`] = ` exports[`Tabs > renders with custom slot correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -91,7 +91,7 @@ exports[`Tabs > renders with custom slot correctly 1`] = ` exports[`Tabs > renders with default slot correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -102,7 +102,7 @@ exports[`Tabs > renders with default slot correctly 1`] = ` exports[`Tabs > renders with defaultValue correctly 1`] = ` "
-
+
And, this is the content for Tab2
@@ -113,7 +113,7 @@ exports[`Tabs > renders with defaultValue correctly 1`] = ` exports[`Tabs > renders with items correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -124,7 +124,7 @@ exports[`Tabs > renders with items correctly 1`] = ` exports[`Tabs > renders with leading slot correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -135,7 +135,7 @@ exports[`Tabs > renders with leading slot correctly 1`] = ` exports[`Tabs > renders with modelValue correctly 1`] = ` "
-
+
And, this is the content for Tab2
@@ -146,7 +146,7 @@ exports[`Tabs > renders with modelValue correctly 1`] = ` exports[`Tabs > renders with orientation vertical correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -157,7 +157,7 @@ exports[`Tabs > renders with orientation vertical correctly 1`] = ` exports[`Tabs > renders with size lg correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -168,7 +168,7 @@ exports[`Tabs > renders with size lg correctly 1`] = ` exports[`Tabs > renders with size md correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -179,7 +179,7 @@ exports[`Tabs > renders with size md correctly 1`] = ` exports[`Tabs > renders with size sm correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -190,7 +190,7 @@ exports[`Tabs > renders with size sm correctly 1`] = ` exports[`Tabs > renders with size xl correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -201,7 +201,7 @@ exports[`Tabs > renders with size xl correctly 1`] = ` exports[`Tabs > renders with size xs correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -212,7 +212,7 @@ exports[`Tabs > renders with size xs correctly 1`] = ` exports[`Tabs > renders with trailing slot correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -223,7 +223,7 @@ exports[`Tabs > renders with trailing slot correctly 1`] = ` exports[`Tabs > renders with ui correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -234,7 +234,7 @@ exports[`Tabs > renders with ui correctly 1`] = ` exports[`Tabs > renders with variant link correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -245,7 +245,7 @@ exports[`Tabs > renders with variant link correctly 1`] = ` exports[`Tabs > renders with variant pill correctly 1`] = ` "
-
+
This is the content shown for Tab1
@@ -256,7 +256,7 @@ exports[`Tabs > renders with variant pill correctly 1`] = ` exports[`Tabs > renders without content correctly 1`] = ` "
-
+
"