-
Notifications
You must be signed in to change notification settings - Fork 4
feat: messages #174
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: messages #174
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ff3ce93
feat: messages
grv-saini-20 271b7a8
feat: ChatMessae
grv-saini-20 edaf143
feat: messages by id
grv-saini-20 9063fdb
fix: messages page
grv-saini-20 1b68184
fix: merge conflicts
grv-saini-20 7f6cc93
fix: icon name
grv-saini-20 f185544
fix: hide bottom nav for chat
grv-saini-20 f19342c
fix: header
grv-saini-20 d043b88
fix: message bubble
grv-saini-20 10f0fdf
fix: message bubble
grv-saini-20 c601232
fix: message bubble
grv-saini-20 3d77da0
fix: as per suggestion
grv-saini-20 b913a12
fix: messaging
grv-saini-20 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
42 changes: 42 additions & 0 deletions
42
platforms/metagram/src/lib/fragments/ChatMessage/ChatMessage.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,42 @@ | ||
import type { ComponentProps } from 'svelte'; | ||
import { ChatMessage } from '..'; | ||
|
||
export default { | ||
title: 'UI/ChatMessage', | ||
component: ChatMessage, | ||
tags: ['autodocs'], | ||
render: (args: { Component: ChatMessage; props: ComponentProps<typeof ChatMessage> }) => ({ | ||
Component: ChatMessage, | ||
props: args | ||
}) | ||
}; | ||
|
||
export const Outgoing = { | ||
args: { | ||
transactionType: 'outgoing' | ||
} | ||
}; | ||
|
||
export const Incoming = { | ||
args: { | ||
transactionType: 'incoming', | ||
message: | ||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed voluptatem accusantium voluptas vel, libero minus veniam at! Doloribus autem, id, ipsum laudantium dolor blanditiis nulla eum eveniet illo perspiciatis iusto.Voluptas ea pariatur eveniet quidem incidunt vitae sunt, hic labore nisi officiis consectetur autem odio repellendus nesciunt quisquam alias consequatur corrupti quaerat, minus qui. Obcaecati deleniti optio quod quibusdam placeat.' | ||
} | ||
}; | ||
|
||
export const OutgoingWithoutHead = { | ||
args: { | ||
transactionType: 'outgoing', | ||
isHeadNeeded: false | ||
} | ||
}; | ||
|
||
export const WithoutHead = { | ||
args: { | ||
transactionType: 'incoming', | ||
isHeadNeeded: false, | ||
message: | ||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed voluptatem accusantium voluptas vel, libero minus veniam at! Doloribus autem, id, ipsum laudantium dolor blanditiis nulla eum eveniet illo perspiciatis iusto.Voluptas ea pariatur eveniet quidem incidunt vitae sunt, hic labore nisi officiis consectetur autem odio repellendus nesciunt quisquam alias consequatur corrupti quaerat, minus qui. Obcaecati deleniti optio quod quibusdam placeat.' | ||
} | ||
}; |
78 changes: 78 additions & 0 deletions
78
platforms/metagram/src/lib/fragments/ChatMessage/ChatMessage.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,78 @@ | ||
<script lang="ts"> | ||
import { Avatar } from '$lib/ui'; | ||
import { cn } from '$lib/utils'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
interface IChatMessageProps extends HTMLAttributes<HTMLElement> { | ||
userImgSrc: string; | ||
message: string; | ||
time: string; | ||
transactionType: 'incoming' | 'outgoing'; | ||
isHeadNeeded?: boolean; | ||
} | ||
let { | ||
userImgSrc = 'https://picsum.photos/id/237/200/300', | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
message = 'i was thinking maybe like 12th?', | ||
time = '12:55 AM', | ||
transactionType = 'incoming', | ||
isHeadNeeded = true, | ||
...restProps | ||
}: IChatMessageProps = $props(); | ||
</script> | ||
|
||
<div | ||
{...restProps} | ||
class={cn( | ||
[ | ||
`flex items-start gap-2 ${transactionType === 'incoming' ? 'flex-row-reverse' : 'flex'}`, | ||
restProps.class | ||
].join(' ') | ||
)} | ||
> | ||
<div class="w-8 flex-shrink-0"> | ||
{#if isHeadNeeded} | ||
<Avatar size="xs" src={userImgSrc} /> | ||
{/if} | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
|
||
<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}> | ||
<div | ||
class={cn( | ||
`relative rounded-3xl px-4 py-2 ${transactionType === 'incoming' ? 'bg-brand-burnt-orange' : 'bg-grey'}` | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
)} | ||
> | ||
{#if isHeadNeeded} | ||
<svg | ||
class={`absolute ${transactionType === 'outgoing' ? 'start-[-5px] top-[-2px]' : 'end-[-5px] top-[2px]'}`} | ||
width="22" | ||
height="17" | ||
viewBox="0 0 22 17" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M0 0C5.79116 4.95613 8.40437 9.60298 10 17L22 2C11 2.5 7.53377 0.634763 0 0Z" | ||
fill={transactionType === 'outgoing' | ||
? '#F5F5F5' | ||
: 'var(--color-brand-burnt-orange)'} | ||
/> | ||
</svg> | ||
{/if} | ||
|
||
<p class={cn(`${transactionType === 'incoming' ? 'text-white' : 'text-black-600'}`)}> | ||
{message} | ||
</p> | ||
</div> | ||
|
||
<p | ||
class={cn( | ||
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${ | ||
transactionType === 'incoming' ? 'justify-end' : 'justify-start' | ||
}` | ||
)} | ||
> | ||
{time} | ||
</p> | ||
</div> | ||
</div> |
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
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
2 changes: 1 addition & 1 deletion
2
...rms/metagram/src/lib/icons/Comment.svelte → ...metagram/src/lib/icons/CommentIcon.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
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ export const isNavigatingThroughNav = $state({ | |
|
||
export const showComments = $state({ | ||
value: false | ||
}); | ||
}); |
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
27 changes: 27 additions & 0 deletions
27
platforms/metagram/src/routes/(protected)/messages/+page.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 |
---|---|---|
@@ -1,2 +1,29 @@ | ||
<script lang="ts"> | ||
import { goto } from '$app/navigation'; | ||
import { Message } from '$lib/fragments'; | ||
import { Input } from '$lib/ui'; | ||
|
||
let searchValue = $state(''); | ||
</script> | ||
|
||
<section> | ||
<Input type="text" bind:value={searchValue} placeholder="Search Messages" class="my-6" /> | ||
{#each { length: 6 } as _, i} | ||
<Message | ||
class="mb-6" | ||
avatar="https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250" | ||
username="donaldthefirstt" | ||
text="i was thinking of making it to the conference so we could take some more fire pictures like last time" | ||
unread={false} | ||
callback={() => goto(`/messages/${i}`)} | ||
/> | ||
<Message | ||
class="mb-6" | ||
avatar="https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250" | ||
username="donaldthefirstt" | ||
text="i was thinking of making it to the conference so we could take some more fire pictures like last time" | ||
unread={true} | ||
callback={() => goto(`/messages/${i}`)} | ||
/> | ||
{/each} | ||
</section> |
Oops, something went wrong.
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.