-
Notifications
You must be signed in to change notification settings - Fork 4
feat: message-input #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: message-input #144
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
85f959d
feat: message-input
grv-saini-20 20d2505
fix: classes merge and a files as a prop
grv-saini-20 10152e5
feat: variant added
grv-saini-20 bbfcfcf
feat: icon replaced
grv-saini-20 b2dc11f
fix: as per code rabbit suggestions
grv-saini-20 f3e0396
fix: icon
grv-saini-20 ac3e7cc
fix: input file button
grv-saini-20 530119d
fix: merge conflicts
grv-saini-20 aa0a7a6
fix: as per suggestion
grv-saini-20 a0c1b0e
fix: classes
grv-saini-20 8d18eb5
fix: no need of error and disabled classes
grv-saini-20 a741e78
fix: input
grv-saini-20 c333006
feat: invalid inputs
sosweetham 28b3869
merge: upstream
sosweetham 9c46831
feat: add number input storybook
sosweetham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
platforms/metagram/src/lib/fragments/MessageInput/MessageInput.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { ComponentProps } from 'svelte'; | ||
import MessageInput from './MessageInput.svelte'; | ||
|
||
export default { | ||
title: 'UI/MessageInput', | ||
component: MessageInput, | ||
tags: ['autodocs'], | ||
render: (args: { Component: MessageInput; props: ComponentProps<typeof MessageInput> }) => ({ | ||
Component: MessageInput, | ||
props: args | ||
}) | ||
}; | ||
|
||
export const Comment = { | ||
args: { | ||
variant: 'comment', | ||
placeholder: 'Write your comment', | ||
handleSend: () => alert('sent') | ||
} | ||
}; | ||
|
||
export const Dm = { | ||
args: { | ||
variant: 'dm', | ||
placeholder: 'Write your message', | ||
handleAdd: () => alert('add'), | ||
handleSend: () => alert('sent') | ||
} | ||
}; |
83 changes: 83 additions & 0 deletions
83
platforms/metagram/src/lib/fragments/MessageInput/MessageInput.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<script lang="ts"> | ||
import { Avatar, Input } from '$lib/ui'; | ||
import { cn } from '$lib/utils'; | ||
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons'; | ||
import { HugeiconsIcon } from '@hugeicons/svelte'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
|
||
interface IMessageInputProps extends HTMLAttributes<HTMLElement> { | ||
variant: 'comment' | 'dm'; | ||
src: string; | ||
value: string; | ||
placeholder?: string; | ||
files?: FileList | undefined; | ||
handleAdd?: () => void; | ||
handleSend: () => Promise<void>; | ||
} | ||
|
||
let { | ||
variant = 'comment', | ||
src = 'https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250', | ||
value, | ||
placeholder, | ||
files = $bindable(), | ||
handleAdd, | ||
handleSend, | ||
...restProps | ||
}: IMessageInputProps = $props(); | ||
|
||
let fileInput: HTMLInputElement | undefined = $state(); | ||
|
||
const cBase = 'flex items-center justify-between gap-2'; | ||
</script> | ||
|
||
<div {...restProps} class={cn([cBase, restProps.class].join(' '))}> | ||
{#if variant === 'comment'} | ||
<Avatar size="sm" {src} /> | ||
{:else} | ||
<!-- svelte-ignore a11y_click_events_have_key_events --> | ||
<!-- svelte-ignore a11y_no_static_element_interactions --> | ||
<button | ||
type="button" | ||
class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full border-0 p-0" | ||
onclick={handleAdd} | ||
aria-label="Add attachment" | ||
> | ||
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" /> | ||
</button> | ||
{/if} | ||
<Input type="text" bind:value {placeholder} /> | ||
{#if value || variant === 'dm'} | ||
<!-- svelte-ignore a11y_click_events_have_key_events --> | ||
<!-- svelte-ignore a11y_no_static_element_interactions --> | ||
<div | ||
class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full" | ||
onclick={handleSend} | ||
> | ||
<HugeiconsIcon size="24px" icon={SentIcon} color="var(--color-black-400)" /> | ||
</div> | ||
{:else} | ||
<div class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full"> | ||
<input | ||
id="add-image" | ||
type="file" | ||
class="hidden" | ||
accept="image/*" | ||
bind:files | ||
bind:this={fileInput} | ||
/> | ||
<button | ||
type="button" | ||
class="bg-grey flex aspect-square h-13 w-13 items-center justify-center rounded-full border-0 p-0" | ||
aria-label="add-image" | ||
onclick={() => fileInput?.click()} | ||
> | ||
<HugeiconsIcon | ||
size="24px" | ||
icon={ImageCompositionOvalIcon} | ||
color="var(--color-black-400)" | ||
/> | ||
</button> | ||
</div> | ||
{/if} | ||
</div> |
67 changes: 32 additions & 35 deletions
67
platforms/metagram/src/lib/fragments/Post/Post.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,38 @@ | ||
import type { ComponentProps } from "svelte"; | ||
import Post from "./Post.svelte"; | ||
import type { ComponentProps } from 'svelte'; | ||
import Post from './Post.svelte'; | ||
|
||
export default { | ||
title: "Fragments/Post", | ||
component: Post, | ||
tags: ["autodocs"], | ||
render: (args: { | ||
Component: Post; | ||
props: ComponentProps<typeof Post>; | ||
}) => ({ | ||
Component: Post, | ||
props: args, | ||
}), | ||
title: 'Fragments/Post', | ||
component: Post, | ||
tags: ['autodocs'], | ||
render: (args: { Component: Post; props: ComponentProps<typeof Post> }) => ({ | ||
Component: Post, | ||
props: args | ||
}) | ||
}; | ||
|
||
export const Primary = { | ||
args: { | ||
avatar: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250", | ||
username: "blurryface", | ||
imgUri: "https://graphicsfamily.com/wp-content/uploads/edd/2023/01/Free-Photographer-Social-Media-Post-Design-Template-870x870.jpg", | ||
postAlt: "Sample", | ||
text: "Took some pictures today! Really love how this one in particular turned out! ", | ||
time: "2 hours ago", | ||
count: { | ||
likes: 100, | ||
comments: 50, | ||
}, | ||
callback: { | ||
like: () => { | ||
alert("Like clicked"); | ||
}, | ||
comment: () => { | ||
alert("Comment clicked"); | ||
}, | ||
menu: () => { | ||
alert("Menu clicked"); | ||
}, | ||
}, | ||
}, | ||
args: { | ||
avatar: 'https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250', | ||
username: 'blurryface', | ||
imgUri: 'https://graphicsfamily.com/wp-content/uploads/edd/2023/01/Free-Photographer-Social-Media-Post-Design-Template-870x870.jpg', | ||
postAlt: 'Sample', | ||
text: 'Took some pictures today! Really love how this one in particular turned out! ', | ||
time: '2 hours ago', | ||
count: { | ||
likes: 100, | ||
comments: 50 | ||
}, | ||
callback: { | ||
like: () => { | ||
alert('Like clicked'); | ||
}, | ||
comment: () => { | ||
alert('Comment clicked'); | ||
}, | ||
menu: () => { | ||
alert('Menu clicked'); | ||
} | ||
} | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as BottomNav } from './BottomNav/BottomNav.svelte'; | ||
export { default as SettingsNavigationButton } from './SettingsNavigationButton/SettingsNavigationButton.svelte'; | ||
export { default as MessageInput } from './MessageInput/MessageInput.svelte'; | ||
export { default as InputFile } from './InputFile/InputFile.svelte'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.