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

feat: use slots in sidebar #5105

Merged
merged 3 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
5 changes: 5 additions & 0 deletions changelog/unreleased/change-use-slots-in-sidebar
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Use slots in the navigation sidebar

In the new sidebar content is defined solely via slots. We've moved all the content into those slots so that the sidebar still gets displayed correctly.

https://github.com/owncloud/web/pull/5105
81 changes: 70 additions & 11 deletions packages/web-runtime/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div>
<div id="web">
<oc-hidden-announcer :announcement="announcement" level="polite" />
<skip-to target="main">
<translate>Skip to main</translate>
Expand All @@ -17,24 +17,51 @@
<template v-else-if="!showHeader">
<router-view name="fullscreen" />
</template>
<div v-else key="core-content" class="uk-flex uk-flex-stretch">
<div v-else id="web-content" key="core-content" class="uk-flex uk-flex-stretch">
<transition :name="appNavigationAnimation">
<focus-trap v-if="isSidebarVisible" :active="isSidebarFixed && appNavigationVisible">
<oc-sidebar
<oc-sidebar-nav
v-show="isSidebarVisible"
id="web-nav-sidebar"
v-touch:swipe.left="handleNavSwipe"
class="oc-app-navigation"
:logo-img="logoImage"
:logo-alt="sidebarLogoAlt"
:nav-items="sidebarNavItems"
:accessible-label="$gettext('Application navigation')"
:class="sidebarClasses"
:fixed="isSidebarFixed"
:accessible-label="accessibleLabel"
@close="toggleAppNavigationVisibility"
>
<template v-if="sidebar.sidebarFooterContentComponent" v-slot:footer>
<template #header>
<div class="uk-text-center">
<oc-button
v-if="isSidebarFixed"
variation="inverse"
appearance="raw"
class="web-sidebar-btn-close"
:aria-label="$gettext('Close sidebar navigation')"
LukasHirt marked this conversation as resolved.
Show resolved Hide resolved
@click="toggleAppNavigationVisibility"
>
<oc-icon name="close" aria-hidden="true" />
LukasHirt marked this conversation as resolved.
Show resolved Hide resolved
</oc-button>
<router-link ref="navigationSidebarLogo" to="/">
<oc-logo :src="logoImage" alt="ownCloud" />
LukasHirt marked this conversation as resolved.
Show resolved Hide resolved
</router-link>
</div>
</template>
<template #nav>
<oc-list>
<oc-sidebar-nav-item
v-for="link in sidebarNavItems"
:key="link.route.path"
:active="link.active"
:target="link.route.path"
:icon="link.icon || link.iconMaterial"
>
{{ link.name }}
</oc-sidebar-nav-item>
</oc-list>
</template>
<template v-if="sidebar.sidebarFooterContentComponent" #footer>
<component :is="sidebar.sidebarFooterContentComponent" />
</template>
</oc-sidebar>
</oc-sidebar-nav>
</focus-trap>
</transition>
<div class="uk-width-expand web-content-container">
Expand Down Expand Up @@ -312,6 +339,12 @@ export default {

toggleAppNavigationVisibility() {
this.appNavigationVisible = !this.appNavigationVisible

if (this.appNavigationVisible) {
this.$nextTick(() => {
this.$refs.navigationSidebarLogo.$el.focus()
})
}
},

$_updateNotifications() {
Expand Down Expand Up @@ -376,6 +409,14 @@ export default {
}
</script>
<style>
html,
body,
#web,
#web-container,
#web-content {
height: 100%;
}

#web-container {
background-color: var(--oc-color-background-default);
}
Expand Down Expand Up @@ -432,4 +473,22 @@ export default {
border: 10px solid;
border-bottom: 10px solid transparent;
}

@media only screen and (max-width: 960px) {
#web-nav-sidebar {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 3;
}
}

.web-sidebar-btn-close {
position: absolute;
right: var(--oc-space-medium);
top: var(--oc-space-medium);
z-index: 3;
}
</style>