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

Feature Added Sidebar. #274

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
68 changes: 68 additions & 0 deletions components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import styles from './sidebar.module.css';
import { useRouter } from 'next/router';
import Image from 'next/image';
import sidebarMenuOptions from 'constants/sidebarMenuOptions';

const Sidebar = () => {
const router = useRouter();
const navigateTo = (url) => router.push(url);

const basePath = router.pathname;
const pagePath = router.pathname.split('/')[1];

const activeOptionClass = (optionURL) =>
pagePath === optionURL || (basePath === '/' && '/' === optionURL)
? ' ' + styles.option_active
: '';

return (
<div className={styles.wrapper} data-testid="sidebar-notification">
<aside className={styles.sidebar}>
<span className={styles.heading}>
<Image src={'/assets/Real-Dev-Squad1x.png'} width={50} height={50} />
<h3>RealDevSquad</h3>
</span>
<div className={styles.options}>
{sidebarMenuOptions.map((option, index) => {
const optionPath = option.urlPath;
return (
<span
key={index}
// this code below insure even if we are in nested path like currency-exchange/**/
//even then the link is active
className={styles.option + activeOptionClass(optionPath)}
onClick={() => navigateTo(optionPath)}
>
<Image
src={option.iconPath}
className={styles.option_image}
width={25}
height={25}
/>
<p>{option.name}</p>
<span className={styles.option_bar}></span>
</span>
);
})}
</div>

<div className={styles.buttonWrapper}>
{router.pathname !== '/currency-exchange' && (
<button className={styles.button}>
<Image src="/assets/InfoSquare.svg" width={25} height={25} />
Trade Now
</button>
)}
<button className={styles.button}>
<Image src="/assets/InfoSquare.svg" width={25} height={25} />
Guide
</button>
MehulKChaudhari marked this conversation as resolved.
Show resolved Hide resolved
</div>
</aside>
</div>
);
};

export default Sidebar;

//pure TDD
94 changes: 94 additions & 0 deletions components/Sidebar/sidebar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.wrapper {
font: 700 16px 'DM Sans', sans-serif;
margin-bottom: 25px;
width: 20vw;
height: max-content;
margin-right: auto;
}

.sidebar {
height: calc(100vh - 78px);
overflow-y: scroll;
background-color: #f8f7ff;
display: flex;
justify-content: flex-start;
align-items: center;
flex-direction: column;
}

.sidebar::-webkit-scrollbar {
width: 0.5px;
}
.sidebar::-webkit-scrollbar-thumb {
visibility: hidden;
}

.sidebar > * {
padding: 1.6rem;
width: 100%;
}

.heading {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 10px;
}

.option {
position: relative;
display: flex;
justify-content: flex-start;
align-items: center;
padding: 6px 9px;
gap: 10px;
color: #a5a2b8;
cursor: pointer;
}

.option:hover {
color: #352e5bd0;
}

.option_image {
position: static;
color: #352e5b;
}

.option_active {
color: #352e5b;
}

.option_bar {
width: 3px;
aspect-ratio: 1/6;
background-color: #9381ff;
border-radius: 1px 0px 0px 1px;
right: -1.2rem;
position: absolute;
display: none;
}

.option_active .option_bar {
display: block;
}

.buttonWrapper {
width: 100%;
margin-top: auto;
}

.button {
width: 100%;
background-color: #041187;
height: 4rem;
border-radius: 8px;
border: none;
color: white;
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
font: 500 16px 'DM Sans', sans-serif;
margin-top: 1rem;
}
32 changes: 32 additions & 0 deletions constants/sidebarMenuOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export default [
{
name: 'Home',
iconPath: '/assets/Home.svg',
urlPath: '/',
},
{
name: 'Dashboard',
iconPath: '/assets/Dashboard.svg',
urlPath: 'dashboard',
},
{
name: 'Curreny Exchange',
iconPath: '/assets/Swap.svg',
urlPath: 'currency-exchange',
},
{
name: 'Auction',
iconPath: '/assets/Auction.svg',
urlPath: 'auction',
},
{
name: 'Stocks',
iconPath: '/assets/Stocks.svg',
urlPath: 'trading',
},
{
name: 'Balance',
iconPath: '/assets/Balance.svg',
urlPath: 'wallet',
},
];
6 changes: 5 additions & 1 deletion pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import personData from '../mock/person.json';

import { wrapper } from '../redux/store';
import '../styles/globals.css';
import Sidebar from '@components/Sidebar';

const MyApp = ({ Component, pageProps }) => (
<>
<NavBar personData={personData} />
<Component {...pageProps} />;
<div className="main_app">
<Sidebar />
<Component {...pageProps} />;
</div>
</>
);

Expand Down
1 change: 1 addition & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function Home() {
<title>Bank Dashboard</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<NavBar personData={personData} />
MehulKChaudhari marked this conversation as resolved.
Show resolved Hide resolved
<main className={styles.mainBody}>
<div className={styles.leftSection}>
<div className={styles.homeUser}>
Expand Down
8 changes: 8 additions & 0 deletions public/assets/Auction.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/assets/Balance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/assets/Dashboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/assets/Home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/assets/InfoSquare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/assets/Stocks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/assets/Swap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/assets/trade.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ footer a {
.d-none {
display: none !important;
}
.main_app {
width: 100vw;
display: flex;
}