From c63683b25759dec4003f16731179ccb32a88710e Mon Sep 17 00:00:00 2001 From: Aashray Katiyar Date: Wed, 18 Jan 2023 18:31:28 +0530 Subject: [PATCH] [NEW] : backport improve navbar #73 --- app/components/conferences/EventAdmin.js | 8 +- app/components/menubar/newMenuBar.js | 350 +++++++++++++++++++++++ app/styles/Menubar.module.css | 116 ++++++-- 3 files changed, 444 insertions(+), 30 deletions(-) create mode 100644 app/components/menubar/newMenuBar.js diff --git a/app/components/conferences/EventAdmin.js b/app/components/conferences/EventAdmin.js index 2685c83f..23d92d73 100644 --- a/app/components/conferences/EventAdmin.js +++ b/app/components/conferences/EventAdmin.js @@ -1,4 +1,5 @@ import { useEffect, useState } from "react"; +import NewMenubar from "../menubar/newMenuBar"; import Menubar from "../menubar"; import _ from "lodash"; import Cookies from "js-cookie"; @@ -52,15 +53,18 @@ export const VerifyUserRole = ({ menuprops }) => { "An error ocurred while getting user details on Superprofile", error ); + throw new Error(`An error ocurred while getting user details on Superprofile: ${error?.response?.data?.errors?.[0]?.detail}`); } return ( <> {abortAdmin()} {verified ? ( - + // + ) : ( - + // + )} ); diff --git a/app/components/menubar/newMenuBar.js b/app/components/menubar/newMenuBar.js new file mode 100644 index 00000000..adefef8b --- /dev/null +++ b/app/components/menubar/newMenuBar.js @@ -0,0 +1,350 @@ +import { useEffect, useRef, useState, forwardRef } from 'react'; +import { Navbar, Nav, Container, Col, Row, Offcanvas, Dropdown } from 'react-bootstrap'; +import styles from '../../styles/Menubar.module.css'; +import BrandLogo from "../brandlogo"; +import RocketChatLinkButton from "../rocketchatlinkbutton"; +import Cookies from "js-cookie"; +import Link from "next/link"; +import { DummyLoginButton } from "../auth/dummy"; +import RCGoogleLoginButton from "../auth/goauth/ui/GoogleRCLogin"; + +const userCookie = Cookies.get("user"); +const isUserLoggedIn = Cookies.get("hashmail") ? true : false; +const hasAllRequiredCreds = + process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID && + process.env.NEXT_PUBLIC_RC_URL; + +const CustomToggle = forwardRef(({ children, onClick }, ref) => ( + { + e.preventDefault(); + onClick(e); + }} + > + {children} + + +)); + +if (!hasAllRequiredCreds) console.log("RC4Community is now using a dummy Auth Component! If you wish to use a robust Auth component, provide all the credentials first (https://github.com/RocketChat/RC4Community/tree/master/app/components/auth)") + + +const ArrowIcon = () => { + return ( + + + + ); +}; + +const MobileNav = ({ nav_Items }) => { + const [dropDown, setDropDown] = useState({ show: false, _id: 0 }); + return ( + + + +
+ + +
+
+ + + + + + + + {nav_Items?.map((nav_Item) => + nav_Item.url ? ( +
+ { + setDropDown({ show: false, _id: 0 }); + }} + > + + + {nav_Item.label} + + + +
+ ) : ( +
+ { + if (dropDown._id === nav_Item.id) { + setDropDown({ show: false, _id: 0 }); + } else { + setDropDown({ show: true, _id: nav_Item.id }); + } + }} + > + + {nav_Item.label} + + + {nav_Item.sub_menus?.data?.length > 1 && ( + + + + )} + + + {dropDown._id === nav_Item.id && dropDown.show ? ( +
+
+ {nav_Item.sub_menus.data.map( + (item, key) => + ( + <> + + {nav_Item.attributes?.parent_id && nav_Item.sub_menus.data.map( + (subItem, key) => + subItem.attributes.parent_id === item.attributes.id && ( + + ) + )} + + ) + )} +
+
+ ) : ( + '' + )} +
+ ) + )} +
+
+ +
+
+ ); +}; + +const DesktopNav = ({ nav_Items }) => { + + const [isShown, setIsShown] = useState(0); + const clickRef = useRef(null); + + const handleClickOutside = (event) => { + if (clickRef.current && !clickRef.current.contains(event.target)) { + setIsShown(false); + } + }; + + useEffect(() => { + document.addEventListener('click', handleClickOutside, true); + return () => { + document.removeEventListener('click', handleClickOutside, true); + }; + }, []); + + return ( + + + + + + + ); +}; + +const SidebarItem = () => { + return ( + +
+ + <> + {isUserLoggedIn && ( + + Click to Chat + + )} + {userCookie && ( +
+ + + + RC4Community Profile + + + Profile + + + + +
+ )} + + +
+ {hasAllRequiredCreds ? ( + + ) : ( + + )} +
+
+ ); +} + +export default function NewMenubar(props) { + return ( + + + + + ); +} diff --git a/app/styles/Menubar.module.css b/app/styles/Menubar.module.css index 1b06045e..e657cd86 100644 --- a/app/styles/Menubar.module.css +++ b/app/styles/Menubar.module.css @@ -5,6 +5,11 @@ display: none !important; } +.clickToChat_button { + position: absolute; + right: 100px; +} + .navbarItem::after { position: absolute; bottom: 0; @@ -22,6 +27,9 @@ width: 100%; } +.brand { + margin-right: 0px; +} .my-dropdown-toggle:after { display: none; } @@ -36,44 +44,46 @@ .default_toggler:hover, .default_toggler:active, .default_toggler:focus { - border: 0; + outline: 0px solid white; + border-inline: 0px solid white; + border: 0px solid white; + border-color: white; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; + box-shadow: 0 0 0 0; +} + +.btn-close:focus { + box-shadow: 0 0 0 0rem rgba(255, 255, 255, 0); + border: 0px solid white; + outline: 0px solid white; } .navbar_toggler { - width: 30px; + width: 33px; height: 20px; position: relative; transition: 0.5s ease-in-out; + border: 0px; } -.navbar_toggler, -.navbar_toggler:focus, -.navbar_toggler:active, -.toggler_icon:focus { - outline: none; - box-shadow: none; - border: 0; +.navbar-light .navbar_toggler { + border: 0px; } .toggler_icon { - margin: 0; - padding: 0; display: block; - position: absolute; height: 2px; width: 100%; - background: rgb(107, 107, 107); + background: rgb(62, 62, 62); border-radius: 1px; - left: 0; - top: 18px; } -.toggler_icon::before, .toggler_icon::after{ +.toggler_icon::before, +.toggler_icon::after { content: ''; position: absolute; left: 0; @@ -85,11 +95,11 @@ } .toggler_icon::after { - top: 10px; + top: 3px; } -.toggler_icon::before{ - top: -10px; +.toggler_icon::before { + top: 13px; } /* when navigation is clicked */ @@ -103,29 +113,73 @@ margin-top: -10px; } -.toggler_bar::after{ +.toggler_bar::after { transform: rotate(-45deg); top: 0; } -.toggler_bar::before{ - transform: rotate(45deg); - top: 0 +.rotate { + transform: rotate(-180deg); + transition: all 0.1s; +} +.navbar_subitems { + position: absolute; + transform: translate(-5rem, 30px); + background-color: white; + padding: 0rem; + max-width: 36rem; + z-index: 10; +} + +.navbar_subitems_items { + padding: 1rem 1rem 1rem 2rem; + width: 18rem; } +.subItemLinks { + cursor: pointer; + + text-decoration: none; + color: black; +} + +.color { + color: red; +} + +.arrow { + margin-left: 80%; +} + +.arrowRotate { + margin-left: 80%; + transform: rotate(180deg); +} +.navbar_item_hover:hover { + cursor: pointer; + color: red; +} + +.dropdown { + cursor: pointer; +} + +.toggler_bar::before { + transform: rotate(45deg); + top: 0; +} .threedots:after { - content: "\2807"; + content: '\2807'; font-size: 30px; height: 100%; padding-left: 7px; } .elipses:hover, -.elipses { - color: #87898d; - text-decoration-line: none !important; - +.elipses { + color: #87898d; + text-decoration-line: none !important; } .dropdown_menu { @@ -141,4 +195,10 @@ .dropdown_menu_item { color: black; text-decoration: none; +} + +.disabled { + pointer-events: none; + cursor: default; + opacity: 0.6; } \ No newline at end of file