From aa14ca6782f7043b8401c3eabb3c6c4f4f99ea70 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 26 Dec 2025 18:51:48 +0100 Subject: [PATCH] Lib: Add options to Card component to further customize the header image appearance --- src/lib/components/cards/Card.svelte | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/components/cards/Card.svelte b/src/lib/components/cards/Card.svelte index 7c4d2fb..1cd3342 100644 --- a/src/lib/components/cards/Card.svelte +++ b/src/lib/components/cards/Card.svelte @@ -2,8 +2,9 @@ import type { Snippet } from "svelte"; import { LazyImage } from "$lib/components"; import { error } from "@sveltejs/kit"; + import type { HTMLAttributes } from "svelte/elements"; - interface CardProps { + interface CardProps extends HTMLAttributes { children: Snippet; /** The URL for a possible header image. Leave undefined for no header image. Set to empty string for an image not yet loaded. */ @@ -24,6 +25,15 @@ /** If the header image is positioned at the left of the card */ imgleft?: boolean; + /** If the header image has a shadow */ + imgshadow?: boolean; + + /** Extra classes to pass to the card header image */ + extraimgclass?: string; + + /** Extra classes to pass to the card content div */ + extraclass?: string; + /** The width class for the card, defaults to [w-auto] */ width?: string; @@ -39,6 +49,9 @@ imgid = undefined, imghidden = false, imgleft = false, + imgshadow = true, + extraimgclass = "", + extraclass = "", width = "w-auto", imgonclick = undefined, ...restProps @@ -57,7 +70,7 @@ src={imgsrc} alt="Card header" draggable="false" - class="select-none shadow" + class="select-none {imgshadow ? 'shadow' : ''} {extraimgclass}" hidden={imghidden} imgwidth={imgwidth ?? 0} imgheight={imgheight ?? 0} @@ -65,7 +78,7 @@ /> {/if} -
+
{@render children()}