Skip to content

Commit

Permalink
Merge pull request #58 from directus/connorwinston/web-361-create-rig…
Browse files Browse the repository at this point in the history
…ht-sidebar

Right Sidebar
  • Loading branch information
phazonoverload authored Nov 27, 2024
2 parents 7bec435 + b177885 commit 49a47c8
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 23 deletions.
78 changes: 78 additions & 0 deletions app/components/aside/AsideSlideover.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<script lang="ts" setup>
const isOpen = defineModel<boolean>();
</script>

<template>
<div>
<div
class="slideover"
:style="`transform: translateX(${isOpen ? '0' : '200%'})`"
>
<button
class="slideover-toggle"
@click="isOpen = !isOpen"
>
<Icon name="material-symbols:close" />
</button>
<div class="nav-scroll">
<slot />
</div>
</div>
<div
class="background-overlay"
:class="{ hidden: !isOpen }"
@click="isOpen = false"
/>
</div>
</template>

<style scoped>
.slideover {
position: fixed;
top: 0;
right: 0;
bottom: 0;
background-color: var(--background);
padding-left: 1.5rem;
padding-bottom: 1rem;
padding-top: 0.5rem;
z-index: 1000;
min-width: 75vw;
transition: transform 0.3s ease;
}
.nav-scroll {
overflow-y: auto;
height: 100%;
padding-right: 1rem;
scrollbar-color: var(--border-subtle) var(--background);
}
.background-overlay {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(5px);
z-index: 999;
}
.hidden {
display: none;
}
.slideover-toggle {
background: none;
border: none;
color: color-mix(in hsl shorter hue, var(--white) 60%, var(--black) 40%);;
font-size: 1.5rem;
cursor: pointer;
height: 40px;
width: 40px;
position: fixed;
top: 0.25rem;
right: 0.25rem;
}
</style>
4 changes: 4 additions & 0 deletions app/components/aside/AsideTableOfContents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ a {
text-decoration: none;
margin-top: 0.5rem;
}
a:hover {
text-decoration: underline;
}
</style>
9 changes: 8 additions & 1 deletion app/components/header/HeaderHero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ h1 {
height: 100%;
flex: 1;
overflow: hidden;
min-width: 400px;
@media (min-width: 400px) {
min-width: 400px;
}
}
.code {
Expand All @@ -214,8 +217,12 @@ h1 {
}
.switcher {
width: 100%;
max-width: 100%;
display: flex;
gap: 1rem;
margin-bottom: 0.5rem;
white-space: nowrap;
overflow-x: auto;
}
</style>
96 changes: 82 additions & 14 deletions app/components/pages/ArticlePage.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const breadcrumbs = computed(() => {
});
return breadcrumbs;
});
const isOpen = ref(false);
</script>

