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.
This commit is contained in:
adilallo committed 2026-11-21 11:42:49 -07:00
1 parent 3a264ac2df
commit 0fe2624002
11 files changed
+132 -14

No files matched your search

+1 -4
View File
@@ -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 =
+1 -1
View File
@@ -97,7 +97,7 @@ const Avatar = memo<AvatarProps>(
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
@@ -16,6 +16,7 @@ const TextInputContainer = forwardRef<HTMLInputElement, TextInputProps>(
state: externalStateProp = "default",
inputSize: inputSizeProp = "medium",
disabled = false,
readOnly = false,
error = false,
label,
placeholder,
@@ -109,6 +110,16 @@ const TextInputContainer = forwardRef<HTMLInputElement, TextInputProps>(
};
}
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<HTMLInputElement, TextInputProps>(
labelId={labelId}
state={actualState}
disabled={disabled}
readOnly={readOnly}
error={error}
label={label}
placeholder={placeholder}
@@ -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;
@@ -13,6 +13,7 @@ export const TextInputView = forwardRef<HTMLInputElement, TextInputViewProps>(
name,
type,
disabled,
readOnly = false,
error = false,
className: _className,
containerClasses,
@@ -90,6 +91,7 @@ export const TextInputView = forwardRef<HTMLInputElement, TextInputViewProps>(
onKeyDown={onKeyDown}
onMouseDown={handleMouseDown}
disabled={disabled}
readOnly={readOnly}
maxLength={maxLength}
autoComplete={autoComplete}
inputMode={inputMode}
@@ -245,9 +245,25 @@ const ShareContainer = memo<ShareProps>((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);
}
+8 -5
View File
@@ -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}
/>
<Button
@@ -303,7 +303,10 @@ export const ShareView = memo(function ShareView({
</div>
) : null}
{linkCopied ? (
</div>
{linkCopied ? (
<div className="shrink-0 px-6 pb-2">
<Alert
type="toast"
status="positive"
@@ -314,8 +317,8 @@ export const ShareView = memo(function ShareView({
hasTrailingIcon={false}
className="w-full"
/>
) : null}
</div>
</div>
) : null}
<div className="flex shrink-0 items-center justify-between border-t border-solid border-[var(--color-border-default-secondary)] bg-[var(--color-surface-default-primary)] px-6 py-4">
<Button