Add vibrant color into media card title

This commit is contained in:
2026-01-16 08:15:19 +05:00
parent 1d56d8ed5d
commit 3289a71e8b
7 changed files with 235 additions and 6 deletions

View File

@ -0,0 +1,15 @@
import type { Palette } from "@vibrant/color";
import { Vibrant } from "node-vibrant/browser";
export const useVibrantPalette = (imageRef: Ref) => {
if (import.meta.server) {
return ref<Palette | null>(null);
}
return computedAsync(async () => {
if (!imageRef.value?.$el) return null;
const vibrant = Vibrant.from(imageRef.value.$el);
const palette = await vibrant.getPalette();
return palette || null;
}, null);
};