feat: several dashboards with a default, icon search and icon upload
Dashboards are separate sets of cards (Home, Work). Settings manages them and sets the one that opens at sign-in, the header and the search bar switch. Migration 0006 puts the existing cards on a dashboard "Home". The link dialog searches dashboard-icons and uploads custom icons (/api/icon, up to 1 MB, SVG served sandboxed). Wallpaper and icons share the upload checks.
This commit is contained in:
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react"
|
||||
import { useSortable } from "@dnd-kit/sortable"
|
||||
import { CSS } from "@dnd-kit/utilities"
|
||||
import { Pencil } from "lucide-react"
|
||||
import { iconSources } from "@/lib/icons"
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
export type HomeLink = {
|
||||
@@ -12,21 +13,6 @@ export type HomeLink = {
|
||||
icon: string | null
|
||||
}
|
||||
|
||||
const dashboardIcon = (name: string) =>
|
||||
`https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/${name
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "")}.png`
|
||||
|
||||
/** Icon sources to try in order; the letter tile is the last resort. */
|
||||
function iconSources({ name, url, icon }: HomeLink) {
|
||||
return [
|
||||
icon && /^https?:\/\//.test(icon) ? icon : dashboardIcon(icon || name),
|
||||
`${new URL(url).origin}/favicon.ico`,
|
||||
]
|
||||
}
|
||||
|
||||
type IconProps = { link: HomeLink; className?: string }
|
||||
|
||||
/** Starts the fallback chain again when the link changes. */
|
||||
|
||||
Reference in New Issue
Block a user