diff --git a/craft/src/components/basic/Navbar.toHtml.test.ts b/craft/src/components/basic/Navbar.toHtml.test.ts index ea2c5bb..7179602 100644 --- a/craft/src/components/basic/Navbar.toHtml.test.ts +++ b/craft/src/components/basic/Navbar.toHtml.test.ts @@ -195,3 +195,13 @@ describe('Navbar.toHtml design tokens (#44)', () => { for (const hex of ['#3f3f46', '#e4e4e7']) expect(lower, `old ${hex}`).not.toContain(hex.toLowerCase()); }); }); + +describe('Navbar mobile menu default', () => { + test('NEW Navbars (craft defaults) get the hamburger; a stored Navbar without the prop keeps its output', async () => { + const { Navbar } = await import('./Navbar'); + expect((Navbar as any).craft.props.showMobileMenu).toBe(true); + const toHtml = (Navbar as any).toHtml; + expect(toHtml({}, '', 'n1').html).not.toContain('navbar-hamburger"'); + expect(toHtml({ showMobileMenu: true }, '', 'n1').html).toContain('class="navbar-hamburger"'); + }); +}); diff --git a/craft/src/components/basic/Navbar.tsx b/craft/src/components/basic/Navbar.tsx index 0be00d2..10cddc9 100644 --- a/craft/src/components/basic/Navbar.tsx +++ b/craft/src/components/basic/Navbar.tsx @@ -246,7 +246,9 @@ Navbar.craft = { padding: '16px 24px', navAlignment: 'space-between', isSticky: false, - showMobileMenu: false, + // On for NEW Navbars (links overflow a phone otherwise). The component's render default and toHtml + // stay falsy so a stored Navbar that never had the prop keeps its exact output. + showMobileMenu: true, style: { borderBottom: `1px solid ${tokenRef('border')}`, }, diff --git a/craft/src/state/PageContext.tsx b/craft/src/state/PageContext.tsx index abc9276..c7f7fea 100644 --- a/craft/src/state/PageContext.tsx +++ b/craft/src/state/PageContext.tsx @@ -252,7 +252,7 @@ export const DEFAULT_HEADER_STATE = JSON.stringify({ padding: '16px 24px', navAlignment: 'space-between', isSticky: false, - showMobileMenu: false, + showMobileMenu: true, style: { borderBottom: '1px solid #e4e4e7' }, }, displayName: 'Navbar',