2025-06-08 16:32:41 +02:00
|
|
|
<script lang="ts" module>
|
|
|
|
|
import { type VariantProps, tv } from "tailwind-variants";
|
|
|
|
|
|
|
|
|
|
export const alertVariants = tv({
|
|
|
|
|
base: "[&>svg]:text-foreground relative w-full rounded-lg border p-4 [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg~*]:pl-7",
|
|
|
|
|
variants: {
|
|
|
|
|
variant: {
|
|
|
|
|
default: "bg-background text-foreground",
|
|
|
|
|
destructive:
|
|
|
|
|
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
defaultVariants: {
|
|
|
|
|
variant: "default",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type AlertVariant = VariantProps<typeof alertVariants>["variant"];
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-04-22 19:36:31 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type { HTMLAttributes } from "svelte/elements";
|
2025-06-08 16:32:41 +02:00
|
|
|
import type { WithElementRef } from "bits-ui";
|
2024-04-22 19:36:31 +02:00
|
|
|
import { cn } from "$lib/utils.js";
|
|
|
|
|
|
2025-06-08 16:32:41 +02:00
|
|
|
let {
|
|
|
|
|
ref = $bindable(null),
|
|
|
|
|
class: className,
|
|
|
|
|
variant = "default",
|
|
|
|
|
children,
|
|
|
|
|
...restProps
|
|
|
|
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
|
|
|
variant?: AlertVariant;
|
|
|
|
|
} = $props();
|
2024-04-22 19:36:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-06-08 16:32:41 +02:00
|
|
|
<div bind:this={ref} class={cn(alertVariants({ variant }), className)} {...restProps} role="alert">
|
|
|
|
|
{@render children?.()}
|
2024-04-22 19:36:31 +02:00
|
|
|
</div>
|