Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sidebar toggle #862

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/common/DocsPageTemplate/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
>
<div>
<h1 class="header-text">
<span @click="toggleSideNav">
<KIcon icon="menu" />
FidalMathew marked this conversation as resolved.
Show resolved Hide resolved
</span>
<span :class="{ code: codeStyle }">{{ title }}</span>
<a
href="#"
Expand Down Expand Up @@ -90,6 +93,9 @@
updateHighlight() {
this.highlighed = ['', '#'].includes(window.location.hash);
},
toggleSideNav() {
this.$emit('update-side-nav', true); // Emit value to parent
},
},
};

Expand Down
5 changes: 5 additions & 0 deletions docs/common/DocsPageTemplate/SideNav/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:showBackground="true"
/>
<span class="header-text">Design System</span>
<span @click="closeSideNav"> <KIcon icon="close"/></span>
</h1>

<DocsFilter v-model="filterText" />
Expand Down Expand Up @@ -99,6 +100,9 @@
throttleHandleScroll: throttle(function handleScroll() {
window.sessionStorage.setItem('nav-scroll', this.$refs.links.scrollTop);
}, 100),
closeSideNav() {
this.$emit('update-side-nav', false);
},
},
};

Expand Down Expand Up @@ -146,6 +150,7 @@
left: 0;
z-index: 100;
width: $nav-width;
transition: transform 0.3s ease;
}

.sidenav {
Expand Down
45 changes: 43 additions & 2 deletions docs/common/DocsPageTemplate/index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<template>

<div class="content-wrapper">
<SideNav />
<SideNav :class="{ show: isSideNavVisible, 'side-nav': true }" @update-side-nav="handleSideNavUpdate"/>
<Header
:sections="pageSections"
:title="page.title"
:codeStyle="page.isCode"
class="floating-header"
@update-side-nav="handleSideNavUpdate"
/>
<div class="border">
<!-- second header used as a spacer -->
Expand Down Expand Up @@ -81,6 +82,16 @@
default: false,
},
},
data() {
return {
isSideNavVisible: false, // Track state received from child
};
},
methods: {
handleSideNavUpdate(visible) {
this.isSideNavVisible = visible; // Update parent state
},
},
computed: {
page() {
let path = this.$route.path;
Expand Down Expand Up @@ -171,13 +182,43 @@
top: 0;
right: 0;
left: $nav-width;
z-index: 100;
z-index: 99;
}

@media screen and (max-width: 768px) {
.floating-header {
left: 0;

}

}

.side-nav {
// display: block;
transform: translateX(0);
}

@media (max-width: 768px) {
.side-nav {
// display: none;
FidalMathew marked this conversation as resolved.
Show resolved Hide resolved
transform: translateX(-100%);
}

.side-nav.show {
transform: translateX(0);
}
}

.content-wrapper {
margin-left: $nav-width;
}

@media (max-width: 768px) {
.content-wrapper {
margin-left: 0;
}
}

.border {
border-left: 1px solid $border-color;
}
Expand Down
Loading