Skip to content

Commit

Permalink
feat: variants for AppHeader position (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrtsky committed Jan 25, 2023
1 parent 5822a28 commit 979086c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .docs/.studio/app.config.json
Expand Up @@ -20,7 +20,11 @@
"title": "",
"logo": true,
"showLinkIcon": true,
"exclude": []
"exclude": [],
"fixed": {
"initial": false,
"lg": true
}
},
"footer": {
"credits": {
Expand Down
3 changes: 3 additions & 0 deletions .docs/content/0.index.md
Expand Up @@ -2,6 +2,9 @@
title: Home
navigation: false
layout: page
header:
fixed:
initial: true
---

:ellipsis{right=0px width=75% blur=150px}
Expand Down
15 changes: 10 additions & 5 deletions components/app/AppHeader.vue
Expand Up @@ -4,6 +4,10 @@ const { navigation } = useContent()
const { hasDocSearch } = useDocSearch()
const hasDialog = computed(() => navigation.value?.length > 1)
defineProps({
...variants
})
</script>

<template>
Expand Down Expand Up @@ -56,18 +60,13 @@ css({
header: {
backdropFilter: '{elements.backdrop.filter}',
position: 'static',
top: 0,
zIndex: 10,
width: '100%',
borderBottom: '1px solid {elements.border.primary.default}',
backgroundColor: '{elements.backdrop.background}',
height: '{docus.header.height}',
'@lg': {
position: 'sticky',
},
'.container': {
display: 'grid',
height: '100%',
Expand Down Expand Up @@ -103,6 +102,12 @@ css({
}
}
}
},
variants: {
fixed: {
true: { position: 'sticky' },
false: {},
}
}
})
</style>
6 changes: 5 additions & 1 deletion components/app/AppLayout.vue
Expand Up @@ -3,6 +3,10 @@ const docus = useDocus()
const { navigation, page } = useContent()
const { navKeyFromPath } = useContentHelpers()
const headerPosition = computed(() => {
return page.value.header?.fixed || docus.value.header.fixed
})
const titleTemplate = computed(() => {
const appTitleTemplate = docus.value.head?.titleTemplate || `%s · ${docus.value.title}`
if (page.value) {
Expand Down Expand Up @@ -36,7 +40,7 @@ useContentHead(docus.value as any)
<template>
<div>
<AppLoadingBar />
<AppHeader v-if="docus.header" />
<AppHeader v-if="docus.header" :fixed="headerPosition"/>
<slot />
<AppFooter v-if="docus.footer" />
</div>
Expand Down

1 comment on commit 979086c

@vercel
Copy link

@vercel vercel bot commented on 979086c Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.