Initial habit tracker project

This commit is contained in:
2026-07-10 16:18:31 +02:00
commit 23416ee382
20 changed files with 1157 additions and 0 deletions
+275
View File
@@ -0,0 +1,275 @@
:root {
--bg: #f6f7f9;
--panel: #ffffff;
--text: #172033;
--muted: #657086;
--line: #d9dee8;
--primary: #176b5b;
--primary-dark: #0f4c40;
--danger: #b42318;
--success-bg: #e8f5ee;
--error-bg: #fdecec;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: Arial, Helvetica, sans-serif;
line-height: 1.5;
}
a {
color: var(--primary);
text-decoration-thickness: 2px;
}
.topbar {
align-items: center;
background: var(--panel);
border-bottom: 1px solid var(--line);
display: flex;
justify-content: space-between;
min-height: 64px;
padding: 0 32px;
}
.brand {
color: var(--text);
font-size: 20px;
font-weight: 700;
text-decoration: none;
}
.nav {
display: flex;
gap: 18px;
}
.logout-form {
margin: 0;
}
.link-button {
background: transparent;
color: var(--primary);
min-height: 0;
padding: 0;
text-decoration: underline;
text-decoration-thickness: 2px;
}
.link-button:hover {
background: transparent;
color: var(--primary-dark);
}
.page {
margin: 0 auto;
max-width: 1080px;
padding: 32px 24px;
}
.notice,
.empty,
.auth-panel,
.form-panel {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
padding: 20px;
}
.notice.success {
background: var(--success-bg);
}
.notice.error {
background: var(--error-bg);
color: var(--danger);
}
.auth-panel,
.form-panel {
max-width: 520px;
}
.dashboard-head {
align-items: center;
display: flex;
justify-content: space-between;
margin-bottom: 24px;
}
.eyebrow {
color: var(--muted);
font-size: 14px;
font-weight: 700;
margin: 0 0 4px;
text-transform: uppercase;
}
h1,
h2 {
line-height: 1.2;
margin: 0;
}
h1 {
font-size: 34px;
}
h2 {
font-size: 20px;
}
.button,
button {
background: var(--primary);
border: 0;
border-radius: 6px;
color: #ffffff;
cursor: pointer;
display: inline-block;
font: inherit;
font-weight: 700;
min-height: 44px;
padding: 10px 16px;
text-decoration: none;
}
button:hover,
.button:hover {
background: var(--primary-dark);
}
button.danger {
background: var(--danger);
}
.form,
.filters {
display: grid;
gap: 10px;
}
.form label,
.filters label {
font-weight: 700;
}
.form label span {
color: var(--muted);
font-weight: 400;
}
input,
select,
textarea {
border: 1px solid var(--line);
border-radius: 6px;
font: inherit;
min-height: 44px;
padding: 10px 12px;
width: 100%;
}
textarea {
resize: vertical;
}
.field-error {
color: var(--danger);
font-weight: 700;
}
input.input-error {
border-color: var(--danger);
}
.filters {
align-items: end;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
grid-template-columns: 1fr 1fr auto;
margin-bottom: 20px;
padding: 16px;
}
.habit-list {
display: grid;
gap: 14px;
}
.habit-card {
align-items: center;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
display: flex;
gap: 18px;
justify-content: space-between;
padding: 18px;
}
.habit-card.done {
border-color: var(--primary);
}
.habit-main {
display: flex;
gap: 14px;
}
.habit-main p {
color: var(--muted);
margin: 8px 0;
}
.category-dot {
border-radius: 999px;
flex: 0 0 14px;
height: 14px;
margin-top: 5px;
width: 14px;
}
.habit-actions {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: flex-end;
}
@media (max-width: 720px) {
.topbar,
.dashboard-head,
.habit-card {
align-items: stretch;
flex-direction: column;
}
.topbar {
gap: 12px;
padding: 16px 20px;
}
.nav {
flex-wrap: wrap;
}
.filters {
grid-template-columns: 1fr;
}
.habit-actions {
justify-content: flex-start;
}
}
+50
View File
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
session_set_cookie_params([
'httponly' => true,
'samesite' => 'Lax',
'secure' => !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off',
]);
session_start();
require __DIR__ . '/../app/helpers.php';
require __DIR__ . '/../app/Core/Database.php';
require __DIR__ . '/../app/Core/View.php';
require __DIR__ . '/../app/Models/User.php';
require __DIR__ . '/../app/Models/Category.php';
require __DIR__ . '/../app/Models/Habit.php';
require __DIR__ . '/../app/Controllers/AuthController.php';
require __DIR__ . '/../app/Controllers/HabitController.php';
$route = $_GET['route'] ?? 'dashboard';
$method = $_SERVER['REQUEST_METHOD'];
$routes = [
'GET' => [
'login' => [AuthController::class, 'showLogin'],
'register' => [AuthController::class, 'showRegister'],
'dashboard' => [HabitController::class, 'dashboard'],
'habits/create' => [HabitController::class, 'create'],
'habits/edit' => [HabitController::class, 'edit'],
],
'POST' => [
'login' => [AuthController::class, 'login'],
'register' => [AuthController::class, 'register'],
'logout' => [AuthController::class, 'logout'],
'habits/store' => [HabitController::class, 'store'],
'habits/update' => [HabitController::class, 'update'],
'habits/delete' => [HabitController::class, 'delete'],
'habits/toggle' => [HabitController::class, 'toggle'],
],
];
if (!isset($routes[$method][$route])) {
http_response_code(404);
echo 'Seite nicht gefunden.';
exit;
}
[$controllerClass, $action] = $routes[$method][$route];
(new $controllerClass())->$action();