feat: Dahoam start page with accounts, cards and search
Replica of the reference start page: wallpaper, serif clock, search bar and link cards, as a TanStack Start app. - Better Auth: email/password and OIDC single sign-on - Postgres with Drizzle for the auth tables, cards, links, settings and uploaded wallpapers; the server applies the migrations on start - cards group links; links are dragged inside and between cards - search with DuckDuckGo, SearXNG or Google, suggestions and / commands - settings page: name, search engine, wallpaper, account - UI from collabry-components, copied into src/vendor/collabry - Dockerfile and a Gitea workflow that checks the code, builds the image for amd64 and arm64 and pushes it to the registry on main
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { useSyncExternalStore } from "react"
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
const subscribe = (tick: () => void) => {
|
||||
const timer = setInterval(tick, 1000)
|
||||
return () => clearInterval(timer)
|
||||
}
|
||||
// changes once a minute, so the clock re-renders once a minute
|
||||
const currentMinute = () => Math.floor(Date.now() / 60_000)
|
||||
|
||||
export function Clock() {
|
||||
// null on the server: its clock and locale are not the visitor's
|
||||
const minute = useSyncExternalStore<number | null>(
|
||||
subscribe,
|
||||
currentMinute,
|
||||
() => null
|
||||
)
|
||||
const now = minute === null ? null : new Date(minute * 60_000)
|
||||
const parts = now
|
||||
? new Intl.DateTimeFormat(undefined, {
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
}).formatToParts(now)
|
||||
: []
|
||||
const time = parts
|
||||
.filter((p) => p.type !== "dayPeriod")
|
||||
.map((p) => p.value)
|
||||
.join("")
|
||||
.trim()
|
||||
const period = parts.find((p) => p.type === "dayPeriod")?.value
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col items-center text-white transition-opacity duration-500 [text-shadow:0_2px_24px_rgb(0_0_0/0.45)]",
|
||||
!now && "opacity-0"
|
||||
)}
|
||||
>
|
||||
<p className="text-lg font-medium sm:text-xl">
|
||||
{now
|
||||
? now.toLocaleDateString(undefined, {
|
||||
weekday: "long",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
})
|
||||
: "\u00a0"}
|
||||
</p>
|
||||
<time
|
||||
dateTime={now?.toISOString()}
|
||||
className="relative mt-2 font-serif text-7xl leading-none tracking-wide sm:text-[9.5rem]"
|
||||
>
|
||||
{time || "0:00"}
|
||||
{period && (
|
||||
<span className="absolute top-1 left-full ml-2 text-xl tracking-normal sm:top-3 sm:ml-4 sm:text-3xl">
|
||||
{period}
|
||||
</span>
|
||||
)}
|
||||
</time>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user