@vuepress/theme-default 2.0.0-beta.60 → 2.0.0-beta.62
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.
- package/lib/client/components/AutoLink.vue +5 -0
- package/lib/client/components/DropdownTransition.vue +4 -0
- package/lib/client/components/Navbar.vue +23 -17
- package/lib/client/components/NavbarItems.vue +13 -14
- package/lib/client/components/Page.vue +7 -0
- package/lib/client/components/Sidebar.vue +5 -0
- package/lib/client/components/ToggleSidebarButton.vue +3 -1
- package/lib/client/components/global/Badge.vue +4 -0
- package/lib/client/components/global/CodeGroup.d.ts +4 -2
- package/lib/client/components/global/CodeGroup.js +1 -0
- package/lib/client/composables/index.d.ts +1 -0
- package/lib/client/composables/index.js +1 -0
- package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
- package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
- package/lib/client/layouts/Layout.vue +14 -0
- package/lib/client/shim.d.ts +5 -0
- package/lib/client/styles/_variables.module.scss +5 -0
- package/lib/client/styles/navbar.scss +9 -5
- package/package.json +21 -20
|
@@ -23,6 +23,11 @@ const props = defineProps({
|
|
|
23
23
|
},
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
+
defineSlots<{
|
|
27
|
+
before?: (props: Record<never, never>) => any
|
|
28
|
+
after?: (props: Record<never, never>) => any
|
|
29
|
+
}>()
|
|
30
|
+
|
|
26
31
|
const route = useRoute()
|
|
27
32
|
const site = useSiteData()
|
|
28
33
|
const { item } = toRefs(props)
|
|
@@ -3,10 +3,21 @@ import NavbarBrand from '@theme/NavbarBrand.vue'
|
|
|
3
3
|
import NavbarItems from '@theme/NavbarItems.vue'
|
|
4
4
|
import ToggleColorModeButton from '@theme/ToggleColorModeButton.vue'
|
|
5
5
|
import ToggleSidebarButton from '@theme/ToggleSidebarButton.vue'
|
|
6
|
-
import { computed,
|
|
7
|
-
import {
|
|
6
|
+
import { computed, ref } from 'vue'
|
|
7
|
+
import {
|
|
8
|
+
DeviceType,
|
|
9
|
+
useThemeLocaleData,
|
|
10
|
+
useUpdateDeviceStatus,
|
|
11
|
+
} from '../composables/index.js'
|
|
8
12
|
|
|
9
|
-
defineEmits
|
|
13
|
+
defineEmits<{
|
|
14
|
+
(e: 'toggle-sidebar'): void
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
defineSlots<{
|
|
18
|
+
before?: (props: Record<never, never>) => any
|
|
19
|
+
after?: (props: Record<never, never>) => any
|
|
20
|
+
}>()
|
|
10
21
|
|
|
11
22
|
const themeLocale = useThemeLocaleData()
|
|
12
23
|
|
|
@@ -23,16 +34,14 @@ const linksWrapperStyle = computed(() => {
|
|
|
23
34
|
}
|
|
24
35
|
})
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const handleLinksWrapWidth = (): void => {
|
|
35
|
-
if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
|
|
37
|
+
useUpdateDeviceStatus(
|
|
38
|
+
DeviceType.MOBILE,
|
|
39
|
+
(mobileDesktopBreakpoint: number): void => {
|
|
40
|
+
// avoid overlapping of long title and long navbar links
|
|
41
|
+
const navbarHorizontalPadding =
|
|
42
|
+
getCssValue(navbar.value, 'paddingLeft') +
|
|
43
|
+
getCssValue(navbar.value, 'paddingRight')
|
|
44
|
+
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
36
45
|
linksWrapperMaxWidth.value = 0
|
|
37
46
|
} else {
|
|
38
47
|
linksWrapperMaxWidth.value =
|
|
@@ -41,10 +50,7 @@ onMounted(() => {
|
|
|
41
50
|
(navbarBrand.value?.offsetWidth || 0)
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
window.addEventListener('resize', handleLinksWrapWidth, false)
|
|
46
|
-
window.addEventListener('orientationchange', handleLinksWrapWidth, false)
|
|
47
|
-
})
|
|
53
|
+
)
|
|
48
54
|
|
|
49
55
|
function getCssValue(el: HTMLElement | null, property: string): number {
|
|
50
56
|
// NOTE: Known bug, will return 'auto' if style value is 'auto'
|
|
@@ -3,7 +3,7 @@ import AutoLink from '@theme/AutoLink.vue'
|
|
|
3
3
|
import NavbarDropdown from '@theme/NavbarDropdown.vue'
|
|
4
4
|
import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
|
|
5
5
|
import { isLinkHttp, isString } from '@vuepress/shared'
|
|
6
|
-
import { computed,
|
|
6
|
+
import { computed, ref } from 'vue'
|
|
7
7
|
import type { ComputedRef } from 'vue'
|
|
8
8
|
import { useRouter } from 'vue-router'
|
|
9
9
|
import type {
|
|
@@ -11,7 +11,12 @@ import type {
|
|
|
11
11
|
NavbarItem,
|
|
12
12
|
ResolvedNavbarItem,
|
|
13
13
|
} from '../../shared/index.js'
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
DeviceType,
|
|
16
|
+
useNavLink,
|
|
17
|
+
useThemeLocaleData,
|
|
18
|
+
useUpdateDeviceStatus,
|
|
19
|
+
} from '../composables/index.js'
|
|
15
20
|
import { resolveRepoType } from '../utils/index.js'
|
|
16
21
|
|
|
17
22
|
/**
|
|
@@ -152,23 +157,17 @@ const navbarLinks = computed(() => [
|
|
|
152
157
|
...navbarRepo.value,
|
|
153
158
|
])
|
|
154
159
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const handleMobile = (): void => {
|
|
162
|
-
if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
|
|
160
|
+
useUpdateDeviceStatus(
|
|
161
|
+
DeviceType.MOBILE,
|
|
162
|
+
(mobileDesktopBreakpoint: number): void => {
|
|
163
|
+
// avoid overlapping of long title and long navbar links
|
|
164
|
+
if (window.innerWidth < mobileDesktopBreakpoint) {
|
|
163
165
|
isMobile.value = true
|
|
164
166
|
} else {
|
|
165
167
|
isMobile.value = false
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
|
-
|
|
169
|
-
window.addEventListener('resize', handleMobile, false)
|
|
170
|
-
window.addEventListener('orientationchange', handleMobile, false)
|
|
171
|
-
})
|
|
170
|
+
)
|
|
172
171
|
</script>
|
|
173
172
|
|
|
174
173
|
<template>
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import PageMeta from '@theme/PageMeta.vue'
|
|
3
3
|
import PageNav from '@theme/PageNav.vue'
|
|
4
|
+
|
|
5
|
+
defineSlots<{
|
|
6
|
+
'top'?: (props: Record<never, never>) => any
|
|
7
|
+
'bottom'?: (props: Record<never, never>) => any
|
|
8
|
+
'content-top'?: (props: Record<never, never>) => any
|
|
9
|
+
'content-bottom'?: (props: Record<never, never>) => any
|
|
10
|
+
}>()
|
|
4
11
|
</script>
|
|
5
12
|
|
|
6
13
|
<template>
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import NavbarItems from '@theme/NavbarItems.vue'
|
|
3
3
|
import SidebarItems from '@theme/SidebarItems.vue'
|
|
4
|
+
|
|
5
|
+
defineSlots<{
|
|
6
|
+
top?: (props: Record<never, never>) => any
|
|
7
|
+
bottom?: (props: Record<never, never>) => any
|
|
8
|
+
}>()
|
|
4
9
|
</script>
|
|
5
10
|
|
|
6
11
|
<template>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { VNode } from 'vue';
|
|
1
|
+
import type { SlotsType, VNode } from 'vue';
|
|
2
2
|
export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
3
3
|
[key: string]: any;
|
|
4
|
-
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}
|
|
4
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, SlotsType<{
|
|
5
|
+
default: () => VNode[];
|
|
6
|
+
}>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { onMounted } from 'vue';
|
|
2
|
+
import cssVars from '../styles/_variables.module.scss?module';
|
|
3
|
+
export var DeviceType;
|
|
4
|
+
(function (DeviceType) {
|
|
5
|
+
DeviceType["MOBILE"] = "mobile";
|
|
6
|
+
})(DeviceType || (DeviceType = {}));
|
|
7
|
+
const DeviceTypeMap = {
|
|
8
|
+
[DeviceType.MOBILE]: Number.parseInt(cssVars.mobile?.replace('px', ''), 10),
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* add listener to detect screen though device type
|
|
12
|
+
*/
|
|
13
|
+
export const useUpdateDeviceStatus = (deviceType, callback) => {
|
|
14
|
+
const width = DeviceTypeMap[deviceType];
|
|
15
|
+
if (!Number.isInteger(width)) {
|
|
16
|
+
if (__VUEPRESS_DEV__)
|
|
17
|
+
throw new Error('device width must be a integer');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
callback(width);
|
|
22
|
+
window.addEventListener('resize', () => callback(width), false);
|
|
23
|
+
window.addEventListener('orientationchange', () => callback(width), false);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -13,6 +13,20 @@ import {
|
|
|
13
13
|
useThemeLocaleData,
|
|
14
14
|
} from '../composables/index.js'
|
|
15
15
|
|
|
16
|
+
defineSlots<{
|
|
17
|
+
'navbar'?: (props: Record<never, never>) => any
|
|
18
|
+
'navbar-before'?: (props: Record<never, never>) => any
|
|
19
|
+
'navbar-after'?: (props: Record<never, never>) => any
|
|
20
|
+
'sidebar'?: (props: Record<never, never>) => any
|
|
21
|
+
'sidebar-top'?: (props: Record<never, never>) => any
|
|
22
|
+
'sidebar-bottom'?: (props: Record<never, never>) => any
|
|
23
|
+
'page'?: (props: Record<never, never>) => any
|
|
24
|
+
'page-top'?: (props: Record<never, never>) => any
|
|
25
|
+
'page-bottom'?: (props: Record<never, never>) => any
|
|
26
|
+
'page-content-top'?: (props: Record<never, never>) => any
|
|
27
|
+
'page-content-bottom'?: (props: Record<never, never>) => any
|
|
28
|
+
}>()
|
|
29
|
+
|
|
16
30
|
const page = usePageData()
|
|
17
31
|
const frontmatter = usePageFrontmatter<DefaultThemePageFrontmatter>()
|
|
18
32
|
const themeLocale = useThemeLocaleData()
|
package/lib/client/shim.d.ts
CHANGED
|
@@ -43,16 +43,20 @@
|
|
|
43
43
|
.navbar {
|
|
44
44
|
padding-left: 4rem;
|
|
45
45
|
|
|
46
|
-
.can-hide {
|
|
47
|
-
display: none;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
.site-name {
|
|
51
|
-
|
|
47
|
+
display: block;
|
|
48
|
+
// 5.5rem for .navbar padding-inline
|
|
49
|
+
// 4.5rem for ColorModeSwitch and NavbarSearch
|
|
50
|
+
// 1rem for gap
|
|
51
|
+
width: calc(100vw - 11rem);
|
|
52
52
|
overflow: hidden;
|
|
53
53
|
white-space: nowrap;
|
|
54
54
|
text-overflow: ellipsis;
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
.can-hide {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.62",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -36,27 +36,28 @@
|
|
|
36
36
|
"templates"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@vueuse/core": "^
|
|
40
|
-
"sass": "^1.
|
|
41
|
-
"
|
|
42
|
-
"vue
|
|
43
|
-
"
|
|
44
|
-
"@vuepress/
|
|
45
|
-
"@vuepress/
|
|
46
|
-
"@vuepress/plugin-container": "2.0.0-beta.
|
|
47
|
-
"@vuepress/plugin-
|
|
48
|
-
"@vuepress/plugin-
|
|
49
|
-
"@vuepress/plugin-
|
|
50
|
-
"@vuepress/plugin-
|
|
51
|
-
"@vuepress/plugin-
|
|
52
|
-
"@vuepress/
|
|
53
|
-
"@vuepress/plugin-prismjs": "2.0.0-beta.
|
|
54
|
-
"@vuepress/
|
|
55
|
-
"@vuepress/
|
|
56
|
-
"@vuepress/
|
|
39
|
+
"@vueuse/core": "^10.1.2",
|
|
40
|
+
"sass": "^1.62.1",
|
|
41
|
+
"sass-loader": "^13.2.2",
|
|
42
|
+
"vue": "^3.3.1",
|
|
43
|
+
"vue-router": "^4.2.0",
|
|
44
|
+
"@vuepress/client": "2.0.0-beta.62",
|
|
45
|
+
"@vuepress/core": "2.0.0-beta.62",
|
|
46
|
+
"@vuepress/plugin-container": "2.0.0-beta.62",
|
|
47
|
+
"@vuepress/plugin-git": "2.0.0-beta.62",
|
|
48
|
+
"@vuepress/plugin-active-header-links": "2.0.0-beta.62",
|
|
49
|
+
"@vuepress/plugin-back-to-top": "2.0.0-beta.62",
|
|
50
|
+
"@vuepress/plugin-palette": "2.0.0-beta.62",
|
|
51
|
+
"@vuepress/plugin-theme-data": "2.0.0-beta.62",
|
|
52
|
+
"@vuepress/shared": "2.0.0-beta.62",
|
|
53
|
+
"@vuepress/plugin-prismjs": "2.0.0-beta.62",
|
|
54
|
+
"@vuepress/utils": "2.0.0-beta.62",
|
|
55
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-beta.62",
|
|
56
|
+
"@vuepress/plugin-nprogress": "2.0.0-beta.62",
|
|
57
|
+
"@vuepress/plugin-external-link-icon": "2.0.0-beta.62"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"sass-loader": "^13.2.
|
|
60
|
+
"sass-loader": "^13.2.1"
|
|
60
61
|
},
|
|
61
62
|
"peerDependenciesMeta": {
|
|
62
63
|
"sass-loader": {
|