vitepress 0.22.2 → 1.0.0-draft.1

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 (134) hide show
  1. package/README.md +4 -4
  2. package/client.d.ts +2 -3
  3. package/dist/client/app/components/ClientOnly.js +1 -1
  4. package/dist/client/app/index.js +5 -7
  5. package/dist/client/app/router.js +11 -5
  6. package/dist/client/theme-default/Layout.vue +25 -183
  7. package/dist/client/theme-default/NotFound.vue +9 -8
  8. package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +127 -0
  9. package/dist/client/theme-default/components/VPBackdrop.vue +39 -0
  10. package/dist/client/theme-default/components/VPContent.vue +44 -0
  11. package/dist/client/theme-default/components/VPContentDoc.vue +173 -0
  12. package/dist/client/theme-default/components/VPContentDocFooter.vue +140 -0
  13. package/dist/client/theme-default/components/VPContentDocOutline.vue +108 -0
  14. package/dist/client/theme-default/components/VPFlyout.vue +149 -0
  15. package/dist/client/theme-default/components/VPLink.vue +37 -0
  16. package/dist/client/theme-default/components/VPLocalNav.vue +106 -0
  17. package/dist/client/theme-default/components/VPMenu.vue +79 -0
  18. package/dist/client/theme-default/components/VPMenuGroup.vue +35 -0
  19. package/dist/client/theme-default/components/VPMenuLink.vue +30 -0
  20. package/dist/client/theme-default/components/VPNav.vue +33 -0
  21. package/dist/client/theme-default/components/VPNavBar.vue +109 -0
  22. package/dist/client/theme-default/components/VPNavBarAppearance.vue +22 -0
  23. package/dist/client/theme-default/components/VPNavBarExtra.vue +107 -0
  24. package/dist/client/theme-default/components/VPNavBarHamburger.vue +79 -0
  25. package/dist/client/theme-default/components/VPNavBarMenu.vue +29 -0
  26. package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +18 -0
  27. package/dist/client/theme-default/components/VPNavBarMenuLink.vue +56 -0
  28. package/dist/client/theme-default/components/VPNavBarSearch.vue +269 -0
  29. package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +27 -0
  30. package/dist/client/theme-default/components/VPNavBarTitle.vue +44 -0
  31. package/dist/client/theme-default/components/VPNavBarTranslations.vue +74 -0
  32. package/dist/client/theme-default/components/VPNavScreen.vue +100 -0
  33. package/dist/client/theme-default/components/VPNavScreenAppearance.vue +30 -0
  34. package/dist/client/theme-default/components/VPNavScreenMenu.vue +24 -0
  35. package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +118 -0
  36. package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +33 -0
  37. package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +35 -0
  38. package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +34 -0
  39. package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +14 -0
  40. package/dist/client/theme-default/components/VPNavScreenTranslations.vue +73 -0
  41. package/dist/client/theme-default/components/VPSidebar.vue +118 -0
  42. package/dist/client/theme-default/components/VPSidebarGroup.vue +44 -0
  43. package/dist/client/theme-default/components/VPSidebarLink.vue +57 -0
  44. package/dist/client/theme-default/components/VPSkipLink.vue +72 -0
  45. package/dist/client/theme-default/components/VPSocialLink.vue +63 -0
  46. package/dist/client/theme-default/components/VPSocialLinks.vue +27 -0
  47. package/dist/client/theme-default/components/VPSwitch.vue +66 -0
  48. package/dist/client/theme-default/components/VPSwitchAppearance.vue +74 -0
  49. package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +8 -0
  50. package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +8 -0
  51. package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +8 -0
  52. package/dist/client/theme-default/components/icons/{ArrowLeft.vue → VPIconArrowLeft.vue} +0 -0
  53. package/dist/client/theme-default/components/icons/{ArrowRight.vue → VPIconArrowRight.vue} +0 -0
  54. package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +5 -0
  55. package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +5 -0
  56. package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +5 -0
  57. package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +5 -0
  58. package/dist/client/theme-default/components/icons/VPIconDiscord.vue +5 -0
  59. package/dist/client/theme-default/components/icons/VPIconEdit.vue +6 -0
  60. package/dist/client/theme-default/components/icons/VPIconExternalLink.vue +13 -0
  61. package/dist/client/theme-default/components/icons/VPIconFacebook.vue +5 -0
  62. package/dist/client/theme-default/components/icons/VPIconGitHub.vue +5 -0
  63. package/dist/client/theme-default/components/icons/VPIconInstagram.vue +5 -0
  64. package/dist/client/theme-default/components/icons/VPIconLanguages.vue +9 -0
  65. package/dist/client/theme-default/components/icons/VPIconLinkedIn.vue +5 -0
  66. package/dist/client/theme-default/components/icons/VPIconMoon.vue +5 -0
  67. package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +7 -0
  68. package/dist/client/theme-default/components/icons/VPIconPlus.vue +5 -0
  69. package/dist/client/theme-default/components/icons/VPIconSlack.vue +5 -0
  70. package/dist/client/theme-default/components/icons/VPIconSun.vue +13 -0
  71. package/dist/client/theme-default/components/icons/VPIconTwitter.vue +5 -0
  72. package/dist/client/theme-default/components/icons/VPIconYouTube.vue +5 -0
  73. package/dist/client/theme-default/composables/edit-link.js +22 -0
  74. package/dist/client/theme-default/composables/flyout.js +40 -0
  75. package/dist/client/theme-default/composables/nav.js +27 -1
  76. package/dist/client/theme-default/composables/outline.js +130 -0
  77. package/dist/client/theme-default/composables/prev-next.js +18 -0
  78. package/dist/client/theme-default/composables/sidebar.js +57 -0
  79. package/dist/client/theme-default/fonts/inter-cyrillic-ext.woff2 +0 -0
  80. package/dist/client/theme-default/fonts/inter-cyrillic.woff2 +0 -0
  81. package/dist/client/theme-default/fonts/inter-greek-ext.woff2 +0 -0
  82. package/dist/client/theme-default/fonts/inter-greek.woff2 +0 -0
  83. package/dist/client/theme-default/fonts/inter-latin-ext.woff2 +0 -0
  84. package/dist/client/theme-default/fonts/inter-latin.woff2 +0 -0
  85. package/dist/client/theme-default/fonts/inter-vietnamese.woff2 +0 -0
  86. package/dist/client/theme-default/index.js +4 -4
  87. package/dist/client/theme-default/styles/base.css +200 -0
  88. package/dist/client/theme-default/styles/fonts.css +67 -0
  89. package/dist/client/theme-default/styles/utils.css +9 -0
  90. package/dist/client/theme-default/styles/vars.css +206 -66
  91. package/dist/client/theme-default/styles/vp-doc.css +419 -0
  92. package/dist/client/theme-default/support/sidebar.js +29 -0
  93. package/dist/client/theme-default/support/utils.js +43 -0
  94. package/dist/node/cli.js +1 -1
  95. package/dist/node/index.d.ts +106 -81
  96. package/dist/node/index.js +1 -1
  97. package/dist/node/{serve-cf4b2162.js → serve-428d4610.js} +27 -10
  98. package/package.json +31 -27
  99. package/types/default-theme.d.ts +105 -80
  100. package/dist/client/theme-default/components/AlgoliaSearchBox.vue +0 -195
  101. package/dist/client/theme-default/components/BuySellAds.vue +0 -152
  102. package/dist/client/theme-default/components/CarbonAds.vue +0 -99
  103. package/dist/client/theme-default/components/EditLink.vue +0 -38
  104. package/dist/client/theme-default/components/Home.vue +0 -31
  105. package/dist/client/theme-default/components/HomeFeatures.vue +0 -143
  106. package/dist/client/theme-default/components/HomeFooter.vue +0 -50
  107. package/dist/client/theme-default/components/HomeHero.vue +0 -161
  108. package/dist/client/theme-default/components/LastUpdated.vue +0 -60
  109. package/dist/client/theme-default/components/NavBar.vue +0 -60
  110. package/dist/client/theme-default/components/NavBarTitle.vue +0 -41
  111. package/dist/client/theme-default/components/NavDropdownLink.vue +0 -135
  112. package/dist/client/theme-default/components/NavDropdownLinkItem.vue +0 -76
  113. package/dist/client/theme-default/components/NavLink.vue +0 -61
  114. package/dist/client/theme-default/components/NavLinks.vue +0 -52
  115. package/dist/client/theme-default/components/NextAndPrevLinks.vue +0 -88
  116. package/dist/client/theme-default/components/Page.vue +0 -53
  117. package/dist/client/theme-default/components/PageFooter.vue +0 -44
  118. package/dist/client/theme-default/components/SideBar.vue +0 -60
  119. package/dist/client/theme-default/components/SideBarLink.js +0 -68
  120. package/dist/client/theme-default/components/SideBarLinks.vue +0 -12
  121. package/dist/client/theme-default/components/ToggleSideBarButton.vue +0 -46
  122. package/dist/client/theme-default/components/icons/OutboundLink.vue +0 -31
  123. package/dist/client/theme-default/composables/activeSidebarLink.js +0 -99
  124. package/dist/client/theme-default/composables/editLink.js +0 -49
  125. package/dist/client/theme-default/composables/navLink.js +0 -42
  126. package/dist/client/theme-default/composables/nextAndPrevLinks.js +0 -37
  127. package/dist/client/theme-default/composables/repo.js +0 -38
  128. package/dist/client/theme-default/composables/sideBar.js +0 -57
  129. package/dist/client/theme-default/styles/code.css +0 -299
  130. package/dist/client/theme-default/styles/custom-blocks.css +0 -76
  131. package/dist/client/theme-default/styles/layout.css +0 -236
  132. package/dist/client/theme-default/styles/sidebar-links.css +0 -107
  133. package/dist/client/theme-default/support/sideBar.js +0 -46
  134. package/dist/client/theme-default/utils.js +0 -63
