Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ Refer to `.env.example` for all variables. Key ones:
- State management: Next Context or Zustand (no Redux unless necessary).
- hls.js integration as per official docs.
- Keep components small and reusable.
- Styling: Tailwind with **semantic tokens** defined in `src/app/globals.css` and wired in `tailwind.config.ts` (`bg-surface`, `text-content`, `border-line`, `accent`…). Don't hardcode raw palette colors in components — use token utilities so both themes stay consistent.
- Dark theme: `next-themes` (`attribute="class"` on `<html>`), system preference by default, manual toggle in `src/components/ThemeToggle.tsx`. `color-scheme` flips per theme, so native controls follow.
- Shared UI primitives live in the component layer (`.surface`, `.btn`, `.input`, `.chip`, `.label`); reuse them instead of re-styling per page.

---

Expand Down
11 changes: 11 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"format:check": "prettier --check ."
},
"dependencies": {
"hls.js": "^1.5.7",
"next": "14.2.5",
"next-themes": "^0.4.6",
"react": "18.3.1",
"react-dom": "18.3.1",
"hls.js": "^1.5.7",
"zustand": "^4.5.2"
},
"devDependencies": {
Expand Down
110 changes: 109 additions & 1 deletion frontend/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,117 @@
@tailwind components;
@tailwind utilities;

/* ---------------------------------------------------------------------------
Design tokens — RGB channels so Tailwind opacity modifiers work.
Light is the default; `.dark` (set by next-themes on <html>) flips every
value, so a single class like `bg-surface` is correct in both themes.
--------------------------------------------------------------------------- */
:root {
color-scheme: light;

--bg: 247 247 248;
--surface: 255 255 255;
--surface-muted: 244 244 245;
--surface-hover: 244 244 245;
--fg: 24 24 27;
--fg-muted: 82 82 91;
--fg-subtle: 161 161 170;
--border: 228 228 231;
--accent: 239 68 68;
--accent-hover: 220 38 38;
--accent-text: 220 38 38;
--accent-soft: 254 226 226;
--accent-fg: 255 255 255;

--shadow-surface: 0 0 0 1px rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.06),
0 4px 12px -2px rgb(0 0 0 / 0.06);
--shadow-surface-hover: 0 0 0 1px rgb(0 0 0 / 0.07), 0 2px 4px -1px rgb(0 0 0 / 0.08),
0 12px 28px -8px rgb(0 0 0 / 0.14);
}

.dark {
color-scheme: dark;

--bg: 9 9 11;
--surface: 24 24 27;
--surface-muted: 39 39 42;
--surface-hover: 45 45 50;
--fg: 244 244 245;
--fg-muted: 161 161 170;
--fg-subtle: 113 113 122;
--border: 42 42 46;
--accent: 239 68 68;
--accent-hover: 248 113 113;
--accent-text: 248 113 113;
--accent-soft: 69 26 28;
--accent-fg: 255 255 255;

--shadow-surface: 0 0 0 1px rgb(255 255 255 / 0.06);
--shadow-surface-hover: 0 0 0 1px rgb(255 255 255 / 0.1), 0 12px 28px -8px rgb(0 0 0 / 0.6);
}

@layer base {
h1,
h2,
h3 {
text-wrap: balance;
}
p {
text-wrap: pretty;
}
/* Nice focus default for anything not using a component class. */
:focus-visible {
outline: 2px solid rgb(var(--accent) / 0.6);
outline-offset: 2px;
}
}

@layer components {
/* Elevated surface with a hairline ring baked into the shadow. */
.surface {
@apply rounded-2xl bg-surface shadow-surface transition-shadow duration-200;
}
.surface-hover:hover {
@apply shadow-surface-hover;
}

.label {
@apply mb-1.5 block text-sm font-medium text-content;
}

.input {
@apply w-full rounded-lg border border-line bg-surface px-3 py-2 text-sm text-content
placeholder:text-content-subtle transition-colors
focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/25;
}

.chip {
@apply inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-xs font-medium text-content-muted;
}

/* One button base; variants set the colour. Press feedback is 0.96 (skill). */
.btn {
@apply inline-flex select-none items-center justify-center gap-2 whitespace-nowrap rounded-lg px-3.5 py-2
text-sm font-medium transition-[background-color,border-color,color,box-shadow,transform]
duration-150 ease-out active:scale-[0.96]
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/45
focus-visible:ring-offset-2 focus-visible:ring-offset-bg
disabled:pointer-events-none disabled:opacity-50;
}
.btn-primary {
@apply bg-accent text-accent-fg shadow-[0_1px_2px_rgb(0_0_0/0.15)] hover:bg-accent-hover;
}
.btn-secondary {
@apply bg-surface text-content shadow-surface hover:shadow-surface-hover;
}
.btn-ghost {
@apply text-content-muted hover:bg-surface-muted hover:text-content;
}
.btn-danger {
@apply bg-red-600 text-white hover:bg-red-700;
}
}

