Initial commit: Hermes Chat App with Svelte 5 + shadcn-svelte
This commit is contained in:
18
src/lib/components/ui/avatar/avatar-fallback.svelte
Normal file
18
src/lib/components/ui/avatar/avatar-fallback.svelte
Normal file
@@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { cn } from "$lib/utils.js";
|
||||
import type { HTMLSpanAttributes } from "svelte/elements";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let { class: className = "", delayMs = 0, children, ...rest }: HTMLSpanAttributes & { delayMs?: number } = $props();
|
||||
let visible = $state(false);
|
||||
|
||||
onMount(() => {
|
||||
const timer = setTimeout(() => { visible = true; }, delayMs);
|
||||
return () => clearTimeout(timer);
|
||||
});
|
||||
</script>
|
||||
{#if visible}
|
||||
<span class={cn("flex h-full w-full items-center justify-center rounded-full bg-muted text-xs font-medium", className)} {...rest}>
|
||||
{@render children?.()}
|
||||
</span>
|
||||
{/if}
|
||||
7
src/lib/components/ui/avatar/avatar-image.svelte
Normal file
7
src/lib/components/ui/avatar/avatar-image.svelte
Normal file
@@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { cn } from "$lib/utils.js";
|
||||
import type { HTMLImgAttributes } from "svelte/elements";
|
||||
|
||||
let { class: className = "", ...rest }: HTMLImgAttributes = $props();
|
||||
</script>
|
||||
<img class={cn("aspect-square h-full w-full", className)} {...rest} />
|
||||
9
src/lib/components/ui/avatar/avatar.svelte
Normal file
9
src/lib/components/ui/avatar/avatar.svelte
Normal file
@@ -0,0 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { cn } from "$lib/utils.js";
|
||||
import type { HTMLAttributes } from "svelte/elements";
|
||||
|
||||
let { class: className = "", children, ...rest }: HTMLAttributes<HTMLDivElement> = $props();
|
||||
</script>
|
||||
<div class={cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className)} {...rest}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
3
src/lib/components/ui/avatar/index.ts
Normal file
3
src/lib/components/ui/avatar/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { default as Avatar } from "./avatar.svelte";
|
||||
export { default as AvatarImage } from "./avatar-image.svelte";
|
||||
export { default as AvatarFallback } from "./avatar-fallback.svelte";
|
||||
Reference in New Issue
Block a user