redesign
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { Head, Link, usePage } from '@inertiajs/react';
|
||||
import {
|
||||
ArrowRight,
|
||||
Compass,
|
||||
LayoutDashboard,
|
||||
Radio,
|
||||
Search,
|
||||
@@ -10,6 +12,7 @@ import {
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { dashboard, home, login, register } from '@/routes';
|
||||
import { show as showChannel } from '@/routes/channels';
|
||||
import type { Category, ChannelCard } from '@/types';
|
||||
@@ -29,6 +32,7 @@ export default function Welcome({
|
||||
const [query, setQuery] = useState('');
|
||||
const [category, setCategory] = useState<string>('all');
|
||||
|
||||
const featuredChannel = liveChannels[0] ?? null;
|
||||
const filteredChannels = useMemo(() => {
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
|
||||
@@ -51,24 +55,41 @@ export default function Welcome({
|
||||
<>
|
||||
<Head title="Live" />
|
||||
<div className="min-h-screen bg-background text-foreground">
|
||||
<header className="border-b">
|
||||
<header className="sticky top-0 z-40 border-b bg-background/90 backdrop-blur">
|
||||
<div className="mx-auto flex h-16 w-full max-w-7xl items-center gap-4 px-4">
|
||||
<Link
|
||||
href={home()}
|
||||
className="flex items-center gap-2 font-semibold"
|
||||
>
|
||||
<span className="flex size-9 items-center justify-center rounded-md bg-neutral-950 text-white dark:bg-white dark:text-neutral-950">
|
||||
<span className="flex size-9 items-center justify-center rounded-md bg-primary text-primary-foreground">
|
||||
<Radio className="size-4" />
|
||||
</span>
|
||||
<span>Nyone</span>
|
||||
</Link>
|
||||
|
||||
<nav className="hidden items-center gap-1 text-sm text-muted-foreground md:flex">
|
||||
<Link
|
||||
href={home()}
|
||||
className="rounded-md px-3 py-2 text-foreground"
|
||||
>
|
||||
Live
|
||||
</Link>
|
||||
{auth.user && (
|
||||
<Link
|
||||
href={dashboard()}
|
||||
className="rounded-md px-3 py-2 hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
Studio
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
{auth.user ? (
|
||||
<Button asChild size="sm">
|
||||
<Link href={dashboard()}>
|
||||
<LayoutDashboard className="size-4" />
|
||||
Dashboard
|
||||
Studio
|
||||
</Link>
|
||||
</Button>
|
||||
) : (
|
||||
@@ -90,38 +111,109 @@ export default function Welcome({
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className="mx-auto flex w-full max-w-7xl flex-col gap-8 px-4 py-8">
|
||||
<section className="grid gap-6 border-b pb-8 lg:grid-cols-[1fr_320px]">
|
||||
<div className="space-y-4">
|
||||
<div className="inline-flex items-center gap-2 rounded-md border px-3 py-1 text-sm text-muted-foreground">
|
||||
<Video className="size-4 text-red-600" />
|
||||
{liveChannels.length} live now
|
||||
</div>
|
||||
<div className="max-w-3xl space-y-3">
|
||||
<h1 className="text-3xl font-semibold tracking-normal md:text-5xl">
|
||||
Live streams from independent channels
|
||||
</h1>
|
||||
<p className="text-base text-muted-foreground md:text-lg">
|
||||
Watch public live broadcasts, follow
|
||||
channels, and chat while creators stream
|
||||
from OBS.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid content-start gap-3 rounded-md border p-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Users className="size-5 text-sky-700 dark:text-sky-400" />
|
||||
<div>
|
||||
<div className="text-sm font-medium">
|
||||
Creator access
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
One channel per account with private
|
||||
stream keys.
|
||||
<main className="mx-auto flex w-full max-w-7xl flex-col gap-8 px-4 py-6 md:py-8">
|
||||
<section className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]">
|
||||
{featuredChannel ? (
|
||||
<Link
|
||||
href={showChannel(featuredChannel.slug)}
|
||||
className="group overflow-hidden rounded-md border bg-card text-card-foreground shadow-sm transition hover:border-primary/50"
|
||||
>
|
||||
<div className="grid md:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.65fr)]">
|
||||
<Thumbnail
|
||||
channel={featuredChannel}
|
||||
className="aspect-video md:min-h-[360px]"
|
||||
label="Featured live"
|
||||
/>
|
||||
<div className="grid content-between gap-6 p-5">
|
||||
<div className="space-y-4">
|
||||
<LiveBadge />
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-semibold md:text-4xl">
|
||||
{featuredChannel.broadcast
|
||||
?.title ??
|
||||
featuredChannel.display_name}
|
||||
</h1>
|
||||
<p className="line-clamp-3 text-sm leading-6 text-muted-foreground">
|
||||
{featuredChannel.description ??
|
||||
`${featuredChannel.display_name} is live now with ${featuredChannel.viewer_count} viewers.`}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-3 text-sm text-muted-foreground">
|
||||
<span className="font-medium text-foreground">
|
||||
{featuredChannel.display_name}
|
||||
</span>
|
||||
<span>
|
||||
{featuredChannel.category
|
||||
?.name ?? 'Uncategorized'}
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<Users className="size-4" />
|
||||
{
|
||||
featuredChannel.viewer_count
|
||||
}{' '}
|
||||
viewers
|
||||
</span>
|
||||
<span className="ml-auto inline-flex items-center gap-1 text-primary">
|
||||
Watch
|
||||
<ArrowRight className="size-4" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
) : (
|
||||
<div className="grid min-h-[360px] content-center gap-4 rounded-md border border-dashed bg-card p-6">
|
||||
<div className="flex size-12 items-center justify-center rounded-md bg-secondary text-secondary-foreground">
|
||||
<Video className="size-5" />
|
||||
</div>
|
||||
<div className="max-w-xl space-y-2">
|
||||
<h1 className="text-2xl font-semibold md:text-4xl">
|
||||
The live floor is quiet
|
||||
</h1>
|
||||
<p className="text-sm leading-6 text-muted-foreground md:text-base">
|
||||
Creators can prepare a broadcast in the
|
||||
studio and go live from OBS when ready.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<aside className="grid content-start gap-3 rounded-md border bg-card p-4">
|
||||
<div className="flex items-center justify-between gap-3 border-b pb-3">
|
||||
<div>
|
||||
<div className="text-sm font-medium">
|
||||
Live signal
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Public channels broadcasting now
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-live rounded-md px-2 py-1 text-xs font-medium text-white">
|
||||
{liveChannels.length}
|
||||
</div>
|
||||
</div>
|
||||
<Metric
|
||||
icon={Radio}
|
||||
label="Live channels"
|
||||
value={String(liveChannels.length)}
|
||||
/>
|
||||
<Metric
|
||||
icon={Users}
|
||||
label="Viewers"
|
||||
value={String(
|
||||
liveChannels.reduce(
|
||||
(total, item) =>
|
||||
total + item.viewer_count,
|
||||
0,
|
||||
),
|
||||
)}
|
||||
/>
|
||||
<Metric
|
||||
icon={Compass}
|
||||
label="Categories"
|
||||
value={String(categories.length)}
|
||||
/>
|
||||
<Button asChild variant="outline">
|
||||
<Link
|
||||
href={auth.user ? dashboard() : register()}
|
||||
@@ -131,14 +223,19 @@ export default function Welcome({
|
||||
: 'Start a channel'}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||
<h2 className="text-xl font-semibold">
|
||||
Live directory
|
||||
</h2>
|
||||
<div className="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold">
|
||||
Live directory
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Browse active channels by category or title.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 sm:flex-row">
|
||||
<div className="relative">
|
||||
<Search className="absolute top-2.5 left-3 size-4 text-muted-foreground" />
|
||||
@@ -147,7 +244,7 @@ export default function Welcome({
|
||||
onChange={(event) =>
|
||||
setQuery(event.target.value)
|
||||
}
|
||||
placeholder="Search channels"
|
||||
placeholder="Search live channels"
|
||||
className="pl-9 sm:w-72"
|
||||
/>
|
||||
</div>
|
||||
@@ -169,53 +266,25 @@ export default function Welcome({
|
||||
</div>
|
||||
|
||||
{filteredChannels.length > 0 ? (
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
|
||||
{filteredChannels.map((channel) => (
|
||||
<Link
|
||||
<StreamCard
|
||||
key={channel.id}
|
||||
href={showChannel(channel.slug)}
|
||||
className="group overflow-hidden rounded-md border bg-card text-card-foreground transition-colors hover:border-neutral-400 dark:hover:border-neutral-600"
|
||||
>
|
||||
<div className="flex aspect-video items-center justify-center bg-neutral-950 text-white">
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<span className="size-2 rounded-full bg-red-500" />
|
||||
Live preview
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-3 p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate font-medium">
|
||||
{channel.broadcast
|
||||
?.title ??
|
||||
channel.display_name}
|
||||
</div>
|
||||
<div className="truncate text-sm text-muted-foreground">
|
||||
{channel.display_name}{' '}
|
||||
by {channel.owner.name}
|
||||
</div>
|
||||
</div>
|
||||
<div className="shrink-0 rounded-md bg-red-600 px-2 py-1 text-xs font-medium text-white">
|
||||
LIVE
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
<span>
|
||||
{channel.category?.name ??
|
||||
'Uncategorized'}
|
||||
</span>
|
||||
<span>
|
||||
{channel.viewer_count}{' '}
|
||||
viewers
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
channel={channel}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex min-h-64 items-center justify-center rounded-md border border-dashed text-sm text-muted-foreground">
|
||||
No live channels match this view.
|
||||
<div className="grid min-h-64 content-center justify-items-center gap-3 rounded-md border border-dashed bg-card p-6 text-center">
|
||||
<Search className="size-8 text-muted-foreground" />
|
||||
<div>
|
||||
<div className="font-medium">
|
||||
No streams match this view
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Clear search or switch categories.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
@@ -224,3 +293,106 @@ export default function Welcome({
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function StreamCard({ channel }: { channel: ChannelCard }) {
|
||||
return (
|
||||
<Link
|
||||
href={showChannel(channel.slug)}
|
||||
className="group overflow-hidden rounded-md border bg-card text-card-foreground shadow-sm transition hover:border-primary/50"
|
||||
>
|
||||
<Thumbnail channel={channel} className="aspect-video" />
|
||||
<div className="grid gap-3 p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate font-medium">
|
||||
{channel.broadcast?.title ?? channel.display_name}
|
||||
</div>
|
||||
<div className="truncate text-sm text-muted-foreground">
|
||||
{channel.display_name} by {channel.owner.name}
|
||||
</div>
|
||||
</div>
|
||||
<LiveBadge compact />
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-3 text-sm text-muted-foreground">
|
||||
<span className="truncate">
|
||||
{channel.category?.name ?? 'Uncategorized'}
|
||||
</span>
|
||||
<span className="shrink-0">
|
||||
{channel.viewer_count} viewers
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function Thumbnail({
|
||||
channel,
|
||||
className,
|
||||
label = 'Live preview',
|
||||
}: {
|
||||
channel: ChannelCard;
|
||||
className?: string;
|
||||
label?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'relative flex items-center justify-center overflow-hidden bg-zinc-950 text-white',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{channel.thumbnail_url ? (
|
||||
<img
|
||||
src={channel.thumbnail_url}
|
||||
alt=""
|
||||
className="h-full w-full object-cover transition duration-300 group-hover:scale-[1.02]"
|
||||
/>
|
||||
) : (
|
||||
<div className="grid h-full w-full place-items-center bg-[radial-gradient(circle_at_40%_30%,oklch(0.34_0.12_326),oklch(0.14_0.04_315)_55%)]">
|
||||
<div className="flex items-center gap-2 text-sm font-medium">
|
||||
<span className="bg-live live-pulse size-2 rounded-full" />
|
||||
{label}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute top-3 left-3">
|
||||
<LiveBadge compact />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LiveBadge({ compact = false }: { compact?: boolean }) {
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
'bg-live inline-flex items-center gap-2 rounded-md px-2 py-1 text-xs font-semibold text-white',
|
||||
compact && 'gap-1.5 px-1.5',
|
||||
)}
|
||||
>
|
||||
<span className="live-pulse size-1.5 rounded-full bg-white" />
|
||||
LIVE
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function Metric({
|
||||
icon: Icon,
|
||||
label,
|
||||
value,
|
||||
}: {
|
||||
icon: typeof Radio;
|
||||
label: string;
|
||||
value: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center justify-between gap-3 rounded-md border bg-background px-3 py-2">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Icon className="size-4 text-primary" />
|
||||
{label}
|
||||
</div>
|
||||
<div className="font-semibold">{value}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user