From 77d0c0122565260ef3771a4d03a1dcb0aae654dc Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Thu, 10 Oct 2024 15:21:18 +0200 Subject: [PATCH 01/11] Use new HorizontalScrollContainer in artist pages To show better scroll indicators + drag to scroll for the albums sections --- frontend/js/src/artist/ArtistPage.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/js/src/artist/ArtistPage.tsx b/frontend/js/src/artist/ArtistPage.tsx index b2f68f8701..a3fa5f5389 100644 --- a/frontend/js/src/artist/ArtistPage.tsx +++ b/frontend/js/src/artist/ArtistPage.tsx @@ -40,6 +40,7 @@ import { useBrainzPlayerDispatch } from "../common/brainzplayer/BrainzPlayerCont import SimilarArtistComponent from "../explore/music-neighborhood/components/SimilarArtist"; import CBReviewModal from "../cb-review/CBReviewModal"; import Pill from "../components/Pill"; +import HorizontalScrollContainer from "../components/HorizontalScrollContainer"; function SortingButtons({ sort, @@ -479,13 +480,13 @@ export default function ArtistPage(): JSX.Element {

{type}

-
{rgGroup.map(getReleaseCard)} -
+ ))} From 9f79e65557fd89af0ea5e20da69d70bfbf8f799f Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Thu, 10 Oct 2024 16:00:33 +0200 Subject: [PATCH 02/11] Tweak HorizontalScrollContainer --- frontend/css/scroll-container.less | 8 +++- .../components/HorizontalScrollContainer.tsx | 42 +++++++++---------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/frontend/css/scroll-container.less b/frontend/css/scroll-container.less index 5bc2337e91..fb7dada927 100644 --- a/frontend/css/scroll-container.less +++ b/frontend/css/scroll-container.less @@ -1,10 +1,16 @@ .horizontal-scroll-container { position: relative; + .horizontal-scroll-container.dragging .horizontal-scroll * { + // Prevent text selection and interactions when the user is actively dragging to scroll + pointer-events: none; + user-select: none; +} + .horizontal-scroll { + overflow-x: auto; .small-scrollbar(); &.no-scrollbar { - overflow-x: scroll; /* Hide the scrollbar: */ -ms-overflow-style: none; /* Internet Explorer and Edge */ scrollbar-width: none; /* Firefox */ diff --git a/frontend/js/src/components/HorizontalScrollContainer.tsx b/frontend/js/src/components/HorizontalScrollContainer.tsx index daa2541a86..daa3de29ea 100644 --- a/frontend/js/src/components/HorizontalScrollContainer.tsx +++ b/frontend/js/src/components/HorizontalScrollContainer.tsx @@ -13,6 +13,9 @@ type HorizontalScrollContainerProps = { className?: string; }; +// How many pixels do the arrow buttons scroll? +const MANUAL_SCROLL_AMOUNT = 500; + export default function HorizontalScrollContainer({ showScrollbar = true, enableDragScroll = true, @@ -25,32 +28,27 @@ export default function HorizontalScrollContainer({ applyRubberBandEffect: true, }); - const onMouseDown: React.MouseEventHandler = (event) => { - // Call the dragScrolluse-draggable-safe hook event + const onMouseDown: React.MouseEventHandler = (event) => { + // Call the use-draggable-scroll-safe hook event events.onMouseDown(event); // Set our own class to allow for snap-scroll - (event.target as HTMLDivElement)?.parentElement?.classList.add("dragging"); + (event.target as HTMLElement)?.parentElement?.classList.add("dragging"); }; - const onMouseUp: React.MouseEventHandler = (event) => { - (event.target as HTMLDivElement)?.parentElement?.classList.remove( - "dragging" - ); + const onMouseUp: React.MouseEventHandler = (event) => { + (event.target as HTMLElement)?.parentElement?.classList.remove("dragging"); }; - const onScroll: React.ReactEventHandler = (event) => { - const element = event.target as HTMLDivElement; + const onScroll: React.ReactEventHandler = (event) => { + const element = event.target as HTMLElement; const parent = element.parentElement; if (!element || !parent) { return; } - // calculate horizontal scroll percentage - const scrollPercentage = - (100 * element.scrollLeft) / (element.scrollWidth - element.clientWidth); - if (scrollPercentage > 95) { + if (element.scrollWidth - element.scrollLeft >= MANUAL_SCROLL_AMOUNT) { parent.classList.add("scroll-end"); parent.classList.remove("scroll-start"); - } else if (scrollPercentage < 5) { + } else if (element.scrollLeft <= MANUAL_SCROLL_AMOUNT) { parent.classList.add("scroll-start"); parent.classList.remove("scroll-end"); } else { @@ -58,34 +56,36 @@ export default function HorizontalScrollContainer({ parent.classList.remove("scroll-start"); } }; + const throttledOnScroll = throttle(onScroll, 400, { leading: true }); - const manualScroll: React.ReactEventHandler = (event) => { + const onManualScroll: React.ReactEventHandler = (event) => { if (!scrollContainerRef?.current) { return; } if (event?.currentTarget.classList.contains("forward")) { scrollContainerRef.current.scrollBy({ - left: 300, + left: MANUAL_SCROLL_AMOUNT, top: 0, behavior: "smooth", }); } else { scrollContainerRef.current.scrollBy({ - left: -300, + left: -MANUAL_SCROLL_AMOUNT, top: 0, behavior: "smooth", }); } + // Also call the onScroll (throttled) event to ensure + // the expected CSS classes are applied to the container + throttledOnScroll(event); }; - const throttledOnScroll = throttle(onScroll, 400, { leading: true }); - return (
{Object.entries(groupedReleaseGroups).map(([type, rgGroup]) => ( -
+

{type}

From 66ef82508af96f32b73b7755eb19cb7d28980725 Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Thu, 10 Oct 2024 18:17:21 +0200 Subject: [PATCH 08/11] Linting --- frontend/css/scroll-container.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/css/scroll-container.less b/frontend/css/scroll-container.less index dd25451682..cce6d7c03c 100644 --- a/frontend/css/scroll-container.less +++ b/frontend/css/scroll-container.less @@ -5,7 +5,7 @@ // Prevent text selection and interactions when the user is actively dragging to scroll pointer-events: none; user-select: none; -} + } .horizontal-scroll { overflow-x: auto; From 5e9d882cfe181877ef0959fb688de66b5d29fb9b Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Thu, 10 Oct 2024 19:03:33 +0200 Subject: [PATCH 09/11] Force display:none in hide-image class Resolves an issue when scrolling through album grids on the artist pages, as images are being lazy loaded the height of the DOM element changes style making the grid items move around in a jarring way. --- frontend/css/release-card.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/css/release-card.less b/frontend/css/release-card.less index d04b32945f..0efd6a39af 100644 --- a/frontend/css/release-card.less +++ b/frontend/css/release-card.less @@ -116,7 +116,7 @@ } .release-coverart.hide-image { - display: none; + display: none !important; height: 0; } From 24a0c629bee625c11c5995230a0f827b5f2fa0ca Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Thu, 10 Oct 2024 19:46:07 +0200 Subject: [PATCH 10/11] Artist Page: allow expanding popular tracks Adds a "See more" button that was thought of originally but commented out, to allow expanding the list of popular tracks --- frontend/css/entity-pages.less | 18 ++++++++++-------- frontend/js/src/artist/ArtistPage.tsx | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/frontend/css/entity-pages.less b/frontend/css/entity-pages.less index 215badc0cb..6a76c00901 100644 --- a/frontend/css/entity-pages.less +++ b/frontend/css/entity-pages.less @@ -117,19 +117,21 @@ min-height: 150px; min-width: 0; .artist-page& { - max-height: 520px; + max-height: 500px; overflow-y: hidden; border-bottom-style: inset; position: relative; - &::after { - content: ""; - background-image: @white-gradient; - position: absolute; - bottom: 0; - height: 8em; - width: 100%; + &.expanded { + max-height: initial; + padding-bottom: 4em; } } + + .read-more { + bottom: 0; + padding: 1em 0; + } + .album-page& .listen-card .track-position { flex: 0 3em; align-self: center; diff --git a/frontend/js/src/artist/ArtistPage.tsx b/frontend/js/src/artist/ArtistPage.tsx index 0f0624980e..d6bc22e76c 100644 --- a/frontend/js/src/artist/ArtistPage.tsx +++ b/frontend/js/src/artist/ArtistPage.tsx @@ -122,6 +122,10 @@ export default function ArtistPage(): JSX.Element { "release_date" ); + const [expandPopularTracks, setExpandPopularTracks] = React.useState( + false + ); + const rgGroups = groupBy( releaseGroups, (rg) => @@ -375,7 +379,7 @@ export default function ArtistPage(): JSX.Element { />
-
+

Popular tracks @@ -420,11 +424,15 @@ export default function ArtistPage(): JSX.Element { /> ); })} - {/*
- -
*/} +

From b0755b5f6cff99ad90bcb1d4a4f8a5a7b8fa58c5 Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Fri, 11 Oct 2024 12:37:37 +0200 Subject: [PATCH 11/11] HortizontalScroll: Place nav buttons higher in z-index --- frontend/css/scroll-container.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/css/scroll-container.less b/frontend/css/scroll-container.less index cce6d7c03c..f69031d091 100644 --- a/frontend/css/scroll-container.less +++ b/frontend/css/scroll-container.less @@ -29,7 +29,7 @@ border: none; font-size: 2em; color: @light-grey; - z-index: 1; + z-index: 2; opacity: 1; transition: opacity 300ms linear; &.backward {