feat: a slider darkens the wallpaper, the dots and the fade are gone
images / check (push) Successful in 28s
images / image (push) Successful in 24s

This commit is contained in:
2026-11-18 17:06:40 +01:00
parent 7798432de6
commit 4b9690e064
10 changed files with 769 additions and 25 deletions
+14 -2
View File
@@ -1,6 +1,8 @@
import { cn } from "@/vendor/collabry/lib/cn"
export const DEFAULT_WALLPAPER = "/wallpaper.jpg"
/** How dark the wallpaper is made until the user moves the slider, in percent. */
export const DEFAULT_WALLPAPER_DIM = 40
function showDefault(img: HTMLImageElement) {
if (!img.src.endsWith(DEFAULT_WALLPAPER)) img.src = DEFAULT_WALLPAPER
@@ -28,11 +30,21 @@ export function WallpaperImage({
)
}
export function Wallpaper({ src }: { src?: string | null }) {
export function Wallpaper({
src,
dim = DEFAULT_WALLPAPER_DIM,
}: {
src?: string | null
/** 0 shows the picture as it is, 100 is black */
dim?: number
}) {
return (
<div className="fixed inset-0 -z-10 bg-black" aria-hidden>
<WallpaperImage src={src} />
<div className="absolute inset-0 wallpaper-dither" />
<div
className="absolute inset-0 bg-black"
style={{ opacity: dim / 100 }}
/>
</div>
)
}
+2
View File
@@ -127,6 +127,8 @@ export const settings = pgTable("settings", {
.default("duckduckgo"),
// null = bundled default wallpaper
wallpaperUrl: text("wallpaper_url"),
// percent of black over the wallpaper, see DEFAULT_WALLPAPER_DIM
wallpaperDim: integer("wallpaper_dim").notNull().default(40),
// the big clock, see src/lib/clock.ts
clockFont: text("clock_font", {
enum: ["serif", "sans", "light", "rounded", "slab"],
+3
View File
@@ -2,6 +2,7 @@ import { createServerFn } from "@tanstack/react-start"
import { getRequestHeaders } from "@tanstack/react-start/server"
import { and, asc, eq, inArray, sql } from "drizzle-orm"
import { z } from "zod"
import { DEFAULT_WALLPAPER_DIM } from "@/components/wallpaper"
import { db } from "@/db"
import { card, link, settings, wallpaper } from "@/db/schema"
import { auth, requireUser, signUpEnabled, ssoName } from "@/lib/auth"
@@ -75,6 +76,7 @@ export const getDashboard = createServerFn({ method: "GET" }).handler(
title: s?.title ?? "Dahoam",
searchEngine: s?.searchEngine ?? "duckduckgo",
wallpaperUrl: s?.wallpaperUrl ?? null,
wallpaperDim: s?.wallpaperDim ?? DEFAULT_WALLPAPER_DIM,
clockFont: s?.clockFont ?? "serif",
clockStyle: s?.clockStyle ?? "solid",
searxngUrl: process.env.SEARXNG_URL || null,
@@ -190,6 +192,7 @@ export const saveSettings = createServerFn({ method: "POST" })
wallpaperUrl: z
.union([httpUrl, z.string().regex(/^\/api\/wallpaper\?v=\d+$/)])
.nullable(),
wallpaperDim: z.int().min(0).max(100),
clockFont: z.enum(CLOCK_FONTS),
clockStyle: z.enum(CLOCK_STYLES),
})
+1 -1
View File
@@ -44,7 +44,7 @@ function Dashboard() {
return (
<div className="relative isolate text-white">
<Wallpaper src={data.wallpaperUrl} />
<Wallpaper src={data.wallpaperUrl} dim={data.wallpaperDim} />
<main className="flex min-h-svh flex-col items-center px-4">
<header className="flex h-20 w-full max-w-[1200px] items-center gap-4 px-2 sm:px-8">
+54 -5
View File
@@ -92,6 +92,9 @@ function Settings() {
const file = useRef<HTMLInputElement>(null)
const [status, setStatus] = useState<"idle" | "saving" | "saved">("idle")
const [error, setError] = useState("")
// follows the slider at once, the save comes a moment later
const [dim, setDim] = useState(data.wallpaperDim)
const dimSave = useRef<ReturnType<typeof setTimeout>>(undefined)
// Every control saves on its own. `action` returns a message when it failed.
const run = async (action: () => Promise<string | void>) => {
@@ -106,6 +109,7 @@ function Settings() {
title?: string
searchEngine?: Engine
wallpaperUrl?: string | null
wallpaperDim?: number
clockFont?: ClockFont
clockStyle?: ClockStyle
}) => run(() => saveSettings({ data: patch }))
@@ -339,11 +343,18 @@ function Settings() {
</SettingsSectionHeader>
<SettingsRow stacked>
<div className="flex flex-wrap items-start gap-x-6 gap-y-4">
<img
src={data.wallpaperUrl ?? DEFAULT_WALLPAPER}
alt="Current wallpaper"
className="aspect-video w-60 flex-none rounded-xl border border-line object-cover"
/>
<div className="relative w-60 flex-none overflow-hidden rounded-xl border border-line">
<img
src={data.wallpaperUrl ?? DEFAULT_WALLPAPER}
alt="Current wallpaper"
className="aspect-video w-full object-cover"
/>
{/* as dark as on the dashboard */}
<div
className="absolute inset-0 bg-black"
style={{ opacity: dim / 100 }}
/>
</div>
<div className="flex min-w-0 flex-[1_1_260px] flex-col gap-3.5">
<Field>
<FieldLabel>Image address</FieldLabel>
@@ -407,6 +418,44 @@ function Settings() {
</div>
</div>
</SettingsRow>
<SettingsRow>
<SettingsRowText>
<SettingsRowLabel htmlFor="settings-dim">
Darken
</SettingsRowLabel>
<SettingsRowDescription>
How much the wallpaper is darkened, so that the text on it
stays readable.
</SettingsRowDescription>
</SettingsRowText>
<SettingsRowControl className="flex items-center gap-3">
<input
id="settings-dim"
type="range"
min={0}
max={100}
step={5}
value={dim}
onChange={(e) => {
const wallpaperDim = Number(e.target.value)
setDim(wallpaperDim)
// one save when the slider rests, not one per step
clearTimeout(dimSave.current)
dimSave.current = setTimeout(
() => save({ wallpaperDim }),
400
)
}}
className="w-48 accent-accent scheme-dark"
/>
<output
htmlFor="settings-dim"
className="w-10 text-right text-sm text-fg-subtle tabular-nums"
>
{dim}%
</output>
</SettingsRowControl>
</SettingsRow>
</SettingsSection>
<SettingsSection id="account" className={section}>
-16
View File
@@ -25,19 +25,3 @@
background: black;
}
}
/* Halftone dots plus a fade to black, as on the reference start page */
@utility wallpaper-dither {
background-image:
linear-gradient(
to bottom,
rgb(0 0 0 / 0.45),
rgb(0 0 0 / 0.25) 30%,
rgb(0 0 0 / 0.4) 65%,
rgb(0 0 0 / 0.95) 100%
),
radial-gradient(rgb(0 0 0 / 0.45) 1px, transparent 1.5px);
background-size:
auto,
4px 4px;
}