Skip to content

Commit

Permalink
feat: auto-collapse sidebar for window width < lg
Browse files Browse the repository at this point in the history
  • Loading branch information
MuazOthman authored and mike-plummer committed Jul 15, 2022
1 parent 198b28d commit 3cd36dd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/app/src/navigation/SidebarNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import CypressLogo from '@packages/frontend-shared/src/assets/logos/cypress_s.pn
import { useI18n } from '@cy/i18n'
import { useRoute } from 'vue-router'
import SidebarNavigationHeader from './SidebarNavigationHeader.vue'
import { useWindowSize } from '@vueuse/core'
const { t } = useI18n()
Expand Down Expand Up @@ -140,6 +141,8 @@ query SideBarNavigation {
}
`
const NAV_EXPAND_MIN_SCREEN_WIDTH = 1024
const query = useQuery({ query: SideBarNavigationDocument })
const setPreferences = useMutation(SideBarNavigation_SetPreferencesDocument)
Expand All @@ -148,20 +151,22 @@ const bindingsOpen = ref(false)
const route = useRoute()
const navIsAlwaysCollapsed = computed(() => route.meta?.navBarExpandedAllowed !== false)
const navIsAlwaysCollapsed = computed(() => width.value >= NAV_EXPAND_MIN_SCREEN_WIDTH && route.meta?.navBarExpandedAllowed !== false)
const isNavBarExpanded = ref(true)
const { width } = useWindowSize()
watchEffect(() => {
if (route.meta?.navBarExpandedAllowed === false) {
if (width.value < NAV_EXPAND_MIN_SCREEN_WIDTH || route.meta?.navBarExpandedAllowed === false) {
isNavBarExpanded.value = false
} else {
isNavBarExpanded.value = query.data?.value?.localSettings.preferences.isSideNavigationOpen ?? true
}
})
const toggleNavbarIfAllowed = () => {
if (route.meta?.navBarExpandedAllowed === false) {
if (width.value < NAV_EXPAND_MIN_SCREEN_WIDTH || route.meta?.navBarExpandedAllowed === false) {
return
}
Expand Down

0 comments on commit 3cd36dd

Please sign in to comment.