Add vibrant color into media card title
This commit is contained in:
15
app/composables/useVibrantColor.ts
Normal file
15
app/composables/useVibrantColor.ts
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user