Phase 1 MVP - Complete implementation

- Login with JWT and refresh token rotation
- Dashboard with projects cards
- ProjectView with TreeView navigation
- DocumentView with markdown editor and auto-save
- Tag management (create, assign, remove)
- Dark mode CSS variables
- Security fixes applied (logout to backend, createDocument endpoint)
This commit is contained in:
Motoko
2026-03-30 15:17:29 +00:00
commit c9cb07dbfc
1341 changed files with 1084068 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
<script setup lang="ts">
interface Props {
variant?: 'primary' | 'secondary' | 'danger' | 'ghost'
size?: 'sm' | 'md' | 'lg'
disabled?: boolean
loading?: boolean
type?: 'button' | 'submit' | 'reset'
}
withDefaults(defineProps<Props>(), {
variant: 'primary',
size: 'md',
disabled: false,
loading: false,
type: 'button'
})
</script>
<template>
<button
:type="type"
:disabled="disabled || loading"
:class="['btn', `btn--${variant}`, `btn--${size}`]"
>
<span v-if="loading" class="btn__spinner"></span>
<slot />
</button>
</template>
<style scoped>
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
border: none;
border-radius: 6px;
font-family: inherit;
font-weight: 500;
cursor: pointer;
transition: all 0.15s ease;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Variants */
.btn--primary {
background: var(--accent);
color: white;
}
.btn--primary:hover:not(:disabled) {
background: var(--accent-hover);
}
.btn--secondary {
background: var(--bg-tertiary);
color: var(--text-primary);
}
.btn--secondary:hover:not(:disabled) {
background: var(--border);
}
.btn--danger {
background: #ef4444;
color: white;
}
.btn--danger:hover:not(:disabled) {
background: #dc2626;
}
.btn--ghost {
background: transparent;
color: var(--text-secondary);
}
.btn--ghost:hover:not(:disabled) {
background: var(--bg-tertiary);
color: var(--text-primary);
}
/* Sizes */
.btn--sm {
padding: 0.375rem 0.75rem;
font-size: 0.875rem;
}
.btn--md {
padding: 0.5rem 1rem;
font-size: 0.9375rem;
}
.btn--lg {
padding: 0.75rem 1.5rem;
font-size: 1rem;
}
.btn__spinner {
width: 1em;
height: 1em;
border: 2px solid transparent;
border-top-color: currentColor;
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>

View File

@@ -0,0 +1,154 @@
<script setup lang="ts">
import { watch, onUnmounted } from 'vue'
interface Props {
show: boolean
title?: string
size?: 'sm' | 'md' | 'lg'
}
withDefaults(defineProps<Props>(), {
size: 'md'
})
const emit = defineEmits<{
close: []
}>()
function handleBackdropClick(e: MouseEvent) {
if ((e.target as HTMLElement).classList.contains('modal')) {
emit('close')
}
}
function handleEscape(e: KeyboardEvent) {
if (e.key === 'Escape') {
emit('close')
}
}
watch(() => emit, () => {}, { immediate: true })
onUnmounted(() => {
document.removeEventListener('keydown', handleEscape)
})
</script>
<template>
<Teleport to="body">
<Transition name="modal">
<div v-if="show" class="modal" @click="handleBackdropClick">
<div :class="['modal__content', `modal__content--${size}`]">
<div v-if="title" class="modal__header">
<h2 class="modal__title">{{ title }}</h2>
<button class="modal__close" @click="emit('close')">×</button>
</div>
<div class="modal__body">
<slot />
</div>
<div v-if="$slots.footer" class="modal__footer">
<slot name="footer" />
</div>
</div>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.modal {
position: fixed;
inset: 0;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(4px);
}
.modal__content {
background: var(--bg-primary);
border-radius: 12px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
max-height: 90vh;
overflow: auto;
}
.modal__content--sm {
width: 90%;
max-width: 400px;
}
.modal__content--md {
width: 90%;
max-width: 560px;
}
.modal__content--lg {
width: 90%;
max-width: 800px;
}
.modal__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
border-bottom: 1px solid var(--border);
}
.modal__title {
margin: 0;
font-size: 1.125rem;
font-weight: 600;
color: var(--text-primary);
}
.modal__close {
background: none;
border: none;
font-size: 1.5rem;
color: var(--text-secondary);
cursor: pointer;
padding: 0;
line-height: 1;
}
.modal__close:hover {
color: var(--text-primary);
}
.modal__body {
padding: 1.5rem;
}
.modal__footer {
display: flex;
justify-content: flex-end;
gap: 0.75rem;
padding: 1rem 1.5rem;
border-top: 1px solid var(--border);
}
/* Transitions */
.modal-enter-active,
.modal-leave-active {
transition: opacity 0.2s ease;
}
.modal-enter-active .modal__content,
.modal-leave-active .modal__content {
transition: transform 0.2s ease;
}
.modal-enter-from,
.modal-leave-to {
opacity: 0;
}
.modal-enter-from .modal__content,
.modal-leave-to .modal__content {
transform: scale(0.95);
}
</style>

