React Animated Side Navigation Bar with Variable Width and React Routing Enabled
npm install react-animated-variablewidth-sidenavbar-withrouting
- Responsive Side Navigation Bar catering to different Screens and Media queries.
- Animated Side Navigation Bar which can be controlled using inbuilt Toggle Button.
- React Routing for the Navigation Links Working out of the box.
- The Width of the Side Navigtion Bar can be controlled from fullscreen (100vw) to Industry Standard Side Navigation Drawer Width.
- Provision to Configure One level Deep Nested Navigation links.
- Provision to Add User Profile Information like Name and Email address in the Navigation Drawer.
- Basic Look and feel of the Navigation Bar (Primary Color, Secondary Color, Navigation Bar Width, Toggle Button Color ) can be configured by passing appropriate values to the Prop.
- LightWeight Css file to configure advanced Styling.
```
npm install react-animated-variablewidth-sidenavbar-withrouting --save
yarn add react-animated-variablewidth-sidenavbar-withrouting
- App.js
`
import React from "react";
import CreateSideBarNavLink from "react-animated-variablewidth-sidenavbar-withrouting";
const App = () => {
const myData = {
navBarSettings: {
navBarWidth: "100vw",
theme: {
primaryColor: "rgb(0, 51, 153,0.5)",
secondaryColor: "rgb(0, 85, 255)",
toggleButtonColor: "rgb(0, 51, 153,1)",
},
},
userInfo: {
name: "aryan sharma",
email: "aryan@gmail.com",
},
link1: {
IconSet: (
className="fa fa-fw fa-list"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Text: "Products",
Expandable: true,
ExpandableIconset: (
className="fas fa-angle-right angleIcon"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Route: "/products",
children: [
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Product1",
Expandable: false,
children: null,
Route: "/products/product1",
},
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Product2",
Expandable: false,
children: null,
Route: "/products/product2",
},
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Product3",
Expandable: false,
children: null,
Route: "/products/product3",
},
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Product4",
Expandable: false,
children: null,
Route: "/products/product4",
},
],
},
link2: {
IconSet: (
className="fa fa-fw fa-edit"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Text: "Portfolio",
Expandable: true,
ExpandableIconset: (
className="fas fa-angle-right angleIcon"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Route: "/portfolio",
children: [
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Portfolio1",
Expandable: false,
children: null,
Route: "/portfolio/portfolio1",
},
],
},
link3: {
IconSet: (
className="fa fa-fw fa-bell"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Text: "About",
Expandable: false,
ExpandableIconset: (
className="fas fa-angle-right angleIcon"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Route: "/about",
children: null,
},
link4: {
IconSet: (
className="fa fa-fw fa-file"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Text: "Catelogues",
Expandable: true,
ExpandableIconset: (
className="fas fa-angle-right angleIcon"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Route: "/catelogue",
children: [
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Catelogues1",
Expandable: false,
children: null,
Route: "/catelogue/catelogue1",
},
{
IconSet: (
className="fas fa-gavel"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
>
),
Text: "Catelogues2",
Expandable: false,
children: null,
Route: "/catelogue/catelogue2",
},
],
},
link5: {
IconSet: (
className="fa fa-fw fa-list"
style={{ fontSize: window.innerWidth > 768 ? "1vw" : "4vw" }}
/>
),
Text: "Contact Us",
Expandable: false,
ExpandableIconset: (
className="fas fa-angle-right angleIcon"
style={{
fontSize: window.innerWidth > 768 ? "1vw" : "4vw",
color: "rgba(255,255,255,0.6)",
}}
/>
),
Route: "/contactus",
children: null,
},
};
return (
);
};
export default App;
`
- AppRoutes.js
`
import React, { Component } from "react";
import { BrowserRouter, Route, Switch } from "react-router-dom";
import { Home } from "./Home";
import { About } from "./About";
import { Product } from "./Product";
import { Portfolio } from "./Portfolio";
import { Catelogue } from "./Catelogue";
import { Contactus } from "./Contactus";
import { Catelogue1 } from "./Catelogue1";
import { Catelogue2 } from "./Catelogue2";
import { Product1 } from "./Product1";
import { Product2 } from "./Product2";
import { Product3 } from "./Product3";
import { Product4 } from "./Product4";
import { Portfolio1 } from "./Portfolio1";
import App from "./App";
class Approutes extends Component {
render() {
return (
);
}
}
export default Approutes;
`
- You should pass One mandatory prop to the CreateSideBarNavLink Component.
- Following attributes can be controlled by passing appropriate values to the Javascript Object mydata as shown in above Code Snippet.
- All values discussed below are mandatory values against their respective keys
IconSet:- Icon FontAwesome Icon Supported Representing the First Parent Navigation Link.
Text:- Text for the First Parent Navigation Link. String
Expandable:- Whether Contains Nested Children Links Or Not Boolean
ExpandableIconset- Valid when Expandable is set to true. Icon Representing the Expand/Collapse of the Children Link Drawer.
Route:- This points to the url the user will be directed to when the link1 is clicked upon. Mapping between Url and Component should be configured by the user inside AppRoutes Components. See the github link for further help. Once mapping between component and url is configured in Approutes, the page will be redirected to the url and the corresponding component will be made visible. String
children:- Array of Children Nested Links which are Part of Parent Link Link1. This should be supplied only when Expandable is set to true. Array
IconSet, Text, Expandable, Children, Route parameters are same as above but this caters to the Children Links.
In Case You want to have support for n Parent Links, please provide link1, link2,...linkn configuration in the mydata Prop/object.
Link to NPM REACT-ROUTING BUG
`
Webpack.config.js
module.exports = () => {
return (
entry:{...}
module: {...},
resolve: {
alias: {
react: path.resolve(__dirname, './node_modules/react'),
'react-dom': path.resolve(__dirname, './node_modules/react-dom'),
'react-router-dom': path.resolve(__dirname, './node_modules/react-router-dom')
}
)
}
``