Skip to content

Commit 64039b1

Browse files
committed
fix(yir): prevent layout shifts in title section before profile loads
1 parent 856cae8 commit 64039b1

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

projects/client/src/lib/sections/yir/_internal/YirTitleSection.svelte

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import UserAvatar from "$lib/sections/lists/components/UserAvatar.svelte";
99
import { toLoadingState } from "$lib/utils/requests/toLoadingState";
1010
import { UrlBuilder } from "$lib/utils/url/UrlBuilder";
11-
import { map } from "rxjs";
1211
1312
const {
1413
slug,
@@ -22,7 +21,7 @@
2221
} = $props();
2322
2423
const profileQuery = $derived(useQuery(userProfileQuery({ slug })));
25-
const profile = $derived(profileQuery.pipe(map(($q) => $q.data)));
24+
const profile = $derived($profileQuery.data);
2625
2726
const now = new Date();
2827
const isAllTime = $derived(year === "all");
@@ -36,12 +35,10 @@
3635
: m.yir_title_year_in_review()),
3736
);
3837
39-
const isProfilePending = $derived(
40-
profileQuery.pipe(map(($q) => toLoadingState($q))),
41-
);
38+
const isProfilePending = $derived(toLoadingState($profileQuery));
4239
43-
const hasGradient = $derived(!$isProfilePending && !$profile?.cover?.url);
44-
const coverSrc = $derived($profile?.cover?.url);
40+
const hasGradient = $derived(!isProfilePending && !profile?.cover?.url);
41+
const coverSrc = $derived(profile?.cover?.url);
4542
</script>
4643

4744
<section class="trakt-yir-title-section" class:is-all-time={isAllTime}>
@@ -52,19 +49,19 @@
5249
</div>
5350
<div class="yir-titles-wrapper">
5451
<div class="yir-titles">
55-
{#if $profile}
56-
<div class="yir-user">
52+
<div class="yir-user">
53+
{#if profile}
5754
<span class="yir-avatar-link">
58-
<UserAvatar user={$profile} size="large" />
55+
<UserAvatar user={profile} size="large" />
5956
</span>
6057
<span class="yir-display-name">
6158
<Link href={UrlBuilder.profile.user(slug)} color="inherit">
62-
{$profile.name.full || $profile.username}
59+
{profile.name.full || profile.username}
6360
</Link>
6461
</span>
65-
</div>
66-
<div class="yir-under-user"></div>
67-
{/if}
62+
{/if}
63+
</div>
64+
<div class="yir-under-user"></div>
6865

6966
<h1 class="yir-year" class:is-text={isAllTime}>
7067
{isAllTime ? m.yir_label_all_time() : year}
@@ -181,6 +178,11 @@
181178
display: inline-flex;
182179
align-items: center;
183180
gap: var(--ni-10);
181+
min-height: var(--ni-40);
182+
183+
@include for-mobile {
184+
min-height: var(--ni-30);
185+
}
184186
}
185187
186188
.yir-avatar-link {

0 commit comments

Comments
 (0)