From 8c2b0220ee234bffe77b15df4ce82d506f150e08 Mon Sep 17 00:00:00 2001 From: eti Date: Wed, 28 Oct 2026 23:27:09 +0100 Subject: [PATCH] web/profile: keep vouch button and vouch tab steady while vouches load Signed-off-by: eti --- .../profile/ProfileChrome.stories.svelte | 20 ++++++++++++++----- .../profile/UserProfileChrome.svelte | 16 +++++++-------- .../lib/components/profile/VouchButton.svelte | 19 ++++++++++++++++-- .../profile/tabs/VouchTab.stories.svelte | 15 +++++++++++++- .../components/profile/tabs/VouchTab.svelte | 4 ++++ 5 files changed, 57 insertions(+), 17 deletions(-) diff --git a/web/src/lib/components/profile/ProfileChrome.stories.svelte b/web/src/lib/components/profile/ProfileChrome.stories.svelte index 9dde65b0c..6cf5fed8f 100644 --- a/web/src/lib/components/profile/ProfileChrome.stories.svelte +++ b/web/src/lib/components/profile/ProfileChrome.stories.svelte @@ -162,8 +162,9 @@ }; const vouchers = [ - { did: "did:plc:erin", handle: "erin.tngl.sh" }, - { did: "did:plc:frank", handle: "frank.tngl.sh" } + { did: "did:plc:erin", handle: "erin.tngl.sh", kind: "vouch" }, + { did: "did:plc:frank", handle: "frank.tngl.sh", kind: "vouch" }, + { did: "did:plc:alice", handle: "alice.tngl.sh", kind: "denounce" } ]; const VOUCH_DELAY = 400; const installLateVouches = () => { @@ -174,11 +175,11 @@ if (url.pathname === "/xrpc/org.tangled.graph.listNetworkVouches") { await new Promise((resolve) => setTimeout(resolve, VOUCH_DELAY)); return Response.json({ - items: vouchers.map((voucher, index) => ({ + items: vouchers.map((voucher) => ({ actor: identity.did, - uri: `at://${voucher.did}/sh.tangled.graph.vouch/3mv${index}`, + uri: `at://${voucher.did}/sh.tangled.graph.vouch/${identity.did}`, value: { - kind: "vouch", + kind: voucher.kind, subject: identity.did, createdAt: "2026-10-01T00:00:00Z" } @@ -198,14 +199,23 @@ }; const vouchesArrive = async ({ canvas }: PlayContext) => { await Promise.all([...document.fonts].map((font) => font.load())); + await expect(window.innerWidth).toBeGreaterThanOrEqual(640); const activity = await canvas.findByRole("heading", { name: "Activity" }); + const follow = canvas.getByRole("button", { name: "Follow" }); const tops: number[] = []; + const lefts: number[] = []; const start = performance.now(); while (performance.now() - start < VOUCH_DELAY + 800) { await frame(); tops.push(activity.getBoundingClientRect().top); + lefts.push(follow.getBoundingClientRect().left); } await expect(canvas.getByRole("link", { name: /Vouched for by 2 users/ })).toBeVisible(); + await expect(canvas.getByTestId("vouchTrigger")).toHaveAttribute( + "data-standing", + "denounce" + ); + expect(Math.max(...lefts) - Math.min(...lefts)).toBeLessThan(0.5); expect(tops.at(-1)).toBeGreaterThan(tops[0]!); expectSteady(tops); }; diff --git a/web/src/lib/components/profile/UserProfileChrome.svelte b/web/src/lib/components/profile/UserProfileChrome.svelte index e44a2260b..e4d64923e 100644 --- a/web/src/lib/components/profile/UserProfileChrome.svelte +++ b/web/src/lib/components/profile/UserProfileChrome.svelte @@ -233,15 +233,13 @@ initialRkey={viewerFollowRkey} /> -
- -
+ {/if} diff --git a/web/src/lib/components/profile/VouchButton.svelte b/web/src/lib/components/profile/VouchButton.svelte index 8f6f0d2d5..734f4fa3a 100644 --- a/web/src/lib/components/profile/VouchButton.svelte +++ b/web/src/lib/components/profile/VouchButton.svelte @@ -52,6 +52,9 @@ import Field from "#lib/components/ui/Field.svelte"; import NetworkVouches from "#lib/components/profile/NetworkVouches.svelte"; import { getAuth } from "#lib/auth.svelte.ts"; + import { prefersReducedMotion } from "svelte/motion"; + import { revealItem } from "#lib/motion/reveal.ts"; + import { RAIL_DURATION, railEasing } from "#lib/motion/spring.ts"; import { createAction } from "#lib/action.svelte.ts"; import { putVouch, deleteVouch, type VouchKind } from "#lib/api/graph.ts"; import { createBobbinClient } from "#lib/api/client.ts"; @@ -178,7 +181,13 @@ href={signedIn ? undefined : loginHref} onclick={signedIn ? start : undefined} > - {trigger.text} + + {#each ["Vouch", "Vouched", "Denounced"] as text (text)} + + {text} + + {/each} + @@ -201,7 +210,13 @@

{#if networkVouches.length > 0} -
+

From your network

}) => { const items = (parameters.vouches as ReturnType[] | undefined) ?? []; + const delay = (parameters.delay as number | undefined) ?? 0; const original = window.fetch; window.fetch = async (input, init) => { const url = input instanceof Request ? input.url : String(input); - if (url.includes("listNetworkVouches")) return Response.json({ items }); + if (url.includes("listNetworkVouches")) { + await new Promise((resolve) => setTimeout(resolve, delay)); + return Response.json({ items }); + } if (url.includes("/xrpc/")) return Response.json({ error: "NotFound" }, { status: 404 }); return original(input, init); @@ -73,3 +77,12 @@ + + { + await expect(canvasElement.querySelector("[aria-hidden=true]")).not.toBeNull(); + await canvas.findByText("Great collaborator."); + }} +/> diff --git a/web/src/lib/components/profile/tabs/VouchTab.svelte b/web/src/lib/components/profile/tabs/VouchTab.svelte index cb7d7c897..115bd596f 100644 --- a/web/src/lib/components/profile/tabs/VouchTab.svelte +++ b/web/src/lib/components/profile/tabs/VouchTab.svelte @@ -6,6 +6,8 @@ import Section from "#lib/components/ui/Section.svelte"; import Error from "#lib/components/ui/Error.svelte"; import EmptyState from "#lib/components/ui/EmptyState.svelte"; + import Bones from "#lib/components/ui/Bones.svelte"; + import profileNetworkvouchesManyVouches from "#lib/bones/profile-networkvouches--many-vouches.bones.json"; import { resolveVouches } from "#lib/components/profile/pages.ts"; import { networkVouchesFor } from "#lib/components/profile/vouchBadge.svelte.ts"; import type { VouchData } from "#lib/components/profile/types.ts"; @@ -63,4 +65,6 @@ {/each} +{:else} + {/if} -- knotmirror 0.0.1