From 76147d89c6020ab6f5a36eee277e267d90915a09 Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 21 Dec 2021 09:42:28 -0300 Subject: [PATCH] Refactor and split Header CSS --- ui/component/header/view.jsx | 110 ++++++------ ui/component/headerMenuButtons/view.jsx | 6 +- .../headerNotificationButton/view.jsx | 7 +- ui/component/headerProfileMenuButton/view.jsx | 8 +- ui/scss/all.scss | 1 - ui/scss/component/_header.scss | 160 ++++++++++-------- ui/scss/component/_wunderbar.scss | 4 +- ui/scss/component/menu-button.scss | 6 - ui/scss/init/_gui.scss | 6 - 9 files changed, 155 insertions(+), 153 deletions(-) diff --git a/ui/component/header/view.jsx b/ui/component/header/view.jsx index ca51d8fb5..93b051868 100644 --- a/ui/component/header/view.jsx +++ b/ui/component/header/view.jsx @@ -1,4 +1,6 @@ // @flow +import 'scss/component/_header.scss'; + import { useIsMobile } from 'effects/use-screensize'; import { withRouter } from 'react-router'; import * as ICONS from 'constants/icons'; @@ -121,38 +123,38 @@ const Header = (props: Props) => { } }, [canBackout, onBackout]); - const userButtons = (className: string) => ( -
+ const userButtons = (hideWallet?: boolean, hideProfile?: boolean) => ( +
+ {isMobile && !authHeader && !canBackout && } + {authenticated ? ( <> - 0 - ? __('Immediately spendable: %spendable_balance%', { spendable_balance: roundedSpendableBalance }) - : __('Your Wallet') - } - > -
-
-
+ {!hideWallet && ( + 0 + ? __('Immediately spendable: %spendable_balance%', { spendable_balance: roundedSpendableBalance }) + : __('Your Wallet') + } + > +
+
+
+ )} - + {!hideProfile && } ) : ( -
-
)} @@ -161,25 +163,27 @@ const Header = (props: Props) => { return (
-
- {!authHeader && canBackout ? ( -
+ {!authHeader && canBackout ? ( +
+
- ) : ( - <> -
+ + {backTitle &&

{(isMobile && simpleBackTitle) || backTitle}

} + + {userButtons(false, isMobile)} +
+ ) : ( + <> +
+
{!authHeader && (
+ {!authHeader && !isMobile && ( +
+ + +
+ )} + {!authHeader && !canBackout - ? userButtons('header__navigation-item menu__title mobile-hidden') + ? userButtons(isMobile) : !isVerifyPage && !hideCancel && ( -
- {/* Add an empty span here so we can use the same style as above */} - {/* This pushes the close button to the right side */} - - +
)} - - )} -
+
+ + )}
); }; diff --git a/ui/component/headerMenuButtons/view.jsx b/ui/component/headerMenuButtons/view.jsx index 34a720fae..17cc32115 100644 --- a/ui/component/headerMenuButtons/view.jsx +++ b/ui/component/headerMenuButtons/view.jsx @@ -1,4 +1,6 @@ // @flow +import 'scss/component/_header.scss'; + import { ENABLE_UI_NOTIFICATIONS, ENABLE_NO_SOURCE_CLAIMS, CHANNEL_STAKED_LEVEL_LIVESTREAM } from 'config'; import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button'; import * as ICONS from 'constants/icons'; @@ -41,7 +43,7 @@ export default function HeaderMenuButtons(props: HeaderMenuButtonProps) { {authenticated && ( - + @@ -59,7 +61,7 @@ export default function HeaderMenuButtons(props: HeaderMenuButtonProps) { - + diff --git a/ui/component/headerNotificationButton/view.jsx b/ui/component/headerNotificationButton/view.jsx index 06c0ce9f8..dd1f4ec4c 100644 --- a/ui/component/headerNotificationButton/view.jsx +++ b/ui/component/headerNotificationButton/view.jsx @@ -1,4 +1,6 @@ // @flow +import 'scss/component/_header.scss'; + import { ENABLE_UI_NOTIFICATIONS } from 'config'; import { useHistory } from 'react-router'; import * as ICONS from 'constants/icons'; @@ -30,10 +32,7 @@ export default function NotificationHeaderButton(props: Props) { return ( - diff --git a/ui/component/headerProfileMenuButton/view.jsx b/ui/component/headerProfileMenuButton/view.jsx index 4eba7c1eb..26c57ec96 100644 --- a/ui/component/headerProfileMenuButton/view.jsx +++ b/ui/component/headerProfileMenuButton/view.jsx @@ -1,4 +1,6 @@ // @flow +import 'scss/component/_header.scss'; + import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button'; import * as ICONS from 'constants/icons'; import * as PAGES from 'constants/pages'; @@ -25,9 +27,9 @@ export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) { {activeChannelUrl ? ( diff --git a/ui/scss/all.scss b/ui/scss/all.scss index 04d9196ec..dc7d5356d 100644 --- a/ui/scss/all.scss +++ b/ui/scss/all.scss @@ -30,7 +30,6 @@ @import 'component/file-render'; @import 'component/footer'; @import 'component/form-field'; -@import 'component/header'; @import 'component/icon'; @import 'component/main'; @import 'component/markdown-editor'; diff --git a/ui/scss/component/_header.scss b/ui/scss/component/_header.scss index 0c2044388..f5fcebb56 100644 --- a/ui/scss/component/_header.scss +++ b/ui/scss/component/_header.scss @@ -1,3 +1,6 @@ +@import '../init/vars'; +@import '../init/mixins'; + .header { z-index: 3; // Main content uses z-index: 1, other content uses z-index: 2, this ensures it always scrolls under the header position: fixed; @@ -6,6 +9,7 @@ background-color: var(--color-header-background); box-shadow: var(--card-box-shadow); font-size: var(--font-body); + user-select: none; -webkit-user-select: none; -webkit-app-region: drag; @@ -23,31 +27,32 @@ opacity: 1; position: relative; overflow: unset; - width: inherit; - height: inherit; + width: unset; + height: unset; } } - - & > * { - user-select: none; - } } .header--minimal { box-shadow: none; background-color: var(--color-background); border-bottom: none; -} -.header--mac { - padding-top: var(--mac-titlebar-height); + .header__navigation { + padding: var(--spacing-xs); + } + + .header__navigationItem--logo { + height: 3rem; + } } .header__contents { - height: calc(var(--header-height)); display: flex; align-items: center; - padding: 0 var(--spacing-m); + flex: 1; + height: var(--header-height); + padding: var(--spacing-s) var(--spacing-m); @media (max-width: $breakpoint-small) { padding: var(--spacing-xs); @@ -55,16 +60,40 @@ } .header__navigation { + display: flex; + align-items: center; + justify-content: space-between; flex: 1; + height: var(--header-height); + padding: var(--spacing-s) var(--spacing-m); + flex-wrap: nowrap; +} + +.card__actions--between { + .header__menu--left { + @media (max-width: $breakpoint-small) { + max-width: 3rem; + } + } +} + +.header__menu { display: flex; align-items: center; } -.header__menu { - margin-left: auto; - display: flex; - justify-content: space-between; - align-items: center; +.header__menu--left { + @extend .header__menu; + justify-content: flex-start; +} + +.header__menu--right { + @extend .header__menu; + justify-content: flex-end; + + @media (max-width: $breakpoint-small) { + max-width: 4rem; + } } .header__buttons { @@ -78,7 +107,7 @@ max-width: fit-content; } -.header__navigation-item { +.header__navigationItem { height: var(--height-button); display: flex; justify-content: center; @@ -90,11 +119,14 @@ svg { stroke: var(--color-text); } + + &[aria-expanded='true'] { + background-color: var(--color-header-button-active); + } } -.header__navigation-item--back, -.header__navigation-item--forward, -.header__navigation-item--icon { +.header__navigationItem--icon { + @extend .header__navigationItem; width: var(--height-button); background-color: var(--color-header-button); border-radius: 1.5rem; @@ -110,6 +142,10 @@ } } + @media (max-width: $breakpoint-small) { + margin: 0; + } + span { display: flex; justify-content: center; @@ -117,8 +153,8 @@ } } -.header__navigation-item--profile-pic { - margin-left: var(--spacing-m); +.header__navigationItem--profilePic { + margin-right: var(--spacing-s); .channel-thumbnail { height: var(--height-button); @@ -131,8 +167,8 @@ } } -.header__navigation-item--balance { - @extend .button--file-action; +.header__navigationItem--balance { + @extend .header__navigationItem; margin: 0 var(--spacing-s); color: var(--color-text); @@ -141,17 +177,8 @@ } } -.header__navigation-item--forward { - margin-right: 0; -} - -.header__navigation-item--icon { - @media (max-width: $breakpoint-small) { - margin: 0; - } -} - -.header__navigation-item--lbry { +.header__navigationItem--logo { + @extend .header__navigationItem; height: 4rem; display: flex; align-items: center; @@ -173,61 +200,44 @@ } } -.header--minimal { - .header__navigation-item--lbry { - height: 3rem; - } -} - -.header__navigation-dropdown { - @extend .menu__list--header; - padding: 0; - position: absolute; - list-style-type: none; - background-color: var(--color-header-background); -} - -.header__navigation-button { - margin: 0; - padding: var(--spacing-xxs) var(--spacing-m); - display: flex; - align-items: center; - - &:hover { - cursor: pointer; - background-color: var(--color-menu-background--active); - } -} - -.header__navigation-button-help { - @extend .help; - margin-top: 0; - margin-left: var(--spacing-s); -} - -.header__auth-buttons { +.header__authButtons { display: flex; align-items: center; font-weight: var(--font-weight-bold); - margin-left: var(--spacing-s); & > *:not(:last-child) { margin: 0 var(--spacing-m); } + + @media (max-width: $breakpoint-small) { + .button--link { + margin: 0; + } + + .button--primary { + padding: var(--spacing-xxs); + } + } } .header__center { display: flex; - justify-content: flex-end; + justify-content: center; width: 100%; - - @media (min-width: $breakpoint-small) { - justify-content: center; - } } -.header__auth-title { +.header__authTitle { + @extend .header__center; + justify-content: center; + @media (min-width: $breakpoint-small) { font-size: var(--font-large); } } + +.ReactModal__Overlay { + .button--close { + margin: 0; + margin-top: var(--spacing-xxs); + } +} diff --git a/ui/scss/component/_wunderbar.scss b/ui/scss/component/_wunderbar.scss index 191cb745d..b08561926 100644 --- a/ui/scss/component/_wunderbar.scss +++ b/ui/scss/component/_wunderbar.scss @@ -1,3 +1,5 @@ +@import './header'; + .wunderbar__wrapper { flex: 1; max-width: 30rem; @@ -227,7 +229,7 @@ .wunderbar__mobile-search { @extend .button--alt; - @extend .header__navigation-item--icon; + @extend .header__navigationItem--icon; padding: var(--spacing-xs); margin-right: var(--spacing-m); diff --git a/ui/scss/component/menu-button.scss b/ui/scss/component/menu-button.scss index 93745c1fc..02dbb227c 100644 --- a/ui/scss/component/menu-button.scss +++ b/ui/scss/component/menu-button.scss @@ -65,12 +65,6 @@ } } -.menu__title { - &[aria-expanded='true'] { - background-color: var(--color-header-button-active); - } -} - .menu__list { box-shadow: var(--card-box-shadow); animation: menu-animate-in var(--animation-duration) var(--animation-style); diff --git a/ui/scss/init/_gui.scss b/ui/scss/init/_gui.scss index 8aca82a6d..f517051e9 100644 --- a/ui/scss/init/_gui.scss +++ b/ui/scss/init/_gui.scss @@ -479,12 +479,6 @@ textarea { } } -.mobile-hidden { - @media (max-width: $breakpoint-small) { - display: none !important; - } -} - .ads-test { height: 50vh; position: relative;