feat: a slider darkens the wallpaper, the dots and the fade are gone
This commit is contained in:
@@ -65,7 +65,7 @@ Build it yourself: `docker build -t dahoam .`
|
||||
- **Search**: `/` focuses the bar. `!w cats` uses DuckDuckGo bangs. `/plex` jumps to
|
||||
a link, `/settings`, `/add link`, `/add card` and `/sign out` run commands.
|
||||
- **Wallpaper**: Settings (or the pencil at the bottom right) takes an image URL or an
|
||||
upload (JPEG, PNG, WebP, AVIF, up to 10 MB).
|
||||
upload (JPEG, PNG, WebP, AVIF, up to 10 MB). A slider sets how much it is darkened.
|
||||
- **Clock**: Settings has five fonts and three styles. Glass shows the wallpaper blurred
|
||||
through the digits, Tinted takes its color from the wallpaper.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "settings" ADD COLUMN "wallpaper_dim" integer DEFAULT 40 NOT NULL;
|
||||
@@ -0,0 +1,686 @@
|
||||
{
|
||||
"id": "4df576be-2fef-462c-affd-4aff0ab26918",
|
||||
"prevId": "ac3af713-2f43-44c7-8e48-d840cfee12c0",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
"public.account": {
|
||||
"name": "account",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"account_id": {
|
||||
"name": "account_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"provider_id": {
|
||||
"name": "provider_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"access_token": {
|
||||
"name": "access_token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"refresh_token": {
|
||||
"name": "refresh_token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"id_token": {
|
||||
"name": "id_token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"access_token_expires_at": {
|
||||
"name": "access_token_expires_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"refresh_token_expires_at": {
|
||||
"name": "refresh_token_expires_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"scope": {
|
||||
"name": "scope",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"password": {
|
||||
"name": "password",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"account_user_id_idx": {
|
||||
"name": "account_user_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"account_user_id_user_id_fk": {
|
||||
"name": "account_user_id_user_id_fk",
|
||||
"tableFrom": "account",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.card": {
|
||||
"name": "card",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"card_user_id_idx": {
|
||||
"name": "card_user_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"card_user_id_user_id_fk": {
|
||||
"name": "card_user_id_user_id_fk",
|
||||
"tableFrom": "card",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.link": {
|
||||
"name": "link",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"card_id": {
|
||||
"name": "card_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"position": {
|
||||
"name": "position",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"url": {
|
||||
"name": "url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"icon": {
|
||||
"name": "icon",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"link_user_id_idx": {
|
||||
"name": "link_user_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"link_card_id_idx": {
|
||||
"name": "link_card_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "card_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"link_user_id_user_id_fk": {
|
||||
"name": "link_user_id_user_id_fk",
|
||||
"tableFrom": "link",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"link_card_id_card_id_fk": {
|
||||
"name": "link_card_id_card_id_fk",
|
||||
"tableFrom": "link",
|
||||
"tableTo": "card",
|
||||
"columnsFrom": [
|
||||
"card_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.session": {
|
||||
"name": "session",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"expires_at": {
|
||||
"name": "expires_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"token": {
|
||||
"name": "token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"ip_address": {
|
||||
"name": "ip_address",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"user_agent": {
|
||||
"name": "user_agent",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"session_user_id_idx": {
|
||||
"name": "session_user_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"session_user_id_user_id_fk": {
|
||||
"name": "session_user_id_user_id_fk",
|
||||
"tableFrom": "session",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"session_token_unique": {
|
||||
"name": "session_token_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"token"
|
||||
]
|
||||
}
|
||||
},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.settings": {
|
||||
"name": "settings",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'Dahoam'"
|
||||
},
|
||||
"search_engine": {
|
||||
"name": "search_engine",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'duckduckgo'"
|
||||
},
|
||||
"wallpaper_url": {
|
||||
"name": "wallpaper_url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"wallpaper_dim": {
|
||||
"name": "wallpaper_dim",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 40
|
||||
},
|
||||
"clock_font": {
|
||||
"name": "clock_font",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'serif'"
|
||||
},
|
||||
"clock_style": {
|
||||
"name": "clock_style",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'solid'"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"settings_user_id_user_id_fk": {
|
||||
"name": "settings_user_id_user_id_fk",
|
||||
"tableFrom": "settings",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.user": {
|
||||
"name": "user",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"email_verified": {
|
||||
"name": "email_verified",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"image": {
|
||||
"name": "image",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"user_email_unique": {
|
||||
"name": "user_email_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"email"
|
||||
]
|
||||
}
|
||||
},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.verification": {
|
||||
"name": "verification",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"identifier": {
|
||||
"name": "identifier",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"value": {
|
||||
"name": "value",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"expires_at": {
|
||||
"name": "expires_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"verification_identifier_idx": {
|
||||
"name": "verification_identifier_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "identifier",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.wallpaper": {
|
||||
"name": "wallpaper",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"mime": {
|
||||
"name": "mime",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"data": {
|
||||
"name": "data",
|
||||
"type": "bytea",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"wallpaper_user_id_user_id_fk": {
|
||||
"name": "wallpaper_user_id_user_id_fk",
|
||||
"tableFrom": "wallpaper",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"sequences": {},
|
||||
"roles": {},
|
||||
"policies": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,13 @@
|
||||
"when": 1795017311884,
|
||||
"tag": "0004_clock",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "7",
|
||||
"when": 1795017884385,
|
||||
"tag": "0005_wallpaper_dim",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -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),
|
||||
})
|
||||
|
||||
@@ -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
@@ -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}>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user