Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff 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: {
isOwn: true
}
};

export const Incoming = {
args: {
isOwn: 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.'
}
};

export const OutgoingWithoutHead = {
args: {
isOwn: true,
isHeadNeeded: false
}
};

export const WithoutHead = {
args: {
isOwn: false,
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.'
}
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
<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;
isOwn: boolean;
isHeadNeeded?: boolean;
}

let {
userImgSrc = 'https://picsum.photos/id/237/200/300',
Comment thread
This conversation was marked as resolved.
message = 'i was thinking maybe like 12th?',
time = '12:55 AM',
isOwn,
isHeadNeeded = true,
...restProps
}: IChatMessageProps = $props();
</script>

<div
{...restProps}
class={cn(
[`flex items-start gap-2 ${isOwn ? 'flex' : 'flex-row-reverse'}`, restProps.class].join(' ')
Comment thread
This conversation was marked as resolved.
)}
>
<div class="w-8 flex-shrink-0">
{#if isHeadNeeded}
<Avatar size="xs" src={userImgSrc} />
{/if}
Comment thread
This conversation was marked as resolved.
</div>

<div class={cn(`max-w-[50%] ${isHeadNeeded ? 'mt-4' : 'mt-0'}`)}>
<div
class={cn(
`relative rounded-3xl px-4 py-2 ${isOwn ? 'bg-grey' : 'bg-brand-burnt-orange'}`
)}
>
{#if isHeadNeeded}
<svg
class={`absolute ${isOwn ? '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={isOwn ? '#F5F5F5' : 'var(--color-brand-burnt-orange)'}
/>
</svg>
{/if}

<p class={cn(`${!isOwn ? 'text-white' : 'text-black-600'}`)}>
{message}
</p>
</div>

<p
class={cn(
`subtext text-black-400 mt-0.5 flex text-xs text-nowrap ${
isOwn ? 'justify-end' : 'justify-start'
}`
)}
>
{time}
</p>
</div>
</div>
8 changes: 6 additions & 2 deletions platforms/metagram/src/lib/fragments/Header/Header.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,16 @@
} from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';
import ActionMenu from '../ActionMenu/ActionMenu.svelte';

interface IHeaderProps extends HTMLAttributes<HTMLElement> {
variant: 'primary' | 'secondary' | 'tertiary';
heading?: string;
callback?: () => void;
options?: { name: string; handler: () => void }[];
}

const { variant, callback, heading, ...restProps }: IHeaderProps = $props();
const { variant, callback, heading, options, ...restProps }: IHeaderProps = $props();

const variantClasses = {
primary: {
Expand DownExpand Up@@ -45,7 +47,7 @@

const classes = $derived({
common: cn(
'flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
'w-full flex items-center justify-between my-4 pb-6 border-b-[1px] md:border-0 border-grey'
),
text: variantClasses[variant].text,
background: variantClasses[variant].background
Expand DownExpand Up@@ -86,6 +88,8 @@
>
<HugeiconsIcon icon={menuButton[variant]} size={24} color="var(--color-black-500)" />
</button>
{:else if variant === 'secondary' && options}
<ActionMenu {options} />
{/if}
</header>

Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/fragments/Message/Message.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@
<button
{...restProps}
class={cn([
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4 hover:bg-gray-100',
'relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-4',
restProps.class
])}
Comment thread
This conversation was marked as resolved.
onclick={callback}
Expand All@@ -39,7 +39,7 @@
<span class="h-2 w-2 rounded-full bg-blue-500"></span>
{/if}
</span>
<p class="text-black/60">{messageText}</p>
<p class="text-start text-black/60">{messageText}</p>
</span>
</button>

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Avatar, Input } from '$lib/ui';
import { cn } from '$lib/utils';
import { ImageCompositionOvalIcon, PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { PlusSignIcon, SentIcon } from '@hugeicons/core-free-icons';
import { HugeiconsIcon } from '@hugeicons/svelte';
import type { HTMLAttributes } from 'svelte/elements';

Expand DownExpand Up@@ -39,47 +39,30 @@
{:else}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<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"
onclick={handleAdd}
aria-label="Add attachment"
aria-label="add-image"
onclick={() => fileInput?.click()}
>
<HugeiconsIcon size="24px" icon={PlusSignIcon} color="var(--color-black-400)" />
</button>
{/if}
<Input type="text" bind:input 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}
<!-- 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>
</div>
1 change: 1 addition & 0 deletions platforms/metagram/src/lib/fragments/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,6 @@ export { default as SideBar } from './SideBar/SideBar.svelte';
export { default as RightAside } from './RightAside/RightAside.svelte';
export { default as SettingsToggleButton } from './SettingsToggleButton/SettingsToggleButton.svelte';
export { default as Post } from './Post/Post.svelte';
export { default as ChatMessage } from './ChatMessage/ChatMessage.svelte';
export { default as Comment } from './Comment/Comment.svelte';
export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { ISvgProps } from './../types';
import type { ISvgProps } from '../types';

let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props();
</script>
Expand Down
4 changes: 2 additions & 2 deletions platforms/metagram/src/lib/icons/Icons.svelte
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { Like, Refresh, Comment, Home, Flash, CommentsTwo, VerticalDots } from '.';
import { Like, Refresh, CommentIcon, Home, Flash, CommentsTwo, VerticalDots } from '.';
</script>

<div class="flex flex-wrap items-center gap-2">
<Like />
<Refresh />
<Comment />
<CommentIcon />
<VerticalDots />
<Home />
<Flash />
Expand Down
2 changes: 1 addition & 1 deletion platforms/metagram/src/lib/icons/index.ts
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
export { default as Icons } from './Icons.svelte';
export { default as Like } from './Like.svelte';
export { default as Refresh } from './Refresh.svelte';
export { default as Comment } from './Comment.svelte';
export { default as CommentIcon } from './CommentIcon.svelte';
export { default as VerticalDots } from './VerticalDots.svelte';
export { default as Home } from './Home.svelte';
export { default as Flash } from './Flash.svelte';
Expand Down
26 changes: 19 additions & 7 deletions platforms/metagram/src/routes/(protected)/+layout.svelte
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,7 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { comments } from '$lib/dummyData';
import { BottomNav, Header, Comment, MessageInput } from '$lib/fragments';
import SideBar from '$lib/fragments/SideBar/SideBar.svelte';
import { BottomNav, Header, Comment, MessageInput, SideBar } from '$lib/fragments';
import { Settings } from '$lib/icons';
import { showComments } from '$lib/store/store.svelte';
import type { CommentType } from '$lib/types';
Expand All@@ -15,6 +14,7 @@
let commentInput: HTMLInputElement | undefined = $state();
let _comments = $state(comments);
let activeReplyToId: string | null = $state(null);
let chatFriendId = $state();

const handleSend = async () => {
const newComment = {
Expand DownExpand Up@@ -52,20 +52,22 @@
};

$effect(() => {
chatFriendId = page.params.id;

if (route.includes('home')) {
heading = 'Feed';
} else if (route.includes('discover')) {
heading = 'Search';
} else if (route.includes('post')) {
heading = 'Post';
} else if (route === `/messages/${chatFriendId}`) {
heading = 'User Name';
} else if (route.includes('messages')) {
heading = 'Messages';
} else if (route.includes('settings')) {
heading = 'Settings';
} else if (route.includes('profile')) {
heading = 'Profile';
} else {
heading = '';
}
});
</script>
Expand All@@ -74,9 +76,16 @@
class={`block h-[100dvh] ${route !== '/home' ? 'grid-cols-[20vw_auto]' : 'grid-cols-[20vw_auto_30vw]'} md:grid`}
>
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} />
<section class="px-4 md:px-8 md:pt-8">
<section class="hide-scrollbar h-[100dvh] overflow-y-auto px-4 pb-8 md:px-8 md:pt-8">
<div class="flex items-center justify-between">
<Header variant="primary" {heading} />
<Header
variant={route === `/messages/${chatFriendId}` ? 'secondary' : 'primary'}
{heading}
options={[
{ name: 'Report', handler: () => alert('report') },
{ name: 'Clear chat', handler: () => alert('clear') }
]}
/>
{#if route === '/profile'}
<div class="mb-6 flex md:hidden">
<button
Expand DownExpand Up@@ -121,5 +130,8 @@
{/if}
</aside>
{/if}
<BottomNav profileSrc="https://picsum.photos/200" />

{#if route !== `/messages/${chatFriendId}`}
<BottomNav class="btm-nav" profileSrc="https://picsum.photos/200" />
{/if}
</main>
27 changes: 27 additions & 0 deletions platforms/metagram/src/routes/(protected)/messages/+page.svelte
Original file line numberDiff line numberDiff 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>
Loading