Initial habit tracker project
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<section class="auth-panel">
|
||||
<h1>Anmelden</h1>
|
||||
<form method="post" action="index.php?route=login" class="form">
|
||||
<?= csrf_field() ?>
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" name="email" type="email" autocomplete="email" required>
|
||||
|
||||
<label for="password">Passwort</label>
|
||||
<input id="password" name="password" type="password" autocomplete="current-password" required>
|
||||
|
||||
<button type="submit">Einloggen</button>
|
||||
</form>
|
||||
<p>Noch kein Konto? <a href="index.php?route=register">Jetzt registrieren</a></p>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<section class="auth-panel">
|
||||
<h1>Registrieren</h1>
|
||||
<form method="post" action="index.php?route=register" class="form">
|
||||
<?= csrf_field() ?>
|
||||
<label for="name">Name</label>
|
||||
<input id="name" name="name" type="text" autocomplete="name" required>
|
||||
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" name="email" type="email" autocomplete="email" required>
|
||||
|
||||
<label for="password">Passwort</label>
|
||||
<input id="password" name="password" type="password" minlength="8" autocomplete="new-password" required>
|
||||
<small>Mindestens 8 Zeichen.</small>
|
||||
|
||||
<button type="submit">Konto erstellen</button>
|
||||
</form>
|
||||
<p>Schon registriert? <a href="index.php?route=login">Zum Login</a></p>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<section class="dashboard-head">
|
||||
<div>
|
||||
<p class="eyebrow">Heute</p>
|
||||
<h1>Deine Habits</h1>
|
||||
</div>
|
||||
<a class="button" href="index.php?route=habits/create">Habit erstellen</a>
|
||||
</section>
|
||||
|
||||
<form method="get" action="index.php" class="filters">
|
||||
<input type="hidden" name="route" value="dashboard">
|
||||
|
||||
<label for="category_id">Kategorie</label>
|
||||
<select id="category_id" name="category_id">
|
||||
<option value="">Alle Kategorien</option>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<option value="<?= (int) $category['id'] ?>" <?= (string) $filters['category_id'] === (string) $category['id'] ? 'selected' : '' ?>>
|
||||
<?= e($category['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<label for="status">Status</label>
|
||||
<select id="status" name="status">
|
||||
<option value="">Alle</option>
|
||||
<option value="open" <?= $filters['status'] === 'open' ? 'selected' : '' ?>>Offen</option>
|
||||
<option value="done" <?= $filters['status'] === 'done' ? 'selected' : '' ?>>Erledigt</option>
|
||||
</select>
|
||||
|
||||
<button type="submit">Filtern</button>
|
||||
</form>
|
||||
|
||||
<?php if (empty($habits)): ?>
|
||||
<p class="empty">Noch keine Habits gefunden. Erstelle deinen ersten Habit.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="habit-list">
|
||||
<?php foreach ($habits as $habit): ?>
|
||||
<article class="habit-card <?= $habit['done_today'] ? 'done' : '' ?>">
|
||||
<div class="habit-main">
|
||||
<span class="category-dot" style="background-color: <?= e($habit['category_color'] ?? '#9ca3af') ?>"></span>
|
||||
<div>
|
||||
<h2><?= e($habit['title']) ?></h2>
|
||||
<p><?= e($habit['description']) ?></p>
|
||||
<small>
|
||||
<?= e($habit['category_name'] ?? 'Ohne Kategorie') ?> |
|
||||
Ziel: <?= (int) $habit['target_per_week'] ?>x pro Woche
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="habit-actions">
|
||||
<form method="post" action="index.php?route=habits/toggle">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= (int) $habit['id'] ?>">
|
||||
<button type="submit"><?= $habit['done_today'] ? 'Heute erledigt' : 'Abhaken' ?></button>
|
||||
</form>
|
||||
<a href="index.php?route=habits/edit&id=<?= (int) $habit['id'] ?>">Bearbeiten</a>
|
||||
<form method="post" action="index.php?route=habits/delete" onsubmit="return confirm('Diesen Habit wirklich loeschen?');">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= (int) $habit['id'] ?>">
|
||||
<button class="danger" type="submit">Loeschen</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php $isEdit = !empty($habit['id']); ?>
|
||||
|
||||
<section class="form-panel">
|
||||
<h1><?= $isEdit ? 'Habit bearbeiten' : 'Habit erstellen' ?></h1>
|
||||
|
||||
<form method="post" action="index.php?route=<?= $isEdit ? 'habits/update' : 'habits/store' ?>" class="form">
|
||||
<?= csrf_field() ?>
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?= (int) $habit['id'] ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<label for="title">Name des Habits</label>
|
||||
<input
|
||||
id="title"
|
||||
name="title"
|
||||
type="text"
|
||||
class="<?= !empty($errors['title']) ? 'input-error' : '' ?>"
|
||||
value="<?= e($habit['title'] ?? '') ?>"
|
||||
required
|
||||
aria-describedby="title-error"
|
||||
>
|
||||
<?php if (!empty($errors['title'])): ?>
|
||||
<small id="title-error" class="field-error"><?= e($errors['title']) ?></small>
|
||||
<?php endif; ?>
|
||||
|
||||
<label for="description">Beschreibung <span>optional</span></label>
|
||||
<textarea id="description" name="description" rows="4"><?= e($habit['description'] ?? '') ?></textarea>
|
||||
|
||||
<label for="category_id">Kategorie</label>
|
||||
<select id="category_id" name="category_id">
|
||||
<option value="">Keine Kategorie</option>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<option value="<?= (int) $category['id'] ?>" <?= (string) ($habit['category_id'] ?? '') === (string) $category['id'] ? 'selected' : '' ?>>
|
||||
<?= e($category['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<label for="target_per_week">Ziel pro Woche</label>
|
||||
<input
|
||||
id="target_per_week"
|
||||
name="target_per_week"
|
||||
type="number"
|
||||
class="<?= !empty($errors['target_per_week']) ? 'input-error' : '' ?>"
|
||||
min="1"
|
||||
max="7"
|
||||
value="<?= e((string) ($habit['target_per_week'] ?? '3')) ?>"
|
||||
required
|
||||
aria-describedby="target-error"
|
||||
>
|
||||
<?php if (!empty($errors['target_per_week'])): ?>
|
||||
<small id="target-error" class="field-error"><?= e($errors['target_per_week']) ?></small>
|
||||
<?php endif; ?>
|
||||
|
||||
<button type="submit"><?= $isEdit ? 'Speichern' : 'Erstellen' ?></button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?= e(config('app_name')) ?></title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<a class="brand" href="index.php?route=dashboard">Habit Tracker</a>
|
||||
<nav class="nav">
|
||||
<?php if (current_user_id()): ?>
|
||||
<a href="index.php?route=dashboard">Dashboard</a>
|
||||
<a href="index.php?route=habits/create">Neuer Habit</a>
|
||||
<form method="post" action="index.php?route=logout" class="logout-form">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit" class="link-button">Logout</button>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<a href="index.php?route=login">Login</a>
|
||||
<a href="index.php?route=register">Registrieren</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="page">
|
||||
<?php if ($message = flash('success')): ?>
|
||||
<p class="notice success"><?= e($message) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($message = flash('error')): ?>
|
||||
<p class="notice error"><?= e($message) ?></p>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user