View File

@@ -0,0 +1,260 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
const router = useRouter()
const authStore = useAuthStore()
const searchQuery = ref('')
const showUserMenu = ref(false)
function handleSearch() {
if (searchQuery.value.trim()) {
router.push({ name: 'dashboard', query: { q: searchQuery.value } })
}
}
function logout() {
authStore.logout()
router.push('/login')
}
</script>
<template>
<header class="header">
<div class="header__left">
<router-link to="/dashboard" class="header__logo">
<svg width="28" height="28" viewBox="0 0 28 28" fill="none">
<rect width="28" height="28" rx="6" fill="var(--accent)"/>
<path d="M8 10h12M8 14h8M8 18h10" stroke="white" stroke-width="2" stroke-linecap="round"/>
</svg>
<span class="header__title">Claudia Docs</span>
</router-link>
</div>
<div class="header__center">
<form class="header__search" @submit.prevent="handleSearch">
<svg class="header__search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<path d="m21 21-4.35-4.35"/>
</svg>
<input
v-model="searchQuery"
type="text"
placeholder="Search documents..."
class="header__search-input"
/>
<kbd class="header__kbd">K</kbd>
</form>
</div>
<div class="header__right">
<div class="header__user" @click="showUserMenu = !showUserMenu">
<div class="header__avatar">
{{ authStore.user?.username?.charAt(0).toUpperCase() || 'U' }}
</div>
<span class="header__username">{{ authStore.user?.username || 'User' }}</span>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="m6 9 6 6 6-6"/>
</svg>
<Transition name="fade">
<div v-if="showUserMenu" class="header__dropdown">
<div class="header__dropdown-item header__dropdown-item--info">
<span>{{ authStore.user?.username }}</span>
<small>{{ authStore.user?.role }}</small>
</div>
<hr class="header__dropdown-divider" />
<button class="header__dropdown-item" @click="logout">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
<polyline points="16 17 21 12 16 7"/>
<line x1="21" y1="12" x2="9" y2="12"/>
</svg>
Logout
</button>
</div>
</Transition>
</div>
</div>
</header>
</template>
<style scoped>
.header {
display: flex;
align-items: center;
justify-content: space-between;
height: 56px;
padding: 0 1.5rem;
background: var(--bg-primary);
border-bottom: 1px solid var(--border);
}
.header__left {
flex: 1;
}
.header__logo {
display: flex;
align-items: center;
gap: 0.75rem;
text-decoration: none;
}
.header__title {
font-size: 1.125rem;
font-weight: 600;
color: var(--text-primary);
}
.header__center {
flex: 2;
max-width: 480px;
}
.header__search {
position: relative;
display: flex;
align-items: center;
}
.header__search-icon {
position: absolute;
left: 0.75rem;
color: var(--text-secondary);
}
.header__search-input {
width: 100%;
padding: 0.5rem 4rem 0.5rem 2.25rem;
background: var(--bg-secondary);
border: 1px solid var(--border);
border-radius: 8px;
font-size: 0.875rem;
color: var(--text-primary);
outline: none;
transition: border-color 0.15s, box-shadow 0.15s;
}
.header__search-input::placeholder {
color: var(--text-secondary);
}
.header__search-input:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.header__kbd {
position: absolute;
right: 0.75rem;
padding: 0.125rem 0.375rem;
background: var(--bg-tertiary);
border: 1px solid var(--border);
border-radius: 4px;
font-size: 0.75rem;
color: var(--text-secondary);
}
.header__right {
flex: 1;
display: flex;
justify-content: flex-end;
}
.header__user {
position: relative;
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.375rem 0.75rem 0.375rem 0.375rem;
border-radius: 8px;
cursor: pointer;
transition: background 0.15s;
}
.header__user:hover {
background: var(--bg-secondary);
}
.header__avatar {
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
background: var(--accent);
border-radius: 6px;
color: white;
font-weight: 600;
font-size: 0.875rem;
}
.header__username {
font-size: 0.875rem;
color: var(--text-primary);
}
.header__dropdown {
position: absolute;
top: 100%;
right: 0;
margin-top: 0.5rem;
min-width: 180px;
background: var(--bg-primary);
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
overflow: hidden;
z-index: 100;
}
.header__dropdown-item {
display: flex;
align-items: center;
gap: 0.5rem;
width: 100%;
padding: 0.75rem 1rem;
background: none;
border: none;
font-size: 0.875rem;
color: var(--text-primary);
cursor: pointer;
text-align: left;
text-decoration: none;
}
.header__dropdown-item:hover {
background: var(--bg-secondary);
}
.header__dropdown-item--info {
flex-direction: column;
align-items: flex-start;
gap: 0.125rem;
}
.header__dropdown-item--info small {
color: var(--text-secondary);
font-size: 0.75rem;
}
.header__dropdown-divider {
margin: 0.25rem 0;
border: none;
border-top: 1px solid var(--border);
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.15s, transform 0.15s;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
transform: translateY(-4px);
}
</style>

