From 0c478c843f6fefbe5b36c4a6519e86496fb24ced Mon Sep 17 00:00:00 2001 From: Spence Pope Date: Tue, 20 Oct 2026 14:41:01 -0400 Subject: [PATCH] Address profile links design feedback (#12101) --- .../components/LinkFormDialog.tsx | 25 ++++++++----------- .../components/SortablePills/index.web.tsx | 16 ++++++++---- .../components/SupportedSitesDialog.tsx | 4 +-- src/features/profileLinks/state.ts | 16 +++++++++--- src/features/profileLinks/types.ts | 5 +++- 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/features/profileLinks/components/LinkFormDialog.tsx b/src/features/profileLinks/components/LinkFormDialog.tsx index 4d3626300..56344010a 100644 --- a/src/features/profileLinks/components/LinkFormDialog.tsx +++ b/src/features/profileLinks/components/LinkFormDialog.tsx @@ -218,6 +218,7 @@ function LinkFormInner({ // support links use bundled logos instead const needsIcon = !provider && !keptIcon let icon = keptIcon + let iconUrl = isNewDestination ? undefined : link?.iconUrl if (needsCheck || needsIcon || isNewDestination) { setReachability('checking') const [meta, uploadedIcon, safelinkAction] = await Promise.all([ @@ -236,11 +237,15 @@ function LinkFormInner({ setReachability('unreachable') return } - icon = uploadedIcon ?? icon + if (uploadedIcon) { + icon = uploadedIcon.icon + iconUrl = uploadedIcon.previewUrl + } } const saved: ProfileLink = {url: targetUrl} if (nextTitle) saved.title = nextTitle if (icon) saved.icon = icon + if (iconUrl) saved.iconUrl = iconUrl // an edit rewrites the same record, so a report on it still points here if (link?.uri) saved.uri = link.uri control.close(() => onSave(saved)) @@ -293,12 +298,12 @@ function LinkFormInner({ Links show as buttons under your bio. Links to support sites like - Ko-fi or Patreon show as a green Support button.{' '} + Ko-fi or Patreon show as a green button.{' '} supportedSitesControl.open())}> - See all sites + View all support sites @@ -321,16 +326,6 @@ function LinkFormInner({ setTouched(true) setReachability('unchecked') setError(undefined) - /* - * "patreon.com" isn't a support link yet, so it may have - * picked up the homepage's title. Drop that once it - * becomes one, so the pill reads "Support on Patreon". - */ - if (autoTitle.current && validateLinkInput(value).provider) { - const previousAuto = autoTitle.current - autoTitle.current = '' - setTitle(prev => (prev === previousAuto ? '' : prev)) - } }} autoFocus autoCapitalize="none" @@ -363,7 +358,7 @@ function LinkFormInner({ ]}> {provider.name} is a recognized support link. It gets the - green Support button. + green support button. diff --git a/src/features/profileLinks/components/SortablePills/index.web.tsx b/src/features/profileLinks/components/SortablePills/index.web.tsx index 3ae886b8d..334a9df38 100644 --- a/src/features/profileLinks/components/SortablePills/index.web.tsx +++ b/src/features/profileLinks/components/SortablePills/index.web.tsx @@ -108,19 +108,25 @@ export function SortablePills({ : frames const height = ready ? rowHeightFor(shown) : 0 - // row width, and pill sizes, from the DOM + /* + * Row width, and pill sizes, from the DOM. Layout sizes rather than + * `getBoundingClientRect`, which includes transforms: the dialog zooms in + * from 95%, so pills measured on open would come out short and end up + * touching, and nothing re-measures once the zoom finishes. + */ useLayoutEffect(() => { const row = rowEl.current if (!row) return const measure = () => { - setRowWidth(row.getBoundingClientRect().width) + setRowWidth(row.offsetWidth) setSizes(prev => { let next = prev for (const [key, el] of elements.current) { - const r = el.getBoundingClientRect() + const w = el.offsetWidth + const h = el.offsetHeight const cur = next[key] - if (!cur || cur.w !== r.width || cur.h !== r.height) { - next = {...next, [key]: {w: r.width, h: r.height}} + if (!cur || cur.w !== w || cur.h !== h) { + next = {...next, [key]: {w, h}} } } return next diff --git a/src/features/profileLinks/components/SupportedSitesDialog.tsx b/src/features/profileLinks/components/SupportedSitesDialog.tsx index 129952ce4..312354291 100644 --- a/src/features/profileLinks/components/SupportedSitesDialog.tsx +++ b/src/features/profileLinks/components/SupportedSitesDialog.tsx @@ -8,7 +8,7 @@ import {SUPPORT_PROVIDERS} from '../providers' import {ProviderLogo} from './ProviderLogo' /** - * Lists the sites whose links get the green Support button. Built from + * Lists the sites whose links get the green support button. Built from * `SUPPORT_PROVIDERS`, so it always matches what the app recognizes. */ export function SupportedSitesDialog({ @@ -42,7 +42,7 @@ function SupportedSitesInner() { Supported sites - Links to these sites show as a green Support button. + Links to these sites show as a green support button. diff --git a/src/features/profileLinks/state.ts b/src/features/profileLinks/state.ts index 473de13c4..01b6b55a7 100644 --- a/src/features/profileLinks/state.ts +++ b/src/features/profileLinks/state.ts @@ -9,6 +9,7 @@ import {useQuery, useQueryClient} from '@tanstack/react-query' import {uploadBlob} from '#/lib/api' import {LINK_FAVICON_PROXY} from '#/lib/constants' +import {blobToDataUri} from '#/lib/media/util' import {isNetworkError} from '#/lib/strings/errors' import {isRecordNotFoundError} from '#/lib/xrpc-error' import {logger} from '#/logger' @@ -240,10 +241,16 @@ const FAVICON_TIMEOUT = 8e3 * like a link card thumbnail. Storing the blob on the record means it's * scanned like any other profile image, instead of hotlinked. Resolves to * undefined when the site has no usable icon; the pill falls back to a globe. + * + * Also resolves to a data URI of the icon: the CDN can't serve the blob until + * the profile is saved and a record points at it, so the editor shows this + * instead. */ export function useUploadLinkIcon() { const pdsClient = usePdsClient() - return async (url: string): Promise => { + return async ( + url: string, + ): Promise<{icon: BlobRef; previewUrl: string} | undefined> => { const controller = new AbortController() const timeout = setTimeout(() => controller.abort(), FAVICON_TIMEOUT) let icon: Blob @@ -263,8 +270,11 @@ export function useUploadLinkIcon() { clearTimeout(timeout) } try { - const {blob} = await uploadBlob(pdsClient, icon, 'image/png') - return blob + const [{blob}, previewUrl] = await Promise.all([ + uploadBlob(pdsClient, icon, 'image/png'), + blobToDataUri(icon), + ]) + return {icon: blob, previewUrl} } catch (e) { if (!isNetworkError(e)) { logger.error('Failed to upload profile link icon', {safeMessage: e}) diff --git a/src/features/profileLinks/types.ts b/src/features/profileLinks/types.ts index 22807a2b3..6e39d6a6d 100644 --- a/src/features/profileLinks/types.ts +++ b/src/features/profileLinks/types.ts @@ -9,7 +9,10 @@ export type ProfileLink = { * Support links don't need one; they use bundled logos. */ icon?: BlobRef - /** The icon's image URL, as returned in profile views. */ + /** + * The icon's image URL, as returned in profile views. For an icon that was + * just fetched and isn't saved yet, a data URI of it. + */ iconUrl?: string /** The `app.bsky.actor.link` record, once the link has been saved. */ uri?: string -- knotmirror 0.0.1