@vuepress/theme-default 2.0.0-rc.8 → 2.0.0-rc.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/lib/client/components/VPAutoLink.vue +32 -0
  2. package/lib/client/components/VPDarkIcon.vue +8 -0
  3. package/lib/client/components/VPDropdownTransition.vue +43 -0
  4. package/lib/client/components/VPEditIcon.vue +12 -0
  5. package/lib/client/components/VPFadeSlideYTransition.vue +43 -0
  6. package/lib/client/components/VPHome.vue +38 -0
  7. package/lib/client/components/VPHomeFeatures.vue +65 -0
  8. package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -3
  9. package/lib/client/components/VPHomeHero.vue +185 -0
  10. package/lib/client/components/VPLightIcon.vue +28 -0
  11. package/lib/client/components/VPNavbar.vue +134 -0
  12. package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +41 -16
  13. package/lib/client/components/VPNavbarDropdown.vue +331 -0
  14. package/lib/client/components/VPNavbarItems.vue +111 -0
  15. package/lib/client/components/VPPage.vue +69 -0
  16. package/lib/client/components/VPPageMeta.vue +134 -0
  17. package/lib/client/components/VPPageNav.vue +125 -0
  18. package/lib/client/components/VPSidebar.vue +113 -0
  19. package/lib/client/components/VPSidebarItem.vue +186 -0
  20. package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +27 -7
  21. package/lib/client/components/VPToggleColorModeButton.vue +55 -0
  22. package/lib/client/components/VPToggleSidebarButton.vue +92 -0
  23. package/lib/client/components/global/Badge.vue +84 -18
  24. package/lib/client/components/global/index.d.ts +1 -3
  25. package/lib/client/components/global/index.js +1 -3
  26. package/lib/client/composables/index.d.ts +9 -1
  27. package/lib/client/composables/index.js +9 -1
  28. package/lib/client/composables/useContributors.d.ts +3 -0
  29. package/lib/client/composables/useContributors.js +11 -0
  30. package/lib/client/composables/useDarkMode.d.ts +0 -1
  31. package/lib/client/composables/useDarkMode.js +19 -16
  32. package/lib/client/composables/useData.d.ts +13 -0
  33. package/lib/client/composables/useData.js +15 -0
  34. package/lib/client/composables/useEditLink.d.ts +3 -0
  35. package/lib/client/composables/useEditLink.js +28 -0
  36. package/lib/client/composables/useHeaders.d.ts +9 -0
  37. package/lib/client/composables/useHeaders.js +38 -0
  38. package/lib/client/composables/useLastUpdated.d.ts +2 -0
  39. package/lib/client/composables/useLastUpdated.js +14 -0
  40. package/lib/client/composables/useNavbarConfig.d.ts +3 -0
  41. package/lib/client/composables/useNavbarConfig.js +29 -0
  42. package/lib/client/composables/useNavbarRepo.d.ts +6 -0
  43. package/lib/client/composables/useNavbarRepo.js +38 -0
  44. package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
  45. package/lib/client/composables/useNavbarSelectLanguage.js +55 -0
  46. package/lib/client/composables/useNavigate.d.ts +1 -0
  47. package/lib/client/composables/useNavigate.js +22 -0
  48. package/lib/client/composables/useRelatedLinks.d.ts +8 -0
  49. package/lib/client/composables/useRelatedLinks.js +90 -0
  50. package/lib/client/composables/useScrollPromise.js +3 -1
  51. package/lib/client/composables/useSidebarItems.d.ts +21 -21
  52. package/lib/client/composables/useSidebarItems.js +96 -86
  53. package/lib/client/composables/useUpdateDeviceStatus.d.ts +1 -1
  54. package/lib/client/composables/useUpdateDeviceStatus.js +10 -5
  55. package/lib/client/config.d.ts +3 -2
  56. package/lib/client/config.js +8 -23
  57. package/lib/client/index.d.ts +2 -1
  58. package/lib/client/index.js +0 -1
  59. package/lib/client/layouts/Layout.vue +127 -54
  60. package/lib/client/layouts/NotFound.vue +25 -11
  61. package/lib/client/shim.d.ts +6 -5
  62. package/lib/client/styles/_mixins.scss +4 -4
  63. package/lib/client/styles/_variables.module.scss +1 -1
  64. package/lib/client/styles/_variables.scss +2 -1
  65. package/lib/client/styles/arrow.scss +18 -24
  66. package/lib/client/styles/code-group.scss +35 -30
  67. package/lib/client/styles/content/code.scss +23 -0
  68. package/lib/client/styles/content/index.scss +3 -0
  69. package/lib/client/styles/content/normalize.scss +39 -0
  70. package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
  71. package/lib/client/styles/external-link-icon.scss +36 -0
  72. package/lib/client/styles/index.scss +3 -13
  73. package/lib/client/styles/layout.scss +5 -197
  74. package/lib/client/styles/normalize.scss +1 -194
  75. package/lib/client/styles/plugins.scss +28 -0
  76. package/lib/client/styles/vars-dark.scss +20 -58
  77. package/lib/client/styles/vars.scss +54 -129
  78. package/lib/client/typings.d.ts +13 -0
  79. package/lib/client/typings.js +1 -0
  80. package/lib/client/utils/index.d.ts +2 -2
  81. package/lib/client/utils/index.js +2 -2
  82. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
  83. package/lib/client/utils/isActiveSidebarItem.js +1 -1
  84. package/lib/client/utils/resolveAutoLink.d.ts +9 -0
  85. package/lib/client/utils/resolveAutoLink.js +17 -0
  86. package/lib/client/utils/resolveEditLink.d.ts +3 -3
  87. package/lib/client/utils/resolveEditLink.js +3 -3
  88. package/lib/client/utils/resolvePrefix.d.ts +1 -0
  89. package/lib/client/utils/resolvePrefix.js +4 -0
  90. package/lib/client/utils/resolveRepoType.d.ts +1 -1
  91. package/lib/client/utils/resolveRepoType.js +4 -4
  92. package/lib/node/defaultTheme.d.ts +2 -1
  93. package/lib/node/defaultTheme.js +50 -56
  94. package/lib/node/index.d.ts +2 -3
  95. package/lib/node/index.js +0 -3
  96. package/lib/node/typings.d.ts +58 -0
  97. package/lib/node/typings.js +1 -0
  98. package/lib/node/utils/assignDefaultLocaleOptions.js +3 -7
  99. package/lib/node/utils/index.d.ts +1 -1
  100. package/lib/node/utils/index.js +1 -1
  101. package/lib/node/utils/resolveMarkdownHintLocales.d.ts +9 -0
  102. package/lib/node/utils/resolveMarkdownHintLocales.js +19 -0
  103. package/lib/shared/index.d.ts +5 -3
  104. package/lib/shared/index.js +1 -3
  105. package/lib/shared/nav.d.ts +19 -30
  106. package/lib/shared/navbar.d.ts +21 -0
  107. package/lib/shared/navbar.js +1 -0
  108. package/lib/shared/options.d.ts +36 -65
  109. package/lib/shared/page.d.ts +9 -6
  110. package/lib/shared/sidebar.d.ts +26 -0
  111. package/lib/shared/sidebar.js +1 -0
  112. package/package.json +29 -27
  113. package/templates/build.html +16 -10
  114. package/lib/client/components/AutoLink.vue +0 -113
  115. package/lib/client/components/DropdownTransition.vue +0 -25
  116. package/lib/client/components/Home.vue +0 -15
  117. package/lib/client/components/HomeContent.vue +0 -5
  118. package/lib/client/components/HomeFeatures.vue +0 -22
  119. package/lib/client/components/HomeHero.vue +0 -97
  120. package/lib/client/components/Navbar.vue +0 -79
  121. package/lib/client/components/NavbarDropdown.vue +0 -126
  122. package/lib/client/components/NavbarItems.vue +0 -199
  123. package/lib/client/components/Page.vue +0 -31
  124. package/lib/client/components/PageMeta.vue +0 -124
  125. package/lib/client/components/PageNav.vue +0 -122
  126. package/lib/client/components/Sidebar.vue +0 -18
  127. package/lib/client/components/SidebarItem.vue +0 -87
  128. package/lib/client/components/ToggleColorModeButton.vue +0 -57
  129. package/lib/client/components/ToggleSidebarButton.vue +0 -24
  130. package/lib/client/components/global/CodeGroup.d.ts +0 -6
  131. package/lib/client/components/global/CodeGroup.js +0 -120
  132. package/lib/client/components/global/CodeGroupItem.vue +0 -27
  133. package/lib/client/composables/useThemeData.d.ts +0 -4
  134. package/lib/client/composables/useThemeData.js +0 -3
  135. package/lib/client/styles/badge.scss +0 -36
  136. package/lib/client/styles/code.scss +0 -263
  137. package/lib/client/styles/custom-container.scss +0 -142
  138. package/lib/client/styles/home.scss +0 -168
  139. package/lib/client/styles/navbar-dropdown.scss +0 -183
  140. package/lib/client/styles/navbar.scss +0 -197
  141. package/lib/client/styles/page.scss +0 -87
  142. package/lib/client/styles/sidebar.scss +0 -134
  143. package/lib/client/styles/transitions.scss +0 -22
  144. package/lib/client/utils/getNavLink.d.ts +0 -15
  145. package/lib/client/utils/getNavLink.js +0 -18
  146. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
  147. package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
  148. package/lib/node/utils/resolveContainerPluginOptions.d.ts +0 -8
  149. package/lib/node/utils/resolveContainerPluginOptions.js +0 -17
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ import type { VNode } from 'vue'
3
+ import type { AutoLinkConfig } from 'vuepress/client'
4
+ import { AutoLink } from 'vuepress/client'
5
+
6
+ defineProps<{
7
+ /**
8
+ * The auto link config
9
+ */
10
+ config: AutoLinkConfig
11
+ }>()
12
+
13
+ defineSlots<{
14
+ default?: (config: AutoLinkConfig) => VNode | VNode[]
15
+ before?: (config: AutoLinkConfig) => VNode | VNode[] | null
16
+ after?: (config: AutoLinkConfig) => VNode | VNode[] | null
17
+ }>()
18
+ </script>
19
+
20
+ <template>
21
+ <AutoLink :config="config">
22
+ <template v-if="$slots.default" #default>
23
+ <slot v-bind="config" />
24
+ </template>
25
+ <template #before>
26
+ <slot name="before" v-bind="config" />
27
+ </template>
28
+ <template #after>
29
+ <slot name="after" v-bind="config" />
30
+ </template>
31
+ </AutoLink>
32
+ </template>
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <svg class="dark-icon" viewBox="0 0 32 32">
3
+ <path
4
+ d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z"
5
+ fill="currentColor"
6
+ />
7
+ </svg>
8
+ </template>
@@ -0,0 +1,43 @@
1
+ <script setup lang="ts">
2
+ import type { VNode } from 'vue'
3
+
4
+ defineSlots<{
5
+ default?: (props: Record<never, never>) => VNode | VNode[] | null
6
+ }>()
7
+
8
+ const setHeight = (item: Element): void => {
9
+ // explicitly set height so that it can be transitioned
10
+ ;(item as HTMLElement).style.height = `${item.scrollHeight}px`
11
+ }
12
+
13
+ const unsetHeight = (item: Element): void => {
14
+ ;(item as HTMLElement).style.height = ''
15
+ }
16
+ </script>
17
+
18
+ <template>
19
+ <Transition
20
+ name="vp-dropdown"
21
+ @enter="setHeight"
22
+ @after-enter="unsetHeight"
23
+ @before-leave="setHeight"
24
+ >
25
+ <slot />
26
+ </Transition>
27
+ </template>
28
+
29
+ <style lang="scss">
30
+ .vp-dropdown {
31
+ &-enter-from,
32
+ &-leave-to {
33
+ height: 0 !important;
34
+ opacity: 0;
35
+ }
36
+
37
+ &-enter-active {
38
+ transition:
39
+ height 0.3s ease-in-out,
40
+ opacity 0.6s ease-out;
41
+ }
42
+ }
43
+ </style>
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <svg class="edit-icon" viewBox="0 0 1024 1024">
3
+ <g fill="currentColor">
4
+ <path
5
+ d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"
6
+ />
7
+ <path
8
+ d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"
9
+ />
10
+ </g>
11
+ </svg>
12
+ </template>
@@ -0,0 +1,43 @@
1
+ <script setup lang="ts">
2
+ import type { VNode } from 'vue'
3
+
4
+ defineEmits<{
5
+ beforeEnter: []
6
+ beforeLeave: []
7
+ }>()
8
+ defineSlots<{
9
+ default: () => VNode | string | null
10
+ }>()
11
+ </script>
12
+
13
+ <template>
14
+ <Transition
15
+ name="vp-fade-slide-y"
16
+ mode="out-in"
17
+ @before-enter="$emit('beforeEnter')"
18
+ @before-leave="$emit('beforeLeave')"
19
+ >
20
+ <slot />
21
+ </Transition>
22
+ </template>
23
+
24
+ <style lang="scss">
25
+ /**
26
+ * fade-slide-y transition
27
+ */
28
+ .vp-fade-slide-y {
29
+ &-enter-active {
30
+ transition: all 0.2s ease;
31
+ }
32
+
33
+ &-leave-active {
34
+ transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
35
+ }
36
+
37
+ &-enter-from,
38
+ &-leave-to {
39
+ opacity: 0;
40
+ transform: translateY(-10px);
41
+ }
42
+ }
43
+ </style>
@@ -0,0 +1,38 @@
1
+ <script setup lang="ts">
2
+ import VPHomeFeatures from '@theme/VPHomeFeatures.vue'
3
+ import VPHomeFooter from '@theme/VPHomeFooter.vue'
4
+ import VPHomeHero from '@theme/VPHomeHero.vue'
5
+ import { Content } from 'vuepress/client'
6
+ </script>
7
+
8
+ <template>
9
+ <main class="vp-home">
10
+ <VPHomeHero />
11
+ <VPHomeFeatures />
12
+ <div vp-content>
13
+ <Content />
14
+ </div>
15
+ <VPHomeFooter />
16
+ </main>
17
+ </template>
18
+
19
+ <style lang="scss">
20
+ @use '../styles/variables' as *;
21
+
22
+ .vp-home {
23
+ display: block;
24
+ max-width: var(--homepage-width);
25
+ margin: 0 auto;
26
+ padding: var(--navbar-height) 2rem 0;
27
+
28
+ @media (max-width: $MQMobileNarrow) {
29
+ padding-right: 1.5rem;
30
+ padding-left: 1.5rem;
31
+ }
32
+
33
+ [vp-content] {
34
+ margin: 0;
35
+ padding: 0;
36
+ }
37
+ }
38
+ </style>
@@ -0,0 +1,65 @@
1
+ <script setup lang="ts">
2
+ import { useData } from '@theme/useData'
3
+ import { computed } from 'vue'
4
+ import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
5
+
6
+ const { frontmatter } = useData<DefaultThemeHomePageFrontmatter>()
7
+
8
+ const features = computed(() => frontmatter.value.features ?? [])
9
+ </script>
10
+
11
+ <template>
12
+ <div v-if="features.length" class="vp-features">
13
+ <div v-for="feature in features" :key="feature.title" class="vp-feature">
14
+ <h2>{{ feature.title }}</h2>
15
+ <p>{{ feature.details }}</p>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <style lang="scss">
21
+ @use '../styles/variables' as *;
22
+
23
+ .vp-features {
24
+ display: flex;
25
+ flex-wrap: wrap;
26
+ place-content: stretch space-between;
27
+ align-items: flex-start;
28
+
29
+ margin-top: 2.5rem;
30
+ padding: 1.2rem 0;
31
+ border-top: 1px solid var(--vp-c-gutter);
32
+
33
+ transition: border-color var(--vp-t-color);
34
+
35
+ @media (max-width: $MQMobile) {
36
+ flex-direction: column;
37
+ }
38
+ }
39
+
40
+ .vp-feature {
41
+ flex-grow: 1;
42
+ flex-basis: 30%;
43
+ max-width: 30%;
44
+
45
+ @media (max-width: $MQMobile) {
46
+ max-width: 100%;
47
+ padding: 0 2.5rem;
48
+ }
49
+
50
+ h2 {
51
+ padding-bottom: 0;
52
+ border-bottom: none;
53
+ font-weight: 500;
54
+ font-size: 1.4rem;
55
+
56
+ @media (max-width: $MQMobileNarrow) {
57
+ font-size: 1.25rem;
58
+ }
59
+ }
60
+
61
+ p {
62
+ color: var(--vp-c-text-mute);
63
+ }
64
+ }
65
+ </style>
@@ -4,14 +4,27 @@ import { usePageFrontmatter } from 'vuepress/client'
4
4
  import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