body {
@apply bg-zinc-50 text-zinc-900 antialiased;
@apply bg-bg text-content antialiased;
}
29 changes: 22 additions & 7 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
import Header from "@/components/Header";
import ScrollToTop from "@/components/ScrollToTop";
import ThemeProvider from "@/components/ThemeProvider";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

const inter = Inter({
subsets: ["latin", "cyrillic"],
display: "swap",
variable: "--font-inter",
});

export const metadata: Metadata = {
title: "Flowix — Video Streaming",
description: "Open-source adaptive HLS platform",
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<Header />
<main className="mx-auto max-w-6xl px-4 py-6">{children}</main>
<footer className="mx-auto max-w-6xl px-4 py-8 text-center text-xs text-zinc-400">
Flowix — open-source HLS • gateway :8080
</footer>
<html lang="en" className={inter.variable} suppressHydrationWarning>
<body className="flex min-h-dvh flex-col">
<ThemeProvider>
<ScrollToTop />
<Header />
<main className="mx-auto w-full max-w-6xl flex-1 px-4 py-8">{children}</main>
<footer className="border-t border-line">
<div className="mx-auto flex max-w-6xl flex-col items-center gap-1 px-4 py-6 text-center text-xs text-content-subtle sm:flex-row sm:justify-between sm:text-left">
<span>Flowix — open-source adaptive HLS platform</span>
<span className="tabular-nums">gateway :8080 · nginx-vod :8081</span>
</div>
</footer>
</ThemeProvider>
</body>
</html>
);
Expand Down
69 changes: 56 additions & 13 deletions frontend/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function LoginPage() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [localError, setLocalError] = useState<string | null>(null);
const message = localError || error;

const onSubmit = async (e: React.FormEvent) => {
e.preventDefault();
Expand All @@ -23,19 +24,61 @@ export default function LoginPage() {
};

return (
<div className="mx-auto max-w-sm">
<h1 className="text-xl font-semibold">Login</h1>
<form onSubmit={onSubmit} className="mt-6 space-y-4">
<input value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Email" type="email" required className="w-full rounded border px-3 py-2 text-sm" />
<input value={password} onChange={(e) => setPassword(e.target.value)} placeholder="Password" type="password" required className="w-full rounded border px-3 py-2 text-sm" />
{(localError || error) && <div className="rounded bg-red-50 p-3 text-sm text-red-700">{localError || error}</div>}
<button disabled={loading} className="w-full rounded bg-black py-2 text-sm font-medium text-white hover:bg-zinc-800 disabled:opacity-50">
{loading ? "Loading…" : "Login"}
</button>
</form>
<p className="mt-4 text-center text-sm text-zinc-500">
No account? <Link href="/register" className="text-red-600 hover:underline">Register</Link>
</p>
<div className="mx-auto mt-6 w-full max-w-sm">
<div className="surface p-6 sm:p-8">
<h1 className="text-xl font-semibold tracking-tight text-content">Welcome back</h1>
<p className="mt-1 text-sm text-content-muted">Sign in to upload and manage your videos.</p>

<form onSubmit={onSubmit} className="mt-6 space-y-4">
<div>
<label htmlFor="email" className="label">
Email
</label>
<input
id="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="you@example.com"
type="email"
autoComplete="email"
required
className="input"
/>
</div>
<div>
<label htmlFor="password" className="label">
Password
</label>
<input
id="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="••••••••"
type="password"
autoComplete="current-password"
required
className="input"
/>
</div>

{message && (
<div className="rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-600 dark:text-red-300">
{message}
</div>
)}

<button disabled={loading} className="btn btn-primary w-full">
{loading ? "Loading…" : "Login"}
</button>
</form>

<p className="mt-6 text-center text-sm text-content-muted">
No account?{" "}
<Link href="/register" className="font-medium text-accent-text hover:underline">
Register
</Link>
</p>
</div>
</div>
);
}
Loading
Loading