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.

Improve category documents view

Smaug67390f0025191639
diff --git a/frontend/pages/dashboard/categories/[id]/index.vue b/frontend/pages/dashboard/categories/[id]/index.vue
index d3375c2e..94999c6a 100644
--- a/frontend/pages/dashboard/categories/[id]/index.vue
+++ b/frontend/pages/dashboard/categories/[id]/index.vue
@@ -1,48 +1,52 @@
<template>
- <div class="document-list">
- <div v-if="documents.length" v-for="document in documents" :key="document.id" class="document-card">
- <div>
- <header class="document-header">
- <i v-html="category?.icon" class="category-icon"></i>
- <NuxtLink :to="`/dashboard/docs/${document.id}`" class="document-title" :style="`border-bottom: 2px solid ${useColorHash(document.id)};`">{{ document.name }}</NuxtLink>
- </header>
- <p class="document-description">{{ document.description }}</p>
- </div>
- <div class="document-tags" v-if="document.tags">
- <tag v-for="tag in document.tags.split(',')" :key="tag" class="blue">{{ tag.trim() }}</tag>
- </div>
- <footer class="document-footer">
- <div class="footer-item">
- <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="var(--font-color)">
- <path
- d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"
- />
- </svg>
- <span>{{ formatDate(parseInt(document.created_timestamp)) }}</span>
+ <div class="card-component">
+ <header>
+ <h1 style="font-size: 20px">Documents of category <tag class="blue">New</tag></h1>
+ </header>
+ <div class="document-list">
+ <div v-if="documents.length" v-for="document in documents" :key="document.id" class="document-card">
+ <div>
+ <header class="document-header">
+ <Icon :name="category(document.category)?.icon || ''" :class="`category-icon ${getAppColor(category(document.category)?.color as number)}`" />
+ <NuxtLink :to="`/dashboard/docs/${document.id}`" :class="`document-title`" :style="`color: var(--${getAppColor(category(document.category)?.color as number)})`">{{ document.name }}</NuxtLink>
+ </header>
+ <p class="document-description">{{ document.description }}</p>
</div>
- <div class="footer-item">
- <span>Updated : {{ formatDate(parseInt(document.updated_timestamp)) }}</span>
+ <div class="document-tags" v-if="document.tags">
+ <tag v-for="tag in document.tags.split(',')" :key="tag" class="blue">{{ tag.trim() }}</tag>
+ </div>
+ <footer class="document-footer">
+ <div class="footer-item">
+ <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="var(--font-color)">
+ <path
+ d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"
+ />
+ </svg>
+ <span>{{ formatDate(parseInt(document.created_timestamp)) }}</span>
+ </div>
+ <div class="footer-item">
+ <span>Updated : {{ formatDate(parseInt(document.updated_timestamp)) }}</span>
+ </div>
+ </footer>
+ </div>
+ <div v-else style="width: 100%; height: 100%">
+ <div style="text-align: center; margin: 10vh auto">
+ <h1>No documents found</h1>
+ <img style="max-width: 300px; max-height: 300px" :src="`/empty-${colorMode.value}.png`" />
+ <p>There are no documents in this category</p>
+ <NuxtLink to="/dashboard/docs/new"><AppButton type="link">+ Create new document </AppButton></NuxtLink>
</div>
- </footer>
- </div>
- <div v-else style="width: 100%; height: 100%">
- <div style="text-align: center; margin: 10vh auto">
- <h1>No documents found</h1>
- <img style="max-width: 300px; max-height: 300px" :src="`/empty-${colorMode.value}.png`" />
- <p>There are no documents in this category</p>
- <NuxtLink to="/dashboard/docs/new"><AppButton type="link">+ Create new document </AppButton></NuxtLink>
</div>
</div>
</div>
</template>
<script setup lang="ts">
-import { useColorHash } from '~/helpers/utils';
-
const route = useRoute();
+const mainCategoryId = route.params.id as string;
const categoriesStore = useCategoriesStore();
const documentsStore = useDocumentsStore();
-const category = computed(() => categoriesStore.getById(route.params.id as string));
+const category = (cat_id?: string) => categoriesStore.getById(cat_id || mainCategoryId);
const colorMode = useColorMode();
definePageMeta({
@@ -52,8 +56,8 @@ definePageMeta({
},
});
const documents = computed(() => {
- const documents = documentsStore.getByCategories(category.value?.id || '');
- const childCategories = categoriesStore.getChilds(category.value?.id || '');
+ const documents = documentsStore.getByCategories(mainCategoryId);
+ const childCategories = categoriesStore.getChilds(mainCategoryId);
for (const childCategory of childCategories) {
const childDocuments = documentsStore.getByCategories(childCategory.id);
documents.push(...childDocuments);
@@ -67,44 +71,39 @@ function formatDate(timestamp: number): string {
</script>
<style scoped lang="scss">
-h1 {
- font-size: 32px;
- margin-bottom: 20px;
-}
-
.document-list {
+ border-top: 1px solid #ddd;
+ padding: 10px 0;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
gap: 20px;
- max-width: 420px * 3 + 100px;
- margin: auto;
- padding: 20px;
width: 100%;
}
.document-card {
- border-radius: 10px;
+ border-radius: 6px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
overflow: hidden;
- width: 350px;
+ min-width: 340px;
+ max-width: 400px;
display: flex;
flex-direction: column;
justify-content: space-between;
- transition: transform 0.2s;
- flex: 0 1 auto;
+ flex: 1;
}
.document-header {
background-color: var(--bg-contrast-2);
- padding: 15px;
+ padding: 12px;
display: flex;
align-items: center;
}
.category-icon {
- font-size: 30px;
margin-right: 10px;
+ padding: 6px;
+ border-radius: 6px;
}
.document-title {
@@ -116,6 +115,9 @@ h1 {
.document-description {
padding: 5px;
font-size: 16px;
+ height: 120px;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
.document-tags {
@@ -126,7 +128,7 @@ h1 {
}
.document-footer {
- padding: 15px;
+ padding: 10px;
background-color: var(--bg-contrast);
display: flex;
flex-direction: column;
@@ -138,25 +140,9 @@ h1 {
.footer-item {
display: flex;
align-items: center;
- margin-bottom: 5px;
}
.footer-item svg {
margin-right: 5px;
}
-
-.category-icon {
- display: flex;
- align-items: center;
-
- &:deep(svg) {
- fill: var(--font-color);
- width: 35px;
- height: 35px;
-
- path {
- fill: var(--font-color);
- }
- }
-}
</style>