This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { mergeProps } from "svelte-toolbelt";
|
||||
import type { ArrowProps } from "./types.js";
|
||||
import { useId } from "../../../internal/use-id.js";
|
||||
|
||||
let {
|
||||
id = useId(),
|
||||
children,
|
||||
child,
|
||||
width = 10,
|
||||
height = 5,
|
||||
...restProps
|
||||
}: ArrowProps = $props();
|
||||
|
||||
const mergedProps = $derived(mergeProps(restProps, { id }));
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps })}
|
||||
{:else}
|
||||
<span {...mergedProps}>
|
||||
{#if children}
|
||||
{@render children?.()}
|
||||
{:else}
|
||||
<svg {width} {height} viewBox="0 0 30 10" preserveAspectRatio="none" data-arrow="">
|
||||
<polygon points="0,0 30,0 15,10" fill="currentColor" />
|
||||
</svg>
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { ArrowProps } from "./types.js";
|
||||
declare const Arrow: import("svelte").Component<ArrowProps, {}, "">;
|
||||
type Arrow = ReturnType<typeof Arrow>;
|
||||
export default Arrow;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default as Arrow } from "./arrow.svelte";
|
||||
export type { ArrowProps } from "./types.js";
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { default as Arrow } from "./arrow.svelte";
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import type { WithChild } from "../../../internal/types.js";
|
||||
import type { BitsPrimitiveSpanAttributes } from "../../../shared/attributes.js";
|
||||
export type ArrowPropsWithoutHTML = WithChild<{
|
||||
/**
|
||||
* The width of the arrow in pixels.
|
||||
*
|
||||
* @defaultValue 10
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* The height of the arrow in pixels.
|
||||
*
|
||||
* @defaultValue 5
|
||||
*/
|
||||
height?: number;
|
||||
}>;
|
||||
export type ArrowProps = ArrowPropsWithoutHTML & BitsPrimitiveSpanAttributes;
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user