Navbar: showMobileMenu defaults to true for new Navbars and the seeded header
Existing Navbars (prop absent/false) are untouched: render default and toHtml stay falsy. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ab7a10073b
commit
79cdd593d9
3 files changed
+14
-2
No files matched your search
@@ -195,3 +195,13 @@ describe('Navbar.toHtml design tokens (#44)', () => {
|
|||||||
for (const hex of ['#3f3f46', '#e4e4e7']) expect(lower, `old ${hex}`).not.toContain(hex.toLowerCase());
|
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"');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -246,7 +246,9 @@ Navbar.craft = {
|
|||||||
padding: '16px 24px',
|
padding: '16px 24px',
|
||||||
navAlignment: 'space-between',
|
navAlignment: 'space-between',
|
||||||
isSticky: false,
|
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: {
|
style: {
|
||||||
borderBottom: `1px solid ${tokenRef('border')}`,
|
borderBottom: `1px solid ${tokenRef('border')}`,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ export const DEFAULT_HEADER_STATE = JSON.stringify({
|
|||||||
padding: '16px 24px',
|
padding: '16px 24px',
|
||||||
navAlignment: 'space-between',
|
navAlignment: 'space-between',
|
||||||
isSticky: false,
|
isSticky: false,
|
||||||
showMobileMenu: false,
|
showMobileMenu: true,
|
||||||
style: { borderBottom: '1px solid #e4e4e7' },
|
style: { borderBottom: '1px solid #e4e4e7' },
|
||||||
},
|
},
|
||||||
displayName: 'Navbar',
|
displayName: 'Navbar',
|
||||||
|
|||||||
Reference in new issue
Block a user