View File

@@ -0,0 +1,175 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useProjectsStore } from '@/stores/projects'
import TreeView from './TreeView.vue'
import Button from '@/components/common/Button.vue'
const router = useRouter()
const projectsStore = useProjectsStore()
const emit = defineEmits<{
'create-folder': []
'create-document': []
}>()
function handleNodeClick(node: { id: string; type: string }) {
if (node.type === 'document') {
router.push(`/documents/${node.id}`)
}
}
function goToDashboard() {
router.push('/dashboard')
}
</script>
<template>
<aside class="sidebar">
<div class="sidebar__header">
<button class="sidebar__back" @click="goToDashboard">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="m15 18-6-6 6-6"/>
</svg>
All Projects
</button>
</div>
<div v-if="projectsStore.currentProject" class="sidebar__content">
<div class="sidebar__project">
<h2 class="sidebar__project-name">{{ projectsStore.currentProject.name }}</h2>
<p v-if="projectsStore.currentProject.description" class="sidebar__project-desc">
{{ projectsStore.currentProject.description }}
</p>
</div>
<div class="sidebar__actions">
<Button size="sm" variant="ghost" @click="emit('create-folder')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
<line x1="12" y1="11" x2="12" y2="17"/>
<line x1="9" y1="14" x2="15" y2="14"/>
</svg>
New Folder
</Button>
<Button size="sm" variant="ghost" @click="emit('create-document')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="12" y1="11" x2="12" y2="17"/>
<line x1="9" y1="14" x2="15" y2="14"/>
</svg>
New Doc
</Button>
</div>
<div class="sidebar__tree">
<TreeView
:nodes="projectsStore.treeNodes"
@node-click="handleNodeClick"
/>
</div>
</div>
<div v-else class="sidebar__empty">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
</svg>
<p>Select a project to view its contents</p>
</div>
</aside>
</template>
<style scoped>
.sidebar {
width: 280px;
min-width: 280px;
height: 100%;
background: var(--bg-secondary);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow: hidden;
}
.sidebar__header {
padding: 1rem;
border-bottom: 1px solid var(--border);
}
.sidebar__back {
display: flex;
align-items: center;
gap: 0.5rem;
width: 100%;
padding: 0.5rem;
background: none;
border: none;
border-radius: 6px;
font-size: 0.875rem;
color: var(--text-secondary);
cursor: pointer;
text-align: left;
transition: all 0.15s;
}
.sidebar__back:hover {
background: var(--bg-tertiary);
color: var(--text-primary);
}
.sidebar__content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.sidebar__project {
padding: 1rem;
border-bottom: 1px solid var(--border);
}
.sidebar__project-name {
margin: 0;
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
}
.sidebar__project-desc {
margin: 0.25rem 0 0;
font-size: 0.8125rem;
color: var(--text-secondary);
line-height: 1.4;
}
.sidebar__actions {
display: flex;
gap: 0.5rem;
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--border);
}
.sidebar__tree {
flex: 1;
overflow-y: auto;
padding: 0.5rem;
}
.sidebar__empty {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
padding: 2rem;
color: var(--text-secondary);
text-align: center;
}
.sidebar__empty p {
margin: 0;
font-size: 0.875rem;
}
</style>

