1- import { useState } from 'react' ;
2- import { NavLInk } from 'react-router-dom' ;
3- import { HiOutlineMenu } from 'react-icons/ri' ;
4- import { RiCloseClone } from 'react-icons/ri' ;
1+ import React , { useState } from 'react' ;
2+ import { NavLink } from 'react-router-dom' ;
3+ import {
4+ HiOutlineHashtag ,
5+ HiOutlineHome ,
6+ HiOutlineMenu ,
7+ HiOutlinePhotograph ,
8+ HiOutlineUserGroup ,
9+ } from 'react-icons/hi' ;
10+ import { RiCloseLine } from 'react-icons/ri' ;
511
612import { logo } from '../assets' ;
7- import { links } from '../assets/constants' ;
8- import { HiOutlineMenu } from 'react-icons/hi' ;
9- const Sidebar = ( ) => {
10- const [ mobileMenuOpen , setMobileMenuOpen ] = useState ( false ) ;
11- } ;
13+
14+ const links = [
15+ { name : 'Discover' , to : '/' , icon : HiOutlineHome } ,
16+ { name : 'Around You' , to : '/around-you' , icon : HiOutlinePhotograph } ,
17+ { name : 'Top Artists' , to : '/top-artists' , icon : HiOutlineUserGroup } ,
18+ { name : 'Top Charts' , to : '/top-charts' , icon : HiOutlineHashtag } ,
19+ ] ;
1220
1321const NavLinks = ( { handleClick } ) => (
1422 < div className = "mt-10" >
1523 { links . map ( ( item ) => (
1624 < NavLink
1725 key = { item . name }
1826 to = { item . to }
19- className = "flex flex-row justify-start items-center my-8 text-sm font-medium text-gray-400 hover: text-cyan-400"
27+ className = "flex flex-row justify-start items-center my-8 text-sm font-medium text-gray-400 hover:text-cyan-400"
2028 onClick = { ( ) => handleClick && handleClick ( ) }
2129 >
2230 < item . icon className = "w-6 h-6 mr-2 " />
@@ -25,29 +33,41 @@ const NavLinks = ({ handleClick }) => (
2533 ) ) }
2634 </ div >
2735) ;
28- return (
29- < >
30- < div clasName = "md:flex hidden flex-col w-[240px] py-10 px-4 bg-[#191624]" >
31- < img src = { logo } alt = "logo" className = "w-full h-14 object-contain" />
32- < NavLinks />
33- </ div >
34- < div className = "absolute md:hidden block top-6 right-3" >
35- { mobileMenuOpen ? (
36- < RiCloseClone className = "w-6 h-6 text-white mr-2" onClick = { ( ) => setMobileMenuOpen ( false ) } />
37- ) : (
38- < HiOutlineMenu className = "w-6 h-6 text-white mr-2" onClick = { ( ) => setMobileMenuOpen ( true ) } />
39- ) }
40- </ div >
4136
42- < div
43- clasName = { `absolute top-0 h-screen w-2/3 bg-gradient-to-tl from-white/10 to-[#483d8b] backdrop-blur-lg z-10 pd-6 md: hidden smooth-transition ${
44- mobileMenuOpen ? left - 0 : '-left-full'
45- } `}
46- >
47- < img src = { logo } alt = "logo" className = "w-full h-14 object-contain" />
48- < NavLinks handleClick = { ( ) => { setMobileMenuOpen ( false ) } / >
49- </ div >
50- </ >
51- );
37+ const Sidebar = ( ) => {
38+ const [ mobileMenuOpen , setMobileMenuOpen ] = useState ( false ) ;
39+
40+ return (
41+ < >
42+ < div className = "md:flex hidden flex-col w-[240px] py-10 px-4 bg-[#191624]" >
43+ < img src = { logo } alt = "logo" className = "w-full h-14 object-contain" />
44+ < NavLinks />
45+ </ div >
46+
47+ { /* Mobile sidebar */ }
48+ < div className = "absolute md:hidden block top-6 right-3" >
49+ { ! mobileMenuOpen ? (
50+ < HiOutlineMenu
51+ className = "w-6 h-6 mr-2 text-white "
52+ onClick = { ( ) => setMobileMenuOpen ( true ) }
53+ />
54+ ) : (
55+ < RiCloseLine
56+ className = "w-6 h-6 mr-2 text-white "
57+ onClick = { ( ) => setMobileMenuOpen ( false ) }
58+ />
59+ ) }
60+ </ div >
61+
62+ < div
63+ className = { `absolute top-0 h-screen w-2/3 bg-gradient-to-tl from-white/10 to-[#483D8B] backdrop-blur-lg z-10 p-6 md:hidden smooth-transition ${
64+ mobileMenuOpen ? 'left - 0' : '-left-full'
65+ } `}
66+ >
67+ < img src = { logo } alt = "logo" className = "w-full h-14 object-contain" />
68+ < NavLinks handleClick = { ( ) => setMobileMenuOpen ( false ) } />
69+ </ div >
70+ </ >
71+ ) ;
72+ } ;
5273export default Sidebar ;
53- // !!!1.17.10
0 commit comments