From 0dae2ea27c086c46a40fc446f226a05c016b82a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Fri, 6 Nov 2026 14:37:05 +0100 Subject: [PATCH 1/3] feat(navbar): show the challenges entry in place of the offer entry When a challenge is published in the page language, "Vos enjeux" takes the place of "Notre offre" in the menu. With no challenge (flag off, or nothing published in that language), the offer entry stays. The /offer route is unchanged and still reachable by URL. Co-Authored-By: Claude --- app/components/navbar/navbar.test.tsx | 15 ++++++-- app/hooks/useMenuItems.test.ts | 54 +++++++++++++++++++++++++++ app/hooks/useMenuItems.ts | 20 +++++++++- 3 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 app/hooks/useMenuItems.test.ts diff --git a/app/components/navbar/navbar.test.tsx b/app/components/navbar/navbar.test.tsx index ef1e865b..a9b8f40f 100644 --- a/app/components/navbar/navbar.test.tsx +++ b/app/components/navbar/navbar.test.tsx @@ -91,22 +91,29 @@ const withChallenges = (challenges: ChallengeMenuEntry[], failed = false) => ({ }); describe('Navbar challenge entry', () => { - it('is hidden when no challenge is published', () => { + it('is hidden when no challenge is published, and the offer stays', () => { render(, withChallenges([])); expect( screen.queryByRole('button', { name: /vos enjeux/i }), ).not.toBeInTheDocument(); + expect( + screen.getByRole('link', { name: 'Notre Offre' }), + ).toBeInTheDocument(); }); - it('comes first and lists the challenges in the order given', async () => { + it('replaces the offer entry and lists the challenges in order', async () => { const user = userEvent.setup(); render(, withChallenges(frenchChallenges)); const trigger = screen.getByRole('button', { name: /vos enjeux/i }); - const offer = screen.getByRole('link', { name: 'Notre Offre' }); expect( - trigger.compareDocumentPosition(offer) & Node.DOCUMENT_POSITION_FOLLOWING, + screen.queryByRole('link', { name: 'Notre Offre' }), + ).not.toBeInTheDocument(); + const stories = screen.getByRole('link', { name: 'Success Stories' }); + expect( + trigger.compareDocumentPosition(stories) & + Node.DOCUMENT_POSITION_FOLLOWING, ).toBeTruthy(); await user.click(trigger); diff --git a/app/hooks/useMenuItems.test.ts b/app/hooks/useMenuItems.test.ts new file mode 100644 index 00000000..9ae466f3 --- /dev/null +++ b/app/hooks/useMenuItems.test.ts @@ -0,0 +1,54 @@ +import { describe, expect, it } from 'vitest'; + +import type { NavItem } from '~/components/navbar/types'; + +import { placeChallengeItem } from './useMenuItems'; + +const offer: NavItem = { key: 'offer', label: 'Notre offre', path: '/offer' }; +const stories: NavItem = { key: 'stories', label: 'Stories', path: '/clients' }; +const contact: NavItem = { + key: 'contact', + label: 'Contact', + path: '/contact', + isButton: true, +}; +const challenges: NavItem = { + key: 'challenges', + label: 'Vos enjeux', + path: null, + dropdown: [ + { + key: 'challenge-revenue-performance', + label: 'Revenue Performance', + path: '/challenges/revenue-performance', + color: 'yellow', + }, + ], +}; + +describe('placeChallengeItem', () => { + it('puts the challenge entry in the place of the offer entry', () => { + const items = placeChallengeItem([offer, stories, contact], challenges); + + expect(items.map((item) => item.key)).toEqual([ + 'challenges', + 'stories', + 'contact', + ]); + expect(items[0]).toBe(challenges); + }); + + it('keeps the offer entry when no challenge is published', () => { + const items = [offer, stories, contact]; + + expect(placeChallengeItem(items, null)).toEqual([offer, stories, contact]); + }); + + it('does not mutate the given list', () => { + const items = [offer, stories]; + + placeChallengeItem(items, challenges); + + expect(items).toEqual([offer, stories]); + }); +}); diff --git a/app/hooks/useMenuItems.ts b/app/hooks/useMenuItems.ts index d7633d5a..7f969c7b 100644 --- a/app/hooks/useMenuItems.ts +++ b/app/hooks/useMenuItems.ts @@ -27,6 +27,21 @@ const menuKeyToSlug: Record = { tools: 'tools', }; +/** + * Puts the challenge entry in the place of the offer entry: "Vos enjeux" + * replaces "Notre offre" once a challenge is published in the page language. + * Without one, the offer entry stays. The `/offer` route itself stays live. + */ +export function placeChallengeItem( + items: NavItem[], + challengeItem: NavItem | null, +): NavItem[] { + if (challengeItem === null) { + return items; + } + return items.map((item) => (item.key === 'offer' ? challengeItem : item)); +} + export function useMenuItems(): NavItem[] { const { t } = useTranslation('common'); const getLocalizedPath = useLocalizedPathname(); @@ -127,8 +142,7 @@ export function useMenuItems(): NavItem[] { }, ]; - return [ - ...(challengeItem ? [challengeItem] : []), + const items: NavItem[] = [ { key: 'offer', label: t('navigation.offer'), @@ -164,4 +178,6 @@ export function useMenuItems(): NavItem[] { isButton: true, }, ]; + + return placeChallengeItem(items, challengeItem); } From 2760917fcc7d8307b84ff59f7ed6d9f8c44b83ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Fri, 6 Nov 2026 14:37:05 +0100 Subject: [PATCH 2/3] fix(navbar): keep the desktop bar on one line The scrolled bar was capped at 5xl (1024px), which left no room once the challenges entry was shown, and the dropdown triggers could break their label onto two lines. Widen the scrolled cap to 6xl, keep every trigger on one line, and tighten item spacing between 1024px and 1280px. Mobile is unchanged. Co-Authored-By: Claude --- app/components/navbar/nav-item-with-dropdown.tsx | 4 +++- app/components/navbar/navbar.tsx | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/components/navbar/nav-item-with-dropdown.tsx b/app/components/navbar/nav-item-with-dropdown.tsx index 228c53c6..d089ddd8 100644 --- a/app/components/navbar/nav-item-with-dropdown.tsx +++ b/app/components/navbar/nav-item-with-dropdown.tsx @@ -31,7 +31,8 @@ export function NavItemWithDropdown({ const triggerStyles = cx( flex({ gap: '1', align: 'center' }), css({ - px: '4', + // Same spacing as the plain links in `navbar.tsx`. + px: { base: '4', lg: '3', xl: '4' }, py: '2', rounded: 'full', fontSize: 'sm', @@ -41,6 +42,7 @@ export function NavItemWithDropdown({ transitionDuration: 'slow', color: isOpen || isCurrentPath ? 'ocobo.dark' : 'gray.500', _hover: { color: 'ocobo.dark' }, + whiteSpace: 'nowrap', }), ); diff --git a/app/components/navbar/navbar.tsx b/app/components/navbar/navbar.tsx index c5e26d18..bb28256c 100644 --- a/app/components/navbar/navbar.tsx +++ b/app/components/navbar/navbar.tsx @@ -19,7 +19,8 @@ const getLinkStyles = (isDropdownActive: boolean, isCurrent: boolean) => cx( flex({ gap: '1', align: 'center' }), css({ - px: '4', + // Tighter between 1024px and 1280px, so the bar stays on one line. + px: { base: '4', lg: '3', xl: '4' }, py: '2', rounded: 'full', fontSize: 'sm', @@ -71,7 +72,9 @@ export function Navbar() { className={css({ position: 'relative', w: 'full', - maxW: scrolled ? '5xl' : '7xl', + // 6xl, not 5xl: the scrolled bar must hold every item on one line + // with the challenges entry shown. + maxW: scrolled ? '6xl' : '7xl', transition: 'all', transitionDuration: '[700ms]', transitionTimingFunction: 'smooth', @@ -136,9 +139,10 @@ export function Navbar() { {/* Desktop Navigation */}
Date: Fri, 6 Nov 2026 14:39:27 +0100 Subject: [PATCH 3/3] refactor(navbar): address review on the challenges swap Keep the challenges entry when no offer entry exists, reword a comment, and drop a flexWrap that changed nothing. Co-Authored-By: Claude --- app/components/navbar/navbar.tsx | 4 +--- app/hooks/useMenuItems.test.ts | 10 ++++++++++ app/hooks/useMenuItems.ts | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/components/navbar/navbar.tsx b/app/components/navbar/navbar.tsx index bb28256c..574c8b7a 100644 --- a/app/components/navbar/navbar.tsx +++ b/app/components/navbar/navbar.tsx @@ -72,8 +72,7 @@ export function Navbar() { className={css({ position: 'relative', w: 'full', - // 6xl, not 5xl: the scrolled bar must hold every item on one line - // with the challenges entry shown. + // 6xl holds every item on one line once the challenges entry shows. maxW: scrolled ? '6xl' : '7xl', transition: 'all', transitionDuration: '[700ms]', @@ -142,7 +141,6 @@ export function Navbar() { hstack({ gap: { base: '2', lg: '1', xl: '2' } }), css({ display: { base: 'none', lg: 'flex' }, - flexWrap: 'nowrap', px: '2', }), )} diff --git a/app/hooks/useMenuItems.test.ts b/app/hooks/useMenuItems.test.ts index 9ae466f3..b284e182 100644 --- a/app/hooks/useMenuItems.test.ts +++ b/app/hooks/useMenuItems.test.ts @@ -44,6 +44,16 @@ describe('placeChallengeItem', () => { expect(placeChallengeItem(items, null)).toEqual([offer, stories, contact]); }); + it('keeps the challenge entry, first, when there is no offer entry', () => { + const items = placeChallengeItem([stories, contact], challenges); + + expect(items.map((item) => item.key)).toEqual([ + 'challenges', + 'stories', + 'contact', + ]); + }); + it('does not mutate the given list', () => { const items = [offer, stories]; diff --git a/app/hooks/useMenuItems.ts b/app/hooks/useMenuItems.ts index 7f969c7b..5076ceaf 100644 --- a/app/hooks/useMenuItems.ts +++ b/app/hooks/useMenuItems.ts @@ -39,6 +39,9 @@ export function placeChallengeItem( if (challengeItem === null) { return items; } + if (!items.some((item) => item.key === 'offer')) { + return [challengeItem, ...items]; + } return items.map((item) => (item.key === 'offer' ? challengeItem : item)); }