···
import { $type, ActorIdentifier, InferXRPCBodyOutput } from "@atcute/lexicons";
import * as TID from "@atcute/tid";
import { A, useParams } from "@solidjs/router";
6
-
import { createEffect, createResource, createSignal, For, Show, untrack } from "solid-js";
import { createStore } from "solid-js/store";
8
-
import { Button } from "../components/button.jsx";
17
+
import { Button, type ButtonProps } from "../components/button.jsx";
import { JSONType, JSONValue } from "../components/json.jsx";
import { agent } from "../components/login.jsx";
import { TextInput } from "../components/text-input.jsx";
···
const [batchDelete, setBatchDelete] = createSignal(false);
const [lastSelected, setLastSelected] = createSignal<number>();
const [reverse, setReverse] = createSignal(false);
84
+
const [filterStuck, setFilterStuck] = createSignal(false);
88
+
let sticky!: HTMLDivElement;
const fetchRecords = async () => {
if (!pds) pds = await resolvePDS(did);
···
171
+
const FilterButton = (props: ButtonProps) => {
174
+
class="flex items-center gap-1 rounded-lg border-[0.5px] border-neutral-300 bg-white px-2 py-1.5 text-xs font-semibold shadow-md dark:border-neutral-700"
176
+
"dark:bg-dark-300 dark:hover:bg-dark-100 dark:active:bg-dark-100 bg-white hover:bg-neutral-50 active:bg-neutral-50":
178
+
"dark:bg-dark-100 dark:hover:bg-dark-50 dark:active:bg-dark-50 bg-neutral-50 hover:bg-neutral-200 active:bg-neutral-200":
187
+
let ticking = false;
188
+
const tick = () => {
189
+
const topPx = parseFloat(getComputedStyle(sticky).top);
190
+
const { top } = sticky.getBoundingClientRect();
191
+
setFilterStuck(top <= topPx + 0.5);
195
+
const onScroll = () => {
198
+
requestAnimationFrame(tick);
202
+
window.addEventListener("scroll", onScroll, { passive: true });
207
+
window.removeEventListener("scroll", onScroll);
<Show when={records.length || response()}>
<div class="flex w-full flex-col items-center">
163
-
<div class="dark:bg-dark-500 sticky top-0 z-5 flex w-screen flex-col items-center justify-center gap-2 bg-neutral-100 pt-1 pb-3">
215
+
ref={(el) => (sticky = el)}
216
+
class="sticky top-2 z-10 flex flex-col items-center justify-center gap-2 rounded-lg p-3 transition-colors"
218
+
"bg-neutral-50 dark:bg-dark-300 border-[0.5px] border-neutral-300 dark:border-neutral-700 shadow-md":
220
+
"bg-transparent border-transparent shadow-none -mt-2": !filterStuck(),
<div class="flex w-[22rem] items-center gap-2 sm:w-[24rem]">
<Show when={agent() && agent()?.sub === did}>
<div class="flex items-center gap-x-2">
···
<Show when={records.length > 1}>
<div class="flex w-[22rem] items-center justify-between gap-x-2 sm:w-[24rem]">
···
class={`iconify ${reverse() ? "lucide--rotate-ccw" : "lucide--rotate-cw"} text-sm`}
<Show when={batchDelete()}>
<span>{records.filter((rec) => rec.toDelete).length}</span>
···
<div class="flex w-[5rem] items-center justify-end">
<Show when={!response.loading}>
247
-
<Button onClick={() => refetch()}>Load More</Button>
306
+
<FilterButton onClick={() => refetch()}>Load More</FilterButton>
<Show when={response.loading}>
<div class="iconify lucide--loader-circle w-[5rem] animate-spin text-xl" />