Skip to content

Commit 9bf5222

Browse files
docs(styles): Fix responsive styles (#2852)
1 parent cb70e07 commit 9bf5222

File tree

1 file changed

+67
-7
lines changed

1 file changed

+67
-7
lines changed

docs/components/Footer.vue

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
11
<script setup lang="ts">
22
import FooterList from './FooterList.vue'
3-
import { useData } from 'vitepress'
3+
import { useData, useRoute } from 'vitepress'
44
import { useWindowSize } from '@vueuse/core'
55
import { computed } from 'vue'
66
7-
const { theme } = useData()
7+
const route = useRoute()
8+
const { theme, frontmatter } = useData()
9+
10+
function ensureStartingSlash(path: any) {
11+
return /^\//.test(path) ? path : `/${path}`
12+
}
13+
function getSidebar(sidebar: any, path: any) {
14+
if (Array.isArray(sidebar)) {
15+
return sidebar
16+
}
17+
if (sidebar == null) {
18+
return []
19+
}
20+
path = ensureStartingSlash(path)
21+
const dir = Object.keys(sidebar)
22+
.sort((a, b) => {
23+
return b.split('/').length - a.split('/').length
24+
})
25+
.find((dir) => {
26+
// make sure the multi sidebar key starts with slash too
27+
return path.startsWith(ensureStartingSlash(dir))
28+
})
29+
return dir ? sidebar[dir] : []
30+
}
31+
32+
const sidebar = computed(() => {
33+
const sidebarConfig = theme.value.sidebar
34+
const relativePath = route.data.relativePath
35+
return sidebarConfig ? getSidebar(sidebarConfig, relativePath) : []
36+
})
37+
const hasSidebar = computed(() => {
38+
return (
39+
frontmatter.value.sidebar !== false && sidebar.value.length > 0 && frontmatter.value.layout !== 'home'
40+
)
41+
})
842
943
// Adjust width based on sidebar
1044
const { width } = useWindowSize()
@@ -33,8 +67,14 @@ const ecosystemList = [
3367
</script>
3468

3569
<template>
36-
<footer class="feathers-footer bg-neutral text-neutral-content" :class="{ 'sidebar-open': addLeftMargin }">
37-
<div class="max-w-6xl w-full mx-auto pt-16 px-4">
70+
<footer
71+
class="VPContent has-sidebar feathers-footer bg-neutral text-neutral-content"
72+
:class="{
73+
'has-sidebar': hasSidebar,
74+
'is-home': frontmatter.layout === 'home'
75+
}"
76+
>
77+
<div class="max-w-6xl w-full mx-auto px-4">
3878
<div class="sidebar-adjust">
3979
<div class="title flex flex-row items-center ml-2">
4080
<img class="logo invert mr-2" src="/logo.svg" />
@@ -58,9 +98,29 @@ const ecosystemList = [
5898
</footer>
5999
</template>
60100

61-
<style>
101+
<style scoped>
62102
/* Only indent the footer on pages other than home-page */
63-
#app:not(.home-page) .feathers-footer.sidebar-open .sidebar-adjust {
64-
margin-left: 272px;
103+
/* @media (min-width: 800px) {
104+
#app:not(.home-page) .feathers-footer.sidebar-open .sidebar-adjust {
105+
margin-left: 272px;
106+
}
107+
} */
108+
109+
@media (min-width: 960px) {
110+
.VPContent {
111+
padding-top: var(--vp-nav-height);
112+
}
113+
114+
.VPContent.has-sidebar {
115+
margin: var(--vp-layout-top-height, 0px) 0 0;
116+
padding-left: var(--vp-sidebar-width);
117+
}
118+
}
119+
120+
@media (min-width: 1440px) {
121+
.VPContent.has-sidebar {
122+
padding-right: calc((100vw - var(--vp-layout-max-width)) / 2);
123+
padding-left: calc((100vw - var(--vp-layout-max-width)) / 2 + var(--vp-sidebar-width));
124+
}
65125
}
66126
</style>

0 commit comments

Comments
 (0)