mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
1 line
24 KiB
JSON
1 line
24 KiB
JSON
{"ast":null,"code":"var _jsxFileName = \"/app/src/Components/Navigation.js\",\n _s = $RefreshSig$();\n\nimport { React, useState, useContext } from 'react';\nimport { Navbar, NavbarBrand, Collapse, Nav, NavbarToggler, NavItem } from 'reactstrap';\nimport { Link, useLocation } from 'react-router-dom';\nimport logo from '../logo.png';\nimport './Navigation.css';\nimport AuthContext from '../Contexts/AuthContext';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst menuItems = ['Home', 'Recent' // 'About',\n];\nconst loggedInMenuItems = ['Home', 'Recent', 'My Profile' // 'Docs',\n];\n\nconst isMobile = () => {\n return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);\n};\n\nconst Navigation = () => {\n _s();\n\n const location = useLocation(); // Lovely hack to highlight the current page (:\n\n let active = \"home\";\n\n if (location && location.pathname && location.pathname.length > 1) {\n active = location.pathname.replace(/\\//, \"\");\n }\n\n let activeStyle = {\n color: '#FFFFFF'\n };\n let {\n user,\n Logout\n } = useContext(AuthContext);\n let [collapsed, setCollapsed] = useState(true);\n\n const toggleCollapsed = () => {\n setCollapsed(!collapsed);\n };\n\n const renderMobileNav = () => {\n return /*#__PURE__*/_jsxDEV(Navbar, {\n color: \"dark\",\n dark: true,\n fixed: \"top\",\n children: [/*#__PURE__*/_jsxDEV(NavbarBrand, {\n className: \"mr-auto\",\n children: /*#__PURE__*/_jsxDEV(Link, {\n className: \"nav-logo-link\",\n to: \"/\",\n children: [/*#__PURE__*/_jsxDEV(\"img\", {\n src: logo,\n className: \"nav-logo\",\n alt: \"logo\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 45,\n columnNumber: 79\n }, this), \" GoScrobble\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 45,\n columnNumber: 40\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 45,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(NavbarToggler, {\n onClick: toggleCollapsed,\n className: \"mr-2\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 46,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(Collapse, {\n isOpen: !collapsed,\n navbar: true,\n children: user ? /*#__PURE__*/_jsxDEV(Nav, {\n className: \"navLinkLoginMobile\",\n navbar: true,\n children: [loggedInMenuItems.map(menuItem => /*#__PURE__*/_jsxDEV(NavItem, {\n children: /*#__PURE__*/_jsxDEV(Link, {\n className: \"navLinkMobile\",\n style: active === menuItem.toLowerCase() ? activeStyle : {},\n to: menuItem === \"My Profile\" ? \"/u/\" + user.username : \"/\" + menuItem.toLowerCase(),\n onClick: toggleCollapsed,\n children: menuItem\n }, menuItem, false, {\n fileName: _jsxFileName,\n lineNumber: 52,\n columnNumber: 17\n }, this)\n }, menuItem, false, {\n fileName: _jsxFileName,\n lineNumber: 51,\n columnNumber: 13\n }, this)), /*#__PURE__*/_jsxDEV(Link, {\n to: \"/user\",\n style: active === \"user\" ? activeStyle : {},\n className: \"navLinkMobile\",\n onClick: toggleCollapsed,\n children: \"Settings\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 61,\n columnNumber: 11\n }, this), user.admin && /*#__PURE__*/_jsxDEV(Link, {\n to: \"/admin\",\n style: active === \"admin\" ? activeStyle : {},\n className: \"navLink\",\n onClick: toggleCollapsed,\n children: \"Admin\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 68,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(Link, {\n to: \"/\",\n className: \"navLink\",\n onClick: Logout,\n children: \"Logout\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 11\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 49,\n columnNumber: 9\n }, this) : /*#__PURE__*/_jsxDEV(Nav, {\n className: \"navLinkLoginMobile\",\n navbar: true,\n children: [menuItems.map(menuItem => /*#__PURE__*/_jsxDEV(NavItem, {\n children: /*#__PURE__*/_jsxDEV(Link, {\n className: \"navLinkMobile\",\n style: active === \"home\" && menuItem.toLowerCase() === \"home\" ? activeStyle : active === menuItem.toLowerCase() ? activeStyle : {},\n to: menuItem.toLowerCase() === \"home\" ? \"/\" : \"/\" + menuItem.toLowerCase(),\n onClick: toggleCollapsed,\n children: menuItem\n }, menuItem, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\n columnNumber: 19\n }, this)\n }, menuItem, false, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 17\n }, this)), /*#__PURE__*/_jsxDEV(NavItem, {\n children: /*#__PURE__*/_jsxDEV(Link, {\n to: \"/login\",\n style: active === \"login\" ? activeStyle : {},\n className: \"navLinkMobile\",\n onClick: toggleCollapsed,\n children: \"Login\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 17\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 15\n }, this), /*#__PURE__*/_jsxDEV(NavItem, {\n children: /*#__PURE__*/_jsxDEV(Link, {\n to: \"/register\",\n className: \"navLinkMobile\",\n style: active === \"register\" ? activeStyle : {},\n onClick: toggleCollapsed,\n children: \"Register\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 17\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 97,\n columnNumber: 15\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 47,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 44,\n columnNumber: 12\n }, this);\n };\n\n const renderDesktopNav = () => {\n return /*#__PURE__*/_jsxDEV(Navbar, {\n color: \"dark\",\n dark: true,\n fixed: \"top\",\n children: [/*#__PURE__*/_jsxDEV(NavbarBrand, {\n className: \"mr-auto\",\n children: /*#__PURE__*/_jsxDEV(Link, {\n className: \"nav-logo-link\",\n to: \"/\",\n children: [/*#__PURE__*/_jsxDEV(\"img\", {\n src: logo,\n className: \"nav-logo\",\n alt: \"logo\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 113,\n columnNumber: 79\n }, this), \" GoScrobble\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 113,\n columnNumber: 40\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 113,\n columnNumber: 7\n }, this), user ? /*#__PURE__*/_jsxDEV(\"div\", {\n children: loggedInMenuItems.map(menuItem => /*#__PURE__*/_jsxDEV(Link, {\n className: \"navLink\",\n style: active === menuItem.toLowerCase() ? activeStyle : {},\n to: menuItem === \"My Profile\" ? \"/u/\" + user.username : \"/\" + menuItem.toLowerCase(),\n children: menuItem\n }, menuItem, false, {\n fileName: _jsxFileName,\n lineNumber: 117,\n columnNumber: 11\n }, this))\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 115,\n columnNumber: 9\n }, this) : /*#__PURE__*/_jsxDEV(\"div\", {\n children: menuItems.map(menuItem => /*#__PURE__*/_jsxDEV(Link, {\n className: \"navLink\",\n style: active === \"home\" && menuItem.toLowerCase() === \"home\" ? activeStyle : active === menuItem.toLowerCase() ? activeStyle : {},\n to: menuItem.toLowerCase() === \"home\" ? \"/\" : \"/\" + menuItem.toLowerCase(),\n children: menuItem\n }, menuItem, false, {\n fileName: _jsxFileName,\n lineNumber: 129,\n columnNumber: 11\n }, this))\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 127,\n columnNumber: 9\n }, this), user ? /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"navLinkLogin\",\n children: [/*#__PURE__*/_jsxDEV(Link, {\n to: \"/user\",\n style: active === \"user\" ? activeStyle : {},\n className: \"navLink\",\n children: \"Settings\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 142,\n columnNumber: 13\n }, this), user.admin && /*#__PURE__*/_jsxDEV(Link, {\n to: \"/admin\",\n style: active === \"admin\" ? activeStyle : {},\n className: \"navLink\",\n children: \"Admin\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 148,\n columnNumber: 13\n }, this), /*#__PURE__*/_jsxDEV(Link, {\n to: \"/admin\",\n className: \"navLink\",\n onClick: Logout,\n children: \"Logout\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 153,\n columnNumber: 13\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 141,\n columnNumber: 9\n }, this) : /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"navLinkLogin\",\n children: [/*#__PURE__*/_jsxDEV(Link, {\n to: \"/login\",\n style: active === \"login\" ? activeStyle : {},\n className: \"navLink\",\n children: \"Login\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 157,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(Link, {\n to: \"/register\",\n className: \"navLink\",\n style: active === \"register\" ? activeStyle : {},\n children: \"Register\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 162,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 156,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 112,\n columnNumber: 12\n }, this);\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: isMobile() ? renderMobileNav() : renderDesktopNav()\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 174,\n columnNumber: 5\n }, this);\n};\n\n_s(Navigation, \"HVWc+ugQ6omqVW30IunTA0viV2o=\", false, function () {\n return [useLocation];\n});\n\n_c = Navigation;\nexport default Navigation;\n\nvar _c;\n\n$RefreshReg$(_c, \"Navigation\");","map":{"version":3,"sources":["/app/src/Components/Navigation.js"],"names":["React","useState","useContext","Navbar","NavbarBrand","Collapse","Nav","NavbarToggler","NavItem","Link","useLocation","logo","AuthContext","menuItems","loggedInMenuItems","isMobile","test","navigator","userAgent","Navigation","location","active","pathname","length","replace","activeStyle","color","user","Logout","collapsed","setCollapsed","toggleCollapsed","renderMobileNav","map","menuItem","toLowerCase","username","admin","renderDesktopNav"],"mappings":";;;AAAA,SAASA,KAAT,EAAgBC,QAAhB,EAA0BC,UAA1B,QAA4C,OAA5C;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,QAA9B,EAAwCC,GAAxC,EAA6CC,aAA7C,EAA4DC,OAA5D,QAA2E,YAA3E;AACA,SAASC,IAAT,EAAeC,WAAf,QAAkC,kBAAlC;AACA,OAAOC,IAAP,MAAiB,aAAjB;AACA,OAAO,kBAAP;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;;AAEA,MAAMC,SAAS,GAAG,CAChB,MADgB,EAEhB,QAFgB,CAGhB;AAHgB,CAAlB;AAMA,MAAMC,iBAAiB,GAAG,CACxB,MADwB,EAExB,QAFwB,EAGxB,YAHwB,CAIxB;AAJwB,CAA1B;;AAOA,MAAMC,QAAQ,GAAG,MAAM;AACrB,SAAQ,iEAAiEC,IAAjE,CAAsEC,SAAS,CAACC,SAAhF,CAAR;AACD,CAFD;;AAIA,MAAMC,UAAU,GAAG,MAAM;AAAA;;AACvB,QAAMC,QAAQ,GAAGV,WAAW,EAA5B,CADuB,CAGvB;;AACA,MAAIW,MAAM,GAAG,MAAb;;AACA,MAAID,QAAQ,IAAIA,QAAQ,CAACE,QAArB,IAAiCF,QAAQ,CAACE,QAAT,CAAkBC,MAAlB,GAA2B,CAAhE,EAAmE;AACjEF,IAAAA,MAAM,GAAGD,QAAQ,CAACE,QAAT,CAAkBE,OAAlB,CAA0B,IAA1B,EAAgC,EAAhC,CAAT;AACD;;AAED,MAAIC,WAAW,GAAG;AAAEC,IAAAA,KAAK,EAAE;AAAT,GAAlB;AACA,MAAI;AAAEC,IAA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AAA;AAAA;AAAA;AAAA,UADF;AASD,CA5JD;;GAAMnB,U;UACaT,W;;;KADbS,U;AA8JN,eAAeA,UAAf","sourcesContent":["import { React, useState, useContext } from 'react';\nimport { Navbar, NavbarBrand, Collapse, Nav, NavbarToggler, NavItem } from 'reactstrap';\nimport { Link, useLocation } from 'react-router-dom';\nimport logo from '../logo.png';\nimport './Navigation.css';\n\nimport AuthContext from '../Contexts/AuthContext';\n\nconst menuItems = [\n 'Home',\n 'Recent',\n // 'About',\n];\n\nconst loggedInMenuItems = [\n 'Home',\n 'Recent',\n 'My Profile',\n // 'Docs',\n]\n\nconst isMobile = () => {\n return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))\n};\n\nconst Navigation = () => {\n const location = useLocation();\n\n // Lovely hack to highlight the current page (:\n let active = \"home\"\n if (location && location.pathname && location.pathname.length > 1) {\n active = location.pathname.replace(/\\//, \"\");\n }\n\n let activeStyle = { color: '#FFFFFF' };\n let { user, Logout } = useContext(AuthContext);\n let [collapsed, setCollapsed] = useState(true);\n\n const toggleCollapsed = () => {\n setCollapsed(!collapsed)\n }\n\n const renderMobileNav = () => {\n return <Navbar color=\"dark\" dark fixed=\"top\">\n <NavbarBrand className=\"mr-auto\"><Link className=\"nav-logo-link\" to=\"/\"><img src={logo} className=\"nav-logo\" alt=\"logo\" /> GoScrobble</Link></NavbarBrand>\n <NavbarToggler onClick={toggleCollapsed} className=\"mr-2\" />\n <Collapse isOpen={!collapsed} navbar>\n {user ?\n <Nav className=\"navLinkLoginMobile\" navbar>\n {loggedInMenuItems.map(menuItem =>\n <NavItem key={menuItem}>\n <Link\n key={menuItem}\n className=\"navLinkMobile\"\n style={active === menuItem.toLowerCase() ? activeStyle : {}}\n to={menuItem === \"My Profile\" ? \"/u/\" + user.username : \"/\" + menuItem.toLowerCase()}\n onClick={toggleCollapsed}\n >{menuItem}</Link>\n </NavItem>\n )}\n <Link\n to=\"/user\"\n style={active === \"user\" ? activeStyle : {}}\n className=\"navLinkMobile\"\n onClick={toggleCollapsed}\n >Settings</Link>\n {user.admin &&\n <Link\n to=\"/admin\"\n style={active === \"admin\" ? activeStyle : {}}\n className=\"navLink\"\n onClick={toggleCollapsed}\n >Admin</Link>}\n <Link to=\"/\" className=\"navLink\" onClick={Logout}>Logout</Link>\n </Nav>\n : <Nav className=\"navLinkLoginMobile\" navbar>\n {menuItems.map(menuItem =>\n <NavItem key={menuItem}>\n <Link\n key={menuItem}\n className=\"navLinkMobile\"\n style={active === \"home\" && menuItem.toLowerCase() === \"home\" ? activeStyle : (active === menuItem.toLowerCase() ? activeStyle : {})}\n to={menuItem.toLowerCase() === \"home\" ? \"/\" : \"/\" + menuItem.toLowerCase()}\n onClick={toggleCollapsed}\n >{menuItem}\n </Link>\n </NavItem>\n )}\n <NavItem>\n <Link\n to=\"/login\"\n style={active === \"login\" ? activeStyle : {}}\n className=\"navLinkMobile\"\n onClick={toggleCollapsed}\n >Login</Link>\n </NavItem>\n <NavItem>\n <Link\n to=\"/register\"\n className=\"navLinkMobile\"\n style={active === \"register\" ? activeStyle : {}}\n onClick={toggleCollapsed}\n >Register</Link>\n </NavItem>\n </Nav>\n }\n </Collapse>\n </Navbar>\n }\n\n const renderDesktopNav = () => {\n return <Navbar color=\"dark\" dark fixed=\"top\">\n <NavbarBrand className=\"mr-auto\"><Link className=\"nav-logo-link\" to=\"/\"><img src={logo} className=\"nav-logo\" alt=\"logo\" /> GoScrobble</Link></NavbarBrand>\n {user ?\n <div>\n {loggedInMenuItems.map(menuItem =>\n <Link\n key={menuItem}\n className=\"navLink\"\n style={active === menuItem.toLowerCase() ? activeStyle : {}}\n to={menuItem === \"My Profile\" ? \"/u/\" + user.username : \"/\" + menuItem.toLowerCase()}\n >\n {menuItem}\n </Link>\n )}\n </div>\n : <div>\n {menuItems.map(menuItem =>\n <Link\n key={menuItem}\n className=\"navLink\"\n style={active === \"home\" && menuItem.toLowerCase() === \"home\" ? activeStyle : (active === menuItem.toLowerCase() ? activeStyle : {})}\n to={menuItem.toLowerCase() === \"home\" ? \"/\" : \"/\" + menuItem.toLowerCase()}\n >\n {menuItem}\n </Link>\n )}\n </div>\n }\n {user ?\n <div className=\"navLinkLogin\">\n <Link\n to=\"/user\"\n style={active === \"user\" ? activeStyle : {}}\n className=\"navLink\"\n >Settings</Link>\n {user.admin &&\n <Link\n to=\"/admin\"\n style={active === \"admin\" ? activeStyle : {}}\n className=\"navLink\"\n >Admin</Link>}\n <Link to=\"/admin\" className=\"navLink\" onClick={Logout}>Logout</Link>\n </div>\n :\n <div className=\"navLinkLogin\">\n <Link\n to=\"/login\"\n style={active === \"login\" ? activeStyle : {}}\n className=\"navLink\"\n >Login</Link>\n <Link\n to=\"/register\"\n className=\"navLink\"\n style={active === \"register\" ? activeStyle : {}}\n >Register</Link>\n </div>\n\n }\n </Navbar>\n }\n\n return (\n <div>\n {\n isMobile()\n ? renderMobileNav()\n : renderDesktopNav()\n }\n </div>\n );\n}\n\nexport default Navigation;"]},"metadata":{},"sourceType":"module"} |