Skip to content

Commit

Permalink
feat(theme): add navigation slots (#739) (#741)
Browse files Browse the repository at this point in the history
Co-authored-by: Divyansh Singh <[email protected]>
  • Loading branch information
stafyniaksacha and brc-dd authored Jul 8, 2022
1 parent 88877b7 commit 0f0453c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/guide/theme-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,12 @@ Full list of slots available in the default theme layout:
- `home-hero-after`
- `home-features-before`
- `home-features-after`
- Always:
- `layout-top`
- `layout-bottom`
- `nav-bar-title-before`
- `nav-bar-title-after`
- `nav-bar-content-before`
- `nav-bar-content-after`
- `nav-screen-content-before`
- `nav-screen-content-after`
9 changes: 8 additions & 1 deletion src/client/theme-default/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ provide('close-sidebar', closeSidebar)
<slot name="layout-top" />
<VPSkipLink />
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />
<VPNav />
<VPNav>
<template #nav-bar-title-before><slot name="nav-bar-title-before" /></template>
<template #nav-bar-title-after><slot name="nav-bar-title-after" /></template>
<template #nav-bar-content-before><slot name="nav-bar-content-before" /></template>
<template #nav-bar-content-after><slot name="nav-bar-content-after" /></template>
<template #nav-screen-content-before><slot name="nav-screen-content-before" /></template>
<template #nav-screen-content-after><slot name="nav-screen-content-after" /></template>
</VPNav>
<VPLocalNav :open="isSidebarOpen" @open-menu="openSidebar" />
<VPSidebar :open="isSidebarOpen" />

Expand Down
12 changes: 10 additions & 2 deletions src/client/theme-default/components/VPNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ provide('close-screen', closeScreen)

<template>
<header class="VPNav" :class="{ 'no-sidebar' : !hasSidebar }">
<VPNavBar :is-screen-open="isScreenOpen" @toggle-screen="toggleScreen" />
<VPNavScreen :open="isScreenOpen" />
<VPNavBar :is-screen-open="isScreenOpen" @toggle-screen="toggleScreen">
<template #nav-bar-title-before><slot name="nav-bar-title-before" /></template>
<template #nav-bar-title-after><slot name="nav-bar-title-after" /></template>
<template #nav-bar-content-before><slot name="nav-bar-content-before" /></template>
<template #nav-bar-content-after><slot name="nav-bar-content-after" /></template>
</VPNavBar>
<VPNavScreen :open="isScreenOpen">
<template #nav-screen-content-before><slot name="nav-screen-content-before" /></template>
<template #nav-screen-content-after><slot name="nav-screen-content-after" /></template>
</VPNavScreen>
</header>
</template>

Expand Down
7 changes: 6 additions & 1 deletion src/client/theme-default/components/VPNavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ const { hasSidebar } = useSidebar()
<template>
<div class="VPNavBar" :class="{ 'has-sidebar' : hasSidebar }">
<div class="container">
<VPNavBarTitle />
<VPNavBarTitle>
<template #nav-bar-title-before><slot name="nav-bar-title-before" /></template>
<template #nav-bar-title-after><slot name="nav-bar-title-after" /></template>
</VPNavBarTitle>

<div class="content">
<slot name="nav-bar-content-before" />
<VPNavBarSearch class="search" />
<VPNavBarMenu class="menu" />
<VPNavBarTranslations class="translations" />
<VPNavBarAppearance class="appearance" />
<VPNavBarSocialLinks class="social-links" />
<VPNavBarExtra class="extra" />
<slot name="nav-bar-content-after" />
<VPNavBarHamburger
class="hamburger"
:active="isScreenOpen"
Expand Down
2 changes: 2 additions & 0 deletions src/client/theme-default/components/VPNavBarTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const { hasSidebar } = useSidebar()
<template>
<div class="VPNavBarTitle" :class="{ 'has-sidebar': hasSidebar }">
<a class="title" :href="site.base">
<slot name="nav-bar-title-before" />
<VPImage class="logo" :image="theme.logo" />
<template v-if="theme.siteTitle">{{ theme.siteTitle }}</template>
<template v-else-if="theme.siteTitle === undefined">{{ site.title }}</template>
<slot name="nav-bar-title-after" />
</a>
</div>
</template>
Expand Down
2 changes: 2 additions & 0 deletions src/client/theme-default/components/VPNavScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ function unlockBodyScroll() {
>
<div v-if="open" class="VPNavScreen" ref="screen">
<div class="container">
<slot name="nav-screen-content-before" />
<VPNavScreenMenu class="menu" />
<VPNavScreenTranslations class="translations" />
<VPNavScreenAppearance class="appearance" />
<VPNavScreenSocialLinks class="social-links" />
<slot name="nav-screen-content-after" />
</div>
</div>
</transition>
Expand Down

0 comments on commit 0f0453c

Please sign in to comment.