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.

New material design (WIP)

Smaug6739d5a90194befa
diff --git a/frontend/App.vue b/frontend/App.vue
index 702a3fae..355add03 100644
--- a/frontend/App.vue
+++ b/frontend/App.vue
@@ -5,3 +5,8 @@
<Notification />
</div>
</template>
+
+<script setup lang="ts">
+const color = usePreferences().get('primaryColor');
+setAppColor(Number(color));
+</script>
diff --git a/frontend/components/AppButton.vue b/frontend/components/AppButton.vue
index c82f1d75..fb268fcc 100644
--- a/frontend/components/AppButton.vue
+++ b/frontend/components/AppButton.vue
@@ -24,14 +24,14 @@ button {
}
}
.primary {
- background: $primary-color;
+ background: var(--primary);
color: white;
&:hover {
background: $primary-dark;
}
}
.secondary {
- outline: 1px solid $primary-color;
+ outline: 1px solid var(--primary);
color: var(--font-color);
&:hover {
box-shadow: 0 2px 10px var(--shadow);
@@ -46,12 +46,11 @@ button {
}
.link {
background: none;
- color: $primary-color;
+ color: var(--primary);
&:hover {
text-decoration: underline;
}
cursor: pointer;
- font-size: 1.1em;
}
.danger {
background: $red;
diff --git a/frontend/components/AppColorPicker.vue b/frontend/components/AppColorPicker.vue
index feb0efad..fbe5a07e 100644
--- a/frontend/components/AppColorPicker.vue
+++ b/frontend/components/AppColorPicker.vue
@@ -29,9 +29,9 @@ function selectColor(color: number) {
flex-wrap: wrap;
gap: 8px;
padding: 6px;
- border-radius: 8px;
+ border-radius: 6px;
border: 1px solid var(--border-color);
- background: var(--background-soft);
+ background: var(--bg-contrast-2);
}
.color-option {
diff --git a/frontend/components/AppDrop.vue b/frontend/components/AppDrop.vue
new file mode 100644
index 00000000..daf38d2d
--- /dev/null
+++ b/frontend/components/AppDrop.vue
@@ -0,0 +1,88 @@
+<template>
+ <div class="dropzone" :class="{ 'drag-over': isDragOver }" @dragover.prevent @drop.prevent="handleFileDrop" @dragenter.prevent="dragEnter" @dragleave.prevent="dragLeave">
+ <input type="file" ref="fileInput" @change="handleFileSelect" />
+ <div v-if="selectedFile" class="file-info">
+ <span>{{ selectedFile.name }}</span>
+ <div class="file-size">{{ readableFileSize(selectedFile.size) }}</div>
+ </div>
+ <div v-else>Drop file here or <span class="clickable" @click="triggerFileSelect">click to select from computer</span>.</div>
+ </div>
+</template>
+<script setup lang="ts">
+const selectedFile: Ref<File | null | undefined> = ref(null);
+const isDragOver = ref(false);
+const fileInput: Ref<HTMLInputElement | null> = ref(null);
+const triggerFileSelect = () => fileInput.value!.click();
+const handleFileSelect = (event: Event) => {
+ emit('select', (event.target as HTMLInputElement | null)?.files?.[0] || null);
+ selectedFile.value = (event.target as HTMLInputElement | null)?.files?.[0] || null;
+};
+const emit = defineEmits(['select']);
+const handleFileDrop = (event: DragEvent) => {
+ if (event.dataTransfer?.files && event.dataTransfer.files.length > 0) {
+ selectedFile.value = event.dataTransfer.files[0];
+ emit('select', event.dataTransfer.files[0]);
+ isDragOver.value = false;
+ }
+};
+const dragEnter = () => (isDragOver.value = true);
+const dragLeave = () => (isDragOver.value = false);
+
+const reset = () => {
+ selectedFile.value = null;
+ if (fileInput.value) fileInput.value.value = '';
+};
+
+defineExpose({ reset });
+</script>
+
+<style scoped lang="scss">
+.dropzone {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ height: 150px;
+ border: 2px dashed var(--border-color);
+ border-radius: 4px;
+ font-size: 14px;
+ color: var(--font-color-light);
+ position: relative;
+ transition: background-color $transition-duration;
+ background-color: var(--dropzone-bg, transparent);
+
+ &:hover {
+ background-color: var(--bg-contrast);
+ }
+
+ input[type='file'] {
+ display: none;
+ }
+}
+
+.drag-over {
+ background-color: var(--bg-contrast);
+ border-color: var(--primary);
+ transition: background-color $transition-duration, border-color $transition-duration;
+}
+
+.file-info {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ color: var(--primary);
+ color: var(--primary);
+
+ .file-size {
+ font-size: 0.8rem;
+ color: var(--font-color-dark);
+ margin-top: 5px;
+ }
+}
+
+.clickable {
+ color: var(--primary);
+ cursor: pointer;
+ text-decoration: underline;
+}
+</style>
diff --git a/frontend/components/AppHint.vue b/frontend/components/AppHint.vue
index d8423e90..1514f4e8 100644
--- a/frontend/components/AppHint.vue
+++ b/frontend/components/AppHint.vue
@@ -22,7 +22,7 @@ const show = ref(false);
.hint-icon {
width: 1rem;
height: 1rem;
- background-color: $primary-color;
+ background-color: var(--primary);
color: white;
font-weight: bold;
border-radius: 50%;
diff --git a/frontend/components/AppSelect.vue b/frontend/components/AppSelect.vue
index 531822cb..6516e4cf 100644
--- a/frontend/components/AppSelect.vue
+++ b/frontend/components/AppSelect.vue
@@ -112,7 +112,6 @@ button,
width: 100%;
padding: 8px;
border: 1px solid var(--border-color);
- background: var(--bg-color);
text-align: left;
border-radius: 8px;
font-size: 15px;
diff --git a/frontend/components/AppSelectNode.vue b/frontend/components/AppSelectNode.vue
index 98c49bcb..2fc6477b 100644
--- a/frontend/components/AppSelectNode.vue
+++ b/frontend/components/AppSelectNode.vue
@@ -36,7 +36,7 @@ function select() {
}
.tree-node:hover {
- background-color: var(--bg-contrast-2);
+ background-color: var(--selection-color);
}
ul,
li {
diff --git a/frontend/components/AppToggle.vue b/frontend/components/AppToggle.vue
index 3d242234..1e70db3b 100644
--- a/frontend/components/AppToggle.vue
+++ b/frontend/components/AppToggle.vue
@@ -42,13 +42,13 @@ const toggle = () => {
}
&.active {
- background: rgba($primary-color, 0.9); // léger fond coloré
- border-color: $primary-color;
+ background: var(--primary-border);
+ border-color: var(--primary);
.circle {
transform: translateX(20px);
background: #fff; // cercle toujours blanc
- border-color: $primary-color;
+ border-color: var(--primary);
}
}
}
diff --git a/frontend/components/BackToTop.vue b/frontend/components/BackToTop.vue
index db2f8555..3226337b 100644
--- a/frontend/components/BackToTop.vue
+++ b/frontend/components/BackToTop.vue
@@ -24,7 +24,7 @@ onUnmounted(() => window.removeEventListener('scroll', onScroll));
right: 2.5rem;
width: 2rem;
height: 1.2rem;
- background-color: $primary-color;
+ background-color: var(--primary);
-webkit-mask: url('/svg/back-to-top.svg') no-repeat;
mask: url('/svg/back-to-top.svg') no-repeat;
z-index: 100;
diff --git a/frontend/components/DataTable.vue b/frontend/components/DataTable.vue
index 14de7b20..3fc901d9 100644
--- a/frontend/components/DataTable.vue
+++ b/frontend/components/DataTable.vue
@@ -56,7 +56,7 @@
<script lang="ts" setup>
import { Paginator } from '../helpers/paginator';
const props = defineProps<{ headers: Header[]; rows: Field[] }>();
-const itemsPerPage = ref(parseInt(usePreferencesStore().get('datatableItemsCount')) || 10);
+const itemsPerPage = ref(parseInt(usePreferences().get('datatableItemsCount')) || 10);
const searchInput = ref('');
const paginator = new Paginator<Field>(
diff --git a/frontend/components/DocumentCard.vue b/frontend/components/DocumentCard.vue
index 747fdb04..baa46735 100644
--- a/frontend/components/DocumentCard.vue
+++ b/frontend/components/DocumentCard.vue
@@ -1,13 +1,13 @@
<template>
<div class="document-card">
<header>
- <Icon :name="category(document.category)?.icon || 'files'" :class="`category-icon ${getAppColor(category(document.category)?.color as number) || 'red'}`" />
+ <Icon :name="category(document.category)?.icon || 'files'" :class="`category-icon ${getAppColor(category(document.category)?.color as number) || 'primary'}`" />
<NuxtLink :to="`/dashboard/docs/${document.id}`" :class="`document-title`" :style="`color: var(--${getAppColor(category(document.category)?.color as number)})`">{{ document.name }}</NuxtLink>
</header>
<div class="tags" v-if="document.tags">
- <tag v-for="tag in document.tags.split(',')" :key="tag" class="blue">{{ tag.trim() }}</tag>
+ <tag v-for="tag in document.tags.split(',')" :key="tag" class="primary">{{ tag.trim() }}</tag>
</div>
- <p class="description">{{ document.description }}</p>
+ <p class="description" v-text="document.description"></p>
<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)">
@@ -38,12 +38,12 @@ function formatDate(timestamp: number): string {
<style scoped lang="scss">
.document-card {
border-radius: 12px;
- border: 1px solid var(--border-color-accent);
+ border: 1px solid var(--border-color);
box-shadow: 0 2px 10px var(--shadow);
overflow: hidden;
min-width: 340px;
max-width: 400px;
- height: 300px;
+ height: 400px;
display: flex;
flex-direction: column;
justify-content: space-between;
@@ -70,9 +70,9 @@ header {
}
.description {
- padding: 0 5px;
+ padding: 8px;
font-size: 16px;
- height: 120px;
+ height: 100%;
overflow: hidden;
margin: 0;
text-overflow: ellipsis;
diff --git a/frontend/components/Error.vue b/frontend/components/Error.vue
index c8dd80f5..77b31ca3 100644
--- a/frontend/components/Error.vue
+++ b/frontend/components/Error.vue
@@ -64,7 +64,7 @@ const handleError = computed(() => {
.error-button {
display: inline-block;
padding: 10px 20px;
- background-color: $primary-color;
+ background-color: var(--primary);
color: white;
text-decoration: none;
border-radius: 5px;
diff --git a/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue
index 5d7d98ab..3cd59d4b 100644
--- a/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -1,10 +1,7 @@
<template>
<div class="card-component" style="height: 100%">
- <header>
- <h1>Markdown editor</h1>
- </header>
<div class="editor-container">
- <Toolbar :document="document" @execute-action="exec" />
+ <Toolbar :document="document" @execute-action="exec" :minimal="minimal" />
<div style="padding: 6px 12px; flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 8px">
<input placeholder="Title" class="title" v-model="document.name" v-if="!minimal" />
<input placeholder="Description" class="description" v-model="document.description" v-if="!minimal" />
@@ -281,7 +278,7 @@ function save() {
.editor-container {
width: 100%;
- height: 100%; /* ou 100% si le parent a déjà une hauteur définie */
+ height: 100%;
display: flex;
flex-direction: column;
}
diff --git a/frontend/components/MarkdownEditor/Toolbar.vue b/frontend/components/MarkdownEditor/Toolbar.vue
index 898e457e..4b984c96 100644
--- a/frontend/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/components/MarkdownEditor/Toolbar.vue
@@ -1,8 +1,8 @@
<template>
<div class="toolbar">
<button v-for="item in toolbar" :key="item.name" v-html="item.icon" @click="emitAction(item.action)" :title="item.name"></button>
- <AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Access" size="100px" />
- <AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="220px" />
+ <AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Access" size="100px" v-if="!minimal" />
+ <AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="220px" v-if="!minimal" />
<input type="text" v-model="document.tags" placeholder="Tags" style="margin-right: 5px" />
<AppHint text="Tags separated with a comma" />
</div>
@@ -96,6 +96,18 @@ const toolbar = [
</script>
<style scoped lang="scss">
+.toolbar {
+ user-select: none;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ background-color: var(--bg-contrast-2);
+ border-radius: 25px;
+ border: 1px solid var(--border-color);
+ padding: 0.25rem;
+ color: var(--font-color-dark);
+ gap: 0 2.5px;
+}
button {
padding: 4px;
margin: 0;
@@ -106,29 +118,14 @@ button {
justify-content: center;
transition: background-color 0.2s;
&:hover {
- background-color: var(--blue-bg);
+ background-color: var(--primary-bg);
&:deep(svg) {
transition: fill 0.2s;
- fill: var(--blue);
+ fill: var(--primary);
}
}
}
-.toolbar {
- user-select: none;
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- background-color: var(--bg-contrast-2);
- border-radius: 25px;
- border: 1px solid var(--border-color);
- padding: 0.25rem;
- color: var(--font-color-dark);
- & > * {
- margin: 0 2.5px;
- }
-}
-
svg,
.toolbar:deep(svg) {
fill: var(--font-color-dark);
diff --git a/frontend/components/Sidebar/Dock.vue b/frontend/components/Sidebar/Dock.vue
index cbb3784b..073d4c6e 100644
--- a/frontend/components/Sidebar/Dock.vue
+++ b/frontend/components/Sidebar/Dock.vue
@@ -12,9 +12,7 @@
<NuxtLink to="/dashboard/cdn">
<Icon name="cdn" fill="var(--font-color)" :big="true" />
</NuxtLink>
- <NuxtLink to="/dashboard/settings">
- <Icon name="settings" fill="var(--font-color)" :big="true" />
- </NuxtLink>
+
<NuxtLink to="/dashboard/import">
<Icon name="import" fill="var(--font-color)" :big="true" />
</NuxtLink>
@@ -22,6 +20,9 @@
<Icon name="users" fill="var(--font-color)" :big="true" />
</NuxtLink>
<div style="margin-top: auto">
+ <NuxtLink to="/dashboard/settings">
+ <Icon name="settings" fill="var(--font-color)" :big="true" />
+ </NuxtLink>
<NuxtLink @click="closeDock">
<Icon name="arrow_close" fill="var(--font-color)" :big="true" />
</NuxtLink>
@@ -34,8 +35,7 @@
display: flex;
flex-direction: column;
padding: 1rem 0.3rem;
- border-right: 1px solid var(--border-color);
- gap: 8px;
+ gap: 10px;
background-color: var(--bg-contrast);
}
a {
@@ -54,7 +54,7 @@ a {
}
a.router-link-active {
- border-bottom: 2.5px solid $primary-color;
+ border-bottom: 2.5px solid var(--primary);
&:deep(svg) {
fill: var(--opposite-color);
}
@@ -63,6 +63,6 @@ a.router-link-active {
<script setup lang="ts">
function closeDock() {
- usePreferencesStore().set({ key: 'hideDock', value: false });
+ usePreferences().set({ key: 'hideDock', value: false });
}
</script>
diff --git a/frontend/components/Sidebar/Sidebar.vue b/frontend/components/Sidebar/Sidebar.vue
index 23b520aa..3ae5b3bd 100644
--- a/frontend/components/Sidebar/Sidebar.vue
+++ b/frontend/components/Sidebar/Sidebar.vue
@@ -48,7 +48,7 @@ import Dock from './Dock.vue';
const { isOpened, hasSidebar } = useSidebar();
const categoriesStore = useCategoriesStore();
-const preferences = usePreferencesStore();
+const preferences = usePreferences();
const userStore = useUserStore();
const filter = ref<string>('');
const showSearchModal = ref<boolean>(false);
@@ -70,7 +70,7 @@ const navigationItemsComputed = computed<Item[]>(() =>
})),
);
const sidebarTree = useSidebarTree();
-const toggleDock = () => preferences.set({ key: 'hideDock', value: !preferences.get('hideDock') });
+const toggleDock = () => preferences.set('hideDock', !preferences.get('hideDock'));
const filterItems = (items: Item[]): Item[] => {
if (!filter.value.trim()) return items;
const filterRecursive = (items: Item[]): Item[] => {
@@ -119,9 +119,10 @@ onBeforeUnmount(() => {
.sidebar {
max-height: 100%;
width: 100%;
- padding: 0.5rem 0.7rem;
+ padding: 0.5rem;
overflow-y: scroll;
font-family: Inter;
+ background-color: var(--bg-color);
* {
font-family: Inter;
}
@@ -172,7 +173,7 @@ onBeforeUnmount(() => {
width: 98%;
outline: none;
background-color: var(--bg-contrast);
- background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="%232573cf" height="24" viewBox="0 -960 960 960" width="22"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>');
+ background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="%236024ec" height="24" viewBox="0 -960 960 960" width="22"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>');
background-repeat: no-repeat;
background-position: 5px;
transition: background-color $transition-duration;
diff --git a/frontend/components/Sidebar/SidebarItem.vue b/frontend/components/Sidebar/SidebarItem.vue
index 25da5e33..e74b6093 100644
--- a/frontend/components/Sidebar/SidebarItem.vue
+++ b/frontend/components/Sidebar/SidebarItem.vue
@@ -107,9 +107,9 @@ const drop = async (event: DragEvent) => {
width: 20px;
height: 20px;
&:deep(svg) {
- fill: $primary-color;
+ fill: var(--primary);
path {
- fill: $primary-color;
+ fill: var(--primary);
}
}
}
@@ -123,7 +123,7 @@ const drop = async (event: DragEvent) => {
}
.drag-over {
- border-bottom: 2px solid $primary-color;
+ border-bottom: 2px solid var(--primary);
box-shadow: 0 2px 10px var(--shadow);
}
.nav {
diff --git a/frontend/components/ViewSelection.vue b/frontend/components/ViewSelection.vue
index ddf01fc5..b9abe963 100644
--- a/frontend/components/ViewSelection.vue
+++ b/frontend/components/ViewSelection.vue
@@ -35,7 +35,7 @@ watch(view, newView => localStorage.setItem('viewSelection', newView as 'table'
transition: background-color 0.3s;
&.active:deep(svg) {
transition: fill 0.1s;
- fill: $primary-color;
+ fill: var(--primary);
}
svg {
diff --git a/frontend/composables/Preferences.ts b/frontend/composables/Preferences.ts
new file mode 100644
index 00000000..10175419
--- /dev/null
+++ b/frontend/composables/Preferences.ts
@@ -0,0 +1,80 @@
+// composables/usePreferences.ts
+import { ref, computed, watch } from 'vue';
+
+export type PreferenceKey = 'printMode' | 'darkMode' | 'hideTOC' | 'compactMode' | 'hideSidebarRessources' | 'normalizeFileIcons' | 'datatableItemsCount' | 'hideDock' | 'primaryColor' | 'docSize' | 'sidebarCollapseItems';
+
+export interface Preference {
+ key: PreferenceKey;
+ value: any;
+}
+
+const DEFAULT_PREFERENCES: Record<PreferenceKey, any> = {
+ printMode: false,
+ darkMode: false,
+ hideTOC: false,
+ compactMode: false,
+ hideSidebarRessources: false,
+ normalizeFileIcons: true,
+ datatableItemsCount: 10,
+ hideDock: false,
+ primaryColor: 0,
+ docSize: 1, // 0 = small, 1 = large
+ sidebarCollapseItems: [],
+};
+
+const preferences = ref<Preference[]>(loadPreferences());
+
+function loadPreferences(): Preference[] {
+ try {
+ const raw = JSON.parse(localStorage.getItem('preferences') || '[]') as Preference[];
+ const map = new Map(raw.map(p => [p.key, p.value]));
+
+ return (Object.keys(DEFAULT_PREFERENCES) as PreferenceKey[]).map(key => ({
+ key,
+ value: map.has(key) ? map.get(key) : DEFAULT_PREFERENCES[key],
+ }));
+ } catch {
+ return Object.entries(DEFAULT_PREFERENCES).map(([key, value]) => ({
+ key: key as PreferenceKey,
+ value,
+ }));
+ }
+}
+
+function savePreferences() {
+ localStorage.setItem('preferences', JSON.stringify(preferences.value));
+}
+
+watch(preferences, savePreferences, { deep: true });
+
+export function usePreferences() {
+ function get(key: PreferenceKey) {
+ const pref = preferences.value.find(p => p.key === key);
+ return pref ? pref.value : DEFAULT_PREFERENCES[key];
+ }
+
+ function set(key: PreferenceKey, value: any) {
+ const existing = preferences.value.find(p => p.key === key);
+ if (existing) {
+ existing.value = value;
+ } else {
+ preferences.value.push({ key, value });
+ }
+ }
+
+ function reset() {
+ preferences.value = Object.entries(DEFAULT_PREFERENCES).map(([key, value]) => ({
+ key: key as PreferenceKey,
+ value,
+ }));
+ }
+
+ const all = computed(() => preferences.value);
+
+ return {
+ get,
+ set,
+ reset,
+ all,
+ };
+}
diff --git a/frontend/composables/TreeStructure.ts b/frontend/composables/TreeStructure.ts
index be8fd533..84dde039 100644
--- a/frontend/composables/TreeStructure.ts
+++ b/frontend/composables/TreeStructure.ts
@@ -1,4 +1,4 @@
-import type { Document, Category, DB_Ressource, Ressource } from '~/stores';
+import type { Document, Category, Ressource } from '~/stores';
import type { DefaultItem } from '../components/Sidebar/helpers';
export interface ANode {
diff --git a/frontend/composables/useSidebarTree.ts b/frontend/composables/useSidebarTree.ts
index 6a2e1b08..4694db32 100644
--- a/frontend/composables/useSidebarTree.ts
+++ b/frontend/composables/useSidebarTree.ts
@@ -9,7 +9,7 @@ export function useSidebarTree() {
const categoriesStore = useCategoriesStore();
const documentsStore = useDocumentsStore();
const ressourcesStore = useRessourcesStore();
- const preferencesStore = usePreferencesStore();
+ const preferencesStore = usePreferences();
const { workspaceId } = useSidebar();
const categories = computed<Item[]>(() =>
diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts
index fe600f82..ed747a04 100644
--- a/frontend/composables/utils.ts
+++ b/frontend/composables/utils.ts
@@ -21,3 +21,26 @@ export const readableFileSize = (size: number): string => {
const i = Math.floor(Math.log(size) / Math.log(1024));
return `${(size / Math.pow(1024, i)).toFixed(2)} ${['B', 'kB', 'MB', 'GB', 'TB'][i]}`;
};
+
+export function debounce(fn: Function, wait: number) {
+ let timer: NodeJS.Timeout;
+ return function (...args: any[]) {
+ if (timer) {
+ clearTimeout(timer); // clear any pre-existing timer
+ }
+ // @ts-ignore
+ const context = this; // get the current context
+ timer = setTimeout(() => {
+ fn.apply(context, args); // call the function if time expires
+ }, wait);
+ };
+}
+
+export function setAppColor(color: string | number) {
+ if (typeof color === 'number') {
+ color = getAppColor(color);
+ }
+ document.documentElement.style.setProperty('--primary', `var(--${color})`);
+ document.documentElement.style.setProperty('--primary-bg', `var(--${color}-bg)`);
+ document.documentElement.style.setProperty('--primary-border', `var(--${color}-border)`);
+}
diff --git a/frontend/error.vue b/frontend/error.vue
index 2901b8d5..c3854043 100644
--- a/frontend/error.vue
+++ b/frontend/error.vue
@@ -62,7 +62,7 @@ const props = defineProps({
.error-button {
display: inline-block;
padding: 10px 20px;
- background-color: $primary-color;
+ background-color: var(--primary);
color: white;
text-decoration: none;
border-radius: 5px;
diff --git a/frontend/helpers/icons.ts b/frontend/helpers/icons.ts
index 08495452..29176645 100644
--- a/frontend/helpers/icons.ts
+++ b/frontend/helpers/icons.ts
@@ -19,6 +19,7 @@ const icons = {
files: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" ><path d="M360-600v440h280v-120q0-17 11.5-28.5T680-320h120v-280H360Zm220 220ZM280-160v-441q0-33 24-56t57-23h439q33 0 56.5 23.5T880-600v287q0 16-6 30.5T857-257L703-103q-11 11-25.5 17T647-80H360q-33 0-56.5-23.5T280-160ZM81-710q-6-33 13-59.5t52-32.5l434-77q32-6 58 13.5t34 51.5l7 31q5 20-6 32t-26 14q-15 2-28.5-5.5T600-770l-7-30-433 77 60 344q3 17-6 30.5T188-332q-17 3-30-6.5T142-365L81-710Z"/></svg>`,
file_parent: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path style="fill:var(--green);" d="M320-320h200v-200H320v200Zm0-280h480v-200H320v200Zm280 280h200v-200H600v200Zm-280 80q-33 0-56.5-23.5T240-320v-480q0-33 23.5-56.5T320-880h480q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H320ZM160-80q-33 0-56.5-23.5T80-160v-560h80v560h560v80H160Z"/></svg>`,
folder: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" style="fill:var(--yellow)"><path style="fill:var(--yellow)" d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640H447l-80-80H160v480l96-320h684L837-217q-8 26-29.5 41.5T760-160H160Zm84-80h516l72-240H316l-72 240Zm0 0 72-240-72 240Zm-84-400v-80 80Z"/></svg>`,
+ folder_s: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" ><path d="M160-160q-33 0-56.5-23.5T80-240v-400q0-33 23.5-56.5T160-720h240l80-80h320q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm73-280h207v-207L233-440Zm-73-40 160-160H160v160Zm0 120v120h640v-480H520v280q0 33-23.5 56.5T440-360H160Zm280-160Z"/></svg>`,
image: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path style="fill:var(--green);" d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"/></svg>`,
import: `<svg xmlns="http://www.w3.org/2000/svg"viewBox="0 -960 960 960" ><path d="M480-800 243-663l237 137 237-137-237-137ZM120-321v-318q0-22 10.5-40t29.5-29l280-161q10-5 19.5-8t20.5-3q11 0 21 3t19 8l280 161q19 11 29.5 29t10.5 40v119q0 17-11.5 28.5T800-480q-17 0-28.5-11.5T760-520v-76L519-457q-19 11-40 11t-40-11L200-596v274l220 128q9 5 14.5 14t5.5 20q0 23-20 34.5t-40 .5L160-252q-19-11-29.5-29T120-321ZM720 0q-83 0-141.5-58.5T520-200q0-83 58.5-141.5T720-400q83 0 141.5 58.5T920-200q0 83-58.5 141.5T720 0ZM480-491Zm220 335-58-58q-6-6-14-6t-14 6q-6 6-6 14t6 14l78 78q6 6 13 8.5t15 2.5q8 0 15-2.5t13-8.5l78-78q6-6 6-14t-6-14q-6-6-14-6t-14 6l-58 58v-144q0-8-6-14t-14-6q-8 0-14 6t-6 14v144Z"/></svg>`,
list: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M160-280q-17 0-28.5-11.5T120-320q0-17 11.5-28.5T160-360h480q17 0 28.5 11.5T680-320q0 17-11.5 28.5T640-280H160Zm80-160q-17 0-28.5-11.5T200-480q0-17 11.5-28.5T240-520h480q17 0 28.5 11.5T760-480q0 17-11.5 28.5T720-440H240Zm80-160q-17 0-28.5-11.5T280-640q0-17 11.5-28.5T320-680h480q17 0 28.5 11.5T840-640q0 17-11.5 28.5T800-600H320Z"/></svg>`,
diff --git a/frontend/pages/(public)/index.vue b/frontend/pages/(public)/index.vue
index e21f2862..e857980b 100644
--- a/frontend/pages/(public)/index.vue
+++ b/frontend/pages/(public)/index.vue
@@ -275,7 +275,7 @@ h3 {
}
.get-started {
- background: $primary-color;
+ background: var(--primary);
color: #fff;
}
diff --git a/frontend/pages/(public)/login.vue b/frontend/pages/(public)/login.vue
index 822cc1da..093085a3 100644
--- a/frontend/pages/(public)/login.vue
+++ b/frontend/pages/(public)/login.vue
@@ -98,7 +98,7 @@ h2 {
margin-bottom: 1rem;
text-align: right;
text-decoration: none;
- color: $primary-color;
+ color: var(--primary);
&:hover {
text-decoration: underline;
}
diff --git a/frontend/pages/(public)/signup.vue b/frontend/pages/(public)/signup.vue
index 4b608093..5f3a12f1 100644
--- a/frontend/pages/(public)/signup.vue
+++ b/frontend/pages/(public)/signup.vue
@@ -147,7 +147,7 @@ h2 {
margin-bottom: 1rem;
text-align: right;
text-decoration: none;
- color: $primary-color;
+ color: var(--primary);
&:hover {
text-decoration: underline;
}
diff --git a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
index a3ccdde3..991b11a2 100644
--- a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
+++ b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
@@ -1,18 +1,18 @@
<template>
<div class="modal">
- <h2>Create a new {{ role == 1 ? 'category' : 'workspace' }}</h2>
- <label>Name</label>
- <input type="text" v-model="category.name" required />
- <label>Icon <AppHint text="SVG supported" /></label>
- <input type="text" v-model="category.icon" id="icon" />
+ <h2>New {{ role == 1 ? 'category' : 'workspace' }}</h2>
+ <label for="name">Name</label>
+ <input class="entry" type="text" v-model="category.name" required id="name" placeholder="Display name" />
+ <label for="icon">Icon <AppHint text="SVG supported" /></label>
+ <input class="entry" type="text" v-model="category.icon" id="icon" />
<label for="color">Color</label>
- <AppColorPicker v-model:selectedColor="category.color" name="color" />
+ <AppColorPicker class="entry" v-model:selectedColor="category.color" id="color" />
<label>Parent</label>
<div>
- <AppSelect v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />
+ <AppSelect class="entry" v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />
</div>
- <label>Order <AppHint text="Order of the category in the sidebar" /></label>
- <input type="number" v-model.number="category.order" id="order" />
+ <label for="order">Order <AppHint text="Order of the category in the sidebar" /></label>
+ <input class="entry" type="number" v-model.number="category.order" id="order" placeholder="0" />
<div class="footer">
<AppButton @click="emit('close')" type="secondary">Cancel</AppButton>
<AppButton type="primary" @click="createCategory">Create</AppButton>
@@ -53,4 +53,7 @@ const createCategory = () => {
label {
margin: 5px 0;
}
+.entry {
+ background: var(--bg-contrast-2);
+}
</style>
diff --git a/frontend/pages/dashboard/cdn/[id]/index.vue b/frontend/pages/dashboard/cdn/[id]/index.vue
index fbec2299..f9a2c559 100644
--- a/frontend/pages/dashboard/cdn/[id]/index.vue
+++ b/frontend/pages/dashboard/cdn/[id]/index.vue
@@ -98,7 +98,7 @@ select {
min-width: 200px;
}
a {
- color: $primary-color;
+ color: var(--primary);
text-decoration: underline;
}
.preview {
diff --git a/frontend/pages/dashboard/cdn/index.vue b/frontend/pages/dashboard/cdn/index.vue
index 189cf66c..a1cdd4b4 100644
--- a/frontend/pages/dashboard/cdn/index.vue
+++ b/frontend/pages/dashboard/cdn/index.vue
@@ -4,14 +4,7 @@
<h1>File manager</h1>
<ViewSelection v-model="view" />
</header>
- <div class="dropzone" :class="{ 'drag-over': isDragOver }" @dragover.prevent @drop.prevent="handleFileDrop" @dragenter.prevent="dragEnter" @dragleave.prevent="dragLeave">
- <input type="file" ref="fileInput" @change="handleFileSelect" />
- <div v-if="selectedFile" class="file-info">
- <span>{{ selectedFile.name }}</span>
- <div class="file-size">{{ readableFileSize(selectedFile.size) }}</div>
- </div>
- <div v-else>Drop file here or <span class="clickable" @click="triggerFileSelect">click to select from computer</span>.</div>
- </div>
+ <AppDrop ref="dropComponent" @select="selectFile" />
<div style="padding: 12px 0; width: 100%; display: flex; align-items: center; gap: 10px; flex-direction: column">
<AppButton @click="submitFile" type="primary" :disabled="!selectedFile">Upload on server</AppButton>
<div v-if="isLoading" class="loading-spinner"></div>
@@ -35,37 +28,23 @@
<script setup lang="ts">
import DeleteRessourceModal from './_modals/DeleteRessourceModal.vue';
import type { DB_Ressource } from '~/stores';
-
+definePageMeta({ breadcrumb: 'Upload' });
const ressourcesStore = useRessourcesStore();
const view = ref<'table' | 'list'>('list');
-const selectedFile: Ref<File | null | undefined> = ref(null);
-const isDragOver = ref(false);
+const selectedFile: Ref<File | undefined> = ref();
const fileLink = ref('');
-const fileInput: Ref<HTMLInputElement | null> = ref(null);
const isLoading = ref(false);
-const triggerFileSelect = () => fileInput.value!.click();
-const handleFileSelect = (event: Event) => (selectedFile.value = (event.target as HTMLInputElement | null)?.files?.[0] || null);
-definePageMeta({ breadcrumb: 'Upload' });
-
-const handleFileDrop = (event: DragEvent) => {
- if (event.dataTransfer?.files && event.dataTransfer.files.length > 0) {
- selectedFile.value = event.dataTransfer.files[0];
- isDragOver.value = false;
- }
-};
-
+const selectFile = (file?: File) => (selectedFile.value = file);
const copyLink = () => navigator.clipboard.writeText(fileLink.value!);
-const dragEnter = () => (isDragOver.value = true);
-const dragLeave = () => (isDragOver.value = false);
-
+const dropComponent = ref();
const submitFile = async () => {
if (!selectedFile.value) return;
isLoading.value = true;
const body = new FormData();
body.append('file', selectedFile.value);
- selectedFile.value = null; // Reset selected file
-
+ selectedFile.value = undefined; // Reset selected file
+ dropComponent.value.reset(); // Reset drop component
await ressourcesStore
.post(body)
.then(r => (fileLink.value = `${CDN}/${(r as DB_Ressource).author_id}/${(r as DB_Ressource).transformed_path}`))
@@ -103,49 +82,6 @@ const deleteRessource = async (id: string) => {
</script>
<style scoped lang="scss">
-.dropzone {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 150px;
- border: 2px dashed var(--border-color);
- border-radius: 4px;
- font-size: 14px;
- color: var(--font-color-light);
- position: relative;
- transition: background-color $transition-duration;
- background-color: var(--dropzone-bg, transparent);
-
- &:hover {
- background-color: var(--bg-contrast);
- }
-
- input[type='file'] {
- display: none;
- }
-}
-
-.drag-over {
- background-color: var(--bg-contrast);
- border-color: #2196f3;
- transition: background-color $transition-duration, border-color $transition-duration;
-}
-
-.file-info {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #2196f3;
- color: #2196f3;
-
- .file-size {
- font-size: 0.8rem;
- color: var(--font-color-dark);
- margin-top: 5px;
- }
-}
-
.link-section {
margin: 6px 0;
display: flex;
@@ -157,19 +93,13 @@ const deleteRessource = async (id: string) => {
.loading-spinner {
border: 5px solid #f3f3f3;
- border-top: 5px solid $primary-color;
+ border-top: 5px solid var(--primary);
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
}
-.clickable {
- color: #2196f3;
- cursor: pointer;
- text-decoration: underline;
-}
-
.ressources-list {
width: 100%;
}
@@ -185,6 +115,6 @@ const deleteRessource = async (id: string) => {
}
.file-info {
- color: #2196f3;
+ color: var(--primary);
}
</style>
diff --git a/frontend/pages/dashboard/docs/[id].vue b/frontend/pages/dashboard/docs/[id].vue
index 6619ac5a..64fad8a7 100644
--- a/frontend/pages/dashboard/docs/[id].vue
+++ b/frontend/pages/dashboard/docs/[id].vue
@@ -1,13 +1,13 @@
<template>
<div v-if="article?.id" style="width: 100%; padding: 0 0.5rem">
<div style="display: flex; justify-content: space-between">
- <div style="width: 100%; max-width: 980px; margin: auto">
+ <div :style="{ width: '100%', margin: 'auto', maxWidth: usePreferences().get('docSize') == 0 ? '980px' : '780px' }">
<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>
<div v-if="!isTablet() && !preferencesStore.get('hideTOC')"><TableOfContent :tags="article.tags" :element="element" :doc_id="article.id" class="toc" style="width: 400px" /></div>
- <div v-else-if="!isTablet() && preferencesStore.get('hideTOC')" style="margin-right: 200px"></div>
+ <div :style="{ marginRight: !isTablet() && preferencesStore.get('hideTOC') && useSidebar().isOpened.value ? '370px' : '0px', transition: 'margin 0.3s' }"></div>
</div>
</div>
<Error v-else-if="error" :error="error" />
@@ -20,7 +20,7 @@ import DocumentCardHeader from './_components/DocumentCardHeader.vue';
import DocumentCardFooter from './_components/DocumentCardFooter.vue';
const route = useRoute();
const documentsStore = useDocumentsStore();
-const preferencesStore = usePreferencesStore();
+const preferencesStore = usePreferences();
const element = ref<HTMLElement>();
const article = ref<Document | undefined>();
diff --git a/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue b/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue
index 8b052359..f0a5537e 100644
--- a/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue
+++ b/frontend/pages/dashboard/docs/_components/DocumentCardFooter.vue
@@ -58,7 +58,7 @@ footer {
}
&:hover {
- border: 1px solid $primary-color;
+ border: 1px solid var(--primary);
}
}
diff --git a/frontend/pages/dashboard/docs/_components/DocumentCardHeader.vue b/frontend/pages/dashboard/docs/_components/DocumentCardHeader.vue
index 70f855e3..9c4cf140 100644
--- a/frontend/pages/dashboard/docs/_components/DocumentCardHeader.vue
+++ b/frontend/pages/dashboard/docs/_components/DocumentCardHeader.vue
@@ -8,7 +8,7 @@
<h1 class="title">{{ doc?.name }}</h1>
<p class="description">{{ doc?.description }}</p>
<div class="document-tags" v-if="doc.tags">
- <tag v-for="tag in doc.tags.split(',')" :key="tag" class="blue">{{ tag.trim() }}</tag>
+ <tag v-for="tag in doc.tags.split(',')" :key="tag" class="primary">{{ tag.trim() }}</tag>
</div>
</div>
<div class="icon">
@@ -22,7 +22,7 @@ import DocumentCardHeaderActionRow from './DocumentCardHeaderActionRow.vue';
import DocumentHeaderIllustration from './DocumentHeaderIllustration.vue';
import type { Document } from '~/stores';
const categories_store = useCategoriesStore();
-const preferences = usePreferencesStore();
+const preferences = usePreferences();
const props = defineProps<{ doc: Document }>();
const category = computed(() => categories_store.getById(props.doc?.category || ''));
</script>
diff --git a/frontend/pages/dashboard/docs/_components/table-of-content/NodeTree.vue b/frontend/pages/dashboard/docs/_components/table-of-content/NodeTree.vue
index a2223485..d0375650 100644
--- a/frontend/pages/dashboard/docs/_components/table-of-content/NodeTree.vue
+++ b/frontend/pages/dashboard/docs/_components/table-of-content/NodeTree.vue
@@ -25,7 +25,7 @@ a {
li {
list-style: none;
padding: 0;
- margin: 4px 0 0 0;
+ margin-top: 4px;
}
ul {
diff --git a/frontend/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue b/frontend/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue
index e5fdd3c4..fec9bcfe 100644
--- a/frontend/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue
+++ b/frontend/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue
@@ -2,10 +2,11 @@
<aside>
<h4 v-if="tags">Tags</h4>
<div style="display: flex; flex-wrap: wrap; font-size: 14px">
- <tag v-if="tags" v-for="tag in tags.split(',')" :key="tag" class="blue">#{{ tag.trim() }}</tag>
+ <tag v-if="tags" v-for="tag in tags.split(',')" :key="tag" class="primary">#{{ tag.trim() }}</tag>
</div>
- <ul ref="list">
- <h4>Table of content</h4>
+ <ul ref="list" style="position: relative">
+ <div class="marker" ref="marker"></div>
+ <h4>Table of contents</h4>
<NodeTree v-if="headers.length" v-for="header of headers_tree" :node="header" :key="header.link" />
<p v-else>Nothing to display</p>
</ul>
@@ -70,56 +71,67 @@ function buildTree(tree: GroupedHeaders[]): TreeItem[] {
const headers = computed(() => getHTMLHeaders());
const headers_tree = computed(() => buildTree(getHeaders(headers.value)));
-const observerCallback = (e: IntersectionObserverEntry[]) => {
- const actives: HTMLAnchorElement[] = [];
- e.forEach(entry => {
- const activeLink = list.value?.querySelector<HTMLAnchorElement>(`[href="#${entry.target.id}"]`);
- if (activeLink && entry.isIntersecting && entry.intersectionRatio === 1) {
- actives.push(activeLink);
- }
- if (activeLink) {
- activeLink.classList.remove('active');
+// On scroll, highlight the current header
+
+const marker = ref<HTMLElement>();
+
+function handleScroll() {
+ const scrollPosition = window.scrollY + window.innerHeight / 7;
+ let activeHeader: HTMLElement | null = null;
+
+ for (const header of headers.value.reverse()) {
+ if (header.offsetTop <= scrollPosition && header.offsetTop + header.offsetHeight > scrollPosition) {
+ activeHeader = header;
+ break;
}
- });
- const best = actives.reduce((prev, current) => {
- const prevRect = prev?.getBoundingClientRect();
- const currentRect = current.getBoundingClientRect();
- return prevRect?.top || 0 < currentRect.top ? prev : current;
- }, actives[0]);
- if (best) {
- best.classList.add('active');
}
-};
-const observer: IntersectionObserver = new IntersectionObserver(observerCallback, { root: null, threshold: 1 });
-watchEffect(() => headers.value.forEach(header => observer.observe(header)));
-onBeforeUnmount(() => observer.disconnect());
+ if (activeHeader) {
+ const link = `#${activeHeader.id}`;
+ const activeItem = list.value?.querySelector(`a[href="${link}"]`);
+ if (activeItem && marker.value) {
+ list.value?.querySelectorAll('a').forEach(item => item.classList.remove('active'));
+ const offsetTop = (activeItem as HTMLElement).offsetTop;
+ marker.value.style.top = `${offsetTop}px`;
+ activeItem.classList.add('active');
+ }
+ }
+}
+onMounted(() => window.addEventListener('scroll', handleScroll));
+onBeforeUnmount(() => window.removeEventListener('scroll', handleScroll));
</script>
<style lang="scss" scoped>
h4 {
color: var(--font-color-light);
- padding: 4px 0;
}
aside {
max-width: 350px;
position: sticky;
top: 20px;
+ left: 10px;
font-size: 0.75rem;
border-left: 1px solid var(--border-color);
padding-left: 10px;
}
-
+.marker {
+ position: absolute;
+ left: -8px;
+ top: 32px;
+ width: 3px;
+ height: 15px;
+ background-color: var(--primary);
+ border-radius: 2px;
+ transition: top 0.25s ease, height 0.25s ease;
+ z-index: 1;
+}
ul {
padding: 0;
margin: 0;
-
- li:deep(a) {
- &.active {
- color: $primary-dark;
- font-weight: 600;
- }
- }
+}
+li:deep(a).active {
+ color: var(--primary);
+ font-weight: 600;
}
</style>
diff --git a/frontend/pages/dashboard/import.vue b/frontend/pages/dashboard/import.vue
index ce03ab2e..c19155ea 100644
--- a/frontend/pages/dashboard/import.vue
+++ b/frontend/pages/dashboard/import.vue
@@ -2,16 +2,9 @@
<div class="card-component">
<header>
<h1 style="font-size: 20px">Import documents <tag class="yellow">Beta</tag></h1>
- <p>You can import documents from a previous export. If you don't have export, you can create a new one from the <NuxtLink to="/dashboard/settings?p=backup">settings</NuxtLink> page.</p>
</header>
- <div class="dropzone" :class="{ 'drag-over': isDragOver }" @dragover.prevent @drop.prevent="handleFileDrop" @dragenter.prevent="dragEnter" @dragleave.prevent="dragLeave">
- <input type="file" ref="fileInput" @change="handleFileSelect" />
- <div v-if="selectedFile" class="file-info">
- <span>{{ selectedFile.name }}</span>
- <div class="file-size">{{ readableFileSize(selectedFile.size) }}</div>
- </div>
- <div v-else>Drop file here or <span class="clickable" @click="triggerFileSelect">click to select from computer</span>.</div>
- </div>
+ <p>You can import documents from a previous export. If you don't have export, you can create a new one from the <NuxtLink to="/dashboard/settings?p=backup">settings</NuxtLink> page.</p>
+ <AppDrop ref="dropComponent" @select="handleFileSelect" />
<div class="submit">
<AppButton @click="submit" type="primary" :disabled="!selectedFile">Analyse file</AppButton>
</div>
@@ -39,32 +32,15 @@ import { analyseFile, validateFileStructure, compareDocumentsAndLocal, prepareNe
import type { DB_Document } from '~/stores';
definePageMeta({ breadcrumb: 'Importations' });
-const selectedFile: Ref<File | null | undefined> = ref(null);
-const isDragOver = ref(false);
-const fileInput: Ref<HTMLInputElement | null> = ref(null);
-const triggerFileSelect = () => fileInput.value!.click();
-const handleFileSelect = (event: Event) => (selectedFile.value = (event.target as HTMLInputElement | null)?.files?.[0] || null);
-
-const handleFileDrop = (event: DragEvent) => {
- if (event.dataTransfer?.files && event.dataTransfer.files.length > 0) {
- selectedFile.value = event.dataTransfer.files[0];
- isDragOver.value = false;
- }
-};
-
-const dragEnter = () => (isDragOver.value = true);
-const dragLeave = () => (isDragOver.value = false);
-const readableFileSize = (size: number): string => {
- const i = Math.floor(Math.log(size) / Math.log(1024));
- return `${(size / Math.pow(1024, i)).toFixed(2)} ${['B', 'kB', 'MB', 'GB', 'TB'][i]}`;
-};
+const selectedFile: Ref<File | undefined> = ref();
+const handleFileSelect = (file?: File) => (selectedFile.value = file);
+const dropComponent = ref();
const files_to_import = ref<DB_Document[]>([]);
async function submit() {
try {
if (!selectedFile.value) return;
- const file = selectedFile.value;
- const fileContent = await analyseFile(file);
+ const fileContent = await analyseFile(selectedFile.value);
const valid = validateFileStructure(fileContent);
if (!valid) useNotifications().add({ type: 'error', title: 'Invalid file structure' });
else useNotifications().add({ type: 'success', title: 'File structure is valid' });
@@ -72,7 +48,9 @@ async function submit() {
} catch (e) {
if (e instanceof Error) useNotifications().add({ type: 'error', title: 'Error while analysing file', message: e.message });
else useNotifications().add({ type: 'error', title: 'Error while analysing file', message: 'Unknown error' });
- selectedFile.value = null;
+ } finally {
+ dropComponent.value.reset(); // Reset drop component
+ selectedFile.value = undefined; // Reset selected file after processing
}
}
function importDoc(file: DB_Document) {
@@ -103,52 +81,10 @@ function importAllDocs() {
header {
padding-bottom: 16px;
a {
- color: $primary-color;
+ color: var(--primary);
}
}
-.dropzone {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 150px;
- border: 2px dashed #9e9e9e;
- border-radius: 4px;
- font-size: 14px;
- color: #9e9e9e;
- position: relative;
- transition: background-color $transition-duration;
- background-color: var(--dropzone-bg, transparent);
-
- &:hover {
- background-color: var(--bg-contrast);
- }
-
- input[type='file'] {
- display: none;
- }
-}
-
-.drag-over {
- background-color: #e3f2fd;
- border-color: #2196f3;
- transition: background-color $transition-duration, border-color $transition-duration;
-}
-
-.file-info {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #2196f3;
- color: #2196f3;
-
- .file-size {
- font-size: 0.8rem;
- color: #757575;
- margin-top: 5px;
- }
-}
.submit {
display: flex;
justify-content: center;
diff --git a/frontend/pages/dashboard/settings/_views/backups.vue b/frontend/pages/dashboard/settings/_views/backups.vue
index 6171b7dc..d658ab50 100644
--- a/frontend/pages/dashboard/settings/_views/backups.vue
+++ b/frontend/pages/dashboard/settings/_views/backups.vue
@@ -44,7 +44,7 @@ watchEffect(() => (currentPage.value = route.query.p || 'profile'));
}
.loading-spinner {
border: 5px solid #f3f3f3;
- border-top: 5px solid $primary-color;
+ border-top: 5px solid var(--primary);
border-radius: 50%;
width: 50px;
height: 50px;
diff --git a/frontend/pages/dashboard/settings/_views/preferences.vue b/frontend/pages/dashboard/settings/_views/preferences.vue
index d57d524f..dd9ff584 100644
--- a/frontend/pages/dashboard/settings/_views/preferences.vue
+++ b/frontend/pages/dashboard/settings/_views/preferences.vue
@@ -14,15 +14,16 @@
{{ choice.label }}
</option>
</select>
+ <AppColorPicker v-else-if="option.type === 'color'" :selectedColor="option.value" @update:selected-color="option.onChange" />
</div>
</div>
</template>
<script setup lang="ts">
const colorMode = useColorMode();
-const preferencesStore = usePreferencesStore();
+const preferencesStore = usePreferences();
-type OptionType = 'toggle' | 'select';
+type OptionType = 'toggle' | 'select' | 'color';
interface BaseOption {
label: string;
@@ -36,6 +37,12 @@ interface ToggleOption extends BaseOption {
onToggle?: () => void;
}
+interface ColorOption extends BaseOption {
+ type: 'color';
+ value: number;
+ onChange?: (value: number) => void;
+}
+
interface SelectOption extends BaseOption {
type: 'select';
value: number;
@@ -43,7 +50,7 @@ interface SelectOption extends BaseOption {
onChange?: (value: number) => void;
}
-type Option = ToggleOption | SelectOption;
+type Option = ToggleOption | SelectOption | ColorOption;
const options = ref<{ label: string; options: Option[] }[]>([
{
@@ -56,6 +63,16 @@ const options = ref<{ label: string; options: Option[] }[]>([
storageKey: 'darkMode',
onToggle: () => (colorMode.value === 'light' ? (colorMode.preference = 'dark') : (colorMode.preference = 'light')),
},
+ {
+ label: 'Choose primary color',
+ type: 'color',
+ value: Number(preferencesStore.get('primaryColor')),
+ storageKey: 'primaryColor',
+ onChange: (value: number) => {
+ setAppColor(value);
+ preferencesStore.set('primaryColor', value);
+ },
+ },
],
},
{
@@ -73,6 +90,16 @@ const options = ref<{ label: string; options: Option[] }[]>([
value: Boolean(preferencesStore.get('hideTOC')),
storageKey: 'hideTOC',
},
+ {
+ label: 'Document size',
+ type: 'select',
+ value: preferencesStore.get('docSize'),
+ storageKey: 'docSize',
+ choices: [
+ { label: 'Large', value: 0 },
+ { label: 'Minimal', value: 1 },
+ ],
+ },
],
},
{
@@ -110,7 +137,7 @@ const options = ref<{ label: string; options: Option[] }[]>([
{
label: 'Default datatable items count',
type: 'select',
- value: preferencesStore.get('datatableItemsCount') || 20,
+ value: preferencesStore.get('datatableItemsCount'),
storageKey: 'datatableItemsCount',
choices: [
{ label: '10', value: 10 },
@@ -126,12 +153,12 @@ const options = ref<{ label: string; options: Option[] }[]>([
const toggleOption = (option: ToggleOption) => {
option.value = !option.value;
- preferencesStore.set({ key: option.storageKey, value: option.value });
+ preferencesStore.set(option.storageKey, option.value);
option.onToggle?.();
};
const selectOption = (option: SelectOption) => {
- preferencesStore.set({ key: option.storageKey, value: option.value });
+ preferencesStore.set(option.storageKey, option.value);
option.onChange?.(option.value);
};
</script>
diff --git a/frontend/stores/preferences.store.ts b/frontend/stores/preferences.store.ts
index f286ceaf..25a0a25c 100644
--- a/frontend/stores/preferences.store.ts
+++ b/frontend/stores/preferences.store.ts
@@ -1,32 +1,76 @@
-/* Store to save user local preferences */
-/* Only local settings with localStorage but no db or requests */
-export type PreferenceKey = 'printMode' | 'darkMode' | 'hideTOC' | 'compactMode' | 'hideSidebarRessources' | 'normalizeFileIcons' | 'datatableItemsCount' | 'hideDock';
+/* types */
+export type PreferenceKey = 'printMode' | 'darkMode' | 'hideTOC' | 'compactMode' | 'hideSidebarRessources' | 'normalizeFileIcons' | 'datatableItemsCount' | 'hideDock' | 'primaryColor' | 'docSize';
+
export interface Preference {
key: PreferenceKey;
value: any;
}
+/* valeurs par défaut */
+const DEFAULT_PREFERENCES: Record<PreferenceKey, any> = {
+ printMode: false,
+ darkMode: false,
+ hideTOC: false,
+ compactMode: false,
+ hideSidebarRessources: false,
+ normalizeFileIcons: true,
+ datatableItemsCount: 10,
+ hideDock: false,
+ primaryColor: 1,
+ docSize: 1, // 0: minimal, 1: large
+};
+
+/* utils */
+function loadPreferences(): Preference[] {
+ try {
+ const raw = JSON.parse(localStorage.getItem('preferences') || '[]') as Preference[];
+ const map = new Map(raw.map(p => [p.key, p.value]));
+
+ // merge with default preferences
+ return (Object.keys(DEFAULT_PREFERENCES) as PreferenceKey[]).map(key => ({
+ key,
+ value: map.has(key) ? map.get(key) : DEFAULT_PREFERENCES[key],
+ }));
+ } catch (e) {
+ return Object.entries(DEFAULT_PREFERENCES).map(([key, value]) => ({
+ key: key as PreferenceKey,
+ value,
+ }));
+ }
+}
+
+function savePreferences(prefs: Preference[]) {
+ localStorage.setItem('preferences', JSON.stringify(prefs));
+}
+
+/* pinia store */
export const usePreferencesStore = defineStore('preferences', {
state: () => ({
- preferences: ref<Preference[]>(JSON.parse(localStorage.getItem('preferences') || '[]')),
+ preferences: ref<Preference[]>(loadPreferences()),
}),
getters: {
getAll: state => state.preferences,
get: state => (key: PreferenceKey) => {
const preference = state.preferences.find(p => p.key === key);
- return preference ? preference.value : null;
+ return preference ? preference.value : DEFAULT_PREFERENCES[key];
},
},
actions: {
- // Set a preference (or update if it already exists)
- set: function (preference: Preference) {
+ set(preference: Preference) {
const existing = this.preferences.find(p => p.key === preference.key);
if (existing) {
existing.value = preference.value;
} else {
this.preferences.push(preference);
}
- localStorage.setItem('preferences', JSON.stringify(this.preferences));
+ savePreferences(this.preferences);
+ },
+ reset() {
+ this.preferences = Object.entries(DEFAULT_PREFERENCES).map(([key, value]) => ({
+ key: key as PreferenceKey,
+ value,
+ }));
+ savePreferences(this.preferences);
},
},
});
diff --git a/frontend/styles/_variables.scss b/frontend/styles/_variables.scss
index 198cbdce..9c4384c1 100644
--- a/frontend/styles/_variables.scss
+++ b/frontend/styles/_variables.scss
@@ -28,12 +28,18 @@ $monospace-font: monospace;
$transition-duration: 0.3s;
-$primary-color: #007aff;
-$primary-light: color.adjust(#007aff, $lightness: 10%);
-$primary-dark: color.adjust(#007aff, $lightness: -10%);
+$primary-color: #6024ec;
+$primary-light: color.adjust(#6024ec, $lightness: 10%);
+$primary-dark: color.adjust(#6024ec, $lightness: -10%);
:root {
+
+
+ --primary: #6024ec;
+ --primary-bg: rgba(111, 66, 193, 0.2);
+ --primary-border: rgba(111, 66, 193, 0.25);
+
--bg-color: #fff;
--bg-contrast: #f2f7fc;
--bg-contrast-2: #e2ebfd;
@@ -65,7 +71,7 @@ $primary-dark: color.adjust(#007aff, $lightness: -10%);
--teal: #00ADB5;
--teal-bg: rgba(23, 162, 184, 0.2);
--teal-border: rgba(23, 162, 184, 0.25);
- --purple: #6f42c1;
+ --purple: #6024ec;
--purple-bg: rgba(111, 66, 193, 0.2);
--purple-border: rgba(111, 66, 193, 0.25);
--pink: #ff0e6a;
@@ -88,23 +94,36 @@ $primary-dark: color.adjust(#007aff, $lightness: -10%);
--shadow: rgba(0, 0, 0, 1);
// COLORS \\
- --grey: #e0e0e0;
- --grey-bg: rgb(47, 47, 47);
- --blue: #47a6ff;
- --blue-bg: rgb(0, 140, 216, 0.2);
- --blue-border: rgba(0, 140, 216, 0.25);
- --green: #009879;
- --green-bg: rgba(40, 167, 69, 0.15);
- --green-border: rgba(40, 167, 69, 0.3);
- --red: #DC3545;
- --red-bg: rgba(220, 53, 69, 0.15);
- --red-border: rgba(220, 53, 69, 0.3);
- --yellow: #F97300;
- --yellow-bg: rgba(255, 197, 23, 0.2);
- --yellow-border: rgba(255, 197, 23, .25);
- --teal: #00d6b4;
- --teal-bg: rgba(0, 255, 255, 0.2);
- --teal-border: rgba(0, 209, 178, .25);
+ --grey: #bbbbbb;
+ --grey-bg: #2c2c2c;
+
+ --blue: #339CFF;
+ --blue-bg: rgba(51, 156, 255, 0.12);
+ --blue-border: rgba(51, 156, 255, 0.25);
+
+ --green: #00c19a;
+ --green-bg: rgba(0, 193, 154, 0.12);
+ --green-border: rgba(0, 193, 154, 0.25);
+
+ --red: #ff4c5b;
+ --red-bg: rgba(255, 76, 91, 0.12);
+ --red-border: rgba(255, 76, 91, 0.25);
+
+ --yellow: #ffae00;
+ --yellow-bg: rgba(255, 174, 0, 0.12);
+ --yellow-border: rgba(255, 174, 0, 0.25);
+
+ --purple: #8e5fff;
+ --purple-bg: rgba(142, 95, 255, 0.12);
+ --purple-border: rgba(142, 95, 255, 0.25);
+
+ --teal: #1cd4d4;
+ --teal-bg: rgba(28, 212, 212, 0.12);
+ --teal-border: rgba(28, 212, 212, 0.25);
+
+ --pink: #ff4da6;
+ --pink-bg: rgba(255, 77, 166, 0.12);
+ --pink-border: rgba(255, 77, 166, 0.25);
}
diff --git a/frontend/styles/components.scss b/frontend/styles/components.scss
index cdd82819..b2cb2c60 100644
--- a/frontend/styles/components.scss
+++ b/frontend/styles/components.scss
@@ -17,11 +17,13 @@
border-radius: 8px;
box-shadow: 0 2px 10px var(--shadow);
- h1 {
- font-size: 20px;
- }
+
header {
+ h1 {
+ font-size: 20px;
+ }
+
display: flex;
justify-content: space-between;
align-items: center;
diff --git a/frontend/styles/document-theme.scss b/frontend/styles/document-theme.scss
index 610197fc..9a5c73a6 100644
--- a/frontend/styles/document-theme.scss
+++ b/frontend/styles/document-theme.scss
@@ -5,7 +5,7 @@
max-width: 100%;
a {
- color: $blue;
+ color: var(--primary);
&:hover {
text-decoration: underline;
diff --git a/frontend/styles/markdown.scss b/frontend/styles/markdown.scss
index e9cc8d3b..3ff6d67f 100644
--- a/frontend/styles/markdown.scss
+++ b/frontend/styles/markdown.scss
@@ -58,8 +58,6 @@
}
}
-
-
.blue {
color: var(--blue);
@@ -230,6 +228,20 @@
}
}
+.primary {
+ border-color: var(--primary-border);
+ color: var(--primary);
+ background-color: var(--primary-bg);
+
+ * {
+ fill: var(--primary) !important;
+
+ path {
+ fill: var(--primary) !important;
+ }
+ }
+}
+
.custom-block.details {
border-color: var(--blue-border);
diff --git a/frontend/styles/theme.scss b/frontend/styles/theme.scss
index aa5fb427..4c29dc65 100644
--- a/frontend/styles/theme.scss
+++ b/frontend/styles/theme.scss
@@ -10,7 +10,7 @@ a {
}
blockquote {
- border-left: 4px solid $primary-color;
+ border-left: 4px solid var(--primary);
padding: 0 15px;
> :first-child {