From 13738f9fefc1234bf71b1ca4aab0c04d78f788af Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Tue, 30 Jul 2024 12:59:23 +0200 Subject: [PATCH] Show watch on small screens / Refactor `header` CSS + Markup - Improve code readability Deconstruct props, simplify Profile text logic, fix typos - Combined `.header__menu-profile` + `.header__menu-bookmarked` + `.header__menu-navigation-button` Consolidated for simplicity - Restructure nested CSS Added BEM classes for child items and modifiers - Align markup with dpl-cms - Introduced `.header__menu-second` - Converted profile to an HTML button - Eliminated redundant CSS - `.hide-linkstyle` - Added `.header__button-responsive-switch` a container to handle the switch between `.header__button` based on screen size --- src/stories/Blocks/header/Header.tsx | 69 ++++++++++------- src/stories/Blocks/header/header.scss | 105 ++++++++++++++------------ 2 files changed, 97 insertions(+), 77 deletions(-) diff --git a/src/stories/Blocks/header/Header.tsx b/src/stories/Blocks/header/Header.tsx index c1b2d31d4..b46b6d62c 100644 --- a/src/stories/Blocks/header/Header.tsx +++ b/src/stories/Blocks/header/Header.tsx @@ -20,14 +20,13 @@ export type HeaderProps = { openDropdown: boolean; }; -export const Header = (props: HeaderProps) => { - const { - signedIn, - haveNotification, - username, - inputPlaceholder, - openDropdown, - } = props; +export const Header = ({ + signedIn, + haveNotification, + username, + inputPlaceholder, + openDropdown, +}: HeaderProps) => { const [isDropdownOpen, setIsDropdownOpen] = useState(openDropdown); useEffect(() => { @@ -43,7 +42,7 @@ export const Header = (props: HeaderProps) => { hasImage libraryName="Hjørring" libraryPlace="Bibliotekerne" - altText="PromoTitle image of libary" + altText="PromoTitle image of library" /> @@ -56,7 +55,7 @@ export const Header = (props: HeaderProps) => {
-
- - {signedIn && haveNotification && ( -
- )} - - {signedIn && ( - {username} - )} - {!signedIn && Login} + +
+ + + Opening hours -
-
- - - Liked + + + Liked
-
+
*:first-child { + @include media-query__small { + display: none; + } } - span { - position: absolute; - bottom: 0; + > *:last-child { + display: none; + + @include media-query__small { + display: flex; + } + } +} + +.header__button-text { + display: none; + + @include media-query__small { + display: block; + @include typography($typo__small-caption); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; width: 100%; padding: 0 $s-xs; text-align: center; - } - - @include media-query__small { - span { - bottom: $s-xs; - } - } - - .header__notification { position: absolute; - width: $s-sm; - height: $s-sm; - border-radius: 100%; - transform: translateX(10px) translateY(-12px); + bottom: $s-xs; } } +.header__button-icon { + width: 24px; + height: 24px; +} + .header__menu-second { height: 100%; } @@ -206,20 +229,6 @@ align-items: center; } -.header__button { - height: 56px; - width: 56px; - display: flex; - justify-content: center; - align-items: center; - color: $color__text-primary-black; - - @include media-query__small { - height: 70px; - width: 70px; - } -} - // has-burger-menu is added dynamically using JS, by calculating if there // is enough space to show the desktop menu, and otherwise enabling the // burger menu. @see header-state.js @@ -248,7 +257,3 @@ display: flex; } } - -#header-sidebar-nav__toggle { - cursor: pointer; -}