Add board page, layout and styles

This commit is contained in:
Grok Bot
2026-11-26 09:10:37 +00:00
parent bfbc6e4407
commit 8be52a3647
3 changed files with 100 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
:root { font-family: system-ui, sans-serif; color: #1c2430; background: #f4f6f9; }
body { margin: 0; }
main { max-width: 1000px; margin: 2rem auto; padding: 0 1rem; }
header { display: flex; justify-content: space-between; align-items: center; }
.pill { font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; background: #ddd; }
.pill.up { background: #c8f0d0; } .pill.down { background: #f6c7c7; }
.add { display: flex; gap: .5rem; margin: 1rem 0; }
.add input { flex: 1; padding: .5rem; border: 1px solid #ccd; border-radius: 6px; font: inherit; }
button { padding: .4rem .8rem; border: 0; border-radius: 6px; background: #2d6cdf; color: #fff; cursor: pointer; font: inherit; }
button.secondary { background: #8a94a6; font-size: .75rem; padding: .25rem .5rem; }
button.danger { background: #c0392b; font-size: .75rem; padding: .25rem .5rem; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
section { background: #e9edf3; border-radius: 8px; padding: .75rem; min-height: 8rem; }
section h2 { font-size: 1rem; margin: 0 0 .5rem; } .count { color: #667; font-weight: 400; }
article { background: #fff; border-radius: 6px; padding: .6rem; margin-bottom: .5rem; box-shadow: 0 1px 2px #0001; display: flex; flex-direction: column; gap: .25rem; }
article small { color: #667; } .actions { display: flex; gap: .25rem; flex-wrap: wrap; }
.error { color: #c0392b; }
footer { margin-top: 2rem; font-size: .75rem; color: #778; text-align: center; word-break: break-all; }
@media (max-width: 700px) { .board { grid-template-columns: 1fr; } }
+12
View File
@@ -0,0 +1,12 @@
import type { ReactNode } from 'react';
import './globals.css';
export const metadata = { title: 'Taskboard', description: 'Next.js + PostgreSQL task board' };
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
+69
View File
@@ -0,0 +1,69 @@
import { addTask, removeTask, setStatus } from './actions';
import { dbHealth } from '@/lib/db';
import { buildInfo } from '@/lib/build-info';
import { listTasks, STATUSES, type Status } from '@/lib/tasks';
// Always render per request: the board is live data, and the footer shows the running build.
export const dynamic = 'force-dynamic';
const TITLES: Record<Status, string> = { todo: 'To do', doing: 'In progress', done: 'Done' };
const bootedAt = new Date().toISOString();
export default async function Home() {
const [tasks, health] = await Promise.all([listTasks().catch(() => null), dbHealth()]);
return (
<main>
<header>
<h1>Taskboard</h1>
<span className={`pill ${health.status}`}>DB {health.status}</span>
</header>
<form action={addTask} className="add">
<input name="title" placeholder="New task…" maxLength={200} required />
<input name="assignee" placeholder="Assignee (optional)" maxLength={80} />
<button type="submit">Add</button>
</form>
{tasks === null ? (
<p className="error">Could not load tasks. Check the database connection.</p>
) : (
<div className="board">
{STATUSES.map((s) => (
<section key={s}>
<h2>
{TITLES[s]} <span className="count">{tasks.filter((t) => t.status === s).length}</span>
</h2>
{tasks
.filter((t) => t.status === s)
.map((t) => (
<article key={t.id}>
<strong>{t.title}</strong>
{t.assignee && <small>@{t.assignee}</small>}
<div className="actions">
{STATUSES.filter((x) => x !== s).map((x) => (
<form action={setStatus} key={x}>
<input type="hidden" name="id" value={t.id} />
<input type="hidden" name="status" value={x} />
<button className="secondary">→ {TITLES[x]}</button>
</form>
))}
<form action={removeTask}>
<input type="hidden" name="id" value={t.id} />
<button className="danger" aria-label={`Delete ${t.title}`}>✕</button>
</form>
</div>
</article>
))}
</section>
))}
</div>
)}
<footer data-testid="build-info">
Build <b>v{buildInfo.version}</b> · commit <b>{buildInfo.commit ?? 'n/a'}</b> · source{' '}
<b>{buildInfo.sourceHash}</b> · built {buildInfo.builtAt} · server started {bootedAt}
</footer>
</main>
);
}