Files
clawd/dashboard/habits.html

268 lines
8.4 KiB
HTML

<!DOCTYPE html>
<html lang="ro">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="/echo/favicon.svg">
<title>Echo · Habits</title>
<link rel="stylesheet" href="/echo/common.css">
<script src="https://unpkg.com/lucide@latest/dist/umd/lucide.min.js"></script>
<script src="/echo/swipe-nav.js"></script>
<style>
.main {
max-width: 1400px;
margin: 0 auto;
padding: var(--space-5);
}
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: var(--space-6);
flex-wrap: wrap;
gap: var(--space-4);
}
.page-title {
font-size: var(--text-xl);
font-weight: 600;
color: var(--text-primary);
}
/* Habits grid */
.habits-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: var(--space-4);
}
@media (max-width: 768px) {
.habits-grid {
grid-template-columns: 1fr;
}
}
@media (min-width: 769px) and (max-width: 1200px) {
.habits-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1201px) {
.habits-grid {
grid-template-columns: repeat(3, 1fr);
}
}
/* Empty state */
.empty-state {
text-align: center;
padding: var(--space-10);
color: var(--text-muted);
}
.empty-state svg {
width: 64px;
height: 64px;
margin-bottom: var(--space-4);
opacity: 0.5;
}
.empty-state p {
font-size: var(--text-lg);
margin-bottom: var(--space-2);
}
.empty-state .hint {
font-size: var(--text-sm);
opacity: 0.7;
}
/* Habit card (placeholder for next story) */
.habit-card {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: var(--space-4);
transition: all var(--transition-base);
}
.habit-card:hover {
border-color: var(--accent);
transform: translateY(-2px);
box-shadow: var(--shadow-md);
}
.habit-name {
font-size: var(--text-base);
font-weight: 600;
color: var(--text-primary);
margin-bottom: var(--space-2);
}
.habit-meta {
font-size: var(--text-sm);
color: var(--text-muted);
}
</style>
</head>
<body>
<header class="header">
<a href="/echo/index.html" class="logo">
<i data-lucide="circle-dot"></i>
Echo
</a>
<nav class="nav">
<a href="/echo/index.html" class="nav-item">
<i data-lucide="layout-dashboard"></i>
<span>Dashboard</span>
</a>
<a href="/echo/workspace.html" class="nav-item">
<i data-lucide="code"></i>
<span>Workspace</span>
</a>
<a href="/echo/notes.html" class="nav-item">
<i data-lucide="file-text"></i>
<span>KB</span>
</a>
<a href="/echo/habits.html" class="nav-item active">
<i data-lucide="dumbbell"></i>
<span>Habits</span>
</a>
<a href="/echo/files.html" class="nav-item">
<i data-lucide="folder"></i>
<span>Files</span>
</a>
<button class="theme-toggle" onclick="toggleTheme()" title="Schimbă tema">
<i data-lucide="sun" id="themeIcon"></i>
</button>
</nav>
</header>
<main class="main">
<div class="page-header">
<h1 class="page-title">Habits</h1>
<button class="btn btn-primary" onclick="showAddHabitModal()">
<i data-lucide="plus"></i>
Add Habit
</button>
</div>
<div id="habitsContainer">
<div class="empty-state">
<i data-lucide="loader"></i>
<p>Loading habits...</p>
</div>
</div>
</main>
<script>
// Theme management
function initTheme() {
const saved = localStorage.getItem('theme') || 'dark';
document.documentElement.setAttribute('data-theme', saved);
updateThemeIcon(saved);
}
function toggleTheme() {
const current = document.documentElement.getAttribute('data-theme') || 'dark';
const next = current === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', next);
localStorage.setItem('theme', next);
updateThemeIcon(next);
}
function updateThemeIcon(theme) {
const icon = document.getElementById('themeIcon');
if (icon) {
icon.setAttribute('data-lucide', theme === 'dark' ? 'sun' : 'moon');
lucide.createIcons();
}
}
initTheme();
// Habits state
let habits = [];
// Load habits from API
async function loadHabits() {
try {
const response = await fetch('/echo/api/habits');
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
habits = await response.json();
renderHabits();
} catch (error) {
console.error('Failed to load habits:', error);
showError('Failed to load habits: ' + error.message);
}
}
// Render habits grid
function renderHabits() {
const container = document.getElementById('habitsContainer');
if (habits.length === 0) {
container.innerHTML = `
<div class="empty-state">
<i data-lucide="dumbbell"></i>
<p>No habits yet. Create your first habit!</p>
<p class="hint">Click "Add Habit" to get started</p>
</div>
`;
lucide.createIcons();
return;
}
const habitsHtml = habits.map(habit => renderHabitCard(habit)).join('');
container.innerHTML = `<div class="habits-grid">${habitsHtml}</div>`;
lucide.createIcons();
}
// Render single habit card (placeholder - full card in next story)
function renderHabitCard(habit) {
return `
<div class="habit-card">
<div class="habit-name">${escapeHtml(habit.name)}</div>
<div class="habit-meta">
Frequency: ${habit.frequency.type}
${habit.category ? ` · ${habit.category}` : ''}
</div>
</div>
`;
}
// Show add habit modal (placeholder - full modal in next stories)
function showAddHabitModal() {
alert('Add Habit modal - coming in next story!');
}
// Show error message
function showError(message) {
const container = document.getElementById('habitsContainer');
container.innerHTML = `
<div class="empty-state">
<i data-lucide="alert-circle"></i>
<p style="color: var(--error)">${escapeHtml(message)}</p>
</div>
`;
lucide.createIcons();
}
// Escape HTML to prevent XSS
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Initialize page
lucide.createIcons();
loadHabits();
</script>
</body>
</html>