Skip to content

Commit 10152e5

Browse files
committed
feat: variant added
1 parent 20d2505 commit 10152e5

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

platforms/metagram/src/lib/fragments/MessageInput/MessageInput.stories.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@ export default {
1111
})
1212
};
1313

14-
export const Primary = {
14+
export const Comment = {
1515
args: {
16-
placeholder: 'Write your message'
16+
variant: 'comment',
17+
placeholder: 'Write your comment',
18+
handleSend: () => alert('sent')
19+
}
20+
};
21+
22+
export const Dm = {
23+
args: {
24+
variant: 'dm',
25+
placeholder: 'Write your message',
26+
handleAdd: () => alert('add'),
27+
handleSend: () => alert('sent')
1728
}
1829
};
Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,63 @@
11
<script lang="ts">
22
import { Avatar, Input } from '$lib/ui';
33
import { cn } from '$lib/utils';
4-
import { ImageAdd02Icon } from '@hugeicons/core-free-icons';
4+
import { ImageAdd02Icon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
55
import { HugeiconsIcon } from '@hugeicons/svelte';
66
import type { HTMLAttributes } from 'svelte/elements';
77
88
interface IMessageInputProps extends HTMLAttributes<HTMLElement> {
9+
variant: 'comment' | 'dm';
910
src: string;
1011
value: string;
1112
placeholder?: string;
1213
files?: FileList | undefined;
14+
handleAdd?: () => void;
15+
handleSend: () => Promise<void>;
1316
}
1417
1518
let {
19+
variant = 'comment',
1620
src = 'https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250',
1721
value,
1822
placeholder,
1923
files = $bindable(),
24+
handleAdd,
25+
handleSend,
2026
...restProps
2127
}: IMessageInputProps = $props();
2228
2329
const cBase = 'flex items-center justify-between gap-2';
2430
</script>
2531

2632
<div {...restProps} class={cn([cBase, restProps.class].join(' '))}>
27-
<Avatar size="sm" {src} />
33+
{#if variant === 'comment'}
34+
<Avatar size="sm" {src} />
35+
{:else}
36+
<!-- svelte-ignore a11y_click_events_have_key_events -->
37+
<!-- svelte-ignore a11y_no_static_element_interactions -->
38+
<div
39+
class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full"
40+
onclick={handleAdd}
41+
>
42+
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
43+
</div>
44+
{/if}
2845
<Input type="text" bind:value {placeholder} />
29-
<div class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full">
30-
<input id="add-image" type="file" class="hidden" accept="image/*" bind:files />
31-
<label for="add-image">
32-
<HugeiconsIcon size="24px" icon={ImageAdd02Icon} color="var(--color-black-400)" />
33-
</label>
34-
</div>
46+
{#if value || variant === 'dm'}
47+
<!-- svelte-ignore a11y_click_events_have_key_events -->
48+
<!-- svelte-ignore a11y_no_static_element_interactions -->
49+
<div
50+
class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full"
51+
onclick={handleSend}
52+
>
53+
<HugeiconsIcon size="24px" icon={SentIcon} color="var(--color-black-400)" />
54+
</div>
55+
{:else}
56+
<div class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full">
57+
<input id="add-image" type="file" class="hidden" accept="image/*" bind:files />
58+
<label for="add-image">
59+
<HugeiconsIcon size="24px" icon={ImageAdd02Icon} color="var(--color-black-400)" />
60+
</label>
61+
</div>
62+
{/if}
3563
</div>

0 commit comments

Comments
 (0)