fix(artist): bio truncation reactivity, adjust margins
- Observe parent container for resize (not clamped element) - Double RAF ensures CSS applies before measurement - top-tracks-section: margin-top 32px - artist-header: margin-bottom 22px
This commit is contained in:
1 parent
f19081ee1d
commit
e404048c5b
1 file changed
+18
-8
@@ -577,6 +577,7 @@
|
|||||||
|
|
||||||
// Smart 3-line truncation with resize detection
|
// Smart 3-line truncation with resize detection
|
||||||
let bioTextEl = $state<HTMLDivElement | null>(null);
|
let bioTextEl = $state<HTMLDivElement | null>(null);
|
||||||
|
let bioContainerEl = $state<HTMLDivElement | null>(null);
|
||||||
let isBioTruncated = $state(false);
|
let isBioTruncated = $state(false);
|
||||||
|
|
||||||
function checkBioTruncation() {
|
function checkBioTruncation() {
|
||||||
@@ -586,19 +587,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!bioTextEl || !bioText) return;
|
if (!bioTextEl || !bioText || !bioContainerEl) return;
|
||||||
|
|
||||||
// Initial check
|
// Initial check after a frame to ensure layout is complete
|
||||||
|
requestAnimationFrame(() => {
|
||||||
checkBioTruncation();
|
checkBioTruncation();
|
||||||
|
});
|
||||||
|
|
||||||
// Observe resize to recalculate when container width changes
|
// Observe the PARENT container (not the clamped element) for width changes
|
||||||
const observer = new ResizeObserver(() => {
|
const observer = new ResizeObserver(() => {
|
||||||
if (!bioExpanded) {
|
if (!bioExpanded) {
|
||||||
|
// Double RAF to ensure CSS has applied after resize
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
checkBioTruncation();
|
checkBioTruncation();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
observer.observe(bioTextEl);
|
observer.observe(bioContainerEl);
|
||||||
|
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
});
|
});
|
||||||
@@ -606,10 +614,12 @@
|
|||||||
// Recheck truncation after collapsing (wait for DOM update)
|
// Recheck truncation after collapsing (wait for DOM update)
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (bioExpanded === false && bioTextEl) {
|
if (bioExpanded === false && bioTextEl) {
|
||||||
// Use requestAnimationFrame to wait for CSS to apply
|
// Use double RAF to wait for CSS to fully apply
|
||||||
|
requestAnimationFrame(() => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
checkBioTruncation();
|
checkBioTruncation();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -877,7 +887,7 @@
|
|||||||
|
|
||||||
<!-- Biography -->
|
<!-- Biography -->
|
||||||
{#if bioText}
|
{#if bioText}
|
||||||
<div class="biography">
|
<div class="biography" bind:this={bioContainerEl}>
|
||||||
<div class="bio-text" class:expanded={bioExpanded} bind:this={bioTextEl}>
|
<div class="bio-text" class:expanded={bioExpanded} bind:this={bioTextEl}>
|
||||||
{@html bioText}
|
{@html bioText}
|
||||||
</div>
|
</div>
|
||||||
@@ -1556,7 +1566,7 @@
|
|||||||
.artist-header {
|
.artist-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 32px;
|
gap: 32px;
|
||||||
margin-bottom: 32px;
|
margin-bottom: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.artist-image-column {
|
.artist-image-column {
|
||||||
@@ -2272,7 +2282,7 @@
|
|||||||
|
|
||||||
/* Top Tracks */
|
/* Top Tracks */
|
||||||
.top-tracks-section {
|
.top-tracks-section {
|
||||||
padding-top: 10px;
|
margin-top: 32px;
|
||||||
margin-bottom: 32px;
|
margin-bottom: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user