From 0fe2624002d84c2642cbf980ec052fb28d8f7262 Mon Sep 17 00:00:00 2001 From: adilallo <39313955+adilallo@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:42:49 -0700 Subject: [PATCH] Show Share initials, a readable link, and a copy confirmation. Filled avatars used white ink on yellow, the link field was a dimmed disabled input, and Copy failed silently when the clipboard API was denied. --- app/(marketing)/r/[shareSlug]/page.tsx | 5 +-- app/components/asset/Avatar/Avatar.tsx | 2 +- .../TextInput/TextInput.container.tsx | 12 ++++++ .../controls/TextInput/TextInput.types.ts | 2 + .../controls/TextInput/TextInput.view.tsx | 2 + .../modals/Share/Share.container.tsx | 18 +++++++- app/components/modals/Share/Share.view.tsx | 13 +++--- tests/components/Avatar.test.tsx | 9 ++++ tests/components/TextInput.test.tsx | 15 +++++++ tests/components/modals/Share.test.tsx | 27 ++++++++++-- tests/pages/shared-rule.test.ts | 41 +++++++++++++++++++ 11 files changed, 132 insertions(+), 14 deletions(-) create mode 100644 tests/pages/shared-rule.test.ts diff --git a/app/(marketing)/r/[shareSlug]/page.tsx b/app/(marketing)/r/[shareSlug]/page.tsx index 74dc1a0..cebb02d 100644 --- a/app/(marketing)/r/[shareSlug]/page.tsx +++ b/app/(marketing)/r/[shareSlug]/page.tsx @@ -30,10 +30,7 @@ export async function generateMetadata({ const { shareSlug } = await params; const resolved = await loadSharedRule(shareSlug); if (!resolved) { - return { - title: messages.pages.ruleDetail.notFoundTitle, - description: "The requested CommunityRule could not be found.", - }; + notFound(); } const { rule } = resolved; const description = diff --git a/app/components/asset/Avatar/Avatar.tsx b/app/components/asset/Avatar/Avatar.tsx index a37b590..d01153c 100644 --- a/app/components/asset/Avatar/Avatar.tsx +++ b/app/components/asset/Avatar/Avatar.tsx @@ -97,7 +97,7 @@ const Avatar = memo( const fallbackChrome = variant === "outlined" ? "border-[1.5px] border-solid border-[var(--color-content-default-brand-primary)] bg-transparent text-[var(--color-content-default-brand-primary)]" - : "bg-[var(--color-surface-invert-brand-primary)] text-[var(--color-content-default-primary)]"; + : "bg-[var(--color-surface-invert-brand-primary)] text-[var(--color-content-invert-primary)]"; // White 30% ring on small photos: no DS token (opacity scale is black-alpha). const smallImageBorder = size === "small" && showImage && loaded diff --git a/app/components/controls/TextInput/TextInput.container.tsx b/app/components/controls/TextInput/TextInput.container.tsx index 5f750a4..1f935b1 100644 --- a/app/components/controls/TextInput/TextInput.container.tsx +++ b/app/components/controls/TextInput/TextInput.container.tsx @@ -16,6 +16,7 @@ const TextInputContainer = forwardRef( state: externalStateProp = "default", inputSize: inputSizeProp = "medium", disabled = false, + readOnly = false, error = false, label, placeholder, @@ -109,6 +110,16 @@ const TextInputContainer = forwardRef( }; } + if (readOnly) { + return { + input: + "bg-[var(--color-surface-default-secondary)] text-[var(--color-content-default-primary)] border border-solid border-[var(--color-border-default-primary)] cursor-default", + label: "text-[var(--color-content-default-secondary)]", + inputWrapper: "relative", + focusRing: "", + }; + } + if (error) { const filledStyles = isFilled ? "font-medium leading-[20px]" @@ -231,6 +242,7 @@ const TextInputContainer = forwardRef( labelId={labelId} state={actualState} disabled={disabled} + readOnly={readOnly} error={error} label={label} placeholder={placeholder} diff --git a/app/components/controls/TextInput/TextInput.types.ts b/app/components/controls/TextInput/TextInput.types.ts index c445828..2ecc8f3 100644 --- a/app/components/controls/TextInput/TextInput.types.ts +++ b/app/components/controls/TextInput/TextInput.types.ts @@ -16,6 +16,7 @@ export interface TextInputProps extends Omit< */ inputSize?: TextInputSizeValue; disabled?: boolean; + readOnly?: boolean; error?: boolean; label?: string; placeholder?: string; @@ -43,6 +44,7 @@ export interface TextInputViewProps { labelId: string; state: "default" | "active" | "hover" | "focus"; disabled: boolean; + readOnly: boolean; error: boolean; label?: string; placeholder?: string; diff --git a/app/components/controls/TextInput/TextInput.view.tsx b/app/components/controls/TextInput/TextInput.view.tsx index 3b3b5a0..07687f1 100644 --- a/app/components/controls/TextInput/TextInput.view.tsx +++ b/app/components/controls/TextInput/TextInput.view.tsx @@ -13,6 +13,7 @@ export const TextInputView = forwardRef( name, type, disabled, + readOnly = false, error = false, className: _className, containerClasses, @@ -90,6 +91,7 @@ export const TextInputView = forwardRef( onKeyDown={onKeyDown} onMouseDown={handleMouseDown} disabled={disabled} + readOnly={readOnly} maxLength={maxLength} autoComplete={autoComplete} inputMode={inputMode} diff --git a/app/components/modals/Share/Share.container.tsx b/app/components/modals/Share/Share.container.tsx index 625add6..fbea707 100644 --- a/app/components/modals/Share/Share.container.tsx +++ b/app/components/modals/Share/Share.container.tsx @@ -245,9 +245,25 @@ const ShareContainer = memo((props) => { const handleCopyLink = useCallback(async () => { if (!settings) return; + const text = settings.shareUrl; try { - await navigator.clipboard.writeText(settings.shareUrl); + await navigator.clipboard.writeText(text); setLinkCopied(true); + return; + } catch { + // Some browsers deny clipboard without a secure context; fall back. + } + try { + const field = document.createElement("textarea"); + field.value = text; + field.setAttribute("readonly", ""); + field.style.position = "fixed"; + field.style.left = "-9999px"; + document.body.appendChild(field); + field.select(); + const copied = document.execCommand("copy"); + field.remove(); + setLinkCopied(copied); } catch { setLinkCopied(false); } diff --git a/app/components/modals/Share/Share.view.tsx b/app/components/modals/Share/Share.view.tsx index d310109..a8b02f4 100644 --- a/app/components/modals/Share/Share.view.tsx +++ b/app/components/modals/Share/Share.view.tsx @@ -170,7 +170,7 @@ export const ShareView = memo(function ShareView({ buttonType="outline" palette="default" size="small" - disabled={inviteBusy || inviteValue.trim().length === 0} + disabled={inviteBusy} onClick={onInvite} > {copy.invite} @@ -252,7 +252,7 @@ export const ShareView = memo(function ShareView({ showHelpIcon={false} label={copy.anyoneWithLink} value={shareUrlDisplay} - disabled + readOnly textHint={copy.linkHint} />