Skip to content
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

feat: added responsive dashboard layout #3

Merged
merged 2 commits into from
Oct 15, 2024
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
3,099 changes: 3,099 additions & 0 deletions packages/frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"globals": "^15.0.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"sass": "^1.79.4",
"svelte": "^4.2.7",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<style>
body {
tobySolutions marked this conversation as resolved.
Show resolved Hide resolved
margin: 0;
}
</style>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
Expand Down
294 changes: 294 additions & 0 deletions packages/frontend/src/lib/navbar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import Logo from '../../static/favicon.png';

let menuOpen = false;

const navItems = [
{ label: 'Home', value: 'home', route: '/dashboard/home' },
{ label: 'Projects', value: 'project', route: '/dashboard/projects' },
{ label: 'Destination', value: 'destination', route: '/dashboard/projects' }
];

const toggleMobileMenu = () => {
menuOpen = !menuOpen;
};
</script>

<nav class="nav">
<div class="logo__container">
<img src={Logo} alt="" width="60px" height="60px" />
<p>STREAM2PEER</p>
</div>
<ul class="nav__items">
<li>My Account</li>
</ul>
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="mobile__nav" on:click={toggleMobileMenu}>
<div id="icon" />
<div class={`${menuOpen ? 'icon-close' : 'icon-menu'}`}></div>

<div class={`${menuOpen ? 'mobile__menu' : 'menu__close'}`}>
<div class="mobile__top">
<div class="icon-close"></div>
</div>
<div class="menu-items">
<ul>
{#each navItems as item}
<li class={`${$page.url.pathname === item.route ? 'active' : ''}`}>
<a
on:click={() => {
toggleMobileMenu;
goto(item.route, { replaceState: true });
}}
href={item.route}>{item.label}</a
>
</li>
{/each}
</ul>
</div>
</div>
</div>
</nav>

<style lang="scss">
@import "../styles//styles.scss";
.nav {
background-color: #1e1e1e;
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 100;
height: 60px;
border-bottom: 1px solid hsl(155, 6%, 42.5%);
display: flex;
align-items: center;
justify-content: space-between;
padding: 36px 25px;

.nav__items {
display: flex;
gap: 20px;
align-items: center;
list-style: none;

li {
font-size: 16px;
font-weight: 400;
font-family: 'Raleway', sans-serif;
padding: 12px 20px;
border-radius: 30px;
cursor: pointer;
color: #ffffff;
}

#active {
color: #000000;
background-color: #ffffff;
font-weight: 600;
}
}

.logo__container {
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;

p {
font-family: 'Crimson Text', serif;
color: #ffffff;
}
}

.nav__icons {
display: flex;
gap: 25px;
align-items: center;

svg {
cursor: pointer;
}
}

.mobile__nav {
cursor: pointer;
position: relative;
display: none;
}
.mobile__nav__items {
display: none;
}
.mobile__menu {
display: none;
width: 100%;
position: fixed;
top: 0;
left: 0;
height: 100vh;
z-index: 1000;
background-color: #1e1e1e;

.mobile__top {
padding: 40px;
display: flex;
justify-content: flex-end;
}
.menu-items {
padding: 0 25px 25px 25px;
ul {
list-style: none;
padding: 0;
display: flex;
flex-direction: column;
gap: 20px;

.active {
background-color: #ffffff;
a {
color: #1e1e1e;
}
}

li {
padding: 10px;
border-radius: 8px;
a {
text-decoration: none;
color: #ffffff;
font-family: 'Raleway' 'sans-serif';
}
}
}
}
}
.menu__close {
display: none;
}
}

@include respond(ms) {
.nav {
.mobile__nav {
display: block;
padding-right: 22px;

icon-menu,
.icon-menu::before,
.icon-menu::after,
.icon-close,
.icon-close::before,
.icon-close::after {
content: '';
display: block;
height: 2.7px;
position: absolute;
width: 28px;
border-radius: 20px;
transition:
top ease 0.3s,
transform ease 0.3s 0.3s,
background 0.3s ease 0.3s;
background: #ffffff;
}

.icon-menu::before {
top: -7px;
transition:
background ease 0.3s,
top ease 0.3s 0.3s,
transform ease 0.3s;
}

.icon-menu::after {
top: 7px;
transition:
background ease 0.3s,
top ease 0.3s 0.3s,
transform ease 0.3s;
}

.icon-close {
background: transparent;
}

/* line one of close icon */
.icon-close::before {
transform: rotate(45deg);
top: 0px;
background: #ffffff;
}

/* line two of close icon */
.icon-close::after {
transform: rotate(-45deg);
top: 0px;
background: #ffffff;
}
}

.nav__items {
display: none;
}

.nav__icons {
display: none;
}

.mobile__nav__items {
display: flex;
position: absolute;
top: 51px;
right: -20px;
background-color: #1e1e1e;
min-width: 220px;
width: 100%;
padding: 12px;

ul {
display: flex;
gap: 12px;
color: #ffffff;
list-style: none;
font-family: 'Raleway', 'san-serif';
align-items: center;
padding: 0;
flex-direction: column;
width: 100%;

.fade-in {
animation: slideUp 0.8s forwards;
}
.nav__link {
opacity: 0;
width: 100%;
text-align: center;
padding: 8px;
transform: translateY(80px);
transition:
transform 0.5s ease,
opacity 0.5s ease;
}
.active {
color: #000000;
background-color: #ffffff;
font-weight: 600;
}
}
}
.mobile__menu {
display: block;
}
.menuopen {
display: flex;
}
.menuclosed {
display: none;
}
}
}
</style>
78 changes: 78 additions & 0 deletions packages/frontend/src/lib/sidebar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<script>
import { page } from '$app/stores';

export const navItems = [
{ label: 'Home', value: 'home', route: '/dashboard/home' },
{ label: 'Projects', value: 'project', route: '/dashboard/projects' },
{ label: 'Destination', value: 'destination', route: '/dashboard/projects' }
// { label: 'About', value: 'about', route: '/about' },
// { label: 'Blog', value: 'blog', route: '/blog' },
// { label: 'Partners', value: 'partners', route: '/partners' }
];
</script>

<aside class="sidebar">
<ul>
{#each navItems as item}
<li class={`${$page.url.pathname === item.route ? 'active' : ''}`}>
<a href={item.route}>{item.label}</a>
</li>
{/each}
</ul>
</aside>

<style lang="scss">
@import "../styles/styles.scss";
.sidebar {
flex-basis: 20%;
padding: 20px;
background-color: #1e1e1e;
margin-top: 72px;
border-right: 1px solid hsl(155, 6%, 42.5%);

ul {
list-style: none;
padding: 0;
display: flex;
flex-direction: column;
gap: 20px;

.active {
background-color: #ffffff;
a {
color: #1e1e1e;
}
}

li {
padding: 10px;
border-radius: 8px;
a {
text-decoration: none;
color: #ffffff;
font-family: 'Raleway' 'sans-serif';
}
}
}
}

@include respond(ms) {
.sidebar {
position: absolute;
bottom: 0;
right: 0;
left: 0;
margin-top: 10px;
border-right: none;
border-top: 1px solid hsl(155, 6%, 42.5%);

ul {
display: flex;
flex-direction: row;
overflow-x: scroll;
width: 100%;
justify-content: space-between;
}
}
}
</style>
Loading