Skip to content

Commit

Permalink
fixed sidebar files
Browse files Browse the repository at this point in the history
  • Loading branch information
ivinayakg committed Aug 16, 2022
1 parent 77864fd commit 6989af5
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 1 deletion.
59 changes: 59 additions & 0 deletions components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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);

return (
<div className={styles.wrapper}>
<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) => {
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 +
(router.pathname.split('/')[1] === option.urlPath ||
(router.pathname === '/' && '/' === option.urlPath)
? ' ' + styles.option_active
: '')
}
onClick={() => navigateTo(option.urlPath)}
>
<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}>
<button className={styles.button}>
<Image src="/assets/InfoSquare.svg" width={25} height={25} />
Guide
</button>
</div>
</aside>
</div>
);
};

export default Sidebar;

//pure TDD
93 changes: 93 additions & 0 deletions components/Sidebar/sidebar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
.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;
}
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
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.
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;
}

0 comments on commit 6989af5

Please sign in to comment.