diff --git a/docs/spec.md b/docs/spec.md index fcc55fa..baaf240 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -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 ``), 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. --- diff --git a/frontend/package-lock.json b/frontend/package-lock.json index ce52067..202243c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "hls.js": "^1.5.7", "next": "14.2.5", + "next-themes": "^0.4.6", "react": "18.3.1", "react-dom": "18.3.1", "zustand": "^4.5.2" @@ -4137,6 +4138,16 @@ } } }, + "node_modules/next-themes": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.4.6.tgz", + "integrity": "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", diff --git a/frontend/package.json b/frontend/package.json index 78f0254..c296774 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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": { diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index a9a33d7..64403b6 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -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 ) 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; } diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index 8b27114..0a20712 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -1,7 +1,16 @@ 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", @@ -9,13 +18,19 @@ export const metadata: Metadata = { export default function RootLayout({ children }: { children: React.ReactNode }) { return ( - - -
-
{children}
- + + + + +
+
{children}
+
+
+ Flowix — open-source adaptive HLS platform + gateway :8080 · nginx-vod :8081 +
+
+ ); diff --git a/frontend/src/app/login/page.tsx b/frontend/src/app/login/page.tsx index 708d7a4..96b54a5 100644 --- a/frontend/src/app/login/page.tsx +++ b/frontend/src/app/login/page.tsx @@ -10,6 +10,7 @@ export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [localError, setLocalError] = useState(null); + const message = localError || error; const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -23,19 +24,61 @@ export default function LoginPage() { }; return ( -
-

Login

-
- setEmail(e.target.value)} placeholder="Email" type="email" required className="w-full rounded border px-3 py-2 text-sm" /> - setPassword(e.target.value)} placeholder="Password" type="password" required className="w-full rounded border px-3 py-2 text-sm" /> - {(localError || error) &&
{localError || error}
} - -
-

- No account? Register -

+
+
+

Welcome back

+

Sign in to upload and manage your videos.

+ +
+
+ + setEmail(e.target.value)} + placeholder="you@example.com" + type="email" + autoComplete="email" + required + className="input" + /> +
+
+ + setPassword(e.target.value)} + placeholder="••••••••" + type="password" + autoComplete="current-password" + required + className="input" + /> +
+ + {message && ( +
+ {message} +
+ )} + + +
+ +

+ No account?{" "} + + Register + +

+
); } diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index f950fb4..c26ddab 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -1,43 +1,99 @@ "use client"; +import Link from "next/link"; import VideoCard from "@/components/VideoCard"; import { listVideos, type Video } from "@/lib/api"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; + +function SkeletonCard() { + return ( +
+
+
+
+
+
+
+
+ ); +} + +function PlayGlyph({ className = "" }: { className?: string }) { + return ( + + + + ); +} export default function HomePage() { const [videos, setVideos] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); - useEffect(() => { + const load = useCallback(() => { + setLoading(true); + setError(null); listVideos(24, 0) .then((res) => setVideos(res.data)) .catch((e) => setError((e as Error).message)) .finally(() => setLoading(false)); }, []); - if (loading) return
Loading videos…
; - if (error) return
Failed to load: {error}
; - - if (videos.length === 0) { - return ( -
-

No videos yet

-

Upload your first video to get started.

- - Upload video - -
- ); - } + useEffect(() => { + load(); + }, [load]); return (
-

Latest videos

-
- {videos.map((v) => ( - setVideos((prev) => prev.filter((x) => x.id !== id))} /> - ))} +
+
+

Latest videos

+

+ {loading ? "Loading the library…" : `${videos.length} video${videos.length === 1 ? "" : "s"} · adaptive HLS`} +

+
+ + Upload video +
+ + {loading ? ( +
+ {Array.from({ length: 6 }).map((_, i) => ( + + ))} +
+ ) : error ? ( +
+
+ + + +
+

Couldn't load videos

+

{error}

+ +
+ ) : videos.length === 0 ? ( +
+
+ +
+

No videos yet

+

Upload your first video to get started.

+ + Upload video + +
+ ) : ( +
+ {videos.map((v) => ( + setVideos((prev) => prev.filter((x) => x.id !== id))} /> + ))} +
+ )}
); } diff --git a/frontend/src/app/register/page.tsx b/frontend/src/app/register/page.tsx index a047763..aceda08 100644 --- a/frontend/src/app/register/page.tsx +++ b/frontend/src/app/register/page.tsx @@ -10,6 +10,7 @@ export default function RegisterPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [localError, setLocalError] = useState(null); + const message = localError || error; const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -23,19 +24,62 @@ export default function RegisterPage() { }; return ( -
-

Create account

-
- setEmail(e.target.value)} placeholder="Email" type="email" required className="w-full rounded border px-3 py-2 text-sm" /> - setPassword(e.target.value)} placeholder="Password (min 8)" type="password" required minLength={8} className="w-full rounded border px-3 py-2 text-sm" /> - {(localError || error) &&
{localError || error}
} - -
-

- Have account? Login -

+
+
+

Create account

+

Start uploading and streaming in a minute.

+ +
+
+ + setEmail(e.target.value)} + placeholder="you@example.com" + type="email" + autoComplete="email" + required + className="input" + /> +
+
+ + setPassword(e.target.value)} + placeholder="At least 8 characters" + type="password" + autoComplete="new-password" + required + minLength={8} + className="input" + /> +
+ + {message && ( +
+ {message} +
+ )} + + +
+ +

+ Have account?{" "} + + Login + +

+
); } diff --git a/frontend/src/app/upload/page.tsx b/frontend/src/app/upload/page.tsx index 7cca3b7..4042007 100644 --- a/frontend/src/app/upload/page.tsx +++ b/frontend/src/app/upload/page.tsx @@ -1,6 +1,7 @@ "use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; +import Link from "next/link"; import { uploadVideo } from "@/lib/api"; import { useAuth } from "@/store/auth"; @@ -14,6 +15,7 @@ export default function UploadPage() { const [uploading, setUploading] = useState(false); const [error, setError] = useState(null); const [doneId, setDoneId] = useState(null); + const [dragOver, setDragOver] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -44,49 +46,128 @@ export default function UploadPage() { }; return ( -
-

Upload video

-

MP4 up to 5GB via presigned direct to MinIO. Stored as raw, then transcoded to 3 renditions.

+
+
+

Upload video

+

+ Uploaded directly to object storage, then transcoded to 360p / 720p / 1080p. +

+
{!email && ( -
- You are not logged in. Login to upload. +
+ + + + + You are not logged in.{" "} + + Login + {" "} + to upload. +
)} -
+
- - setFile(e.target.files?.[0] ?? null)} - className="mt-1 block w-full rounded border p-2 text-sm" - /> - {file &&

{file.name} — {(file.size / 1_000_000).toFixed(1)} MB

} + Video file +
+
- - setTitle(e.target.value)} placeholder="My video" className="mt-1 w-full rounded border px-3 py-2 text-sm" /> + + setTitle(e.target.value)} + placeholder="My video" + className="input" + />
+
- -