Skip to content

Allow toggling sidebar navigator on/off, for large breakpoints #99

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3e4981c
feat: allow toggling the navigator on desktop resolutions
Mar 25, 2022
593561a
feat: allow dragging to close entirely
Mar 25, 2022
6e91dcd
fix: make sure hidden item is hidden, even for Screen Readers and tab…
Mar 25, 2022
df8af04
chore: fix eslint
Mar 25, 2022
c05127e
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Mar 28, 2022
400b39c
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Mar 28, 2022
c32e8dd
fix: add separator to sidebar toggle icon
Mar 28, 2022
2ea28f8
Merge branch 'dhristov/r89564104-allow-toggling-sidebar-on-dekstop' o…
Mar 28, 2022
df987f4
refactor: make sidebar available to Medium sizes again
Mar 28, 2022
e028535
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Mar 31, 2022
74253f8
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Mar 31, 2022
d831f3f
fix: navigator toggle focus area
Mar 31, 2022
c436e5f
fix: navigator closing overflow issues
Mar 31, 2022
cdf8509
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Apr 1, 2022
2dd44b1
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Apr 4, 2022
a6d1d6e
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 1, 2022
86ce6f6
chore: fix merge conflicts
Jul 1, 2022
dd02d97
refactor: update the sidebar toggling logic. Track container size. Re…
Jul 1, 2022
cfb9941
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 12, 2022
8fe63a8
refactor: improve the toggle icon animation
Jul 13, 2022
0f6f83b
fix: side borders
Jul 13, 2022
269efe1
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 13, 2022
288146f
chore: remove unnecessary code
Jul 13, 2022
f8090fa
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 14, 2022
2c90b07
refactor: improvements to the large navigator toggling
Jul 14, 2022
95ce2eb
Merge remote-tracking branch 'public-docc/main' into dhristov/r895641…
Jul 14, 2022
acfebdd
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 15, 2022
01fbb6e
refactor: improve the hide sidebar animation
Jul 15, 2022
97709a3
chore: add tests
Jul 15, 2022
dace31c
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 18, 2022
59b8856
refactor: general renaming and cleanup. Adding tests.
Jul 18, 2022
571c0a1
refactor: cleanup
Jul 18, 2022
4e5da45
chore: forgotten license header
Jul 18, 2022
bf10a7c
fix: make sure the Navigator toggle also animates, in sync with the n…
Jul 19, 2022
3f2787d
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Jul 19, 2022
7eb3924
fix: issues with body height and weirdly wrapping text
Jul 19, 2022
5206b72
Merge branch 'dhristov/r89564104-allow-toggling-sidebar-on-dekstop' o…
Jul 19, 2022
d1dbe2c
refactor: toggle border radius
Jul 21, 2022
1334f8a
refactor: allow navigator toggle to be shown on small only
Jul 28, 2022
2a7f24a
Merge branch 'main' into dhristov/r89564104-allow-toggling-sidebar-on…
Aug 1, 2022
ed74616
refactor: properly add `.sidebar-transitioning` class to the Adjustab…
Aug 2, 2022
e97f62a
fix: NavigatorCard.vue close icon focus area
Aug 2, 2022
d9ae6b8
refactor: minor cleanup of constants
Aug 2, 2022
d88bb76
fix: quirk in chrome
Aug 2, 2022
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
97 changes: 83 additions & 14 deletions src/components/AdjustableSidebarWidth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
-->

