From 931211a634183a8122ce0be874cc1f9048768d88 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 16 Jan 2025 16:09:08 +0100 Subject: [PATCH] fix(NavigationMenu): highlight open items on `horizontal` orientation only --- src/theme/navigation-menu.ts | 26 ++++- .../NavigationMenu-vue.spec.ts.snap | 96 +++++++++---------- .../__snapshots__/NavigationMenu.spec.ts.snap | 96 +++++++++---------- 3 files changed, 118 insertions(+), 100 deletions(-) diff --git a/src/theme/navigation-menu.ts b/src/theme/navigation-menu.ts index 05448be5..75c6d6d2 100644 --- a/src/theme/navigation-menu.ts +++ b/src/theme/navigation-menu.ts @@ -108,8 +108,17 @@ export default (options: Required) => ({ active: false, variant: 'pill', class: { - link: ['hover:text-[var(--ui-text-highlighted)] hover:before:bg-[var(--ui-bg-elevated)]/50 data-[state=open]:text-[var(--ui-text-highlighted)]', options.theme.transitions && 'transition-colors before:transition-colors'], - linkLeadingIcon: ['group-hover:text-[var(--ui-text)] group-data-[state=open]:text-[var(--ui-text)]', options.theme.transitions && 'transition-colors'] + link: ['hover:text-[var(--ui-text-highlighted)] hover:before:bg-[var(--ui-bg-elevated)]/50', options.theme.transitions && 'transition-colors before:transition-colors'], + linkLeadingIcon: ['group-hover:text-[var(--ui-text)]', options.theme.transitions && 'transition-colors'] + } + }, { + disabled: false, + active: false, + variant: 'pill', + orientation: 'horizontal', + class: { + link: 'data-[state=open]:text-[var(--ui-text-highlighted)]', + linkLeadingIcon: 'group-data-[state=open]:text-[var(--ui-text)]' } }, { disabled: false, @@ -163,8 +172,17 @@ export default (options: Required) => ({ active: false, variant: 'link', class: { - link: ['hover:text-[var(--ui-text-highlighted)] data-[state=open]:text-[var(--ui-text-highlighted)]', options.theme.transitions && 'transition-colors'], - linkLeadingIcon: ['group-hover:text-[var(--ui-text)] group-data-[state=open]:text-[var(--ui-text)]', options.theme.transitions && 'transition-colors'] + link: ['hover:text-[var(--ui-text-highlighted)]', options.theme.transitions && 'transition-colors'], + linkLeadingIcon: ['group-hover:text-[var(--ui-text)]', options.theme.transitions && 'transition-colors'] + } + }, { + disabled: false, + active: false, + variant: 'link', + orientation: 'horizontal', + class: { + link: 'data-[state=open]:text-[var(--ui-text-highlighted)]', + linkLeadingIcon: 'group-data-[state=open]:text-[var(--ui-text)]' } }, ...(options.theme.colors || []).map((color: string) => ({ color, diff --git a/test/components/__snapshots__/NavigationMenu-vue.spec.ts.snap b/test/components/__snapshots__/NavigationMenu-vue.spec.ts.snap index e455b669..e2589b99 100644 --- a/test/components/__snapshots__/NavigationMenu-vue.spec.ts.snap +++ b/test/components/__snapshots__/NavigationMenu-vue.spec.ts.snap @@ -5,7 +5,7 @@ exports[`NavigationMenu > renders with arrow correctly 1`] = `
  • -
  • @@ -24,7 +24,7 @@ exports[`NavigationMenu > renders with arrow correctly 1`] = `
      -
    • GitHub +
    • GitHub @@ -51,7 +51,7 @@ exports[`NavigationMenu > renders with as correctly 1`] = `
      • -
      • @@ -70,7 +70,7 @@ exports[`NavigationMenu > renders with as correctly 1`] = `
          -
        • GitHub +
        • GitHub @@ -95,7 +95,7 @@ exports[`NavigationMenu > renders with class correctly 1`] = `
          • -
          • @@ -114,7 +114,7 @@ exports[`NavigationMenu > renders with class correctly 1`] = `
              -
            • GitHub +
            • GitHub @@ -139,7 +139,7 @@ exports[`NavigationMenu > renders with custom slot correctly 1`] = `
              • -
              • @@ -158,7 +158,7 @@ exports[`NavigationMenu > renders with custom slot correctly 1`] = `
                  -
                • GitHub +
                • GitHub @@ -183,7 +183,7 @@ exports[`NavigationMenu > renders with item slot correctly 1`] = `
                  • -
                  • +
                  • @@ -200,7 +200,7 @@ exports[`NavigationMenu > renders with item slot correctly 1`] = `
                      -
                    • Item slot +
                    • Item slot
                    • @@ -221,7 +221,7 @@ exports[`NavigationMenu > renders with item-label slot correctly 1`] = `
                      • -
                      • @@ -240,7 +240,7 @@ exports[`NavigationMenu > renders with item-label slot correctly 1`] = `
                          -
                        • Item label slot +
                        • Item label slot @@ -265,7 +265,7 @@ exports[`NavigationMenu > renders with item-leading slot correctly 1`] = `
                          • -
                          • @@ -284,7 +284,7 @@ exports[`NavigationMenu > renders with item-leading slot correctly 1`] = `
                              -
                            • Item leading slotGitHub +
                            • Item leading slotGitHub @@ -309,7 +309,7 @@ exports[`NavigationMenu > renders with item-trailing slot correctly 1`] = `
                              • -
                              • +
                              • @@ -326,7 +326,7 @@ exports[`NavigationMenu > renders with item-trailing slot correctly 1`] = `
                                  -
                                • GitHubItem trailing slot +
                                • GitHubItem trailing slot
                                • @@ -347,7 +347,7 @@ exports[`NavigationMenu > renders with items correctly 1`] = `
                                  • -
                                  • @@ -366,7 +366,7 @@ exports[`NavigationMenu > renders with items correctly 1`] = `
                                      -
                                    • GitHub +
                                    • GitHub @@ -391,7 +391,7 @@ exports[`NavigationMenu > renders with labelKey correctly 1`] = `
                                      • -
                                      • @@ -410,7 +410,7 @@ exports[`NavigationMenu > renders with labelKey correctly 1`] = `
                                          -
                                        • i-simple-icons-github +
                                        • i-simple-icons-github @@ -435,7 +435,7 @@ exports[`NavigationMenu > renders with neutral variant link correctly 1`] = `
                                          • -
                                          • @@ -454,7 +454,7 @@ exports[`NavigationMenu > renders with neutral variant link correctly 1`] = `
                                              -
                                            • GitHub +
                                            • GitHub @@ -479,7 +479,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight correctly
                                              • -
                                              • @@ -498,7 +498,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight correctly
                                                  -
                                                • GitHub +
                                                • GitHub @@ -523,7 +523,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight neutral co
                                                  • -
                                                  • @@ -542,7 +542,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight neutral co
                                                      -
                                                    • GitHub +
                                                    • GitHub @@ -567,7 +567,7 @@ exports[`NavigationMenu > renders with neutral variant pill correctly 1`] = `
                                                      • -
                                                      • @@ -586,7 +586,7 @@ exports[`NavigationMenu > renders with neutral variant pill correctly 1`] = `
                                                          -
                                                        • GitHub +
                                                        • GitHub @@ -611,7 +611,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight correctly
                                                          • -
                                                          • @@ -630,7 +630,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight correctly
                                                              -
                                                            • GitHub +
                                                            • GitHub @@ -655,7 +655,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight neutral co
                                                              • -
                                                              • @@ -674,7 +674,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight neutral co
                                                                  -
                                                                • GitHub +
                                                                • GitHub @@ -704,7 +704,7 @@ exports[`NavigationMenu > renders with orientation vertical correctly 1`] = `
                                                              • -
                                                              • @@ -723,7 +723,7 @@ exports[`NavigationMenu > renders with orientation vertical correctly 1`] = `
                                                                  -
                                                                • GitHub +
                                                                • GitHub @@ -745,7 +745,7 @@ exports[`NavigationMenu > renders with primary variant link correctly 1`] = `
                                                                  • -
                                                                  • @@ -764,7 +764,7 @@ exports[`NavigationMenu > renders with primary variant link correctly 1`] = `
                                                                      -
                                                                    • GitHub +
                                                                    • GitHub @@ -789,7 +789,7 @@ exports[`NavigationMenu > renders with primary variant link highlight correctly
                                                                      • -
                                                                      • @@ -808,7 +808,7 @@ exports[`NavigationMenu > renders with primary variant link highlight correctly
                                                                          -
                                                                        • GitHub +
                                                                        • GitHub @@ -833,7 +833,7 @@ exports[`NavigationMenu > renders with primary variant pill correctly 1`] = `
                                                                          • -
                                                                          • @@ -852,7 +852,7 @@ exports[`NavigationMenu > renders with primary variant pill correctly 1`] = `
                                                                              -
                                                                            • GitHub +
                                                                            • GitHub @@ -877,7 +877,7 @@ exports[`NavigationMenu > renders with primary variant pill highlight correctly
                                                                              • -
                                                                              • @@ -896,7 +896,7 @@ exports[`NavigationMenu > renders with primary variant pill highlight correctly
                                                                                  -
                                                                                • GitHub +
                                                                                • GitHub @@ -921,7 +921,7 @@ exports[`NavigationMenu > renders with trailingIcon correctly 1`] = `
                                                                                  • -
                                                                                  • @@ -940,7 +940,7 @@ exports[`NavigationMenu > renders with trailingIcon correctly 1`] = `
                                                                                      -
                                                                                    • GitHub +
                                                                                    • GitHub @@ -965,7 +965,7 @@ exports[`NavigationMenu > renders with ui correctly 1`] = `
                                                                                      • -
                                                                                      • @@ -984,7 +984,7 @@ exports[`NavigationMenu > renders with ui correctly 1`] = `
                                                                                          -
                                                                                        • GitHub +
                                                                                        • GitHub @@ -1009,7 +1009,7 @@ exports[`NavigationMenu > renders with unmountOnHide correctly 1`] = `
                                                                                          • -
                                                                                          • @@ -1026,7 +1026,7 @@ exports[`NavigationMenu > renders with unmountOnHide correctly 1`] = `
                                                                                              -
                                                                                            • GitHub +
                                                                                            • GitHub diff --git a/test/components/__snapshots__/NavigationMenu.spec.ts.snap b/test/components/__snapshots__/NavigationMenu.spec.ts.snap index 5cb9ccc3..c1564911 100644 --- a/test/components/__snapshots__/NavigationMenu.spec.ts.snap +++ b/test/components/__snapshots__/NavigationMenu.spec.ts.snap @@ -5,7 +5,7 @@ exports[`NavigationMenu > renders with arrow correctly 1`] = `
                                                                                              • -
                                                                                              • @@ -24,7 +24,7 @@ exports[`NavigationMenu > renders with arrow correctly 1`] = `
                                                                                                  -
                                                                                                • GitHub +
                                                                                                • GitHub @@ -51,7 +51,7 @@ exports[`NavigationMenu > renders with as correctly 1`] = `
                                                                                                  • -
                                                                                                  • @@ -70,7 +70,7 @@ exports[`NavigationMenu > renders with as correctly 1`] = `
                                                                                                      -
                                                                                                    • GitHub +
                                                                                                    • GitHub @@ -95,7 +95,7 @@ exports[`NavigationMenu > renders with class correctly 1`] = `
                                                                                                      • -
                                                                                                      • @@ -114,7 +114,7 @@ exports[`NavigationMenu > renders with class correctly 1`] = `
                                                                                                          -
                                                                                                        • GitHub +
                                                                                                        • GitHub @@ -139,7 +139,7 @@ exports[`NavigationMenu > renders with custom slot correctly 1`] = `
                                                                                                          • -
                                                                                                          • @@ -158,7 +158,7 @@ exports[`NavigationMenu > renders with custom slot correctly 1`] = `
                                                                                                              -
                                                                                                            • GitHub +
                                                                                                            • GitHub @@ -183,7 +183,7 @@ exports[`NavigationMenu > renders with item slot correctly 1`] = `
                                                                                                              • -
                                                                                                              • +
                                                                                                              • @@ -200,7 +200,7 @@ exports[`NavigationMenu > renders with item slot correctly 1`] = `
                                                                                                                  -
                                                                                                                • Item slot +
                                                                                                                • Item slot
                                                                                                                • @@ -221,7 +221,7 @@ exports[`NavigationMenu > renders with item-label slot correctly 1`] = `
                                                                                                                  • -
                                                                                                                  • @@ -240,7 +240,7 @@ exports[`NavigationMenu > renders with item-label slot correctly 1`] = `
                                                                                                                      -
                                                                                                                    • Item label slot +
                                                                                                                    • Item label slot @@ -265,7 +265,7 @@ exports[`NavigationMenu > renders with item-leading slot correctly 1`] = `
                                                                                                                      • -
                                                                                                                      • @@ -284,7 +284,7 @@ exports[`NavigationMenu > renders with item-leading slot correctly 1`] = `
                                                                                                                          -
                                                                                                                        • Item leading slotGitHub +
                                                                                                                        • Item leading slotGitHub @@ -309,7 +309,7 @@ exports[`NavigationMenu > renders with item-trailing slot correctly 1`] = `
                                                                                                                          • -
                                                                                                                          • +
                                                                                                                          • @@ -326,7 +326,7 @@ exports[`NavigationMenu > renders with item-trailing slot correctly 1`] = `
                                                                                                                              -
                                                                                                                            • GitHubItem trailing slot +
                                                                                                                            • GitHubItem trailing slot
                                                                                                                            • @@ -347,7 +347,7 @@ exports[`NavigationMenu > renders with items correctly 1`] = `
                                                                                                                              • -
                                                                                                                              • @@ -366,7 +366,7 @@ exports[`NavigationMenu > renders with items correctly 1`] = `
                                                                                                                                  -
                                                                                                                                • GitHub +
                                                                                                                                • GitHub @@ -391,7 +391,7 @@ exports[`NavigationMenu > renders with labelKey correctly 1`] = `
                                                                                                                                  • -
                                                                                                                                  • @@ -410,7 +410,7 @@ exports[`NavigationMenu > renders with labelKey correctly 1`] = `
                                                                                                                                      -
                                                                                                                                    • i-simple-icons-github +
                                                                                                                                    • i-simple-icons-github @@ -435,7 +435,7 @@ exports[`NavigationMenu > renders with neutral variant link correctly 1`] = `
                                                                                                                                      • -
                                                                                                                                      • @@ -454,7 +454,7 @@ exports[`NavigationMenu > renders with neutral variant link correctly 1`] = `
                                                                                                                                          -
                                                                                                                                        • GitHub +
                                                                                                                                        • GitHub @@ -479,7 +479,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight correctly
                                                                                                                                          • -
                                                                                                                                          • @@ -498,7 +498,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight correctly
                                                                                                                                              -
                                                                                                                                            • GitHub +
                                                                                                                                            • GitHub @@ -523,7 +523,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight neutral co
                                                                                                                                              • -
                                                                                                                                              • @@ -542,7 +542,7 @@ exports[`NavigationMenu > renders with neutral variant link highlight neutral co
                                                                                                                                                  -
                                                                                                                                                • GitHub +
                                                                                                                                                • GitHub @@ -567,7 +567,7 @@ exports[`NavigationMenu > renders with neutral variant pill correctly 1`] = `
                                                                                                                                                  • -
                                                                                                                                                  • @@ -586,7 +586,7 @@ exports[`NavigationMenu > renders with neutral variant pill correctly 1`] = `
                                                                                                                                                      -
                                                                                                                                                    • GitHub +
                                                                                                                                                    • GitHub @@ -611,7 +611,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight correctly
                                                                                                                                                      • -
                                                                                                                                                      • @@ -630,7 +630,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight correctly
                                                                                                                                                          -
                                                                                                                                                        • GitHub +
                                                                                                                                                        • GitHub @@ -655,7 +655,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight neutral co
                                                                                                                                                          • -
                                                                                                                                                          • @@ -674,7 +674,7 @@ exports[`NavigationMenu > renders with neutral variant pill highlight neutral co
                                                                                                                                                              -
                                                                                                                                                            • GitHub +
                                                                                                                                                            • GitHub @@ -704,7 +704,7 @@ exports[`NavigationMenu > renders with orientation vertical correctly 1`] = `
                                                                                                                                                          • -
                                                                                                                                                          • @@ -723,7 +723,7 @@ exports[`NavigationMenu > renders with orientation vertical correctly 1`] = `
                                                                                                                                                              -
                                                                                                                                                            • GitHub +
                                                                                                                                                            • GitHub @@ -745,7 +745,7 @@ exports[`NavigationMenu > renders with primary variant link correctly 1`] = `
                                                                                                                                                              • -
                                                                                                                                                              • @@ -764,7 +764,7 @@ exports[`NavigationMenu > renders with primary variant link correctly 1`] = `
                                                                                                                                                                  -
                                                                                                                                                                • GitHub +
                                                                                                                                                                • GitHub @@ -789,7 +789,7 @@ exports[`NavigationMenu > renders with primary variant link highlight correctly
                                                                                                                                                                  • -
                                                                                                                                                                  • @@ -808,7 +808,7 @@ exports[`NavigationMenu > renders with primary variant link highlight correctly
                                                                                                                                                                      -
                                                                                                                                                                    • GitHub +
                                                                                                                                                                    • GitHub @@ -833,7 +833,7 @@ exports[`NavigationMenu > renders with primary variant pill correctly 1`] = `
                                                                                                                                                                      • -
                                                                                                                                                                      • @@ -852,7 +852,7 @@ exports[`NavigationMenu > renders with primary variant pill correctly 1`] = `
                                                                                                                                                                          -
                                                                                                                                                                        • GitHub +
                                                                                                                                                                        • GitHub @@ -877,7 +877,7 @@ exports[`NavigationMenu > renders with primary variant pill highlight correctly
                                                                                                                                                                          • -
                                                                                                                                                                          • @@ -896,7 +896,7 @@ exports[`NavigationMenu > renders with primary variant pill highlight correctly
                                                                                                                                                                              -
                                                                                                                                                                            • GitHub +
                                                                                                                                                                            • GitHub @@ -921,7 +921,7 @@ exports[`NavigationMenu > renders with trailingIcon correctly 1`] = `
                                                                                                                                                                              • -
                                                                                                                                                                              • @@ -940,7 +940,7 @@ exports[`NavigationMenu > renders with trailingIcon correctly 1`] = `
                                                                                                                                                                                  -
                                                                                                                                                                                • GitHub +
                                                                                                                                                                                • GitHub @@ -965,7 +965,7 @@ exports[`NavigationMenu > renders with ui correctly 1`] = `
                                                                                                                                                                                  • -
                                                                                                                                                                                  • @@ -984,7 +984,7 @@ exports[`NavigationMenu > renders with ui correctly 1`] = `
                                                                                                                                                                                      -
                                                                                                                                                                                    • GitHub +
                                                                                                                                                                                    • GitHub @@ -1009,7 +1009,7 @@ exports[`NavigationMenu > renders with unmountOnHide correctly 1`] = `
                                                                                                                                                                                      • -
                                                                                                                                                                                      • @@ -1026,7 +1026,7 @@ exports[`NavigationMenu > renders with unmountOnHide correctly 1`] = `