From 136865e196c8c3b4cf07100effe0181af267bd6f Mon Sep 17 00:00:00 2001 From: Richard Xia Date: Thu, 27 Jun 2024 21:04:10 -0700 Subject: [PATCH] Add login/profile widget to nav bar. This allows the login page to be discoverable, since previously, you had to manually type in the address of the login page into the address bar. This is gated as a new whitelabel property named `loginEnabled`, which is only being enabled on the SFSG site and the legacy default askdarcel site. --- app/components/ui/Navigation.module.scss | 50 ++++++++++++++++++++++++ app/components/ui/Navigation.tsx | 48 ++++++++++++++++++----- app/components/ui/nav-profile-icon.svg | 1 + app/utils/whitelabel.ts | 4 ++ 4 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 app/components/ui/nav-profile-icon.svg diff --git a/app/components/ui/Navigation.module.scss b/app/components/ui/Navigation.module.scss index 853296631..c62557863 100644 --- a/app/components/ui/Navigation.module.scss +++ b/app/components/ui/Navigation.module.scss @@ -199,3 +199,53 @@ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15); } } + +.profileMenuContainer { + position: relative; +} + +.profileMenuButton { + background: transparent; + // Unset the global styles coming from _forms.scss + height: revert; + padding: revert; + + &:active, + &:focus, + &:hover { + box-shadow: none; + } +} + +.profileMenuButtonImage { + height: 32px; + // Esoteric way to force an image to any color you want. This matches + // $color-brand + // https://stackoverflow.com/a/53336754 + filter: invert(32%) sepia(55%) saturate(4616%) hue-rotate(211deg) + brightness(97%) contrast(85%); +} + +.profileMenu { + display: none; + position: absolute; + right: 0; + box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.2); + min-width: 200px; + background: white; + + &.isOpen { + display: block; + } +} + +.profileMenuItemLink { + display: block; + padding: 12px 16px; + + &:active, + &:focus, + &:hover { + backdrop-filter: brightness(95%); + } +} diff --git a/app/components/ui/Navigation.tsx b/app/components/ui/Navigation.tsx index c9263a65f..d12eb5d1c 100644 --- a/app/components/ui/Navigation.tsx +++ b/app/components/ui/Navigation.tsx @@ -5,6 +5,7 @@ import qs from "qs"; import { useAppContext, whiteLabel } from "utils"; import Translate from "./Translate"; import styles from "./Navigation.module.scss"; +import navProfileIcon from "./nav-profile-icon.svg"; const { appImages: { logoSmall }, @@ -14,6 +15,7 @@ const { showReportCrisis, siteNavStyle, title, + loginEnabled, } = whiteLabel; export const Navigation = ({ @@ -94,15 +96,6 @@ const SiteLinks = () => { return (