@@ -3,8 +3,12 @@ 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 , onMounted , ref } from ' vue'
7
- import { useThemeLocaleData } from ' ../composables/index.js'
6
+ import { computed , ref } from ' vue'
7
+ import {
8
+ DeviceType ,
9
+ useThemeLocaleData ,
10
+ useUpdateDeviceStatus ,
11
+ } from ' ../composables/index.js'
8
12
9
13
defineEmits ([' toggle-sidebar' ])
10
14
@@ -23,16 +27,14 @@ const linksWrapperStyle = computed(() => {
23
27
}
24
28
})
25
29
26
- // avoid overlapping of long title and long navbar links
27
- onMounted (() => {
28
- // TODO: migrate to css var
29
- // refer to _variables.scss
30
- const MOBILE_DESKTOP_BREAKPOINT = 719
31
- const navbarHorizontalPadding =
32
- getCssValue (navbar .value , ' paddingLeft' ) +
33
- getCssValue (navbar .value , ' paddingRight' )
34
- const handleLinksWrapWidth = (): void => {
35
- if (window .innerWidth < MOBILE_DESKTOP_BREAKPOINT ) {
30
+ useUpdateDeviceStatus (
31
+ DeviceType .MOBILE ,
32
+ (mobileDesktopBreakpoint : number ): void => {
33
+ // avoid overlapping of long title and long navbar links
34
+ const navbarHorizontalPadding =
35
+ getCssValue (navbar .value , ' paddingLeft' ) +
36
+ getCssValue (navbar .value , ' paddingRight' )
37
+ if (window .innerWidth < mobileDesktopBreakpoint ) {
36
38
linksWrapperMaxWidth .value = 0
37
39
} else {
38
40
linksWrapperMaxWidth .value =
@@ -41,10 +43,7 @@ onMounted(() => {
41
43
(navbarBrand .value ?.offsetWidth || 0 )
42
44
}
43
45
}
44
- handleLinksWrapWidth ()
45
- window .addEventListener (' resize' , handleLinksWrapWidth , false )
46
- window .addEventListener (' orientationchange' , handleLinksWrapWidth , false )
47
- })
46
+ )
48
47
49
48
function getCssValue(el : HTMLElement | null , property : string ): number {
50
49
// NOTE: Known bug, will return 'auto' if style value is 'auto'
0 commit comments