From aaa4267c4cbaf7edb6a5c60878548ec489f63510 Mon Sep 17 00:00:00 2001 From: Omar Bravo Date: Mon, 24 Jun 2024 09:11:17 -0600 Subject: [PATCH] Navbar-update (#366) Made Navbar responsive and updated styles to match Figma designs --- src/components/Navbar/Navbar.stories.tsx | 12 +-- src/components/Navbar/Navbar.tsx | 56 +++----------- src/components/Navbar/navbar.less | 94 ++++++++++++++++++------ src/components/PageHeader/header.less | 12 +-- 4 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/components/Navbar/Navbar.stories.tsx b/src/components/Navbar/Navbar.stories.tsx index 70920b34f..4bf3e005b 100644 --- a/src/components/Navbar/Navbar.stories.tsx +++ b/src/components/Navbar/Navbar.stories.tsx @@ -21,20 +21,14 @@ const LoggedInUser = { export const LoggedIn: Story = { args: { - links: ExampleLinks, - user: LoggedInUser + links: ExampleLinks } }; export const LoggedOut: Story = { - args: { - links: ExampleLinks, - user: { loginHref: '#' } - } + args: {} }; export const NoUser: Story = { - args: { - links: ExampleLinks - } + args: {} }; diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx index 25c3d7ec2..f68877c50 100644 --- a/src/components/Navbar/Navbar.tsx +++ b/src/components/Navbar/Navbar.tsx @@ -1,4 +1,3 @@ -import type { JSXElement } from '~/src/types/jsxElement'; import CFPBLogo from '../../assets/images/cfpb-logo.png'; import Link from '../Link/Link'; import './navbar.less'; @@ -35,54 +34,16 @@ const Links = ({ interface NavbarProperties { links?: JSX.Element[]; - user?: User; href?: string; } -export interface User { - name?: string; - loginHref?: string; - logoutHref?: string; -} - -interface UserActionsProperties { - user?: User; -} - -const UserActions = ({ user }: UserActionsProperties): JSXElement => { - if (!user) return null; - - if (!user.name) - return ( -
- - LOGIN - -
- ); - - return ( -
- {user.name} - - LOGOUT - -
- ); -}; - -export default function Navbar({ - links, - user, - href -}: NavbarProperties): JSX.Element { +export default function Navbar({ links, href }: NavbarProperties): JSX.Element { return (
-
@@ -90,13 +51,16 @@ export default function Navbar({ } export const ExampleLinks: JSX.Element[] = [ - - HOME + + Home + , + + Filing , - - FILING HOME + + John Sample , - - DATASETS + + LOG OUT ]; diff --git a/src/components/Navbar/navbar.less b/src/components/Navbar/navbar.less index 506344fe3..a7077620d 100644 --- a/src/components/Navbar/navbar.less +++ b/src/components/Navbar/navbar.less @@ -1,49 +1,99 @@ @import (reference) '/src/assets/styles/_shared.less'; +@breakpoint: 56.3125em; + .navbar { display: flex; - flex-flow: row; - align-items: center; - justify-content: space-between; - font-size: 14px; + flex-direction: column; + align-items: flex-start; + font-size: 16px; padding-bottom: @space-sm; + @media (min-width: @breakpoint) { + flex-direction: row; + justify-content: space-between; + align-items: center; + + .o-header_logo { + min-width: 237px; + } + } + .nav-items { display: flex; - flex-flow: row; - } + flex-direction: column; + width: 100%; - .nav-item { - margin-right: @space-xl; - letter-spacing: unit((1px / @base-font-size-px), em); + @media (min-width: @breakpoint) { + flex-direction: row; + justify-content: flex-end; + } + + .links { + display: flex; + flex-direction: column; + width: 100%; + + a { + cursor: pointer; + } + .a-btn { + font-weight: 400; + } + .a-btn__link { + text-decoration: none; + } + + @media (min-width: @breakpoint) { + flex-direction: row; + justify-content: flex-end; + width: auto; + } + } + + .links > *:first-child { + border-top: 1px dashed @pacific-90; + @media (min-width: @breakpoint) { + border-top: none; + } + } + + .links > *:last-child { + margin-right: 0; + } } - .user-actions :last-child { + .nav-item { margin-right: 0; - } + letter-spacing: unit((1px / @base-font-size-px), em); + padding: 10px 0; - .a-link { - color: @gray-dark; - font-weight: 600; + @media (min-width: @breakpoint) { + margin-right: @space-xl; + padding: 0; + } } - .a-link:not(.o-header_logo):hover { + .a-link:not(.o-header_logo) { color: @pacific-90; border-bottom: 1px dashed; } - .a-link:focus { - color: @pacific-90; - } - - .a-link.selected { - border-bottom: 3px solid @gray-dark; + .a-link:not(.o-header_logo):hover, + .a-link:not(.o-header_logo).active { + border-bottom: 1px solid @pacific-90; } .username { + color: @pacific-90; font-size: unit((16px / @base-font-size-px), em); - margin-right: @space-xl; + margin-right: 0; font-weight: 400; line-height: unit((22px / @base-font-size-px), em); + border-bottom: 1px dashed; + + @media (min-width: @breakpoint) { + margin-right: @space-xl; + } } } diff --git a/src/components/PageHeader/header.less b/src/components/PageHeader/header.less index 4383e9e1a..b8774af16 100644 --- a/src/components/PageHeader/header.less +++ b/src/components/PageHeader/header.less @@ -3,17 +3,11 @@ position: relative; z-index: 10; background-color: #ffffff; - + &.bottom-border { border-bottom: 5px solid #20aa3f; } } - -@media only all and (min-width: 63.8125em) { - .o-header { - min-width: 1021px; - } -} .o-header_content { position: relative; } @@ -63,7 +57,7 @@ } .o-header_logo-img { height: 34px; - width: auto; + width: 100%; margin-top: 10px; margin-bottom: 10px; vertical-align: middle; @@ -99,5 +93,3 @@ .print .o-header_logo { margin-left: 15px !important; } - -