Skip to content

Commit

Permalink
Merge pull request #12 from marsinearth:bugfix/mobile-modal-size-for-…
Browse files Browse the repository at this point in the history
…scrollbar

add: html body overflow control with modal on/off
  • Loading branch information
marsinearth authored Mar 13, 2023
2 parents c34099e + bc9cec5 commit d73f9b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/components/AlbumCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ function AlbumCard({
disconnected,
setAlbum,
}: AlbumCardProps) {
const onCloseModal = () => {
setAlbum(index);
const body = document.querySelector("body");
if (body) {
body.style.overflow = "auto";
}
};

return (
<ImageLoader
className="albumCardContainer"
Expand All @@ -30,9 +38,7 @@ function AlbumCard({
disconnected={disconnected}
data-tooltip-content={`${album_artist}: ${track_title}`}
style={{ maxWidth: 400, maxHeight: 400, border: "1px outset #dddddd" }}
onClick={() => {
setAlbum(index);
}}
onClick={onCloseModal}
>
<div
className="albumCardPlayingNowOverlay"
Expand Down
4 changes: 4 additions & 0 deletions src/components/AudioPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ const AudioPlayer = forwardRef<ReactH5AudioPlayer, AudioPlayerProps>(

const onOpenModal = useCallback(() => {
setModalOpen(true);
const body = document.querySelector("body");
if (body) {
body.style.overflow = "hidden";
}
}, []);

useEffect(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/styles/AlbumCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@

@media screen and (min-width: 769px) {
.imgContainer.albumCardContainer {
width: calc((100vw - 27px) / 5);
height: calc((100vw - 27px) / 5);
width: calc((100vw - 24px) / 5);
height: calc((100vw - 24px) / 5);
}
}

@media screen and (max-width: 768px) {
.imgContainer.albumCardContainer {
width: calc((100vw - 27px) / 3);
height: calc((100vw - 27px) / 3);
width: calc((100vw - 24px) / 3);
height: calc((100vw - 24px) / 3);
}
}

@media screen and (max-width: 480px) {
.imgContainer.albumCardContainer {
width: calc((100vw - 27px) / 2);
height: calc((100vw - 27px) / 2);
width: calc((100vw - 24px) / 2);
height: calc((100vw - 24px) / 2);
}
}

1 comment on commit d73f9b2

@vercel
Copy link

@vercel vercel bot commented on d73f9b2 Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.