<template>
<div class="adjustable-sidebar-width">
<div
class="adjustable-sidebar-width"
:class="{
dragging: isDragging,
'sidebar-hidden': hiddenOnLarge
}"
>
<div
ref="sidebar"
class="sidebar"
Expand All @@ -19,8 +25,9 @@
:style="asideStyles"
class="aside"
ref="aside"
@transitionstart="isTransitioning = true"
@transitionend="isTransitioning = false"
:aria-hidden="hiddenOnLarge ? 'true': null"
@transitionstart="trackTransitionStart"
@transitionend="trackTransitionEnd"
>
<slot
name="aside"
Expand All @@ -35,7 +42,7 @@
@touchstart.prevent="startDrag"
/>
</div>
<div class="content">
<div class="content" ref="content">
<slot />
</div>
<BreakpointEmitter :scope="BreakpointScopes.nav" @change="breakpoint = $event" />
Expand Down Expand Up @@ -96,8 +103,13 @@ export default {
components: {
BreakpointEmitter,
},
inject: ['store'],
props: {
openExternally: {
shownOnMobile: {
type: Boolean,
default: false,
},
hiddenOnLarge: {
type: Boolean,
default: false,
},
Expand Down Expand Up @@ -149,12 +161,13 @@ export default {
'--app-height': `${windowHeight}px`,
}),
asideClasses: ({
isDragging, openExternally, noTransition, isTransitioning, mobileTopOffset,
isDragging, shownOnMobile, noTransition, isTransitioning, hiddenOnLarge, mobileTopOffset,
}) => ({
dragging: isDragging,
'force-open': openExternally,
'show-on-mobile': shownOnMobile,
'hide-on-large': hiddenOnLarge,
'no-transition': noTransition,
animating: isTransitioning,
'sidebar-transitioning': isTransitioning,
'has-mobile-top-offset': mobileTopOffset,
}),
scrollLockID: () => SCROLL_LOCK_ID,
Expand All @@ -175,7 +188,7 @@ export default {
window.removeEventListener('resize', this.storeWindowSize);
window.removeEventListener('orientationchange', this.storeWindowSize);
window.removeEventListener('scroll', this.storeTopOffset);
if (this.openExternally) {
if (this.shownOnMobile) {
this.toggleScrollLock(false);
}
if (this.focusTrapInstance) this.focusTrapInstance.destroy();
Expand Down Expand Up @@ -208,7 +221,13 @@ export default {
// re-apply transitions
this.noTransition = false;
},
openExternally: 'handleExternalOpen',
shownOnMobile: 'handleExternalOpen',
isTransitioning(value) {
if (!value) this.updateContentWidthInStore();
},
hiddenOnLarge() {
this.isTransitioning = true;
},
},
methods: {
getWidthInCheck: debounce(function getWidthInCheck() {
Expand All @@ -226,10 +245,11 @@ export default {
await this.$nextTick();
this.windowWidth = window.innerWidth;
this.windowHeight = window.innerHeight;
this.updateContentWidthInStore();
}, 100),
closeMobileSidebar() {
if (!this.openExternally) return;
this.$emit('update:openExternally', false);
if (!this.shownOnMobile) return;
this.$emit('update:shownOnMobile', false);
},
startDrag({ type }) {
this.isTouch = type === 'touchstart';
Expand All @@ -254,8 +274,18 @@ export default {
if (newWidth > this.maxWidth) {
newWidth = this.maxWidth;
}
// calculate the forceClose cutoff point
const forceCloseCutoff = this.minWidth / 2;
// if we are going beyond the cutoff point and we are closed, open the navigator
if (this.hiddenOnLarge && newWidth >= forceCloseCutoff) {
this.$emit('update:hiddenOnLarge', false);
}
// prevent from shrinking too much
this.width = Math.max(newWidth, this.minWidth);
// if the new width is smaller than the cutoff point, force close the nav
if (newWidth <= forceCloseCutoff) {
this.$emit('update:hiddenOnLarge', true);
}
},
/**
* Stop the dragging upon mouse up
Expand All @@ -273,6 +303,7 @@ export default {
},
emitEventChange(width) {
this.$emit('width-change', width);
this.updateContentWidthInStore();
},
getTopOffset() {
const stickyNavAnchor = document.getElementById(baseNavStickyAnchorId);
Expand All @@ -286,6 +317,10 @@ export default {
}
this.toggleScrollLock(isOpen);
},
async updateContentWidthInStore() {
await this.$nextTick();
this.store.setContentWidth(this.$refs.content.offsetWidth);
},
/**
* Toggles the scroll lock on/off
*/
Expand All @@ -307,6 +342,16 @@ export default {
storeTopOffset: throttle(function storeTopOffset() {
this.topOffset = this.getTopOffset();
}, 60),
trackTransitionStart({ propertyName }) {
if (propertyName === 'width' || propertyName === 'transform') {
this.isTransitioning = true;
}
},
trackTransitionEnd({ propertyName }) {
if (propertyName === 'width' || propertyName === 'transform') {
this.isTransitioning = false;
}
},
},
};
</script>
Expand All @@ -320,6 +365,14 @@ export default {
display: block;
position: relative;
}

&.dragging /deep/ * {
cursor: col-resize !important;
}

&.sidebar-hidden.dragging /deep/ * {
cursor: e-resize !important;
}
}

.sidebar {
Expand All @@ -339,6 +392,22 @@ export default {
transition: none !important;
}

@include breakpoints-from(large, nav) {

&:not(.dragging) {
transition: width $adjustable-sidebar-hide-transition-duration ease-in,
visibility 0s linear 0s;
}

&.hide-on-large {
width: 0 !important;
visibility: hidden;
pointer-events: none;
transition: width $adjustable-sidebar-hide-transition-duration ease-in,
visibility 0s linear $adjustable-sidebar-hide-transition-duration;
}
}

@include breakpoint(medium, nav) {
width: 100% !important;
overflow: hidden;
Expand All @@ -348,15 +417,15 @@ export default {
position: fixed;
top: var(--top-offset-mobile);
bottom: 0;
z-index: $nav-z-index;
z-index: $nav-z-index + 1;
transform: translateX(-100%);
transition: transform 0.15s ease-in;

/deep/ .aside-animated-child {
opacity: 0;
}

&.force-open {
&.show-on-mobile {
transform: translateX(0);

/deep/ .aside-animated-child {
Expand Down
6 changes: 0 additions & 6 deletions src/components/DocumentationTopic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,6 @@ export default {
outline-style: none;
height: 100%;

@include with-adjustable-sidebar {
@include breakpoints-from(xlarge) {
border-right: 1px solid var(--color-grid);
}
}

@include inTargetIde {
min-height: 100vh;
display: flex;
Expand Down
Loading