5
5
 
6
6
  const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
7
+
7
8
  const footer = computed(() => frontmatter.value.footer)
8
9
  const footerHtml = computed(() => frontmatter.value.footerHtml)
9
10
  </script>
10
11
 
11
12
  <template>
12
13
  <template v-if="footer">
13
- <!-- eslint-disable-next-line vue/no-v-html -->
14
- <div v-if="footerHtml" class="footer" v-html="footer" />
15
- <div v-else class="footer" v-text="footer" />
14
+ <div v-if="footerHtml" class="vp-footer" vp-footer v-html="footer" />
15
+ <div v-else class="vp-footer" vp-footer v-text="footer" />
16
16
  </template>
17
17
  </template>
18
+
19
+ <style>
20
+ .vp-footer {
21
+ padding: 2.5rem;
22
+ border-top: 1px solid var(--vp-c-border);
23
+
24
+ color: var(--vp-c-text-mute);
25
+
26
+ text-align: center;
27
+
28
+ transition: border-color var(--vp-t-color);
29
+ }
30
+ </style>
@@ -0,0 +1,185 @@
1
+ <script setup lang="ts">
2
+ import VPAutoLink from '@theme/VPAutoLink.vue'
3
+ import { useDarkMode } from '@theme/useDarkMode'
4
+ import { useData } from '@theme/useData'
5
+ import type { FunctionalComponent } from 'vue'
6
+ import { computed, h } from 'vue'
7
+ import { ClientOnly, withBase } from 'vuepress/client'
8
+ import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
9
+
10
+ const { frontmatter, siteLocale } = useData<DefaultThemeHomePageFrontmatter>()
11
+ const isDarkMode = useDarkMode()
12
+
13
+ const heroText = computed(() => {
14
+ if (frontmatter.value.heroText === null) {
15
+ return null
16
+ }
17
+ return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
18
+ })
19
+ const tagline = computed(() => {
20
+ if (frontmatter.value.tagline === null) {
21
+ return null
22
+ }
23
+
24
+ return (
25
+ frontmatter.value.tagline ||
26
+ siteLocale.value.description ||
27
+ 'Welcome to your VuePress site'
28
+ )
29
+ })
30
+ const heroImage = computed(() => {
31
+ if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined) {
32
+ return frontmatter.value.heroImageDark
33
+ }
34
+ return frontmatter.value.heroImage
35
+ })
36
+ const heroAlt = computed(
37
+ () => frontmatter.value.heroAlt || heroText.value || 'hero',
38
+ )
39
+ const heroHeight = computed(() => frontmatter.value.heroHeight ?? 280)
40
+
41
+ const actions = computed(() => {
42
+ if (!Array.isArray(frontmatter.value.actions)) {
43
+ return []
44
+ }
45
+
46
+ return frontmatter.value.actions.map(({ type = 'primary', ...rest }) => ({
47
+ type,
48
+ ...rest,
49
+ }))
50
+ })
51
+
52
+ const HomeHeroImage: FunctionalComponent = () => {
53
+ if (!heroImage.value) return null
54
+
55
+ const img = h('img', {
56
+ class: 'vp-hero-image',
57
+ src: withBase(heroImage.value),
58
+ alt: heroAlt.value,
59
+ height: heroHeight.value,
60
+ })
61
+
62
+ if (frontmatter.value.heroImageDark === undefined) {
63
+ return img
64
+ }
65
+
66
+ // wrap hero image with <ClientOnly> to avoid ssr-mismatch
67
+ // when using a different hero image in dark mode
68
+ return h(ClientOnly, () => img)
69
+ }
70
+ </script>
71
+
72
+ <template>
73
+ <header class="vp-hero">
74
+ <HomeHeroImage />
75
+
76
+ <h1 v-if="heroText" id="main-title">
77
+ {{ heroText }}
78
+ </h1>
79
+
80
+ <p v-if="tagline" class="vp-hero-description">
81
+ {{ tagline }}
82
+ </p>
83
+
84
+ <p v-if="actions.length" class="vp-hero-actions">
85
+ <VPAutoLink
86
+ v-for="action in actions"
87
+ :key="action.text"
88
+ class="vp-hero-action-button"
89
+ :class="[action.type]"
90
+ :config="action"
91
+ />
92
+ </p>
93
+ </header>
94
+ </template>
95
+
96
+ <style lang="scss">
97
+ @use '../styles/variables' as *;
98
+
99
+ .vp-hero {
100
+ text-align: center;
101
+ }
102
+
103
+ .vp-hero-image {
104
+ display: block;
105
+ max-width: 100%;
106
+ max-height: 280px;
107
+ margin: 3rem auto 1.5rem;
108
+
109
+ @media (max-width: $MQMobileNarrow) {
110
+ max-height: 210px;
111
+ margin: 2rem auto 1.2rem;
112
+ }
113
+ }
114
+
115
+ #main-title {
116
+ font-size: 3rem;
117
+
118
+ @media (max-width: $MQMobileNarrow) {
119
+ font-size: 2rem;
120
+ }
121
+ }
122
+
123
+ #main-title,
124
+ .vp-hero-description,
125
+ .vp-hero-actions {
126
+ margin: 1.8rem auto;
127
+
128
+ @media (max-width: $MQMobileNarrow) {
129
+ margin: 1.2rem auto;
130
+ }
131
+ }
132
+
133
+ .vp-hero-actions {
134
+ display: flex;
135
+ flex-wrap: wrap;
136
+ gap: 1rem;
137
+ justify-content: center;
138
+ }
139
+
140
+ .vp-hero-description {
141
+ max-width: 35rem;
142
+ color: var(--vp-c-text-mute);
143
+ font-size: 1.6rem;
144
+ line-height: 1.3;
145
+
146
+ @media (max-width: $MQMobileNarrow) {
147
+ font-size: 1.2rem;
148
+ }
149
+ }
150
+
151
+ .vp-hero-action-button {
152
+ display: inline-block;
153
+
154
+ box-sizing: border-box;
155
+ padding: 0.8rem 1.6rem;
156
+ border: 2px solid var(--vp-c-accent-bg);
157
+ border-radius: 4px;
158
+
159
+ background-color: var(--vp-c-bg);
160
+ color: var(--vp-c-accent);
161
+
162
+ font-size: 1.2rem;
163
+
164
+ transition: background-color border-color color var(--vp-t-color);
165
+
166
+ @media (max-width: $MQMobileNarrow) {
167
+ padding: 0.6rem 1.2rem;
168
+ font-size: 1rem;
169
+ }
170
+
171
+ &:hover {
172
+ color: var(--vp-c-accent-text);
173
+ }
174
+
175
+ &.primary {
176
+ background-color: var(--vp-c-accent-bg);
177
+ color: var(--vp-c-accent-text);
178
+
179
+ &:hover {
180
+ border-color: var(--vp-c-accent-hover);
181
+ background-color: var(--vp-c-accent-hover);
182
+ }
183
+ }
184
+ }
185
+ </style>
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <svg class="light-icon" viewBox="0 0 32 32">
3
+ <path
4
+ d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z"
5
+ fill="currentColor"
6
+ />
7
+ <path
8
+ d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z"
9
+ fill="currentColor"
10
+ />
11
+ <path d="M2 15.005h5v2H2z" fill="currentColor" />
12
+ <path
13
+ d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z"
14
+ fill="currentColor"
15
+ />
16
+ <path d="M15 25.005h2v5h-2z" fill="currentColor" />
17
+ <path
18
+ d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z"
19
+ fill="currentColor"
20
+ />
21
+ <path d="M25 15.005h5v2h-5z" fill="currentColor" />
22
+ <path
23
+ d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z"
24
+ fill="currentColor"
25
+ />
26
+ <path d="M15 2.005h2v5h-2z" fill="currentColor" />
27
+ </svg>
28
+ </template>
@@ -0,0 +1,134 @@
1
+ <script setup lang="ts">
2
+ import VPNavbarBrand from '@theme/VPNavbarBrand.vue'
3
+ import VPNavbarItems from '@theme/VPNavbarItems.vue'
4
+ import VPToggleColorModeButton from '@theme/VPToggleColorModeButton.vue'
5
+ import VPToggleSidebarButton from '@theme/VPToggleSidebarButton.vue'
6
+ import { useData } from '@theme/useData'
7
+ import { DeviceType, useUpdateDeviceStatus } from '@theme/useUpdateDeviceStatus'
8
+ import { hasGlobalComponent } from '@vuepress/helper/client'
9
+ import type { VNode } from 'vue'
10
+ import { computed, ref, resolveComponent, useTemplateRef } from 'vue'
11
+
12
+ defineEmits<{
13
+ toggleSidebar: []
14
+ }>()
15
+
16
+ defineSlots<{
17
+ before?: (props: Record<never, never>) => VNode | VNode[] | null
18
+ after?: (props: Record<never, never>) => VNode | VNode[] | null
19
+ }>()
20
+
21
+ const SearchBox = hasGlobalComponent('SearchBox')
22
+ ? resolveComponent('SearchBox')
23
+ : (): null => null
24
+
25
+ const { themeLocale } = useData()
26
+
27
+ const navbar = useTemplateRef<HTMLElement | null>('navbar')
28
+ const navbarBrand = useTemplateRef<HTMLElement | null>('navbar-brand')
29
+
30
+ const linksWrapperMaxWidth = ref(0)
31
+ const linksWrapperStyle = computed(() => {
32
+ if (!linksWrapperMaxWidth.value) {
33
+ return {}
34
+ }
35
+ return {
36
+ maxWidth: `${linksWrapperMaxWidth.value}px`,
37
+ }
38
+ })
39
+
40
+ const getCssValue = (el: HTMLElement | null, property: string): number => {
41
+ // NOTE: Known bug, will return 'auto' if style value is 'auto'
42
+ const val = el?.ownerDocument.defaultView?.getComputedStyle(el, null)[
43
+ property as keyof CSSStyleDeclaration
44
+ ]
45
+
46
+ const num = Number.parseInt(val as string, 10)
47
+
48
+ return Number.isNaN(num) ? 0 : num
49
+ }
50
+
51
+ useUpdateDeviceStatus(
52
+ DeviceType.Mobile,
53
+ (mobileDesktopBreakpoint: number): void => {
54
+ // avoid overlapping of long title and long navbar links
55
+ const navbarHorizontalPadding =
56
+ getCssValue(navbar.value, 'paddingLeft') +
57
+ getCssValue(navbar.value, 'paddingRight')
58
+ if (window.innerWidth < mobileDesktopBreakpoint) {
59
+ linksWrapperMaxWidth.value = 0
60
+ } else {
61
+ linksWrapperMaxWidth.value =
62
+ navbar.value!.offsetWidth -
63
+ navbarHorizontalPadding -
64
+ (navbarBrand.value?.offsetWidth ?? 0)
65
+ }
66
+ },
67
+ )
68
+ </script>
69
+
70
+ <template>
71
+ <header ref="navbar" class="vp-navbar" vp-navbar>
72
+ <VPToggleSidebarButton @toggle="$emit('toggleSidebar')" />
73
+
74
+ <span ref="navbar-brand">
75
+ <VPNavbarBrand />
76
+ </span>
77
+
78
+ <div class="vp-navbar-items-wrapper" :style="linksWrapperStyle">
79
+ <slot name="before" />
80
+ <VPNavbarItems class="vp-hide-mobile" />
81
+ <slot name="after" />
82
+ <VPToggleColorModeButton v-if="themeLocale.colorModeSwitch" />
83
+ <SearchBox />
84
+ </div>
85
+ </header>
86
+ </template>
87
+
88
+ <style lang="scss">
89
+ @use '../styles/variables' as *;
90
+
91
+ .vp-navbar {
92
+ --navbar-line-height: calc(
93
+ var(--navbar-height) - 2 * var(--navbar-padding-v)
94
+ );
95
+
96
+ position: fixed;
97
+ top: 0;
98
+ right: 0;
99
+ left: 0;
100
+ z-index: 20;
101
+
102
+ box-sizing: border-box;
103
+ height: var(--navbar-height);
104
+ padding: var(--navbar-padding-v) var(--navbar-padding-h);
105
+ border-bottom: 1px solid var(--vp-c-border);
106
+
107
+ background-color: var(--vp-navbar-c-bg);
108
+
109
+ line-height: var(--navbar-line-height);
110
+
111
+ transition:
112
+ background-color var(--vp-t-color),
113
+ border-color var(--vp-t-color);
114
+
115
+ @media screen and (max-width: $MQMobile) {
116
+ padding-left: 4rem;
117
+ }
118
+ }
119
+
120
+ .vp-navbar-items-wrapper {
121
+ position: absolute;
122
+ top: var(--navbar-padding-v);
123
+ right: var(--navbar-padding-h);
124
+
125
+ display: flex;
126
+
127
+ box-sizing: border-box;
128
+ height: var(--navbar-line-height);
129
+ padding-left: var(--navbar-padding-h);
130
+
131
+ font-size: 0.9rem;
132
+ white-space: nowrap;
133
+ }
134
+ </style>