Skip to content

Commit 349dc79

Browse files
committed
✨ Enhance HomePage layout and functionality with dynamic time display and login feature
1 parent 98a0f6e commit 349dc79

1 file changed

Lines changed: 97 additions & 17 deletions

File tree

app/page.tsx

Lines changed: 97 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,131 @@
1+
'use client';
12
import { GithubIcon } from "@/components/icons/github";
23
import { SearchIcon } from "@/components/icons/search";
34
import { VisualStudioCodeIcon } from "@/components/icons/vscode";
45
import { WindowsIcon } from "@/components/icons/windows";
5-
import { cn } from "@/lib/utils";
6+
import Image from "next/image";
7+
import { useEffect, useState } from 'react';
8+
import { useRouter } from 'next/navigation';
9+
import { LoaderIcon } from "lucide-react";
610

711
const menuItems = [
812
{
913
name: 'Windows',
1014
href: '#',
1115
icon: WindowsIcon,
12-
className: '',
16+
className: 'max-sm:size-4 size-7',
1317
},
1418
{
1519
name: 'Search',
1620
href: '#',
1721
icon: SearchIcon,
18-
className: 'text-gray-500 size-6',
22+
className: 'max-sm:size-4 text-gray-500 size-6',
1923
},
2024
{
2125
name: 'GitHub',
2226
href: '#',
2327
icon: GithubIcon,
24-
className: 'text-gray-600 size-7',
28+
className: 'max-sm:size-4 text-gray-600 size-7',
2529
},
2630
{
2731
name: 'VS Code',
2832
href: '#',
2933
icon: VisualStudioCodeIcon,
30-
className: 'text-blue-500 size-7 mt-0.5',
34+
className: 'max-sm:size-4 text-blue-500 size-7 mt-0.5',
3135
},
3236
];
3337

3438

3539
export default function HomePage() {
40+
41+
const [currentTime, setCurrentTime] = useState(new Date());
42+
const [ loggingIn, setLoggingIn ] = useState(false);
43+
const [pin, setPin] = useState('1234');
44+
const router = useRouter();
45+
46+
useEffect(() => {
47+
const timer = setInterval(() => {
48+
setCurrentTime(new Date());
49+
}, 1000);
50+
51+
return () => clearInterval(timer);
52+
}, []);
53+
54+
const formatTime = (date: Date) => {
55+
return date.toLocaleTimeString('en-US', {
56+
hour: 'numeric',
57+
minute: '2-digit',
58+
hour12: true
59+
});
60+
};
61+
62+
const formatDate = (date: Date) => {
63+
return date.toLocaleDateString('en-US', {
64+
weekday: 'long',
65+
month: 'long',
66+
day: 'numeric',
67+
year: 'numeric'
68+
});
69+
};
70+
71+
const loginHandler = () => {
72+
setLoggingIn(true);
73+
74+
setTimeout(() => {
75+
setLoggingIn(false);
76+
router.push('/desktop');
77+
}, 1000);
78+
}
79+
80+
3681
return (
37-
<main className="min-h-screen relative bg-amber-50">
38-
<footer className="fixed bottom-0 inset-x-0 border-t backdrop-blur-sm border-black/5 bg-white/50">
39-
<ul className="flex w-full max-w-3xl mx-auto justify-center py-1.5 gap-1">
40-
{menuItems.map((item) => (
41-
<li key={item.name}>
42-
<a href={item.href} className="relative flex items-center justify-center size-9 rounded-lg hover:bg-white hover:shadow-lg duration-400 shadow-black/10 transition-colors">
43-
<item.icon className={cn('size-7 text-gray-600', item.className )} />
44-
</a>
45-
</li>
46-
))}
47-
</ul>
48-
</footer>
82+
<main className="min-h-screen font-sans relative bg-amber-50 text-center">
83+
<div className="flex flex-col gap-3 items-center justify-center min-h-screen">
84+
85+
<div className="flex justify-center max-sm:mt-5 flex-col">
86+
<p className="leading-4 text-sm mb-2">Welcome back,</p>
87+
<time dateTime="" className="max-sm:text-3xl text-6xl font-bold"> {formatTime(currentTime)}</time>
88+
<p className="max-sm:text-lg text-foreground/70 text-2xl font-medium mt-1">{formatDate(currentTime)}</p>
89+
</div>
90+
91+
92+
<div className="flex w-full p-5 flex-col max-sm:mt-2 mt-5 justify-center gap-5">
93+
<div className="max-sm:size-20 relative size-32 bg-gray-100 rounded-full mx-auto mb-4 flex items-center justify-center ring-2 ring-amber-200 ring-offset-4">
94+
<WindowsIcon className="max-sm:size-10 size-12" />
95+
96+
<Image src="/cambodia-flag-icon-128.png" alt="Avatar" width={120} height={120} className="absolute ring-2 bottom-1 -right-2 ring-amber-200 rounded w-9 hover:scale-110 transition-all duration-300 h-auto object-cover" />
97+
98+
</div>
99+
<div className="max-sm:flex-col max-sm:mt-5 mt-7 items-center flex-col flex mx-auto justify-center gap-0">
100+
<h1 className="font-bold font-sans text-xl">Sophat LEAT</h1>
101+
</div>
102+
103+
<div className="flex w-full max-w-xs mx-auto justify-center max-sm:gap-1 gap-2">
104+
<input type="password" className="text-base leading-5 w-full font-normal px-3 py-1.5 rounded-xl rounded-r-sm border" placeholder="PIN" value={pin} onChange={(e) => setPin(e.target.value)} />
105+
<button type="submit" disabled={loggingIn} onClick={loginHandler} className="text-base shrink-0 bg-amber-100 disabled:opacity-50 cursor-pointer text-amber-900 leading-5 font-medium px-3 py-1.5 rounded-xl rounded-l-sm border">
106+
{
107+
loggingIn
108+
? <span className="flex gap-1 items-center"><LoaderIcon className="size-4 animate-spin" /> {'Sign In'} </span> : 'Sign In'
109+
}
110+
</button>
111+
</div>
112+
</div>
113+
114+
115+
<footer className="pb-5 mt-10 w-full px-4 mb-5">
116+
<ul className="flex w-full max-w-3xl overflow-x-auto mx-auto justify-center py-1.5 gap-5">
117+
{menuItems.map((item) => (
118+
<li key={item.name} className="flex items-center gap-0.5 justify-center">
119+
<a href={item.href} className="relative flex flex-col items-center justify-center size-9 rounded-lg hover:bg-white hover:shadow-lg duration-400 shadow-black/10 transition-colors">
120+
<item.icon className={item.className} />
121+
</a>
122+
<span className="max-sm:text-xs whitespace-nowrap mt-0.5">{item.name}</span>
123+
</li>
124+
))}
125+
</ul>
126+
</footer>
127+
128+
</div>
49129
</main>
50130
);
51131
}

0 commit comments

Comments
 (0)