Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: variants for AppHeader position #750

Merged
merged 4 commits into from Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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