-
Notifications
You must be signed in to change notification settings - Fork 4
feat: responsive setup for mobile and desktop #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d13c459
feat: responsive setup for mobile and desktop
grv-saini-20 76f6422
fix: width of sidebar and rightaside
grv-saini-20 75746da
fix: responsive layout
grv-saini-20 442ca2c
feat: SideBar
grv-saini-20 8c354ec
fix: added some finishing touches to sidebar and button
grv-saini-20 6f4a2ef
fix: prevent pages transition on desktop
grv-saini-20 6c00adb
fix: icon center
grv-saini-20 5d72eb7
feat: settings page and icon added
grv-saini-20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
platforms/metagram/src/lib/fragments/SideBar/SideBar.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { ComponentProps } from 'svelte'; | ||
import { SideBar } from '..'; | ||
|
||
export default { | ||
title: 'UI/SideBar', | ||
component: SideBar, | ||
tags: ['autodocs'], | ||
render: (args: { Component: SideBar; props: ComponentProps<typeof SideBar> }) => ({ | ||
Component: SideBar, | ||
props: args | ||
}) | ||
}; | ||
|
||
export const Primary = { | ||
args: {} | ||
}; |
174 changes: 174 additions & 0 deletions
174
platforms/metagram/src/lib/fragments/SideBar/SideBar.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
<script lang="ts"> | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
import { Home, CommentsTwo, Search, Camera, Settings } from '$lib/icons'; | ||
import { goto } from '$app/navigation'; | ||
import { page } from '$app/state'; | ||
import Button from '$lib/ui/Button/Button.svelte'; | ||
import { cn } from '$lib/utils'; | ||
|
||
interface ISideBarProps extends HTMLAttributes<HTMLElement> { | ||
activeTab?: string; | ||
profileSrc: string; | ||
handlePost?: () => Promise<void>; | ||
} | ||
let { | ||
activeTab = $bindable('home'), | ||
profileSrc = 'https://picsum.photos/200', | ||
handlePost, | ||
...restProps | ||
}: ISideBarProps = $props(); | ||
|
||
let _activeTab = $derived(page.url.pathname); | ||
|
||
const handleNavClick = (newTab: string) => { | ||
activeTab = newTab; | ||
goto(`/${newTab}`); | ||
}; | ||
|
||
$effect(() => { | ||
activeTab = _activeTab.split('/').pop() ?? ''; | ||
}); | ||
|
||
const cBase = | ||
'hidden h-screen border border-y-0 border-e-gray-200 py-14 md:flex md:justify-center'; | ||
</script> | ||
|
||
<!-- svelte-ignore a11y_no_noninteractive_element_to_interactive_role --> | ||
<nav | ||
{...restProps} | ||
aria-label="Main navigation" | ||
class={cn([cBase, restProps.class].join(' '))} | ||
role="tablist" | ||
> | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
<div class="flex flex-col items-start justify-start gap-12"> | ||
<h1 class="bg-[image:var(--color-brand-gradient)] bg-clip-text text-transparent"> | ||
Pictique | ||
</h1> | ||
<button | ||
type="button" | ||
class="flex items-center gap-2" | ||
aria-current={activeTab === 'home' ? 'page' : undefined} | ||
onclick={() => handleNavClick('home')} | ||
> | ||
<Home | ||
size="24px" | ||
color={activeTab === 'home' | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-400)'} | ||
fill={activeTab === 'home' ? 'var(--color-brand-burnt-orange)' : 'white'} | ||
/> | ||
<h3 | ||
class={`${activeTab === 'home' ? 'text-brand-burnt-orange' : 'text-black-800'} mt-[4px]`} | ||
> | ||
Feed | ||
</h3> | ||
</button> | ||
|
||
<button | ||
type="button" | ||
class="flex items-center gap-2" | ||
aria-current={activeTab === 'discover' ? 'page' : undefined} | ||
onclick={() => handleNavClick('discover')} | ||
> | ||
<Search | ||
size="24px" | ||
color={activeTab === 'discover' | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-400)'} | ||
fill={activeTab === 'discover' ? 'var(--color-brand-burnt-orange)' : 'white'} | ||
/> | ||
<h3 | ||
class={`${activeTab === 'discover' ? 'text-brand-burnt-orange' : 'text-black-800'} mt-[4px]`} | ||
> | ||
Search | ||
</h3> | ||
</button> | ||
|
||
<button | ||
type="button" | ||
class="flex items-center gap-2" | ||
aria-current={activeTab === 'post' ? 'page' : undefined} | ||
onclick={() => handleNavClick('post')} | ||
> | ||
<Camera | ||
size="24px" | ||
color={activeTab === 'post' | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-400)'} | ||
fill={activeTab === 'post' ? 'var(--color-brand-burnt-orange)' : 'white'} | ||
/> | ||
<h3 | ||
class={`${activeTab === 'post' ? 'text-brand-burnt-orange' : 'text-black-800'} mt-[4px]`} | ||
> | ||
Upload a photo | ||
</h3> | ||
</button> | ||
|
||
<button | ||
type="button" | ||
class="flex items-center gap-2" | ||
aria-current={activeTab === 'messages' ? 'page' : undefined} | ||
onclick={() => handleNavClick('messages')} | ||
> | ||
<CommentsTwo | ||
size="24px" | ||
color={activeTab === 'messages' | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-400)'} | ||
fill={activeTab === 'messages' ? 'var(--color-brand-burnt-orange)' : 'white'} | ||
/> | ||
<h3 | ||
class={`${activeTab === 'messages' ? 'text-brand-burnt-orange' : 'text-black-800'} mt-[4px]`} | ||
> | ||
Messages | ||
</h3> | ||
</button> | ||
|
||
<button | ||
type="button" | ||
class="flex items-center gap-2" | ||
aria-current={activeTab === 'settings' ? 'page' : undefined} | ||
onclick={() => handleNavClick('settings')} | ||
> | ||
<Settings | ||
size="24px" | ||
color={activeTab === 'settings' | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-400)'} | ||
fill={activeTab === 'settings' ? 'var(--color-brand-burnt-orange)' : 'white'} | ||
/> | ||
<h3 | ||
class={`${activeTab === 'settings' ? 'text-brand-burnt-orange' : 'text-black-800'} mt-[4px]`} | ||
> | ||
Settings | ||
</h3> | ||
</button> | ||
|
||
<button | ||
type="button" | ||
class="flex items-center gap-2" | ||
aria-current={activeTab === 'profile' ? 'page' : undefined} | ||
onclick={() => handleNavClick('profile')} | ||
> | ||
<span | ||
class={`inline-block w-full rounded-full border p-1 ${activeTab === 'profile' ? 'border-brand-burnt-orange' : 'border-transparent'}`} | ||
> | ||
<img | ||
width="24px" | ||
height="24px" | ||
class="aspect-square rounded-full" | ||
src={profileSrc} | ||
alt="profile" | ||
/> | ||
</span> | ||
<h3 | ||
class={`${activeTab === 'profile' ? 'text-brand-burnt-orange' : 'text-black-800'} mt-[4px]`} | ||
> | ||
Profile | ||
</h3> | ||
</button> | ||
{#if handlePost} | ||
<Button size="sm" variant="secondary" callback={handlePost}>Post a photo</Button> | ||
{/if} | ||
</div> | ||
</nav> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import type { ISvgProps } from './../types'; | ||
|
||
let { size = '20px', color = '#A5A5A5', ...restProps }: ISvgProps = $props(); | ||
</script> | ||
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width={size} height={size} color={color} fill="none"> | ||
<path d="M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z" stroke={color} stroke-width="1.5"></path> | ||
<path d="M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z" stroke={color} stroke-width="1.5" stroke-linecap="round"></path> | ||
</svg> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
<script lang="ts"> | ||
import { BottomNav } from '$lib/fragments'; | ||
import { page } from '$app/state'; | ||
import { BottomNav, Header } from '$lib/fragments'; | ||
import SideBar from '$lib/fragments/SideBar/SideBar.svelte'; | ||
let { children } = $props(); | ||
let route = $derived(page.url.pathname); | ||
let heading = $state(""); | ||
$effect(() => { | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
switch (route) { | ||
case "/home": | ||
heading = "Feed"; | ||
break; | ||
case "/discover": | ||
heading = "Search"; | ||
break; | ||
case "/post": | ||
heading = "Post"; | ||
break; | ||
case "/messages": | ||
heading = "Messages"; | ||
break; | ||
case "/settings": | ||
heading = "Settings"; | ||
break; | ||
case "/profile": | ||
heading = "Profile"; | ||
break; | ||
} | ||
}) | ||
</script> | ||
|
||
<main> | ||
{@render children()} | ||
<main class="block h-[100dvh] grid-cols-[22vw_auto_31vw] md:grid"> | ||
<SideBar profileSrc="https://picsum.photos/200" handlePost={async () => alert('adas')} /> | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
<section class="md:pt-10"> | ||
<Header variant="primary" {heading}/> | ||
{@render children()} | ||
</section> | ||
{#if !route.endsWith('/messages')} | ||
<aside class="hidden border border-y-0 border-s-gray-200 md:block md:pt-14"> | ||
Right Aside | ||
</aside> | ||
{/if} | ||
<BottomNav profileSrc="https://picsum.photos/200" /> | ||
</main> |
2 changes: 0 additions & 2 deletions
2
platforms/metagram/src/routes/(protected)/discover/+page.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
<script lang="ts"> | ||
</script> | ||
|
||
<h1>Discover Page</h1> |
10 changes: 0 additions & 10 deletions
10
platforms/metagram/src/routes/(protected)/home/+page.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,2 @@ | ||
<script lang="ts"> | ||
import { goto } from '$app/navigation'; | ||
import { isNavigatingThroughNav } from '$lib/store/store.svelte'; | ||
import { Button } from '$lib/ui'; | ||
</script> | ||
|
||
<h1>Home</h1> | ||
<Button | ||
callback={async () => { | ||
(isNavigatingThroughNav.value = false), goto('/discover'); | ||
}}>discover</Button | ||
> |
2 changes: 0 additions & 2 deletions
2
platforms/metagram/src/routes/(protected)/messages/+page.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
<script lang="ts"> | ||
</script> | ||
|
||
<h1>Messages</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
<script lang="ts"> | ||
</script> | ||
|
||
<h1>Post</h1> |
2 changes: 0 additions & 2 deletions
2
platforms/metagram/src/routes/(protected)/profile/+page.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
<script lang="ts"> | ||
</script> | ||
|
||
<h1>Profile</h1> |
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.