feat: implement responsive dashboard layout with sidebar navigation and full-screen clock overlay

This commit is contained in:
Poyraz Avsever
2026-05-08 12:09:41 +03:00
parent a08042bf83
commit c309539db5
2 changed files with 370 additions and 273 deletions
+270 -237
View File
@@ -1,291 +1,324 @@
"use client"; "use client";
import { useMemo } from "react"; import { useMemo } from "react";
import { useLiveQuery } from "dexie-react-hooks";
import { Activity, Brain, CheckCircle, PenTool } from "lucide-react";
import { import {
Bar, Bar,
BarChart, BarChart,
CartesianGrid, CartesianGrid,
Legend, Cell,
Line, Line,
LineChart, LineChart,
Pie,
PieChart,
ResponsiveContainer, ResponsiveContainer,
Tooltip, Tooltip,
XAxis, XAxis,
YAxis, YAxis,
} from "recharts"; } from "recharts";
import { LogOut, CheckSquare2, Droplets, Moon, Target, Activity, MoreHorizontal, PenTool } from "lucide-react";
import { db, type Journal, type Task } from "@/lib/db"; // Mock Data
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; const focusTrendData = [
{ date: "May 12", value: 55 },
{ date: "May 13", value: 42 },
{ date: "May 14", value: 60 },
{ date: "May 15", value: 85 },
{ date: "May 16", value: 72 },
{ date: "May 17", value: 87 },
{ date: "May 18", value: 100 },
];
const EMPTY_JOURNALS: Journal[] = []; const sleepData = [
const EMPTY_TASKS: Task[] = []; { day: "M", value: 6.5 },
{ day: "T", value: 7.2 },
{ day: "W", value: 5.8 },
{ day: "T", value: 6.1 },
{ day: "F", value: 8.0 },
{ day: "S", value: 7.5 },
{ day: "S", value: 8.5 },
];
const moodScores: Record<string, number> = { const waterData = [
happy: 4, { day: "M", value: 1.5 },
neutral: 3, { day: "T", value: 2.1 },
sad: 2, { day: "W", value: 1.8 },
angry: 1, { day: "T", value: 2.5 },
}; { day: "F", value: 2.0 },
{ day: "S", value: 3.0 },
{ day: "S", value: 2.8 },
];
const moodData = [
{ day: "M", value: 60 },
{ day: "T", value: 85 },
{ day: "W", value: 70 },
{ day: "T", value: 65 },
{ day: "F", value: 80 },
{ day: "S", value: 90 },
{ day: "S", value: 95 },
];
const focusDistributionData = [
{ name: "Deep Work", value: 45, color: "#6C5BB0" },
{ name: "Shallow Work", value: 30, color: "#54468B" },
{ name: "Meetings", value: 15, color: "#3B3161" },
{ name: "Breaks", value: 10, color: "#221C38" },
];
const upcomingEvents = [
{ time: "10:00 AM", title: "Deep Work Session", category: "FOCUS", color: "border-l-pink-500" },
{ time: "12:30 PM", title: "Team Standup", category: "MEETING", color: "border-l-orange-500" },
{ time: "02:00 PM", title: "Project Review", category: "WORK", color: "border-l-blue-500" },
{ time: "04:00 PM", title: "Workout", category: "HEALTH", color: "border-l-emerald-500" },
{ time: "07:00 PM", title: "Daily Reflection", category: "PERSONAL", color: "border-l-purple-500" },
];
export default function DashboardPage() { export default function DashboardPage() {
const liveJournals = useLiveQuery<Journal[]>(() => const currentDate = new Date().toLocaleDateString('tr-TR', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
db.journals.orderBy("date").toArray(), const currentTime = new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
);
const liveTasks = useLiveQuery<Task[]>(() => db.tasks.toArray());
const journals = liveJournals ?? EMPTY_JOURNALS;
const tasks = liveTasks ?? EMPTY_TASKS;
const pendingTasksCount = tasks.filter((task) => task.status === "todo").length;
const today = new Date().toISOString().split("T")[0];
const todaysJournal = journals.find((journal) => journal.date === today);
const todaysEnergy = todaysJournal ? todaysJournal.energy : "--";
const trendData = useMemo(() => {
const dataMap: Record<
string,
{ date: string; moodSum: number; energySum: number; count: number }
> = {};
journals.forEach((journal) => {
if (!dataMap[journal.date]) {
dataMap[journal.date] = {
date: journal.date,
moodSum: 0,
energySum: 0,
count: 0,
};
}
dataMap[journal.date].moodSum += moodScores[journal.mood] || 3;
dataMap[journal.date].energySum += journal.energy;
dataMap[journal.date].count += 1;
});
return Object.values(dataMap)
.map((entry) => ({
date: entry.date.slice(5),
Mood: Number((entry.moodSum / entry.count).toFixed(1)),
Enerji: Number((entry.energySum / entry.count).toFixed(1)),
}))
.slice(-7);
}, [journals]);
const tagData = useMemo(() => {
const counts: Record<string, number> = {};
journals.forEach((journal) => {
journal.ai_tags?.forEach((tag) => {
counts[tag] = (counts[tag] || 0) + 1;
});
});
return Object.entries(counts)
.map(([name, value]) => ({ name, Değer: value }))
.sort((a, b) => b.Değer - a.Değer)
.slice(0, 5);
}, [journals]);
const lastInsight = [...journals]
.reverse()
.find((journal) => journal.ai_summary)?.ai_summary;
return ( return (
<div className="mx-auto max-w-6xl animate-in space-y-6 fade-in slide-in-from-bottom-4 duration-500"> <div className="mx-auto max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500 space-y-6 text-foreground font-sans">
<div className="flex flex-col gap-2">
<h1 className="text-3xl font-bold tracking-tight">Bugün Nasılsın?</h1>
<p className="text-muted-foreground">
Kişisel özetin ve yapay zeka analizlerin burada görünecek.
</p>
</div>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"> <div className="grid grid-cols-1 xl:grid-cols-3 gap-6 mt-4">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Günlük Kayıtları</CardTitle>
<PenTool className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{journals.length}</div>
<p className="mt-1 text-xs text-muted-foreground">
{journals.length === 0
? "Henüz kayıt girilmedi"
: "Toplam kayıt eklendi"}
</p>
</CardContent>
</Card>
<Card> {/* LEFT COLUMN: Focus Trend (Takes 2 columns on XL) */}
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <div className="xl:col-span-2 flex flex-col gap-6">
<CardTitle className="text-sm font-medium">Aktif Görevler</CardTitle> <div className="rounded-sm border border-white/5 bg-[#0A0710] p-6 flex-1 min-h-[400px]">
<CheckCircle className="h-4 w-4 text-muted-foreground" /> <div className="flex justify-between items-start mb-8">
</CardHeader> <div>
<CardContent> <h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-4">Focus Trend</h3>
<div className="text-2xl font-bold">{pendingTasksCount}</div> <div className="text-5xl font-bold mb-1 text-primary">87<span className="text-2xl">%</span></div>
<p className="mt-1 text-xs text-muted-foreground">Bekleyen görev</p> <div className="text-sm text-muted-foreground">Average Focus Score</div>
</CardContent> </div>
</Card> <div className="flex items-center gap-3">
<select className="bg-transparent border border-white/10 rounded-sm text-xs px-3 py-1.5 outline-none focus:border-primary/50 cursor-pointer">
<option className="bg-[#0A0710]">7 DAYS</option>
<option className="bg-[#0A0710]">14 DAYS</option>
<option className="bg-[#0A0710]">30 DAYS</option>
</select>
<button className="p-1.5 border border-white/10 rounded-sm hover:bg-white/5 transition-colors">
<Activity className="h-4 w-4" />
</button>
</div>
</div>
<Card> <div className="h-[280px] w-full">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Bugünkü Enerji</CardTitle>
<Activity className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{todaysEnergy}</div>
<p className="mt-1 text-xs text-muted-foreground">
{todaysJournal ? "/ 5 seviyesinde" : "Kayıt bekleniyor"}
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Local AI Durumu</CardTitle>
<Brain className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-green-500">Hazır</div>
<p className="mt-1 text-xs text-muted-foreground">
Ollama / Veri bekliyor
</p>
</CardContent>
</Card>
</div>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
<Card className="flex flex-col justify-between p-6 lg:col-span-4">
<div className="mb-4">
<h3 className="mb-1 text-lg font-medium">Ruh Hali ve Enerji Trendi</h3>
<p className="text-sm text-muted-foreground">
Son 7 günlük ortalamalar (1-5 arası puanlama)
</p>
</div>
<div className="h-[250px] w-full">
{trendData.length > 0 ? (
<ResponsiveContainer width="100%" height="100%"> <ResponsiveContainer width="100%" height="100%">
<LineChart data={trendData}> <LineChart data={focusTrendData}>
<CartesianGrid <CartesianGrid strokeDasharray="3 3" vertical={false} stroke="#ffffff10" />
strokeDasharray="3 3"
vertical={false}
stroke="#88888833"
/>
<XAxis <XAxis
dataKey="date" dataKey="date"
axisLine={false} axisLine={false}
tickLine={false} tickLine={false}
tick={{ fontSize: 12 }} tick={{ fontSize: 11, fill: '#8F89A5' }}
dy={10}
/> />
<YAxis <YAxis
domain={[1, 5]} domain={[0, 100]}
axisLine={false} axisLine={false}
tickLine={false} tickLine={false}
tick={{ fontSize: 12 }} tick={{ fontSize: 11, fill: '#8F89A5' }}
width={30} width={30}
dx={-10}
/> />
<Tooltip <Tooltip
contentStyle={{ contentStyle={{ backgroundColor: "#1F172B", borderColor: "#3B3448", borderRadius: "4px", fontSize: "12px" }}
borderRadius: "8px", itemStyle={{ color: "#6C5BB0" }}
backgroundColor: "#fff",
color: "#000",
border: "none",
}}
itemStyle={{ fontWeight: "500" }}
/>
<Legend wrapperStyle={{ paddingTop: "10px", fontSize: "14px" }} />
<Line
type="monotone"
dataKey="Mood"
stroke="#3b82f6"
strokeWidth={3}
dot={{ r: 4 }}
activeDot={{ r: 6 }}
/> />
<Line <Line
type="monotone" type="monotone"
dataKey="Enerji" dataKey="value"
stroke="#10b981" stroke="#6C5BB0"
strokeWidth={3} strokeWidth={3}
dot={{ r: 4 }} dot={{ r: 4, fill: "#1F172B", strokeWidth: 2 }}
activeDot={{ r: 6 }} activeDot={{ r: 6, fill: "#6C5BB0", stroke: "#1F172B" }}
/> />
</LineChart> </LineChart>
</ResponsiveContainer> </ResponsiveContainer>
) : ( </div>
<div className="flex h-full items-center justify-center rounded-md border-2 border-dashed bg-muted/20">
<p className="text-sm text-muted-foreground">Veri bekleniyor...</p>
</div>
)}
</div> </div>
</Card> </div>
<div className="flex flex-col space-y-4 lg:col-span-3"> {/* RIGHT COLUMN: Quick Add & Upcoming */}
<Card className="flex flex-1 flex-col p-6"> <div className="flex flex-col gap-6">
<div className="mb-4">
<h3 className="mb-1 text-lg font-medium">AI Konu Dağılımı</h3> {/* Quick Add */}
<p className="text-sm text-muted-foreground"> <div className="rounded-sm border border-white/5 bg-[#0A0710] p-6">
Günlüklerinden çıkarılan en sık 5 etiket <h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-4">Quick Add</h3>
</p> <div className="bg-[#150F1D] border border-white/5 rounded-sm p-3 mb-4">
<input
type="text"
placeholder="What's on your mind?"
className="w-full bg-transparent border-none outline-none text-sm placeholder:text-muted-foreground/50"
/>
</div> </div>
<div className="mt-auto h-[150px] w-full"> <div className="grid grid-cols-3 gap-3">
{tagData.length > 0 ? ( <button className="flex flex-col items-center justify-center gap-2 border border-white/5 rounded-sm py-3 hover:bg-white/5 transition-colors text-muted-foreground hover:text-foreground">
<ResponsiveContainer width="100%" height="100%"> <PenTool className="h-5 w-5" />
<BarChart data={tagData} layout="vertical" margin={{ left: -20 }}> <span className="text-[10px] font-semibold tracking-wider">NOTE</span>
<CartesianGrid </button>
strokeDasharray="3 3" <button className="flex flex-col items-center justify-center gap-2 border border-white/5 rounded-sm py-3 hover:bg-white/5 transition-colors text-muted-foreground hover:text-foreground">
horizontal={false} <Target className="h-5 w-5" />
stroke="#88888833" <span className="text-[10px] font-semibold tracking-wider">HABIT</span>
/> </button>
<XAxis type="number" hide /> <button className="flex flex-col items-center justify-center gap-2 border border-white/5 rounded-sm py-3 hover:bg-white/5 transition-colors text-muted-foreground hover:text-foreground">
<YAxis <CheckSquare2 className="h-5 w-5" />
dataKey="name" <span className="text-[10px] font-semibold tracking-wider">GOAL</span>
type="category" </button>
axisLine={false} </div>
tickLine={false} </div>
tick={{ fontSize: 13 }}
width={90} {/* Upcoming */}
/> <div className="rounded-sm border border-white/5 bg-[#0A0710] p-6 flex-1">
<Tooltip <div className="flex justify-between items-center mb-6">
cursor={{ fill: "transparent" }} <h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Upcoming</h3>
contentStyle={{ <button className="text-[10px] uppercase font-semibold text-muted-foreground hover:text-foreground">View All</button>
borderRadius: "8px", </div>
backgroundColor: "#fff", <div className="space-y-4">
color: "#000", {upcomingEvents.map((event, idx) => (
border: "none", <div key={idx} className="flex items-center text-sm py-1">
}} <div className={`w-1 h-10 ${event.color} border-l-2 mr-4 rounded-full`}></div>
/> <div className="w-20 text-muted-foreground text-xs">{event.time}</div>
<Bar <div className="flex-1 font-medium">{event.title}</div>
dataKey="Değer" <div className="text-[10px] uppercase font-semibold text-muted-foreground tracking-wider">{event.category}</div>
fill="#8b5cf6"
radius={[0, 4, 4, 0]}
barSize={20}
/>
</BarChart>
</ResponsiveContainer>
) : (
<div className="flex h-full items-center justify-center rounded-md border-2 border-dashed bg-muted/20">
<p className="text-sm text-muted-foreground">Yeterli etiket yok.</p>
</div> </div>
)} ))}
</div> </div>
</Card> </div>
<Card className="flex-1 border-primary/20 bg-primary/5 p-6">
<h3 className="mb-3 flex items-center gap-2 text-lg font-medium">
<Brain className="h-5 w-5 text-primary" />
Son AI İçgörüsü
</h3>
<p className="text-sm italic leading-relaxed text-foreground/80">
{lastInsight
? `"${lastInsight}"`
: "Henüz bir içgörü oluşmadı. Biraz günlük yaz, AI analiz yapsın."}
</p>
</Card>
</div> </div>
</div> </div>
{/* BOTTOM ROW: Mini Charts & Donut */}
<div className="grid grid-cols-1 md:grid-cols-3 xl:grid-cols-4 gap-6">
{/* Sleep Hours */}
<div className="rounded-sm border border-white/5 bg-[#0A0710] p-6 flex flex-col justify-between">
<div className="flex justify-between items-start mb-6">
<h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Sleep Hours</h3>
<Moon className="h-4 w-4 text-primary" />
</div>
<div>
<div className="flex items-baseline gap-1 mb-6">
<span className="text-4xl font-bold">7.2</span>
<span className="text-[10px] text-muted-foreground tracking-wider">HOURS</span>
</div>
<div className="h-[80px] w-full">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={sleepData} margin={{ top: 0, right: 0, bottom: 0, left: 0 }}>
<XAxis dataKey="day" axisLine={false} tickLine={false} tick={{ fontSize: 10, fill: '#8F89A5' }} dy={5} />
<Tooltip cursor={{ fill: '#ffffff05' }} contentStyle={{ backgroundColor: "#1F172B", border: "none", fontSize: "12px" }} />
<Bar dataKey="value" fill="#6C5BB0" radius={[2, 2, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</div>
<div className="mt-4 pt-4 border-t border-white/5 text-[11px] text-primary">Goal: 7-8 Hours</div>
</div>
</div>
{/* Water Intake */}
<div className="rounded-sm border border-white/5 bg-[#0A0710] p-6 flex flex-col justify-between">
<div className="flex justify-between items-start mb-6">
<h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Water Intake</h3>
<Droplets className="h-4 w-4 text-primary" />
</div>
<div>
<div className="flex items-baseline gap-1 mb-6">
<span className="text-4xl font-bold">2.1</span>
<span className="text-[10px] text-muted-foreground tracking-wider">LITERS</span>
</div>
<div className="h-[80px] w-full">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={waterData} margin={{ top: 0, right: 0, bottom: 0, left: 0 }}>
<XAxis dataKey="day" axisLine={false} tickLine={false} tick={{ fontSize: 10, fill: '#8F89A5' }} dy={5} />
<Tooltip cursor={{ fill: '#ffffff05' }} contentStyle={{ backgroundColor: "#1F172B", border: "none", fontSize: "12px" }} />
<Bar dataKey="value" fill="#6C5BB0" radius={[2, 2, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</div>
<div className="mt-4 pt-4 border-t border-white/5 text-[11px] text-primary">Goal: 2.5L</div>
</div>
</div>
{/* Mood Score */}
<div className="rounded-sm border border-white/5 bg-[#0A0710] p-6 flex flex-col justify-between">
<div className="flex justify-between items-start mb-6">
<h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Mood Score</h3>
<Activity className="h-4 w-4 text-primary" />
</div>
<div>
<div className="flex items-baseline gap-1 mb-6">
<span className="text-4xl font-bold">78</span>
<span className="text-[10px] text-muted-foreground tracking-wider">/100</span>
</div>
<div className="h-[80px] w-full">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={moodData} margin={{ top: 0, right: 0, bottom: 0, left: 0 }}>
<XAxis dataKey="day" axisLine={false} tickLine={false} tick={{ fontSize: 10, fill: '#8F89A5' }} dy={5} />
<Tooltip cursor={{ fill: '#ffffff05' }} contentStyle={{ backgroundColor: "#1F172B", border: "none", fontSize: "12px" }} />
<Bar dataKey="value" fill="#6C5BB0" radius={[2, 2, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</div>
<div className="mt-4 pt-4 border-t border-white/5 text-[11px] text-primary">Positive</div>
</div>
</div>
{/* Focus Distribution */}
<div className="rounded-sm border border-white/5 bg-[#0A0710] p-6">
<h3 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-6">Focus Distribution</h3>
<div className="flex items-center justify-between h-[160px]">
<div className="w-[140px] h-full relative flex items-center justify-center">
<ResponsiveContainer width="100%" height="100%">
<PieChart>
<Pie
data={focusDistributionData}
cx="50%"
cy="50%"
innerRadius={45}
outerRadius={65}
paddingAngle={2}
dataKey="value"
stroke="none"
>
{focusDistributionData.map((entry, index) => (
<Cell key={`cell-${index}`} fill={entry.color} />
))}
</Pie>
<Tooltip contentStyle={{ backgroundColor: "#1F172B", border: "none", fontSize: "12px" }} />
</PieChart>
</ResponsiveContainer>
</div>
<div className="flex-1 ml-6 space-y-3">
{focusDistributionData.map((item, idx) => (
<div key={idx} className="flex justify-between items-center text-xs">
<div className="flex items-center gap-2">
<div className="w-2 h-2 rounded-sm" style={{ backgroundColor: item.color }}></div>
<span className="text-muted-foreground">{item.name}</span>
</div>
<span className="font-semibold">{item.value}%</span>
</div>
))}
</div>
</div>
</div>
</div>
{/* Quote Footer */}
<div className="rounded-sm border border-white/5 bg-[#0A0710] p-6 flex justify-between items-center">
<div className="flex gap-4 items-center">
<div className="bg-[#150F1D] text-muted-foreground border border-white/5 p-2 rounded-sm">
<MoreHorizontal className="h-4 w-4" />
</div>
<div>
<div className="text-[10px] font-semibold tracking-wider text-muted-foreground mb-1">SYSTEM REMINDER</div>
<div className="text-sm">"Discipline is the bridge between goals and accomplishment."</div>
</div>
</div>
<div className="text-sm text-muted-foreground italic">- Jim Rohn</div>
</div>
</div> </div>
); );
} }
+87 -23
View File
@@ -13,11 +13,11 @@ import {
import { sidebarData } from "@/config/sidebar"; import { sidebarData } from "@/config/sidebar";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { AnimatePresence, motion } from "framer-motion"; import { AnimatePresence, motion } from "framer-motion";
import { ChevronDown, LogOut, Menu, Settings2 } from "lucide-react"; import { ChevronDown, LogOut, Menu, Settings2, Clock } from "lucide-react";
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import { usePathname } from "next/navigation"; import { usePathname } from "next/navigation";
import { useState } from "react"; import { useState, useEffect } from "react";
type DashboardShellProps = { type DashboardShellProps = {
children: React.ReactNode; children: React.ReactNode;
@@ -32,6 +32,7 @@ type DashboardShellProps = {
export function DashboardShell({ children, user }: DashboardShellProps) { export function DashboardShell({ children, user }: DashboardShellProps) {
const pathname = usePathname(); const pathname = usePathname();
const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false); const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState(false);
const [isClockFullScreen, setIsClockFullScreen] = useState(false);
const closeMobileSidebar = () => setIsMobileSidebarOpen(false); const closeMobileSidebar = () => setIsMobileSidebarOpen(false);
@@ -39,10 +40,29 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
<div className="relative h-screen overflow-hidden bg-background text-foreground"> <div className="relative h-screen overflow-hidden bg-background text-foreground">
<AmbientBackdrop /> <AmbientBackdrop />
{/* Full Screen Clock Overlay */}
<AnimatePresence>
{isClockFullScreen && (
<motion.div
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.3, ease: "easeOut" }}
className="fixed inset-0 z-[100] bg-[#0A0710] flex flex-col items-center justify-center cursor-pointer"
onClick={() => setIsClockFullScreen(false)}
>
<div className="absolute top-8 right-8 text-muted-foreground text-sm tracking-widest uppercase">
Click anywhere to close
</div>
<FullScreenClock />
</motion.div>
)}
</AnimatePresence>
<div className="relative z-10 flex h-screen"> <div className="relative z-10 flex h-screen">
{/* Desktop Sidebar */} {/* Desktop Sidebar */}
<div className="hidden shrink-0 lg:block lg:w-[260px] h-screen border-r border-white/5 bg-[#0A0710]"> <div className="hidden shrink-0 lg:block lg:w-[260px] h-screen border-r border-white/5 bg-[#0A0710]">
<SidebarPanel pathname={pathname} user={user} desktop /> <SidebarPanel pathname={pathname} user={user} desktop onClockClick={() => setIsClockFullScreen(true)} />
</div> </div>
{/* Mobile Sidebar */} {/* Mobile Sidebar */}
@@ -71,6 +91,7 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
pathname={pathname} pathname={pathname}
user={user} user={user}
onNavigate={closeMobileSidebar} onNavigate={closeMobileSidebar}
onClockClick={() => setIsClockFullScreen(true)}
/> />
</motion.div> </motion.div>
</motion.div> </motion.div>
@@ -96,10 +117,8 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
</Button> </Button>
</div> </div>
<main className="flex-1 p-4 lg:p-8"> <main className="flex-1 p-6 lg:p-10">
<div className="min-h-[calc(100vh-2rem)] rounded-2xl border border-white/5 bg-[linear-gradient(180deg,rgba(31,23,43,0.3),rgba(18,13,28,0.1))] shadow-2xl ring-1 ring-white/5 backdrop-blur-xl"> {children}
<div className="h-full p-6 md:p-8">{children}</div>
</div>
</main> </main>
</div> </div>
</div> </div>
@@ -112,22 +131,20 @@ function SidebarPanel({
user, user,
desktop = false, desktop = false,
onNavigate, onNavigate,
onClockClick,
}: { }: {
pathname: string; pathname: string;
user: DashboardShellProps["user"]; user: DashboardShellProps["user"];
desktop?: boolean; desktop?: boolean;
onNavigate?: () => void; onNavigate?: () => void;
onClockClick: () => void;
}) { }) {
return ( return (
<aside className="flex h-full flex-col overflow-hidden"> <aside className="flex h-full flex-col overflow-hidden">
{/* Header / Logo */} {/* Header / Time Badge */}
<Link <div className="pt-8 pb-2 px-4 flex justify-start">
href="/" <ClockBadge onClick={onClockClick} />
className="relative font-bold text-xl text-left py-4 pl-6 text-foreground" </div>
onClick={onNavigate}
>
Hoş Geldin
</Link>
{/* Main Navigation Links */} {/* Main Navigation Links */}
<nav className="flex-1 space-y-4 px-3 overflow-y-auto tiny-scrollbar mt-4 pb-4"> <nav className="flex-1 space-y-4 px-3 overflow-y-auto tiny-scrollbar mt-4 pb-4">
@@ -234,14 +251,15 @@ function SidebarPanel({
{user.email} {user.email}
</DropdownMenuLabel> </DropdownMenuLabel>
<DropdownMenuSeparator className="bg-white/5" /> <DropdownMenuSeparator className="bg-white/5" />
<form action={signOut}> <DropdownMenuItem
<button type="submit" className="w-full"> className="rounded-md px-2 py-1.5 text-destructive focus:bg-destructive/10 focus:text-destructive cursor-pointer flex items-center gap-2 text-sm"
<DropdownMenuItem className="rounded-md px-2 py-1.5 text-destructive focus:bg-destructive/10 focus:text-destructive cursor-pointer flex items-center gap-2 text-sm"> onClick={async () => {
<LogOut className="h-4 w-4" /> await signOut();
Çıkış Yap }}
</DropdownMenuItem> >
</button> <LogOut className="h-4 w-4" />
</form> Çıkış Yap
</DropdownMenuItem>
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
</div> </div>
@@ -249,6 +267,52 @@ function SidebarPanel({
); );
} }
function ClockBadge({ onClick }: { onClick: () => void }) {
const [time, setTime] = useState<string>("");
useEffect(() => {
const updateTime = () => {
setTime(new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' }));
};
updateTime();
const interval = setInterval(updateTime, 1000);
return () => clearInterval(interval);
}, []);
if (!time) {
return <div className="h-[34px] w-[100px] bg-white/5 animate-pulse rounded-sm" />;
}
return (
<button
onClick={onClick}
className="border border-white/5 bg-[#150F1D] px-3 py-2 text-xs font-semibold tracking-wider text-muted-foreground hover:text-foreground hover:border-primary/50 transition-colors rounded-sm flex items-center gap-2 group outline-none"
>
<Clock className="h-3.5 w-3.5 text-primary/70 group-hover:text-primary transition-colors" />
<span suppressHydrationWarning>{time}</span>
</button>
);
}
function FullScreenClock() {
const [time, setTime] = useState<string>("");
useEffect(() => {
const updateTime = () => {
setTime(new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit' }));
};
updateTime();
const interval = setInterval(updateTime, 1000);
return () => clearInterval(interval);
}, []);
return (
<div className="text-[12vw] font-black tracking-tighter text-primary/90 drop-shadow-[0_0_60px_rgba(108,91,176,0.3)] select-none tabular-nums">
<span suppressHydrationWarning>{time || "..."}</span>
</div>
);
}
function Avatar({ user }: { user: DashboardShellProps["user"] }) { function Avatar({ user }: { user: DashboardShellProps["user"] }) {
if (user.avatarUrl) { if (user.avatarUrl) {
return ( return (