Skip to content

Commit 33e2185

Browse files
committed
fix: target prop to Avatar and Badge
1 parent 81b3d1b commit 33e2185

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

.changeset/thick-clocks-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-5-ui-lib": patch
3+
---
4+
5+
fix: target prop to Avatar and Badge

src/lib/avatar/Avatar.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Indicator } from "$lib";
33
import { type AvatarProps as Props, avatar } from ".";
44
5-
let { children, src, href, cornerStyle = "circular", border = false, stacked = false, dot, class: className, alt, size = "md", onclick, ...restProps }: Props = $props();
5+
let { children, src, href, target, cornerStyle = "circular", border = false, stacked = false, dot, class: className, alt, size = "md", onclick, ...restProps }: Props = $props();
66
77
dot = dot && { placement: "top-right", color: "gray", size: "lg", ...dot };
88
@@ -18,7 +18,7 @@
1818
</script>
1919

2020
{#if !src || !!href || children || dot}
21-
<svelte:element this={href ? "a" : "div"} role={href ? "link" : "img"} {onclick} {href} {...restProps} class={avatarClass}>
21+
<svelte:element this={href ? "a" : "div"} role={href ? "link" : "img"} {onclick} {href} {target} {...restProps} class={avatarClass}>
2222
{#if src}
2323
<img {alt} {src} class={cornerStyle === "circular" ? "rounded-full" : "rounded"} />
2424
{:else if children}

src/lib/avatar/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { Snippet } from "svelte";
2-
import type { HTMLAttributes } from "svelte/elements";
2+
import type { HTMLAttributes, HTMLAnchorAttributes } from "svelte/elements";
33
import Avatar from "./Avatar.svelte";
44
import { avatar } from "./theme";
55

66
interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
77
children?: Snippet;
8-
href?: string;
8+
href?: HTMLAnchorAttributes["href"];
9+
target?: HTMLAnchorAttributes["target"];
910
src?: string;
1011
cornerStyle?: "rounded" | "circular";
1112
stacked?: boolean;

src/lib/badge/Badge.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { fade } from "svelte/transition";
55
import type { ParamsType } from "$lib/types";
66
7-
let { children, icon, badgeStatus = $bindable(true), color = "primary", large = false, dismissable = false, class: className, border, href, rounded, transition = fade, params, aClass, onclick, ...restProps }: Props = $props();
7+
let { children, icon, badgeStatus = $bindable(true), color = "primary", large = false, dismissable = false, class: className, border, href, target, rounded, transition = fade, params, aClass, onclick, ...restProps }: Props = $props();
88
99
const { base, hrefClass } = $derived(badge({ color, size: large ? "large" : "small", border, rounded }));
1010
// $inspect('badgeStatus: ', badgeStatus);
@@ -13,7 +13,7 @@
1313
{#if badgeStatus}
1414
<div {...restProps} transition:transition={params as ParamsType} class={base({ className })}>
1515
{#if href}
16-
<a {href} class={hrefClass({ class: aClass })}>
16+
<a {href} {target} class={hrefClass({ class: aClass })}>
1717
{@render children()}
1818
</a>
1919
{:else}

src/lib/badge/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Snippet } from "svelte";
22
import type { ParamsType, TransitionFunc } from "../types";
3-
import type { HTMLAttributes } from "svelte/elements";
3+
import type { HTMLAttributes, HTMLAnchorAttributes } from "svelte/elements";
44
import Badge from "./Badge.svelte";
55
import { badge } from "./theme";
66

@@ -14,7 +14,8 @@ interface BadgeProps extends HTMLAttributes<HTMLDivElement> {
1414
large?: boolean;
1515
dismissable?: boolean;
1616
border?: boolean;
17-
href?: string;
17+
href?: HTMLAnchorAttributes["href"];
18+
target?: HTMLAnchorAttributes["target"];
1819
rounded?: boolean;
1920
transition?: TransitionFunc;
2021
params?: ParamsType;

0 commit comments

Comments
 (0)