View File

@@ -0,0 +1,169 @@
<script setup lang="ts">
import { ref, watch } from 'vue'
import type { TreeNode } from '@/types'
interface Props {
nodes: TreeNode[]
}
const props = defineProps<Props>()
const emit = defineEmits<{
'node-click': [node: TreeNode]
}>()
const expandedFolders = ref<Set<string>>(new Set())
// Auto-expand first level
watch(() => props.nodes, (newNodes) => {
newNodes.forEach(node => {
if (node.type === 'folder') {
expandedFolders.value.add(node.id)
}
})
}, { immediate: true })
function toggleFolder(node: TreeNode, event: Event) {
event.stopPropagation()
if (expandedFolders.value.has(node.id)) {
expandedFolders.value.delete(node.id)
} else {
expandedFolders.value.add(node.id)
}
}
function handleClick(node: TreeNode) {
emit('node-click', node)
}
</script>
<template>
<ul class="tree">
<li v-for="node in nodes" :key="node.id" class="tree__item">
<div
:class="['tree__node', { 'tree__node--folder': node.type === 'folder' }]"
@click="handleClick(node)"
>
<button
v-if="node.type === 'folder'"
class="tree__toggle"
@click="toggleFolder(node, $event)"
>
<svg
:class="['tree__arrow', { 'tree__arrow--expanded': expandedFolders.has(node.id) }]"
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<path d="m9 18 6-6-6-6"/>
</svg>
</button>
<span v-else class="tree__icon">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
</span>
<span class="tree__label">{{ node.name }}</span>
</div>
<Transition name="expand">
<TreeView
v-if="node.type === 'folder' && expandedFolders.has(node.id) && node.children?.length"
:nodes="node.children"
class="tree__children"
@node-click="emit('node-click', $event)"
/>
</Transition>
</li>
</ul>
</template>
<style scoped>
.tree {
list-style: none;
margin: 0;
padding: 0;
}
.tree__item {
margin: 2px 0;
}
.tree__node {
display: flex;
align-items: center;
gap: 0.375rem;
padding: 0.375rem 0.5rem;
border-radius: 6px;
cursor: pointer;
transition: background 0.1s;
}
.tree__node:hover {
background: var(--bg-tertiary);
}
.tree__toggle {
display: flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
padding: 0;
background: none;
border: none;
color: var(--text-secondary);
cursor: pointer;
}
.tree__icon {
display: flex;
align-items: center;
justify-content: center;
width: 18px;
color: var(--text-secondary);
}
.tree__arrow {
transition: transform 0.15s;
}
.tree__arrow--expanded {
transform: rotate(90deg);
}
.tree__label {
flex: 1;
font-size: 0.875rem;
color: var(--text-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.tree__children {
margin-left: 1rem;
}
.expand-enter-active,
.expand-leave-active {
transition: all 0.2s ease;
overflow: hidden;
}
.expand-enter-from,
.expand-leave-to {
opacity: 0;
max-height: 0;
}
.expand-enter-to,
.expand-leave-from {
max-height: 500px;
}
</style>