toot medias: extract color from blurhash
All checks were successful
/ depoly (push) Successful in 1m17s

This commit is contained in:
thislight 2024-11-11 16:53:34 +08:00
parent c372ea4a92
commit 2aa2cf21da
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
5 changed files with 226 additions and 40 deletions

View file

@ -20,6 +20,7 @@ import {
} from "@solid-primitives/resize-observer";
import { useStore } from "@nanostores/solid";
import { $settings } from "../settings/stores";
import { averageColorHex } from "../platform/blurhash";
type ElementSize = { width: number; height: number };
@ -120,7 +121,9 @@ const MediaAttachmentGrid: Component<{
// we may need better tool to manage the performance impact
// before using this. See #37.
// TODO: use fast average color to extract accent color
const accentColor = item.meta?.colors?.accent;
const accentColor =
item.meta?.colors?.accent ??
(item.blurhash ? averageColorHex(item.blurhash) : undefined);
return Object.assign(
{