mirror of https://github.com/vuejs/vitepress
Reserve the navbar title column only when a sidebar is present. Add browser coverage for home, sidebar-free, 404, and sidebar pages. Fixes vuejs/vitepress#5426 Assisted-by: OpenAI Codexpull/5414/merge
parent
5457dc99db
commit
e9215cbfdd
@ -0,0 +1,30 @@
|
|||||||
|
describe('navbar layout', () => {
|
||||||
|
test.each([959, 960, 1440])(
|
||||||
|
'reserves space beside the title only for a visible sidebar at %ipx',
|
||||||
|
async (width) => {
|
||||||
|
await page.setViewportSize({ width, height: 720 })
|
||||||
|
|
||||||
|
const searchOffset = async (path: string) => {
|
||||||
|
await goto(path)
|
||||||
|
await page.evaluate(() => document.fonts.ready)
|
||||||
|
|
||||||
|
const title = await page.locator('.VPNavBarTitle').boundingBox()
|
||||||
|
const search = await page.locator('.VPNavBarSearch').boundingBox()
|
||||||
|
return search!.x - title!.x
|
||||||
|
}
|
||||||
|
|
||||||
|
const homeOffset = await searchOffset('/')
|
||||||
|
|
||||||
|
for (const path of ['/navbar/no-sidebar', '/missing-page']) {
|
||||||
|
expect(await searchOffset(path)).toBeCloseTo(homeOffset, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sidebarOffset = await searchOffset('/home')
|
||||||
|
if (width >= 960) {
|
||||||
|
expect(sidebarOffset).toBeGreaterThan(homeOffset)
|
||||||
|
} else {
|
||||||
|
expect(sidebarOffset).toBeCloseTo(homeOffset, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
sidebar: false
|
||||||
|
---
|
||||||
|
|
||||||
|
# Page without a sidebar
|
||||||
|
|
||||||
|
The navigation title should keep its natural width when the sidebar is hidden.
|
||||||
Loading…
Reference in new issue