Fix scrollbar

This commit is contained in:
prayag17 committed 2023-04-10 16:03:21 +05:30
1 parent 45655b7464
commit 0d3b7c855c
9 files changed
+65 -107

No files matched your search

+9 -6
View File
@@ -7,7 +7,7 @@ import IconButton from "@mui/material/IconButton";
import Toolbar from "@mui/material/Toolbar"; import Toolbar from "@mui/material/Toolbar";
import Avatar from "@mui/material/Avatar"; import Avatar from "@mui/material/Avatar";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Zoom from "@mui/material/Zoom"; import useScrollTrigger from "@mui/material/useScrollTrigger";
import { MdiMagnify } from "../icons/mdiMagnify"; import { MdiMagnify } from "../icons/mdiMagnify";
import { theme } from "../../theme"; import { theme } from "../../theme";
@@ -44,6 +44,11 @@ export const AppBar = () => {
}, },
}); });
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 0,
});
useEffect(() => { useEffect(() => {
if (location.pathname == "/home") { if (location.pathname == "/home") {
dispatch(hideBackButton()); dispatch(hideBackButton());
@@ -54,13 +59,11 @@ export const AppBar = () => {
visible && ( visible && (
<MuiAppBar <MuiAppBar
sx={{ sx={{
width: `calc(100vw - ${theme.spacing(7)} - 10px)`, width: `calc(100vw - ${theme.spacing(7)})`,
// mr: "10px", // mr: "10px",
background: "transparent", backgroundColor: "transparent",
}} }}
className={ className={trigger ? "appBar backdropVisible" : "appBar"}
backdropVisible ? "appBar backdropVisible" : "appBar"
}
elevation={backdropVisible ? 6 : 0} elevation={backdropVisible ? 6 : 0}
> >
<Toolbar sx={{ justifyContent: "space-between" }}> <Toolbar sx={{ justifyContent: "space-between" }}>
+3 -3
View File
@@ -1,10 +1,10 @@
/** @format */ /** @format */
.appBar { .appBar {
transition: background $transition-time-default, transition: background-color $transition-time-fast,
box-shadow $transition-time-default; box-shadow $transition-time-default !important;
&.backdropVisible { &.backdropVisible {
background: $clr-background-dark; background-color: $clr-background-dark;
} }
&-avatar { &-avatar {
background: $clr-gradient-dark; background: $clr-gradient-dark;
+3 -25
View File
@@ -1,6 +1,6 @@
/** @format */ /** @format */
import { useState, useEffect, useRef } from "react"; import { useState } from "react";
import { Blurhash } from "react-blurhash"; import { Blurhash } from "react-blurhash";
@@ -14,13 +14,11 @@ import { theme } from "../../theme";
import "./home.module.scss"; import "./home.module.scss";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Skeleton from "@mui/material/Skeleton";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import Paper from "@mui/material/Paper"; import Paper from "@mui/material/Paper";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Chip from "@mui/material/Chip"; import Chip from "@mui/material/Chip";
import Divider from "@mui/material/Divider"; import Divider from "@mui/material/Divider";
import useScrollTrigger from "@mui/material/useScrollTrigger";
import { yellow } from "@mui/material/colors"; import { yellow } from "@mui/material/colors";
@@ -40,8 +38,7 @@ import { MdiPlayOutline } from "../../components/icons/mdiPlayOutline";
import { MdiChevronRight } from "../../components/icons/mdiChevronRight"; import { MdiChevronRight } from "../../components/icons/mdiChevronRight";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { showSidemenu } from "../../utils/slice/sidemenu"; import { showAppBar } from "../../utils/slice/appBar";
import { showAppBar, setBackdrop } from "../../utils/slice/appBar";
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api"; import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
@@ -49,14 +46,12 @@ import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
import { useNavigate, useLocation, Link } from "react-router-dom"; import { useNavigate, useLocation } from "react-router-dom";
import { formateDate } from "../../utils/date/formateDate"; import { formateDate } from "../../utils/date/formateDate";
import { getRuntime } from "../../utils/date/time"; import { getRuntime } from "../../utils/date/time";
const Home = () => { const Home = () => {
const queryClient = useQueryClient();
const authUser = useQuery({ const authUser = useQuery({
queryKey: ["home", "authenticateUser"], queryKey: ["home", "authenticateUser"],
queryFn: async () => { queryFn: async () => {
@@ -193,18 +188,6 @@ const Home = () => {
dispatch(showAppBar()); dispatch(showAppBar());
} }
const [scrollTarget, setScrollTarget] = useState(undefined);
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 0,
target: scrollTarget,
});
useEffect(() => {
dispatch(setBackdrop(trigger));
}, [trigger]);
return ( return (
<> <>
<Box <Box
@@ -217,11 +200,6 @@ const Home = () => {
pb: 3, pb: 3,
position: "relative", position: "relative",
}} }}
ref={(node) => {
if (node) {
setScrollTarget(node);
}
}}
> >
<Carousel <Carousel
className="hero-carousel" className="hero-carousel"
+3 -21
View File
@@ -6,17 +6,12 @@ import CircularProgress from "@mui/material/CircularProgress";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack"; import Stack from "@mui/material/Stack";
import Chip from "@mui/material/Chip"; import Chip from "@mui/material/Chip";
import useScrollTrigger from "@mui/material/useScrollTrigger";
import Divider from "@mui/material/Divider"; import Divider from "@mui/material/Divider";
import LinearProgress from "@mui/material/LinearProgress"; import LinearProgress from "@mui/material/LinearProgress";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import { Blurhash } from "react-blurhash"; import { Blurhash } from "react-blurhash";
import { import { showAppBar, showBackButton } from "../../../utils/slice/appBar";
setBackdrop,
showAppBar,
showBackButton,
} from "../../../utils/slice/appBar";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
@@ -36,23 +31,15 @@ const ItemMovie = () => {
const { id } = useParams(); const { id } = useParams();
const dispatch = useDispatch(); const dispatch = useDispatch();
const appBarVisiblity = useSelector((state) => state.appBar.visible); const appBarVisiblity = useSelector((state) => state.appBar.visible);
const [scrollTarget, setScrollTarget] = useState(undefined);
const [primageImageLoaded, setPrimaryImageLoaded] = useState(false); const [primageImageLoaded, setPrimaryImageLoaded] = useState(false);
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false); const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 0,
target: scrollTarget,
});
useEffect(() => { useEffect(() => {
if (!appBarVisiblity) { if (!appBarVisiblity) {
dispatch(showAppBar()); dispatch(showAppBar());
} }
dispatch(setBackdrop(trigger));
dispatch(showBackButton()); dispatch(showBackButton());
}, [trigger]); }, []);
const user = useQuery({ const user = useQuery({
queryKey: ["user"], queryKey: ["user"],
@@ -78,7 +65,7 @@ const ItemMovie = () => {
<Box <Box
sx={{ sx={{
width: "100%", width: "100%",
height: "100%", height: "100vh",
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
@@ -122,11 +109,6 @@ const ItemMovie = () => {
flexFlow: "column", flexFlow: "column",
gap: 5, gap: 5,
}} }}
ref={(node) => {
if (node) {
setScrollTarget(node);
}
}}
> >
<Box className="item-detail-header"> <Box className="item-detail-header">
<Box className="item-detail-header-backdrop"> <Box className="item-detail-header-backdrop">
+3 -21
View File
@@ -6,17 +6,12 @@ import CircularProgress from "@mui/material/CircularProgress";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack"; import Stack from "@mui/material/Stack";
import Chip from "@mui/material/Chip"; import Chip from "@mui/material/Chip";
import useScrollTrigger from "@mui/material/useScrollTrigger";
import Divider from "@mui/material/Divider"; import Divider from "@mui/material/Divider";
import LinearProgress from "@mui/material/LinearProgress"; import LinearProgress from "@mui/material/LinearProgress";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import { Blurhash } from "react-blurhash"; import { Blurhash } from "react-blurhash";
import { import { showAppBar, showBackButton } from "../../../utils/slice/appBar";
setBackdrop,
showAppBar,
showBackButton,
} from "../../../utils/slice/appBar";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
@@ -36,23 +31,15 @@ const ItemSeries = () => {
const { id } = useParams(); const { id } = useParams();
const dispatch = useDispatch(); const dispatch = useDispatch();
const appBarVisiblity = useSelector((state) => state.appBar.visible); const appBarVisiblity = useSelector((state) => state.appBar.visible);
const [scrollTarget, setScrollTarget] = useState(undefined);
const [primageImageLoaded, setPrimaryImageLoaded] = useState(false); const [primageImageLoaded, setPrimaryImageLoaded] = useState(false);
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false); const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 0,
target: scrollTarget,
});
useEffect(() => { useEffect(() => {
if (!appBarVisiblity) { if (!appBarVisiblity) {
dispatch(showAppBar()); dispatch(showAppBar());
} }
dispatch(setBackdrop(trigger));
dispatch(showBackButton()); dispatch(showBackButton());
}, [trigger]); }, []);
const user = useQuery({ const user = useQuery({
queryKey: ["user"], queryKey: ["user"],
@@ -78,7 +65,7 @@ const ItemSeries = () => {
<Box <Box
sx={{ sx={{
width: "100%", width: "100%",
height: "100%", height: "100vh",
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
@@ -122,11 +109,6 @@ const ItemSeries = () => {
flexFlow: "column", flexFlow: "column",
gap: 5, gap: 5,
}} }}
ref={(node) => {
if (node) {
setScrollTarget(node);
}
}}
> >
<Box className="item-detail-header"> <Box className="item-detail-header">
<Box className="item-detail-header-backdrop"> <Box className="item-detail-header-backdrop">
+25 -10
View File
@@ -1,15 +1,12 @@
/** @format */ /** @format */
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { import { showAppBar, showBackButton } from "../../utils/slice/appBar";
showAppBar,
setBackdrop,
showBackButton,
} from "../../utils/slice/appBar";
import { useParams, useNavigate } from "react-router-dom"; import { useParams, useNavigate } from "react-router-dom";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import useScrollTrigger from "@mui/material/useScrollTrigger";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Grid2 from "@mui/material/Unstable_Grid2"; import Grid2 from "@mui/material/Unstable_Grid2";
import Stack from "@mui/material/Stack"; import Stack from "@mui/material/Stack";
@@ -301,8 +298,6 @@ const LibraryView = () => {
enabled: !!user.data, enabled: !!user.data,
}); });
dispatch(setBackdrop(true));
const handleCurrentViewType = (e) => { const handleCurrentViewType = (e) => {
setCurrentViewType(e.target.value); setCurrentViewType(e.target.value);
}; };
@@ -324,6 +319,11 @@ const LibraryView = () => {
setFilterButtonAnchorEl(null); setFilterButtonAnchorEl(null);
}; };
const trigger = useScrollTrigger({
disableHysteresis: true,
threshold: 1,
});
return ( return (
<Box <Box
sx={{ sx={{
@@ -343,13 +343,28 @@ const LibraryView = () => {
> >
<AppBar <AppBar
position="fixed" position="fixed"
elevation={0} elevation={trigger ? 1 : 0}
sx={{ sx={{
width: `calc(100vw - ${theme.spacing(7)} - 10px)`, width: `calc(100vw - ${theme.spacing(7)})`,
mt: 8, mt: 8,
background: "transparent",
backgroundColor: trigger
? `${theme.palette.background.paper} !important`
: "transparent",
transition:
"transition: background-color 150ms, box-shadow 150ms !important",
}} }}
> >
<Divider /> <Divider
sx={{
transform: trigger
? "scaleX(1)"
: "scaleX(0)",
transition: "transform 150ms",
transformOrigin: "left",
transitionDelay: "50ms",
}}
/>
<Toolbar sx={{ justifyContent: "space-between" }}> <Toolbar sx={{ justifyContent: "space-between" }}>
<Stack alignItems="center" direction="row"> <Stack alignItems="center" direction="row">
<Typography <Typography
+16 -10
View File
@@ -1,19 +1,22 @@
/** @format */ /** @format */
::-webkit-scrollbar { ::-webkit-scrollbar {
z-index: 10000; width: 14px;
width: 10px;
background: $clr-background-dark; background: $clr-background-dark;
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
z-index: 10000;
background-color: transparent; background-color: transparent;
&:hover { &:hover {
background: rgb(255 255 255 / 0.25); background-color: rgb(255 255 255 / 0.15);
} }
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
z-index: 10000; border: 4px solid transparent;
background: rgb(255 255 255 / 0.25); background-clip: padding-box;
border-radius: 9999px;
background-color: rgb(255 255 255 / 0.25);
&:hover {
background-color: rgb(255 255 255 / 0.35);
}
} }
body { body {
@@ -24,14 +27,17 @@ body {
position: relative; position: relative;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
overflow-x: hidden;
overflow-y: overlay;
} }
#root, #root,
.root-page { .root-page {
height: 100vh; height: fit-content;
width: 100%; width: 100%;
overflow: hidden;
position: relative; position: relative;
overflow-y: visible;
overflow-x: hidden;
} }
.centered { .centered {
@@ -81,8 +87,8 @@ h1 {
.scrollY { .scrollY {
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: visible;
height: 100vh; height: fit-content;
width: inherit; width: inherit;
box-sizing: border-box; box-sizing: border-box;
} }
+1
View File
@@ -24,3 +24,4 @@ $border-radius-default: 10px;
$border-radius-intensity-1: 5px; $border-radius-intensity-1: 5px;
$transition-time-default: 250ms; $transition-time-default: 250ms;
$transition-time-fast: 150ms;
+2 -11
View File
@@ -5,7 +5,6 @@ export const appBarSlice = createSlice({
name: "appBar", name: "appBar",
initialState: { initialState: {
visible: false, visible: false,
backdrop: false,
backButtonVisible: false, backButtonVisible: false,
}, },
reducers: { reducers: {
@@ -15,9 +14,6 @@ export const appBarSlice = createSlice({
hideAppBar: (state) => { hideAppBar: (state) => {
state.visible = false; state.visible = false;
}, },
setBackdrop: (state, action) => {
state.backdrop = action.payload;
},
showBackButton: (state, action) => { showBackButton: (state, action) => {
state.backButtonVisible = true; state.backButtonVisible = true;
}, },
@@ -27,11 +23,6 @@ export const appBarSlice = createSlice({
}, },
}); });
export const { export const { showAppBar, hideAppBar, showBackButton, hideBackButton } =
showAppBar, appBarSlice.actions;
hideAppBar,
setBackdrop,
showBackButton,
hideBackButton,
} = appBarSlice.actions;
export default appBarSlice.reducer; export default appBarSlice.reducer;