<template>
Expand All @@ -22,29 +24,46 @@ const breadcrumbs = computed(() => {
<div class="page">
<div class="left-column">
<main v-if="data">
<div class="breadcrumbs">
<NuxtLink
v-for="(breadcrumb, index) in breadcrumbs"
:key="breadcrumb.to"
class="breadcrumb section-title"
:to="breadcrumb.to"
<div class="page-section-row">
<div class="breadcrumbs">
<NuxtLink
v-for="(breadcrumb, index) in breadcrumbs"
:key="breadcrumb.to"
class="breadcrumb section-title"
:to="breadcrumb.to"
>
{{ breadcrumb.name }}
<Icon
v-if="index < breadcrumbs.length - 1"
name="material-symbols:chevron-right-rounded"
class="breadcrumb-icon"
/>
</NuxtLink>
</div>

<a
v-if="data?.body?.toc && data?.body?.toc?.links?.length > 0"
class="slideover-toggle"
@click="isOpen = !isOpen"
>
{{ breadcrumb.name }}
<Icon
v-if="index < breadcrumbs.length - 1"
name="material-symbols:chevron-right-rounded"
class="breadcrumb-icon"
/>
</NuxtLink>
<Icon name="material-symbols:menu" />
On This Page
</a>
</div>

<AsideSlideover v-model="isOpen">
<AsideTableOfContents
v-if="data?.body?.toc && data?.body?.toc?.links?.length > 0"
:toc="data.body.toc"
/>
</AsideSlideover>
<article>
<ContentRenderer :value="data">
<div class="prose">
<h1>
{{ data.title }}
</h1>
</div>

<div class="tags">
<div
v-for="tag in data.tags"
Expand All @@ -64,6 +83,13 @@ const breadcrumbs = computed(() => {
</template>
</ContentRenderer>
</article>
<div class="bottom-aside">
<hr>
<AsideFeedback />
<hr>
<AsideNewsletter />
<AsideWidget />
</div>
</main>
</div>
<aside class="right-aside">
Expand Down Expand Up @@ -105,6 +131,41 @@ const breadcrumbs = computed(() => {
</template>

<style lang="scss" scoped>
.bottom-aside {
margin-top: 24px;
display: none;
flex-direction: column;
gap: 12px;
}
@media (max-width: 1024px) {
.bottom-aside {
display: flex;
}
}
.slideover-toggle {
display: none;
align-items: center;
gap: 0.25rem;
text-decoration: none;
font-size: 0.75rem;
color: var(--typography-subdued);
cursor: pointer;
}
@media (max-width: 1024px) {
.slideover-toggle{
display: flex;
}
}
.page-section-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.tags {
display: flex;
gap: 0.5rem;
Expand Down Expand Up @@ -210,6 +271,13 @@ main {
width: 100%;
}
}
@media (max-width: 1024px) {
.right-aside {
display: none;
}
}
.page-layout {
margin-top: 24px;
display: grid;
Expand Down
78 changes: 70 additions & 8 deletions app/components/pages/DocumentationPage.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defineProps<{
allPages: AllPages;
allNavigation: NavItems;
}>();
const isOpen = ref(false);
</script>

<template>
Expand All @@ -28,15 +30,33 @@ defineProps<{
v-if="data"
class="main-content"
>
<AsideSlideover v-model="isOpen">
<AsideTableOfContents
v-if="data?.body?.toc && data?.body?.toc?.links?.length > 0"
:toc="data.body.toc"
/>
</AsideSlideover>

<article>
<ContentRenderer :value="data">
<span
v-if="data._dir"
v-title
class="section-title"
>
{{ data._dir }}
</span>
<div class="page-section-row">
<span
v-if="data._dir"
v-title
class="section-title"
>
{{ data._dir }}
</span>

<a
v-if="data?.body?.toc && data?.body?.toc?.links?.length > 0"
class="slideover-toggle"
@click="isOpen = !isOpen"
>
<Icon name="material-symbols:menu" />
On This Page
</a>
</div>
<ContentRendererMarkdown
class="prose"
:value="data"
Expand All @@ -46,6 +66,13 @@ defineProps<{
</template>
</ContentRenderer>
</article>
<div class="bottom-aside">
<hr>
<AsideFeedback />
<hr>
<AsideNewsletter />
<AsideWidget />
</div>
</main>
<aside class="right-aside">
<AsideTableOfContents
Expand All @@ -63,6 +90,28 @@ defineProps<{
</template>

<style lang="scss" scoped>
.slideover-toggle {
display: none;
align-items: center;
gap: 0.25rem;
text-decoration: none;
font-size: 0.75rem;
color: var(--typography-subdued);
cursor: pointer;
}
@media (max-width: 1024px) {
.slideover-toggle{
display: flex;
}
}
.page-section-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.docs-grid {
padding-top: 3rem;
padding-bottom: 6rem;
Expand Down Expand Up @@ -91,7 +140,7 @@ defineProps<{
border-left: 2px solid var(--border);
display: flex;
flex-direction: column;
gap: calc(24px / 2);
gap: 12px;
}
.right-aside > * {
Expand Down Expand Up @@ -119,4 +168,17 @@ defineProps<{
display: none;
}
}
.bottom-aside {
margin-top: 24px;
display: none;
flex-direction: column;
gap: 12px;
}
@media (max-width: 1024px) {
.bottom-aside {
display: flex;
}
}
</style>

0 comments on commit 49a47c8

Please sign in to comment.