UNPKG

template_assets

Version:

![Compatibility](https://img.shields.io/badge/compatibility-0.6.25-blue) [![Build Status](https://github.com/dfinity/examples/workflows/motoko-superheroes-example/badge.svg)](https://github.com/dfinity/examples/actions?query=workflow%3Amotoko-superheroes

36 lines (32 loc) 1.48 kB
import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import { motion, AnimatePresence } from 'framer-motion'; import { MENU_ITEMS } from './items'; import "./styles.scss"; export const NavBar = () => { const [location, setLocation] = useState(window.location.hash.replace("#", "")); return ( <nav className="nav-bar"> { MENU_ITEMS.map((item, index) => { return ( <Link to={item.path} onClick={() => setLocation(item.path)} className="nav-bar__item" key={`nav-bar-item-${index}`}> <div className={`nav-bar__item__icon ${location === item.path ? 'active' : ''}`}> {item.icon} </div> <span className={`nav-bar__item__name ${location === item.path ? 'active' : ''}`}>{ item.name }</span> <AnimatePresence> {location === item.path && ( <motion.div layoutId="navlink" className="nav-bar__item__backdrop-active" /> )} </AnimatePresence> </Link> ) }) } </nav> ) };