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.

Styles improvments

Smaug67396e223c98db13
diff --git a/frontend/components/table-of-content/TableOfContents.vue b/frontend/components/table-of-content/TableOfContents.vue
index f8b3e515..53027beb 100644
--- a/frontend/components/table-of-content/TableOfContents.vue
+++ b/frontend/components/table-of-content/TableOfContents.vue
@@ -1,11 +1,11 @@
<template>
- <aside>
- <ul ref="list" class="toc">
- <h4>Table of content</h4>
- <NodeTree v-if="headers.length" v-for="header of headers_tree" :node="header" :key="header.link" />
- <p v-else>Aucun élément à afficher</p>
- </ul>
- </aside>
+ <aside>
+ <ul ref="list" class="toc">
+ <h4>Table of content</h4>
+ <NodeTree v-if="headers.length" v-for="header of headers_tree" :node="header" :key="header.link" />
+ <p v-else>Aucun élément à afficher</p>
+ </ul>
+ </aside>
</template>
<script lang="ts" setup>
@@ -15,96 +15,93 @@ const props = defineProps<{ element?: HTMLElement }>();
const list = ref<HTMLElement>();
interface GroupedHeaders {
- title: string;
- link: string;
- level: number;
+ title: string;
+ link: string;
+ level: number;
}
interface TreeItem {
- title: string;
- link: string;
- level: number;
- childrens?: TreeItem[];
+ title: string;
+ link: string;
+ level: number;
+ childrens?: TreeItem[];
}
const getHTMLHeaders = (): HTMLElement[] => {
- if (!props.element) return [];
- const headers = props.element.querySelectorAll('h1, h2, h3, h4, h5, h6') as NodeListOf<HTMLElement>;
- return Array.from(headers);
+ if (!props.element) return [];
+ const headers = props.element.querySelectorAll('h1, h2, h3, h4, h5, h6') as NodeListOf<HTMLElement>;
+ return Array.from(headers);
};
function getHeaders(headers: HTMLElement[]): GroupedHeaders[] {
- const tree: GroupedHeaders[] = [];
- for (const header of headers) {
- const level = parseInt(header.tagName[1] || '1');
- const title = header.textContent?.replace(/#/g, '') || '';
- const link = `#${header.id}`;
- const node: GroupedHeaders = { title, link, level };
- tree.push(node);
- }
- return tree;
+ const tree: GroupedHeaders[] = [];
+ for (const header of headers) {
+ const level = parseInt(header.tagName[1] || '1');
+ const title = header.textContent?.replace(/#/g, '') || '';
+ const link = `#${header.id}`;
+ const node: GroupedHeaders = { title, link, level };
+ tree.push(node);
+ }
+ return tree;
}
function buildTree(tree: GroupedHeaders[]): TreeItem[] {
- const result: TreeItem[] = [];
- const stack: TreeItem[] = [];
- for (const node of tree) {
- const item: TreeItem = { title: node.title, link: node.link, level: node.level };
- while (stack.length > 0 && stack[stack.length - 1].level >= node.level) {
- stack.pop();
- }
- if (stack.length > 0) {
- if (!stack[stack.length - 1].childrens) stack[stack.length - 1].childrens = [];
- // @ts-ignore
- stack[stack.length - 1].childrens.push(item);
- } else {
- result.push(item);
- }
- stack.push(item);
- }
- return result;
+ const result: TreeItem[] = [];
+ const stack: TreeItem[] = [];
+ for (const node of tree) {
+ const item: TreeItem = { title: node.title, link: node.link, level: node.level };
+ while (stack.length > 0 && stack[stack.length - 1].level >= node.level) {
+ stack.pop();
+ }
+ if (stack.length > 0) {
+ if (!stack[stack.length - 1].childrens) stack[stack.length - 1].childrens = [];
+ // @ts-ignore
+ stack[stack.length - 1].childrens.push(item);
+ } else {
+ result.push(item);
+ }
+ stack.push(item);
+ }
+ return result;
}
const headers = computed(() => getHTMLHeaders());
const headers_tree = computed(() => buildTree(getHeaders(headers.value)));
const observerCallback = (e: IntersectionObserverEntry[]) => {
- e.forEach((entry) => {
- const activeLink = list.value?.querySelector<HTMLAnchorElement>(`[href="#${entry.target.id}"]`)
- if (activeLink && entry.isIntersecting && entry.intersectionRatio === 1) {
- activeLink.classList.add('active')
- } else if (activeLink) {
- activeLink.classList.remove('active')
- }
- })
+ e.forEach(entry => {
+ const activeLink = list.value?.querySelector<HTMLAnchorElement>(`[href="#${entry.target.id}"]`);
+ if (activeLink && entry.isIntersecting && entry.intersectionRatio === 1) {
+ activeLink.classList.add('active');
+ } else if (activeLink) {
+ activeLink.classList.remove('active');
+ }
+ });
};
-
const observer: IntersectionObserver = new IntersectionObserver(observerCallback, { root: null, threshold: 1 });
-watchEffect(() => headers.value.forEach((header) => observer.observe(header)));
-onBeforeUnmount(() => observer.disconnect())
+watchEffect(() => headers.value.forEach(header => observer.observe(header)));
+onBeforeUnmount(() => observer.disconnect());
</script>
<style lang="scss" scoped>
-@media (min-width: 1280px) {
- .toc {
- position: sticky;
- top: 20px;
- padding-left: 15px;
- margin-left: 10px;
- font-size: 0.75rem;
- max-width: 100%;
- font-weight: 500;
- }
+.toc {
+ position: sticky;
+ top: 20px;
+ padding-left: 15px;
+ margin-left: 10px;
+ font-size: 0.75rem;
+ max-width: 100%;
+ font-weight: 400;
+}
- ul {
- border-left: 1px solid var(--border-color);
- padding: 0;
- margin: 0;
+ul {
+ border-left: 1px solid var(--border-color);
+ padding: 0;
+ margin: 0;
- li:deep(a) {
- &.active {
- color: $primary-400 !important;
- }
- }
- }
+ li:deep(a) {
+ &.active {
+ font-weight: 600;
+ }
+ }
}
</style>
diff --git a/frontend/components/table-of-content/types.ts b/frontend/components/table-of-content/types.ts
deleted file mode 100644
index b719e15e..00000000
--- a/frontend/components/table-of-content/types.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export interface GroupedHeaders {
- title: string;
- link: string;
- childrens?: GroupedHeaders[];
-}
diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts
index 49ddae77..5f91726f 100644
--- a/frontend/composables/utils.ts
+++ b/frontend/composables/utils.ts
@@ -25,7 +25,10 @@ export interface APIResult<Data> {
export interface FetchOptions {
id: string; // id of the ressource
}
+// Little screen size
export const isMobile = () => (import.meta.client ? window.innerWidth <= 768 : false);
+// Intermediate screen size
+export const isTablet = () => (import.meta.client ? window.innerWidth <= 1280 : false);
export async function makeRequest<T>(route: string, method: string, body: Object, retry = false): Promise<APIResult<T>> {
const userStore = useUserStore();
diff --git a/frontend/pages/dashboard/docs/[id].vue b/frontend/pages/dashboard/docs/[id].vue
index 684ec72f..42b924dd 100644
--- a/frontend/pages/dashboard/docs/[id].vue
+++ b/frontend/pages/dashboard/docs/[id].vue
@@ -1,24 +1,21 @@
<template>
- <transition name="slide-fade" mode="out-in">
-
- <div v-if="article?.id" style="width:100%;">
- <div style="display:flex; justify-content: space-between;">
- <div style="width:100%;max-width: 900px;margin: auto;">
- <DocumentCardHeader :doc="article" style="margin-bottom: 20px;" />
- <article class="document-theme" style="max-width: 100%;" ref="element" v-html="article.content_html">
- </article>
- <DocumentCardFooter :document="article" :next="next" :previous="previous" />
- </div>
- <TableOfContent :element="element" :doc_id="article.id" class="toc" />
- </div>
- </div>
- </transition>
+ <transition name="slide-fade" mode="out-in">
+ <div v-if="article?.id" style="width: 100%">
+ <div style="display: flex; justify-content: space-between">
+ <div style="width: 100%; max-width: 900px; margin: auto">
+ <DocumentCardHeader :doc="article" style="margin-bottom: 20px" />
+ <article class="document-theme" style="max-width: 100%" ref="element" v-html="article.content_html"></article>
+ <DocumentCardFooter :document="article" :next="next" :previous="previous" />
+ </div>
+ <TableOfContent :element="element" :doc_id="article.id" class="toc" style="width: 400px" v-if="!isTablet()" />
+ </div>
+ </div>
+ </transition>
</template>
<script setup lang="ts">
-
import { useDocumentsStore, type Document } from '@/stores';
-import TableOfContent from "@/components/table-of-content/TableOfContents.vue";
+import TableOfContent from '@/components/table-of-content/TableOfContents.vue';
const route = useRoute();
const documentsStore = useDocumentsStore();
@@ -27,53 +24,40 @@ const element = ref<HTMLElement>();
const article = ref<Document | undefined>();
watchEffect(async () => {
- const document_id = route.params.id as string;
- const docFromStore = documentsStore.getById(document_id);
- article.value = undefined;
- if (docFromStore?.partial) {
- try {
- article.value = await documentsStore.fetch({ id: document_id });
- } catch (error) {
- }
- } else article.value = docFromStore;
- useHead({ title: `Alexandrie ${article.value?.name || ''}` });
+ const document_id = route.params.id as string;
+ const docFromStore = documentsStore.getById(document_id);
+ article.value = undefined;
+ if (docFromStore?.partial) {
+ try {
+ article.value = await documentsStore.fetch({ id: document_id });
+ } catch (error) {}
+ } else article.value = docFromStore;
+ useHead({ title: `Alexandrie ${article.value?.name || ''}` });
});
definePageMeta({
- breadcrumb: () => {
- const doc = useDocumentsStore().getById(useRoute().params.id as string);
- return doc?.name || '';
- }
+ breadcrumb: () => {
+ const doc = useDocumentsStore().getById(useRoute().params.id as string);
+ return doc?.name || '';
+ },
});
const next = computed(() => documentsStore.getNext(article.value));
const previous = computed(() => documentsStore.getPrevious(article.value));
-
</script>
<style scoped>
-.toc {
- width: 400px;
- display: none;
-}
-
-@media (min-width: 1280px) {
- .toc {
- display: block;
- }
-}
-
.slide-fade-enter-active {
- transition: all .3s ease;
+ transition: all 0.3s ease;
}
.slide-fade-leave-active {
- transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
+ transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-leave-to {
- transform: translateX(10px);
- opacity: 0;
+ transform: translateX(10px);
+ opacity: 0;
}
-</style>
\ No newline at end of file
+</style>
diff --git a/frontend/pages/dashboard/settings.vue b/frontend/pages/dashboard/settings.vue
index f024a112..6151c8c4 100644
--- a/frontend/pages/dashboard/settings.vue
+++ b/frontend/pages/dashboard/settings.vue
@@ -87,15 +87,17 @@
</form>
</div>
<div v-show="currentPage == 'backup'" class="page backup_page">
- <h2>Create a Database Backup</h2>
+ <h1>Create a Database Backup</h1>
<p>Click the button below to create a backup of your database.</p>
- <button @click="submitFile">Create Backup</button>
+ <button @click="submitFile" class="btn primary">Create Backup</button>
<div v-if="isLoading" class="loading-spinner"></div>
<div class="link-section" v-if="downloadLink">
<p>Your backup is ready. You can copy the link to share it or download it.</p>
<input type="text" v-model="downloadLink" readonly placeholder="Backup Link" />
- <button @click="copyLink">Copy Link</button>
- <a :href="downloadLink" download="true" class="download">Download Backup</a>
+ <div style="display: flex">
+ <button @click="copyLink" class="btn secondary">Copy Link</button>
+ <a :href="downloadLink" download><button class="btn primary">Download Backup</button></a>
+ </div>
</div>
</div>
</div>
@@ -167,7 +169,7 @@ async function submitFile() {
if (result.status != 'success') {
return useNotifications().add({ type: 'error', title: 'Error', message: result.message, timeout: 5000 });
}
- downloadLink.value = `${CDN}/${result.result?.url || ''}`;
+ downloadLink.value = `${CDN}${result.result?.url || ''}`;
}
</script>
@@ -281,26 +283,10 @@ form {
}
}
.backup_page {
- .backup-component {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 2rem;
- margin: 0 auto;
- height: min-content;
-
- h2 {
- margin-bottom: 1rem;
- }
-
- input {
- margin-bottom: 1rem;
- }
-
- .download {
- margin-left: 15px;
- }
- }
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin: 0 auto;
.loading-spinner {
border: 5px solid #f3f3f3;
diff --git a/frontend/styles/_variables.scss b/frontend/styles/_variables.scss
index b41ef3e7..09a89344 100644
--- a/frontend/styles/_variables.scss
+++ b/frontend/styles/_variables.scss
@@ -14,6 +14,10 @@ $primary-400: #334155;
$primary-300: lighten($primary-400, 10%);
$primary-500: darken($primary-400, 10%);
+$secondary-400: #8e8d8a;
+$secondary-300: lighten($secondary-400, 10%);
+$secondary-500: darken($secondary-400, 10%);
+
@import "./font.scss";
$external-font: 'Poppins', sans-serif;
@@ -24,8 +28,6 @@ $transition-duration: 0.3s;
:root {
- --primary-400: #334155;
-
--bg-color: #fff;
--bg-contrast: #F1F6FD;
--bg-contrast-2: #ECF2FF;
diff --git a/frontend/styles/document-theme.scss b/frontend/styles/document-theme.scss
index f47d7bcb..167d7f9a 100644
--- a/frontend/styles/document-theme.scss
+++ b/frontend/styles/document-theme.scss
@@ -2,7 +2,7 @@
max-width: 100%;
a {
- color: $primary-400;
+ color: $blue;
&:hover {
text-decoration: underline;
diff --git a/frontend/styles/main.scss b/frontend/styles/main.scss
index c3c65e47..83e9e043 100644
--- a/frontend/styles/main.scss
+++ b/frontend/styles/main.scss
@@ -51,15 +51,22 @@
font-weight: 600;
margin-right: 5px;
color: #fff;
+ gap: 5px;
+ margin-top: 5px;
&.primary {
- background: var(--primary-400);
+ background: $primary-400;
&:hover {
background: $primary-500;
}
}
+ &.secondary {
+ border: 1px solid $primary-400;
+ color: var(--font-color)
+ }
+
&.danger {
background: $red;
diff --git a/frontend/styles/theme.scss b/frontend/styles/theme.scss
index 5ae4670c..a2bee53a 100644
--- a/frontend/styles/theme.scss
+++ b/frontend/styles/theme.scss
@@ -4,12 +4,12 @@ a {
transition: color $transition-duration;
&:hover {
- color: $primary-400;
+ color: $primary-500;
}
}
blockquote {
- border-left: 4px solid var(--primary-color);
+ border-left: 4px solid $primary-400;
padding: 0 15px;
> :first-child {
@@ -23,13 +23,13 @@ blockquote {
button {
padding: 8px 16px;
- background-color: var(--primary-color);
border: none;
border-radius: 6px;
color: var(--font-color);
cursor: pointer;
transition: transform $transition-duration;
width: fit-content;
+ background: transparent;
&:hover {
background-color: var(--bg-contrast-2);
@@ -133,6 +133,11 @@ textarea {
}
}
+input {
+ display: block;
+ width: 100%;
+}
+
label {
display: block;
margin-bottom: 0.5rem;