Custom body scrollbar + disable body scroll when overlay or image viewer opened (#897)
This commit is contained in:
parent
6a69e02d57
commit
56f8d8b71a
7 changed files with 41 additions and 5 deletions
|
@ -295,6 +295,11 @@ function App(props: Props) {
|
||||||
document.documentElement.setAttribute('theme', theme);
|
document.documentElement.setAttribute('theme', theme);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// $FlowFixMe
|
||||||
|
document.body.style.overflowY = currentModal ? 'hidden' : '';
|
||||||
|
}, [currentModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasMyChannels && !hasActiveChannelClaim) {
|
if (hasMyChannels && !hasActiveChannelClaim) {
|
||||||
setActiveChannelIfNotSet();
|
setActiveChannelIfNotSet();
|
||||||
|
|
|
@ -250,6 +250,7 @@ function SideNavigation(props: Props) {
|
||||||
|
|
||||||
const showMicroMenu = !sidebarOpen && !menuCanCloseCompletely;
|
const showMicroMenu = !sidebarOpen && !menuCanCloseCompletely;
|
||||||
const showPushMenu = sidebarOpen && !menuCanCloseCompletely;
|
const showPushMenu = sidebarOpen && !menuCanCloseCompletely;
|
||||||
|
const showOverlay = isAbsolute && sidebarOpen;
|
||||||
|
|
||||||
const showSubscriptionSection = shouldRenderLargeMenu && isPersonalized && subscriptions && subscriptions.length > 0;
|
const showSubscriptionSection = shouldRenderLargeMenu && isPersonalized && subscriptions && subscriptions.length > 0;
|
||||||
const showTagSection = sidebarOpen && isPersonalized && followedTags && followedTags.length;
|
const showTagSection = sidebarOpen && isPersonalized && followedTags && followedTags.length;
|
||||||
|
@ -362,6 +363,11 @@ function SideNavigation(props: Props) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
// $FlowFixMe
|
||||||
|
document.body.style.overflowY = showOverlay ? 'hidden' : '';
|
||||||
|
}, [showOverlay]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (purchaseSuccess) {
|
if (purchaseSuccess) {
|
||||||
setPulseLibrary(true);
|
setPulseLibrary(true);
|
||||||
|
@ -501,7 +507,7 @@ function SideNavigation(props: Props) {
|
||||||
</nav>
|
</nav>
|
||||||
<div
|
<div
|
||||||
className={classnames('navigation__overlay', {
|
className={classnames('navigation__overlay', {
|
||||||
'navigation__overlay--active': isAbsolute && sidebarOpen,
|
'navigation__overlay--active': showOverlay,
|
||||||
})}
|
})}
|
||||||
onClick={() => setSidebarOpen(false)}
|
onClick={() => setSidebarOpen(false)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
z-index: 3; // Main content uses z-index: 1, other content uses z-index: 2, this ensures it always scrolls under the 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;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100vw;
|
||||||
background-color: var(--color-header-background);
|
background-color: var(--color-header-background);
|
||||||
font-size: var(--font-body);
|
font-size: var(--font-body);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
@ -137,6 +137,7 @@
|
||||||
height: var(--header-height);
|
height: var(--header-height);
|
||||||
padding: var(--spacing-s) var(--spacing-m);
|
padding: var(--spacing-s) var(--spacing-m);
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
|
margin-right: var(--body-scrollbar-width);
|
||||||
|
|
||||||
.wunderbar__wrapper {
|
.wunderbar__wrapper {
|
||||||
.wunderbar__input {
|
.wunderbar__input {
|
||||||
|
|
|
@ -20,6 +20,8 @@ html {
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
width: calc(100vw - var(--body-scrollbar-width));
|
||||||
|
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
|
@ -33,11 +35,20 @@ body {
|
||||||
scrollbar-color: var(--color-scrollbar-thumb-bg) var(--color-scrollbar-track-bg);
|
scrollbar-color: var(--color-scrollbar-thumb-bg) var(--color-scrollbar-track-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
body *::-webkit-scrollbar {
|
body::-webkit-scrollbar {
|
||||||
width: 6px;
|
width: var(--body-scrollbar-width);
|
||||||
height: 6px;
|
height: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body *::-webkit-scrollbar {
|
||||||
|
width: var(--scrollbar-width);
|
||||||
|
height: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body::-webkit-scrollbar-track {
|
||||||
|
background: var(--color-body-scrollbar-track-bg);
|
||||||
|
}
|
||||||
|
|
||||||
body *::-webkit-scrollbar-track {
|
body *::-webkit-scrollbar-track {
|
||||||
background: var(--color-scrollbar-track-bg);
|
background: var(--color-scrollbar-track-bg);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +58,12 @@ body *::-webkit-scrollbar-thumb {
|
||||||
// standard currently doesn't support it. Stick with square
|
// standard currently doesn't support it. Stick with square
|
||||||
// scrollbar for all browsers.
|
// scrollbar for all browsers.
|
||||||
background-color: var(--color-scrollbar-thumb-bg);
|
background-color: var(--color-scrollbar-thumb-bg);
|
||||||
border-radius: 4px;
|
border-radius: var(--scrollbar-radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
body::-webkit-scrollbar-thumb {
|
||||||
|
background-color: var(--color-scrollbar-thumb-bg);
|
||||||
|
border-radius: var(--scrollbar-radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
|
|
|
@ -107,10 +107,16 @@
|
||||||
// Animations
|
// Animations
|
||||||
--resizing-animation-function: ease-in;
|
--resizing-animation-function: ease-in;
|
||||||
--resizing-animation-timing: 180ms;
|
--resizing-animation-timing: 180ms;
|
||||||
|
|
||||||
|
//Scrollbars
|
||||||
|
--body-scrollbar-width: 12px;
|
||||||
|
--scrollbar-width: 6px;
|
||||||
|
--scrollbar-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $breakpoint-small) {
|
@media (max-width: $breakpoint-small) {
|
||||||
:root {
|
:root {
|
||||||
--font-body: 0.8rem;
|
--font-body: 0.8rem;
|
||||||
|
--body-scrollbar-width: 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,7 @@
|
||||||
// Scrollbar
|
// Scrollbar
|
||||||
--color-scrollbar-thumb-bg: rgba(255, 255, 255, 0.2);
|
--color-scrollbar-thumb-bg: rgba(255, 255, 255, 0.2);
|
||||||
--color-scrollbar-track-bg: transparent;
|
--color-scrollbar-track-bg: transparent;
|
||||||
|
--color-body-scrollbar-track-bg: rgba(0, 0, 0, 0.5);
|
||||||
|
|
||||||
--background-shade: linear-gradient(-180deg, rgba(25, 25, 25, 0.2) 2%, #202020),
|
--background-shade: linear-gradient(-180deg, rgba(25, 25, 25, 0.2) 2%, #202020),
|
||||||
radial-gradient(circle at 50% 117%, rgba(25, 25, 25, 0.2) 0, #202020 100%);
|
radial-gradient(circle at 50% 117%, rgba(25, 25, 25, 0.2) 0, #202020 100%);
|
||||||
|
|
|
@ -180,6 +180,7 @@
|
||||||
// Scrollbar
|
// Scrollbar
|
||||||
--color-scrollbar-thumb-bg: rgba(0, 0, 0, 0.2);
|
--color-scrollbar-thumb-bg: rgba(0, 0, 0, 0.2);
|
||||||
--color-scrollbar-track-bg: transparent;
|
--color-scrollbar-track-bg: transparent;
|
||||||
|
--color-body-scrollbar-track-bg: var(--color-header-button);
|
||||||
|
|
||||||
--background-shade: linear-gradient(-180deg, rgba(var(--color-background-base), 0.6) 2%, #f1f1f1),
|
--background-shade: linear-gradient(-180deg, rgba(var(--color-background-base), 0.6) 2%, #f1f1f1),
|
||||||
radial-gradient(circle at 50% 217%, rgba(var(--color-background-base), 0.6) 0, #f8f8f8 100%);
|
radial-gradient(circle at 50% 217%, rgba(var(--color-background-base), 0.6) 0, #f8f8f8 100%);
|
||||||
|
|
Loading…
Reference in a new issue