Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

feat(UI): Update Breadcrumb component

TheVijayVigneshbfc6f47b7648
diff --git a/frontend/app/components/BreadCrumb.vue b/frontend/app/components/BreadCrumb.vue
index 5f254650..e79e67cc 100644
--- a/frontend/app/components/BreadCrumb.vue
+++ b/frontend/app/components/BreadCrumb.vue
@@ -1,12 +1,26 @@
<template>
<nav class="breadcrumb">
- <svg v-if="preferences.get('navbarItems').value.navigation" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" @click="next">
+ <svg
+ v-if="preferences.get('navbarItems').value.navigation"
+ :class="{ disabled: !canGoBack }"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 -960 960 960"
+ @click="goBack"
+ >
<path d="M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z" />
</svg>
- <svg v-if="preferences.get('navbarItems').value.navigation" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" @click="previous">
+
+ <svg
+ v-if="preferences.get('navbarItems').value.navigation"
+ :class="{ disabled: !canGoForward }"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 -960 960 960"
+ @click="goForward"
+ >
<path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z" />
</svg>
- <ol class="breadcrumb">
+
+ <ol class="breadcrumb-list">
<li v-for="(segment, index) in breadcrumbs" :key="index" class="breadcrumb-item">
<NuxtLink :to="segment.path"> {{ segment.name }} </NuxtLink>
</li>
@@ -17,23 +31,37 @@
<script setup lang="ts">
const route = useRoute();
const router = useRouter();
-const breadcrumbs: Ref<Array<{ name: string; path: string }>> = ref([]);
const preferences = usePreferences();
-const next = () => useRouter().go(-1);
-const previous = () => useRouter().go(1);
+
+const breadcrumbs = ref<Array<{ name: string; path: string }>>([]);
+
+const canGoBack = ref(false);
+const canGoForward = ref(false);
+
+// Renamed for clarity
+const goBack = () => router.go(-1);
+const goForward = () => {
+ console.log('Going forward');
+ router.go(1);
+};
declare module 'vue-router' {
interface RouteMeta {
- breadcrumb: () => string;
+ breadcrumb?: string | (() => string);
}
}
watchEffect(() => {
+ canGoBack.value = window.history.state?.back !== null;
+ canGoForward.value = window.history.state?.forward !== null;
breadcrumbs.value = [];
route.matched.forEach(match => {
+ if (!match.meta?.breadcrumb) return;
+
let name = '';
- if (typeof match.meta.breadcrumb == 'function') name = match.meta.breadcrumb();
- else if (typeof match.meta.breadcrumb == 'string') name = match.meta.breadcrumb;
+ if (typeof match.meta.breadcrumb === 'function') name = match.meta.breadcrumb();
+ else if (typeof match.meta.breadcrumb === 'string') name = match.meta.breadcrumb;
+
if (!name) return;
const r = router.resolve(match);
breadcrumbs.value.push({
@@ -44,36 +72,67 @@ watchEffect(() => {
});
</script>
-<style scoped lang="scss">
+<style lang="scss" scoped>
.breadcrumb {
display: flex;
- padding: 3px;
align-items: center;
+ gap: 8px;
+ padding: 3px;
flex-wrap: wrap;
- list-style: none;
-}
-// Svg bubble button nav
-.breadcrumb svg {
- width: 27px;
- height: 27px;
- border-radius: 50%;
- transition: all 0.3s ease;
- cursor: pointer;
- fill: var(--font-color);
- margin-right: 8px;
-
- &:hover {
- background-color: var(--border-color);
+
+ svg {
+ width: 27px;
+ height: 27px;
+ border-radius: 50%;
+ transition: all 0.3s ease;
+ cursor: pointer;
+ fill: var(--font-color);
+ margin-right: 8px;
+
+ &:hover:not(.disabled) {
+ opacity: 0.8;
+ background-color: var(--selection-color);
+ }
+
+ &.disabled {
+ opacity: 0.4;
+ cursor: not-allowed;
+ }
}
}
-.breadcrumb-item + .breadcrumb-item::before {
- padding: 0 0.5rem;
- content: '>'; /* Separator */
+.breadcrumb-list {
+ display: flex;
+ align-items: center;
+ list-style: none;
+ padding: 0;
+ margin: 0;
}
-.breadcrumb-item a {
- font-size: 14px;
- font-weight: 500;
+.breadcrumb-item {
+ display: inline-flex;
+ align-items: center;
+
+ a {
+ color: var(--font-color);
+ text-decoration: none;
+ padding: 4px 8px;
+ border-radius: 4px;
+ font-size: 14px;
+ font-weight: 500;
+
+ &:hover {
+ }
+
+ &.router-link-active {
+ }
+ }
+
+ &:not(:last-child)::after {
+ content: '/';
+ margin: 0 8px;
+ color: var(--font-color-light);
+ }
}
</style>
+```
\ No newline at end of file