@@ -0,0 +1,269 @@
1
+ <script lang="ts" setup>
2
+ import '@docsearch/css'
3
+ import { useData } from 'vitepress'
4
+ import { defineAsyncComponent, ref, onMounted, onUnmounted } from 'vue'
5
+
6
+ const VPAlgoliaSearchBox = defineAsyncComponent(
7
+ () => import('./VPAlgoliaSearchBox.vue')
8
+ )
9
+
10
+ const { theme } = useData()
11
+
12
+ // to avoid loading the docsearch js upfront (which is more than 1/3 of the
13
+ // payload), we delay initializing it until the user has actually clicked or
14
+ // hit the hotkey to invoke it.
15
+ const loaded = ref(false)
16
+
17
+ const metaKey = ref()
18
+
19
+ onMounted(() => {
20
+ if (!theme.value.algolia) {
21
+ return
22
+ }
23
+
24
+ // meta key detect (same logic as in @docsearch/js)
25
+ metaKey.value.textContent = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)
26
+ ? '⌘'
27
+ : 'Ctrl'
28
+
29
+ const handleSearchHotKey = (e: KeyboardEvent) => {
30
+ if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
31
+ e.preventDefault()
32
+ load()
33
+ remove()
34
+ }
35
+ }
36
+
37
+ const remove = () => {
38
+ window.removeEventListener('keydown', handleSearchHotKey)
39
+ }
40
+
41
+ window.addEventListener('keydown', handleSearchHotKey)
42
+
43
+ onUnmounted(remove)
44
+ })
45
+
46
+ function load() {
47
+ if (!loaded.value) {
48
+ loaded.value = true
49
+ }
50
+ }
51
+ </script>
52
+
53
+ <template>
54
+ <div v-if="theme.algolia" class="VPNavBarSearch">
55
+ <VPAlgoliaSearchBox v-if="loaded" />
56
+
57
+ <div v-else id="docsearch" @click="load">
58
+ <button
59
+ type="button"
60
+ class="DocSearch DocSearch-Button"
61
+ aria-label="Search"
62
+ >
63
+ <span class="DocSearch-Button-Container">
64
+ <svg
65
+ class="DocSearch-Search-Icon"
66
+ width="20"
67
+ height="20"
68
+ viewBox="0 0 20 20"
69
+ >
70
+ <path
71
+ d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
72
+ stroke="currentColor"
73
+ fill="none"
74
+ fill-rule="evenodd"
75
+ stroke-linecap="round"
76
+ stroke-linejoin="round"
77
+ />
78
+ </svg>
79
+ <span class="DocSearch-Button-Placeholder">Search</span>
80
+ </span>
81
+ <span class="DocSearch-Button-Keys">
82
+ <span class="DocSearch-Button-Key" ref="metaKey">Meta</span>
83
+ <span class="DocSearch-Button-Key">K</span>
84
+ </span>
85
+ </button>
86
+ </div>
87
+ </div>
88
+ </template>
89
+
90
+ <style>
91
+ .VPNavBarSearch {
92
+ display: flex;
93
+ align-items: center;
94
+ }
95
+
96
+ @media (min-width: 768px) {
97
+ .VPNavBarSearch {
98
+ flex-grow: 1;
99
+ padding-left: 24px;
100
+ }
101
+ }
102
+
103
+ @media (min-width: 960px) {
104
+ .VPNavBarSearch {
105
+ padding-left: 32px;
106
+ }
107
+ }
108
+
109
+ .DocSearch {
110
+ --docsearch-primary-color: var(--vp-c-brand);
111
+ --docsearch-highlight-color: var(--docsearch-primary-color);
112
+ --docsearch-text-color: var(--vp-c-text-1);
113
+ --docsearch-muted-color: var(--vp-c-text-2);
114
+ --docsearch-searchbox-shadow: none;
115
+ --docsearch-searchbox-focus-background: transparent;
116
+ --docsearch-key-gradient: transparent;
117
+ --docsearch-key-shadow: none;
118
+ --docsearch-modal-background: var(--vp-c-bg-soft);
119
+ --docsearch-footer-background: var(--vp-c-bg);
120
+ }
121
+
122
+ .dark .DocSearch {
123
+ --docsearch-modal-shadow: none;
124
+ --docsearch-footer-shadow: none;
125
+ --docsearch-logo-color: var(--vp-c-text-2);
126
+ --docsearch-hit-background: var(--vp-c-bg-mute);
127
+ --docsearch-hit-color: var(--vp-c-text-2);
128
+ --docsearch-hit-shadow: none;
129
+ }
130
+
131
+ .DocSearch-Button {
132
+ display: flex;
133
+ justify-content: center;
134
+ align-items: center;
135
+ margin: 0;
136
+ padding: 0;
137
+ width: 32px;
138
+ height: 55px;
139
+ background: transparent;
140
+ transition: border-color 0.25s;
141
+ }
142
+
143
+ .DocSearch-Button:hover {
144
+ background: transparent;
145
+ }
146
+
147
+ .DocSearch-Button:focus {
148
+ outline: 1px dotted;
149
+ outline: 5px auto -webkit-focus-ring-color;
150
+ }
151
+
152
+ .DocSearch-Button:focus:not(:focus-visible) {
153
+ outline: none !important;
154
+ }
155
+
156
+ @media (min-width: 768px) {
157
+ .DocSearch-Button {
158
+ justify-content: flex-start;
159
+ border: 1px solid transparent;
160
+ border-radius: 8px;
161
+ padding: 0 10px 0 12px;
162
+ width: 100%;
163
+ height: 40px;
164
+ background-color: var(--vp-c-bg-sidebar);
165
+ }
166
+
167
+ .DocSearch-Button:hover {
168
+ border-color: var(--vp-c-brand);
169
+ background: var(--vp-c-bg-sidebar);
170
+ }
171
+ }
172
+
173
+ .DocSearch-Button .DocSearch-Button-Container {
174
+ display: flex;
175
+ align-items: center;
176
+ }
177
+
178
+ .DocSearch-Button .DocSearch-Search-Icon {
179
+ position: relative;
180
+ width: 16px;
181
+ height: 16px;
182
+ color: var(--vp-c-text-1);
183
+ fill: currentColor;
184
+ transition: color 0.5s;
185
+ }
186
+
187
+ .DocSearch-Button:hover .DocSearch-Search-Icon {
188
+ color: var(--vp-c-text-1);
189
+ }
190
+
191
+ @media (min-width: 768px) {
192
+ .DocSearch-Button .DocSearch-Search-Icon {
193
+ top: 1px;
194
+ margin-right: 8px;
195
+ width: 14px;
196
+ height: 14px;
197
+ color: var(--vp-c-text-2);
198
+ }
199
+ }
200
+
201
+ .DocSearch-Button .DocSearch-Button-Placeholder {
202
+ display: none;
203
+ margin-top: 2px;
204
+ padding: 0 16px 0 0;
205
+ font-size: 13px;
206
+ font-weight: 500;
207
+ color: var(--vp-c-text-2);
208
+ transition: color 0.5s;
209
+ }
210
+
211
+ .DocSearch-Button:hover .DocSearch-Button-Placeholder {
212
+ color: var(--vp-c-text-1);
213
+ }
214
+
215
+ @media (min-width: 768px) {
216
+ .DocSearch-Button .DocSearch-Button-Placeholder {
217
+ display: inline-block;
218
+ }
219
+ }
220
+
221
+ .DocSearch-Button .DocSearch-Button-Keys {
222
+ display: none;
223
+ min-width: auto;
224
+ }
225
+
226
+ @media (min-width: 768px) {
227
+ .DocSearch-Button .DocSearch-Button-Keys {
228
+ display: flex;
229
+ align-items: center;
230
+ }
231
+ }
232
+
233
+ .DocSearch-Button .DocSearch-Button-Key {
234
+ display: block;
235
+ margin: 2px 0 0 0;
236
+ border: 1px solid var(--vp-c-divider);
237
+ border-right: none;
238
+ border-radius: 4px 0 0 4px;
239
+ padding-left: 6px;
240
+ min-width: 0;
241
+ width: auto;
242
+ height: 22px;
243
+ line-height: 22px;
244
+ font-size: 12px;
245
+ font-weight: 500;
246
+ transition: color 0.5s, border-color 0.5s;
247
+ }
248
+
249
+ .DocSearch-Button .DocSearch-Button-Key + .DocSearch-Button-Key {
250
+ border-right: 1px solid var(--vp-c-divider);
251
+ border-left: none;
252
+ border-radius: 0 4px 4px 0;
253
+ padding-left: 2px;
254
+ padding-right: 6px;
255
+ }
256
+
257
+ .dark .DocSearch-Footer {
258
+ border-top: 1px solid var(--vp-c-divider);
259
+ }
260
+
261
+ .DocSearch-Form {
262
+ border: 1px solid var(--vp-c-brand);
263
+ background-color: var(--vp-c-white);
264
+ }
265
+
266
+ .dark .DocSearch-Form {
267
+ background-color: var(--vp-c-bg-mute);
268
+ }
269
+ </style>
@@ -0,0 +1,27 @@
1
+ <script lang="ts" setup>
2
+ import { useData } from 'vitepress'
3
+ import VPSocialLinks from './VPSocialLinks.vue'
4
+
5
+ const { theme } = useData()
6
+ </script>
7
+
8
+ <template>
9
+ <VPSocialLinks
10
+ v-if="theme.socialLinks"
11
+ class="VPNavBarSocialLinks"
12
+ :links="theme.socialLinks"
13
+ />
14
+ </template>
15
+
16
+ <style scoped>
17
+ .VPNavBarSocialLinks {
18
+ display: none;
19
+ }
20
+
21
+ @media (min-width: 1280px) {
22
+ .VPNavBarSocialLinks {
23
+ display: flex;
24
+ align-items: center;
25
+ }
26
+ }
27
+ </style>
@@ -0,0 +1,44 @@
1
+ <script setup lang="ts">
2
+ import { useData } from 'vitepress'
3
+
4
+ const { site, theme } = useData()
5
+ </script>
6
+
7
+ <template>
8
+ <a class="VPNavBarTitle" href="/">
9
+ <img v-if="theme.logo" class="logo" :src="theme.logo" :alt="site.title">
10
+ {{ site.title }}
11
+ </a>
12
+ </template>
13
+
14
+ <style scoped>
15
+ .VPNavBarTitle {
16
+ display: flex;
17
+ align-items: center;
18
+ height: var(--vp-nav-height-mobile);
19
+ font-size: 16px;
20
+ font-weight: 600;
21
+ color: var(--vp-c-text-1);
22
+ transition: background-color 0.5s, opacity 0.25s;
23
+ }
24
+
25
+ .VPNavBarTitle:hover {
26
+ opacity: 0.6;
27
+ }
28
+
29
+ @media (min-width: 960px) {
30
+ .VPNavBarTitle {
31
+ flex-shrink: 0;
32
+ margin-right: 32px;
33
+ border-bottom: 1px solid var(--vp-c-divider-light);
34
+ width: calc(var(--vp-sidebar-width) - 64px);
35
+ height: var(--vp-nav-height-desktop);
36
+ background-color: var(--vp-c-bg-sidebar);
37
+ }
38
+ }
39
+
40
+ .logo {
41
+ margin-right: 8px;
42
+ height: 24px;
43
+ }
44
+ </style>
@@ -0,0 +1,74 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue'
3
+ import { useData } from 'vitepress'
4
+ import VPIconLanguages from './icons/VPIconLanguages.vue'
5
+ import VPFlyout from './VPFlyout.vue'
6
+
7
+ const { theme } = useData()
8
+
9
+ const isOpen = ref(false)
10
+
11
+ function toggle() {
12
+ isOpen.value = !isOpen.value
13
+ }
14
+ </script>
15
+
16
+ <template>
17
+ <VPFlyout
18
+ v-if="theme.localeLinks"
19
+ class="VPNavBarTranslations"
20
+ :icon="VPIconLanguages"
21
+ >
22
+ <div class="container">
23
+ <p class="title">
24
+ {{ theme.localeLinks.text }}
25
+ </p>
26
+
27
+ <ul class="list">
28
+ <li v-for="locale in theme.localeLinks.items" :key="locale.link" class="lang">
29
+ <a class="link" :href="locale.link">{{ locale.text }}</a>
30
+ </li>
31
+ </ul>
32
+ </div>
33
+ </VPFlyout>
34
+ </template>
35
+
36
+ <style scoped>
37
+ .VPNavBarTranslations {
38
+ display: none;
39
+ }
40
+
41
+ @media (min-width: 1280px) {
42
+ .VPNavBarTranslations {
43
+ display: flex;
44
+ align-items: center;
45
+ }
46
+ }
47
+
48
+ .container {
49
+ padding: 0 16px;
50
+ }
51
+
52
+ .title {
53
+ display: flex;
54
+ align-items: center;
55
+ font-size: 13px;
56
+ font-weight: 600;
57
+ color: var(--vp-c-text-1);
58
+ }
59
+
60
+ .lang {
61
+ padding: 4px 0 0 0;
62
+ }
63
+
64
+ .link {
65
+ line-height: 28px;
66
+ font-size: 13px;
67
+ color: var(--vp-c-text-1);
68
+ transition: color 0.25s;
69
+ }
70
+
71
+ .link:hover {
72
+ color: var(--vp-c-brand);
73
+ }
74
+ </style>
@@ -0,0 +1,100 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+ import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'
4
+ import VPNavScreenMenu from './VPNavScreenMenu.vue'
5
+ import VPNavScreenAppearance from './VPNavScreenAppearance.vue'
6
+ import VPNavScreenTranslations from './VPNavScreenTranslations.vue'
7
+ import VPNavScreenSocialLinks from './VPNavScreenSocialLinks.vue'
8
+
9
+ defineProps<{
10
+ open: boolean
11
+ }>()
12
+
13
+ const screen = ref<HTMLElement | null>(null)
14
+
15
+ function lockBodyScroll() {
16
+ disableBodyScroll(screen.value!, { reserveScrollBarGap: true })
17
+ }
18
+
19
+ function unlockBodyScroll() {
20
+ clearAllBodyScrollLocks()
21
+ }
22
+ </script>
23
+
24
+ <template>
25
+ <transition
26
+ name="fade"
27
+ @enter="lockBodyScroll"
28
+ @after-leave="unlockBodyScroll"
29
+ >
30
+ <div v-if="open" class="VPNavScreen" ref="screen">
31
+ <div class="container">
32
+ <VPNavScreenMenu class="menu" />
33
+ <VPNavScreenTranslations class="translations" />
34
+ <VPNavScreenAppearance class="appearance" />
35
+ <VPNavScreenSocialLinks class="social-links" />
36
+ </div>
37
+ </div>
38
+ </transition>
39
+ </template>
40
+
41
+ <style scoped>
42
+ .VPNavScreen {
43
+ position: fixed;
44
+ top: var(--vp-nav-height-mobile);
45
+ right: 0;
46
+ bottom: 0;
47
+ left: 0;
48
+ padding: 0 32px;
49
+ width: 100%;
50
+ background-color: var(--vp-c-bg);
51
+ overflow-y: auto;
52
+ transition: background-color 0.5s;
53
+ }
54
+
55
+ .VPNavScreen.fade-enter-active,
56
+ .VPNavScreen.fade-leave-active {
57
+ transition: opacity 0.25s;
58
+ }
59
+
60
+ .VPNavScreen.fade-enter-active .container,
61
+ .VPNavScreen.fade-leave-active .container {
62
+ transition: transform 0.25s ease;
63
+ }
64
+
65
+ .VPNavScreen.fade-enter-from,
66
+ .VPNavScreen.fade-leave-to {
67
+ opacity: 0;
68
+ }
69
+
70
+ .VPNavScreen.fade-enter-from .container,
71
+ .VPNavScreen.fade-leave-to .container {
72
+ transform: translateY(-8px);
73
+ }
74
+
75
+ @media (min-width: 768px) {
76
+ .VPNavScreen {
77
+ display: none;
78
+ }
79
+ }
80
+
81
+ .container {
82
+ margin: 0 auto;
83
+ padding: 24px 0 96px;
84
+ max-width: 288px;
85
+ }
86
+
87
+ .menu + .translations,
88
+ .menu + .appearance,
89
+ .translations + .appearance {
90
+ margin-top: 24px;
91
+ }
92
+
93
+ .menu + .social-links {
94
+ margin-top: 16px;
95
+ }
96
+
97
+ .appearance + .social-links {
98
+ margin-top: 16px;
99
+ }
100
+ </style>
@@ -0,0 +1,30 @@
1
+ <script lang="ts" setup>
2
+ import VPSwitchAppearance from './VPSwitchAppearance.vue'
3
+ </script>
4
+
5
+ <template>
6
+ <div class="VPNavScreenAppearance">
7
+ <p class="text">Appearance</p>
8
+ <VPSwitchAppearance />
9
+ </div>
10
+ </template>
11
+
12
+ <style scoped>
13
+ .VPNavScreenAppearance {
14
+ display: flex;
15
+ justify-content: space-between;
16
+ align-items: center;
17
+ border-radius: 8px;
18
+ padding: 12px 14px 12px 16px;
19
+ background-color: var(--vp-c-bg-soft);
20
+ transition: background-color 0.5s;
21
+ }
22
+
23
+ .text {
24
+ line-height: 24px;
25
+ font-size: 12px;
26
+ font-weight: 500;
27
+ color: var(--vp-c-text-2);
28
+ transition: color 0.5s;
29
+ }
30
+ </style>
@@ -0,0 +1,24 @@
1
+ <script lang="ts" setup>
2
+ import { useData } from 'vitepress'
3
+ import VPNavScreenMenuLink from './VPNavScreenMenuLink.vue'
4
+ import VPNavScreenMenuGroup from './VPNavScreenMenuGroup.vue'
5
+
6
+ const { theme } = useData()
7
+ </script>
8
+
9
+ <template>
10
+ <nav v-if="theme.nav" class="VPNavScreenMenu">
11
+ <template v-for="item in theme.nav" :key="item.text">
12
+ <VPNavScreenMenuLink
13
+ v-if="'link' in item"
14
+ :text="item.text"
15
+ :link="item.link"
16
+ />
17
+ <VPNavScreenMenuGroup
18
+ v-else
19
+ :text="item.text || ''"
20
+ :items="item.items"
21
+ />
22
+ </template>
23
+ </nav>
24
+ </template>
@@ -0,0 +1,118 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref } from 'vue'
3
+ import { DefaultTheme } from 'vitepress'
4
+ import VPIconPlus from './icons/VPIconPlus.vue'
5
+ import VPNavScreenMenuGroupLink from './VPNavScreenMenuGroupLink.vue'
6
+ import VPNavScreenMenuGroupSection from './VPNavScreenMenuGroupSection.vue'
7
+
8
+ const props = defineProps<{
9
+ text: string
10
+ items: DefaultTheme.NavItemChild[]
11
+ }>()
12
+
13
+ const isOpen = ref(false)
14
+
15
+ const groupId = computed(() =>
16
+ `NavScreenGroup-${props.text.replace(' ', '-').toLowerCase()}`
17
+ )
18
+
19
+ function toggle() {
20
+ isOpen.value = !isOpen.value
21
+ }
22
+ </script>
23
+
24
+ <template>
25
+ <div class="VPNavScreenMenuGroup" :class="{ open: isOpen }">
26
+ <button
27
+ class="button"
28
+ :aria-controls="groupId"
29
+ :aria-expanded="isOpen"
30
+ @click="toggle"
31
+ >
32
+ <span class="button-text">{{ text }}</span>
33
+ <VPIconPlus class="button-icon" />
34
+ </button>
35
+
36
+ <div :id="groupId" class="items">
37
+ <template v-for="item in items" :key="item.text">
38
+ <div v-if="'link' in item" :key="item.text" class="item">
39
+ <VPNavScreenMenuGroupLink
40
+ :text="item.text"
41
+ :link="item.link"
42
+ />
43
+ </div>
44
+
45
+ <div v-else class="group">
46
+ <VPNavScreenMenuGroupSection
47
+ :text="item.text"
48
+ :items="item.items"
49
+ />
50
+ </div>
51
+ </template>
52
+ </div>
53
+ </div>
54
+ </template>
55
+
56
+ <style scoped>
57
+ .VPNavScreenMenuGroup {
58
+ border-bottom: 1px solid var(--vp-c-divider-light);
59
+ height: 48px;
60
+ overflow: hidden;
61
+ transition: border-color 0.5s;
62
+ }
63
+
64
+ .VPNavScreenMenuGroup .items {
65
+ visibility: hidden;
66
+ }
67
+
68
+ .VPNavScreenMenuGroup.open .items {
69
+ visibility: visible;
70
+ }
71
+
72
+ .VPNavScreenMenuGroup.open {
73
+ padding-bottom: 10px;
74
+ height: auto;
75
+ }
76
+
77
+ .VPNavScreenMenuGroup.open .button {
78
+ padding-bottom: 6px;
79
+ color: var(--vp-c-brand);
80
+ }
81
+
82
+ .VPNavScreenMenuGroup.open .button-icon {
83
+ transform: rotate(45deg);
84
+ }
85
+
86
+ .button {
87
+ display: flex;
88
+ justify-content: space-between;
89
+ align-items: center;
90
+ padding: 12px 4px 11px 0;
91
+ width: 100%;
92
+ line-height: 24px;
93
+ font-size: 14px;
94
+ font-weight: 500;
95
+ color: var(--vp-c-text-1);
96
+ transition: color 0.25s;
97
+ }
98
+
99
+ .button:hover {
100
+ color: var(--vp-c-brand);
101
+ }
102
+
103
+ .button-icon {
104
+ width: 14px;
105
+ height: 14px;
106
+ fill: var(--vp-c-text-2);
107
+ transition: fill 0.5s, transform 0.25s;
108
+ }
109
+
110
+ .group:first-child {
111
+ padding-top: 0px;
112
+ }
113
+
114
+ .group + .group,
115
+ .group + .item {
116
+ padding-top: 4px;
117
+ }
118
+ </style>