feature/ux-improvements #26

Merged
ilia merged 73 commits from feature/ux-improvements into main 2026-02-18 14:43:05 +00:00
Showing only changes of commit d3297d519f - Show all commits

View File

@@ -15,6 +15,7 @@ import {
TypographyMenu,
controlManager,
} from '$features/SetupFont';
import { throttle } from '$shared/lib/utils';
let text = $state('The quick brown fox jumps over the lazy dog...');
let wrapper = $state<HTMLDivElement | null>(null);
@@ -23,7 +24,9 @@ let innerHeight = $state(0);
// Is the component above the middle of the viewport?
let isAboveMiddle = $state(false);
const isLoading = $derived(unifiedFontStore.isFetching || unifiedFontStore.isLoading);
const isLoading = $derived(
unifiedFontStore.isFetching || unifiedFontStore.isLoading,
);
/**
* Load more fonts by moving to the next page
@@ -62,14 +65,14 @@ const displayRange = $derived.by(() => {
return `Showing ${loadedCount} of ${total} fonts`;
});
function checkPosition() {
const checkPosition = throttle(() => {
if (!wrapper) return;
const rect = wrapper.getBoundingClientRect();
const viewportMiddle = innerHeight / 2;
isAboveMiddle = rect.top < viewportMiddle;
}
}, 100);
</script>
<svelte:window
@@ -95,7 +98,12 @@ function checkPosition() {
proximity,
index,
})}
<FontListItem {font} {isFullyVisible} {isPartiallyVisible} {proximity}>
<FontListItem
{font}
{isFullyVisible}
{isPartiallyVisible}
{proximity}
>
<FontSampler {font} bind:text {index} />
</FontListItem>
{/snippet}