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

[F003] Dashboard layout #7

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
13 changes: 13 additions & 0 deletions cypress/integration/pages/home/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('Dashboard layout', () => {
beforeEach(() => {
cy.visit('/home');
});

it('should find the header', () => {
cy.get('.header').contains('h2', 'Crit');
});

it('should find the side navigation bar', () => {
cy.get('.navigation-bar-aside').contains('span', 'Home');
});
});
18 changes: 11 additions & 7 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const nextConfig = {
reactStrictMode: true,

env: {
BACKEND_API: 'http://localhost:8000'
BACKEND_API: 'http://localhost:8000',
},

images: {
domains: ['picsum.photos'],
},

async redirects() {
Expand All @@ -12,19 +16,19 @@ const nextConfig = {
source: '/',
destination: '/home',
permanent: true,
}
]
},
];
},

webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
})
});

return config
return config;
},
}
};

module.exports = nextConfig
module.exports = nextConfig;
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "jest"
},
"dependencies": {
"@headlessui/react": "^1.6.4",
"@heroicons/react": "^1.0.6",
"@hookform/resolvers": "^2.8.8",
"@reduxjs/toolkit": "^1.8.1",
Expand Down
4 changes: 2 additions & 2 deletions pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Layout from '../../src/layouts/base';
import Layout from '../../src/layouts/dashboard';

import type { ReactElement } from 'react';

const index = () => {
return <div>index</div>;
return <div></div>;
};

index.getLayout = function getLayout(page: ReactElement) {
Expand Down
10 changes: 10 additions & 0 deletions public/icons/logoff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Link from 'next/link';
import { useState } from 'react';
import HeaderLobby from './HeaderLobby';
import HeaderUtilities from './HeaderUtilities';
import CritSVG from '../../public/images/critLogo.svg';

const Header = () => {
const [isLoggedIn, setIsLoggedIn] = useState(true);

return (
<header className="header">
<div className="header__left">
<Link href={'/home'} passHref>
<div className="header__image">
<CritSVG />
<h2>Crit</h2>
</div>
</Link>
<div className="header__message-of-the-day">
<p>Your pretty awesome</p>
</div>
aetheryna marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div className="header__right">
{isLoggedIn ? (
<>
<HeaderLobby />
<HeaderUtilities />
</>
) : (
<Link href={'/auth/sign-in'} passHref>
<button className="header__login-button button button--primary">
Login
</button>
</Link>
)}
</div>
</header>
);
};

export default Header;
54 changes: 54 additions & 0 deletions src/components/HeaderLobby.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import Image from 'next/image';
import Link from 'next/link';

const HeaderLobby = () => {
const userList = [
{
image: 'https://picsum.photos/100',
username: 'username',
},
{
image: 'https://picsum.photos/100',
username: 'username',
},
{
image: 'https://picsum.photos/100',
username: 'username',
},
{
image: 'https://picsum.photos/100',
username: 'username',
},
{
image: 'https://picsum.photos/100',
username: 'username',
},
];

return (
<div className="header-lobby">
<ul className="header-lobby__users">
{userList.map((user, index) => (
<Link href={'/home'} passHref key={index}>
<li className="header-lobby__user" key={index}>
<div className="header-lobby__user-picture">
<Image
src={user.image}
width={30}
height={30}
objectFit={'cover'}
alt={'username'}
/>
</div>
<div className="header-lobby__user-hover-name">
<span>{user.username}</span>
</div>
</li>
</Link>
))}
</ul>
</div>
);
};

export default HeaderLobby;
17 changes: 17 additions & 0 deletions src/components/HeaderUtilities.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BellIcon } from '@heroicons/react/outline';
import LogOffIcon from '../../public/icons/logoff.svg';

const HeaderUtilities = () => {
return (
<div className="header-utilities">
<button className="header-utilities__notifications">
<BellIcon />
</button>
<button className="header-utilities__logout">
<LogOffIcon />
</button>
</div>
);
};

export default HeaderUtilities;
40 changes: 40 additions & 0 deletions src/components/NavigationBarAside.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Image from 'next/image';
import Link from 'next/link';
import { useState } from 'react';
import NavigationBarAsideItems from './NavigationBarAsideItems';

const NavigationBarAside = () => {
const [isLoggedIn, setIsLoggedIn] = useState(true);

return (
<aside className="navigation-bar-aside">
<div className="navigation-bar-aside__wrapper">
aetheryna marked this conversation as resolved.
Show resolved Hide resolved
<div
className={`navigation-bar-aside__profile-block ${
isLoggedIn ? 'logged-in' : 'logged-out'
}`}
>
{isLoggedIn ? (
aetheryna marked this conversation as resolved.
Show resolved Hide resolved
<>
<div className="navigation-bar-aside__profile-picture">
<Image
src={'https://picsum.photos/100'}
width={50}
height={50}
objectFit={'cover'}
alt={'profile picture'}
/>
</div>
<Link href={'/home'} passHref>
<h3>Aethery</h3>
</Link>
</>
) : null}
</div>
<NavigationBarAsideItems />
</div>
</aside>
);
};

export default NavigationBarAside;
59 changes: 59 additions & 0 deletions src/components/NavigationBarAsideItems.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import Link from 'next/link';
import { useRouter } from 'next/router';
import { HomeIcon, UserCircleIcon, UsersIcon } from '@heroicons/react/solid';
import { ClockIcon, HashtagIcon, TagIcon } from '@heroicons/react/outline';

const NavigationBarAsideItems = () => {
const router = useRouter();
const navigationItems = [
{
href: '/home',
svg: <HomeIcon />,
name: 'Home',
},
{
href: '/my-profile',
svg: <UserCircleIcon />,
name: 'My Profile',
},
{
href: '/activity-feed',
svg: <HashtagIcon />,
name: 'Activity Feed',
},
{
href: '/trending',
svg: <TagIcon />,
name: 'Trending',
},
{
href: '/friends',
svg: <UsersIcon />,
name: 'Friends',
},
{
href: '/lobbies',
svg: <ClockIcon />,
name: 'Lobbies',
},
];

return (
<ul className="navigation-bar-aside-items">
{navigationItems.map((item, index) => (
<Link key={index} href={item.href} passHref>
<li
className={`navigation-bar-aside-items__item ${
router.pathname.includes(item.href) ? 'active' : ''
}`}
>
{item.svg}
<span>{item.name}</span>
</li>
</Link>
))}
</ul>
);
};

export default NavigationBarAsideItems;
13 changes: 13 additions & 0 deletions src/components/UtilityWheel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ChatIcon } from '@heroicons/react/outline';

const UtilityWheel = () => {
return (
<aside className="utility-wheel">
<button className="utility-wheel__chat">
<ChatIcon />
</button>
</aside>
);
};

export default UtilityWheel;
22 changes: 11 additions & 11 deletions src/helpers/setPageTitle.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useEffect } from "react";
import { useEffect } from 'react';

export const PageTitle = (router: {pathname: string}) => {
const currentURL = router.pathname
const pageURL = currentURL.replace(/\//g, "") + "-page"
const routeTitle = currentURL.replace(/\//g, "")
export const PageTitle = (router: { pathname: string }) => {
const currentURL = router.pathname;
const pageURL = currentURL.replace(/\//g, '') + '-page';
const routeTitle = currentURL.replace(/\//g, '');

useEffect(() => {
document.querySelector<HTMLElement>("body")!.classList.add(pageURL)
})
document.querySelector<HTMLElement>('body')!.classList.add(pageURL);
});

const capitalizeFirstLetter = (URL: string) => {
return URL.charAt(0).toUpperCase() + URL.slice(1)
}
return URL.charAt(0).toUpperCase() + URL.slice(1);
};

return capitalizeFirstLetter(routeTitle)
}
return capitalizeFirstLetter(routeTitle);
};
Loading