From 771fd5ddf614fb0234286ea1eb745814929e2d25 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 2 Jun 2026 13:23:51 +0300 Subject: [PATCH] [Chat] Tweak styles in invite link dialog (#10638) --- src/components/forms/Toggle/index.tsx | 10 +- .../Messages/components/EditTextButton.tsx | 5 +- .../Messages/components/InviteLinkDialog.tsx | 169 ++++++++++-------- 3 files changed, 106 insertions(+), 78 deletions(-) diff --git a/src/components/forms/Toggle/index.tsx b/src/components/forms/Toggle/index.tsx index e22ede36ec..a62a82b62f 100644 --- a/src/components/forms/Toggle/index.tsx +++ b/src/components/forms/Toggle/index.tsx @@ -212,9 +212,12 @@ export function Item({ ) const highlightStyle = highlightRow - ? selected - ? [a.rounded_full, a.p_md, {backgroundColor: t.palette.primary_50}] - : [a.rounded_full, a.p_md] + ? [ + a.rounded_full, + a.p_md, + hovered && t.atoms.bg_contrast_25, + selected && {backgroundColor: t.palette.primary_50}, + ] : null return ( @@ -588,6 +591,7 @@ export function RadioWithLabel({ style={[ a.font_medium, a.flex_1, + a.text_md, a.leading_tight, selected ? t.atoms.text : t.atoms.text_contrast_high, ]}> diff --git a/src/screens/Messages/components/EditTextButton.tsx b/src/screens/Messages/components/EditTextButton.tsx index 8a1ccc620a..d578e39e5f 100644 --- a/src/screens/Messages/components/EditTextButton.tsx +++ b/src/screens/Messages/components/EditTextButton.tsx @@ -35,13 +35,14 @@ export function EditTextButton({ a.flex_row, a.align_center, a.justify_between, - a.px_md, + a.pl_lg, + a.pr_sm, a.py_sm, + a.gap_sm, ]}> {typeof children === 'function' ? children(context) : children} { + const joinLinkRuleKey = joinLink ? joinLinkToKey(joinLink) : null + const [prevKey, setPrevKey] = useState(joinLinkRuleKey) + if (joinLinkRuleKey !== prevKey) { setStep(joinLinkRuleKey ? Step.MANAGE : Step.INFO) - setWhoCanJoin([joinLinkRuleKey ?? 'anyone']) - }, [joinLinkRuleKey]) + setWhoCanJoin(joinLinkRuleKey ?? 'anyone') + setPrevKey(joinLinkRuleKey) + } const {openComposer} = useOpenComposer() @@ -163,22 +163,32 @@ export function InviteLinkDialog({ let content: React.ReactNode = null let header: string | null = null switch (step) { - case Step.INFO: + case Step.INFO: { header = l`Invite link` content = ( <> - - + + An invite link lets people join this group chat without being - added directly. You control who can use the link and whether - they need your approval. You can disable the link at any time. + added directly. You control who can join the chat. You can + disable the link at any time. - + - Your name, avatar, and the name of the group chat will be - visible to everyone. + Group chats can only have a maximum of{' '} + {plural(convo.details.memberLimit, { + one: '# person', + other: '# people', + })} + . + + + + + Your name, avatar, the name of the group chat, and the number of + members will be visible to everyone. @@ -199,15 +209,16 @@ export function InviteLinkDialog({ ) break - case Step.GENERATE: - header = - joinLink && enabledStatus === 'enabled' - ? l`Update invite link` - : l`Generate invite link` + } + case Step.GENERATE: { + const linkEnabled = joinLink?.enabledStatus === 'enabled' + const linkHasChanged = linkEnabled && joinLinkRuleKey !== whoCanJoin + + header = linkEnabled ? l`Update invite link` : l`Generate invite link` content = ( <> - + Choose who can join this group chat and how. @@ -215,9 +226,9 @@ export function InviteLinkDialog({ - + values={[whoCanJoin]} + onChange={([value]) => setWhoCanJoin(value)}> + {whoCanJoinOptions.map(option => ( ) break + } case Step.MANAGE: { + const linkEnabled = joinLink?.enabledStatus === 'enabled' + const linkDisabled = joinLink?.enabledStatus === 'disabled' const joinLinkURI = joinLink?.code ? `https://bsky.app/chat/${joinLink.code}` : 'https://bsky.app/chat' const createdAt = joinLink ? new Date(joinLink.createdAt) : null - const currentOptionName = joinLink - ? `${joinLink.joinRule}${joinLink.requireApproval ? ':requireApproval' : ''}` - : whoCanJoinOptions[0].name - const currentOption = whoCanJoinOptions.find( - o => o.name === currentOptionName, - ) + const currentOption = + whoCanJoinOptions.find( + o => o.name === (joinLink ? joinLinkToKey(joinLink) : null), + ) ?? whoCanJoinOptions[0] const ownerValue = currentOption?.owner ?? whoCanJoinOptions[0].owner const memberValue = currentOption?.member ?? whoCanJoinOptions[0].member - header = - enabledStatus === 'enabled' ? l`Invite link` : l`Invite link disabled` + header = linkEnabled ? l`Invite link` : l`Invite link disabled` content = ( <> {joinLinkURI} @@ -319,25 +336,25 @@ export function InviteLinkDialog({ ) : null} - {enabledStatus === 'enabled' ? ( + {linkEnabled ? ( {isOwner ? ( setStep(Step.GENERATE)}> - - + + {ownerValue} ) : ( - {memberValue} + {memberValue} )} ) : null} - {enabledStatus === 'enabled' ? ( + {linkEnabled ? ( {isOwner ? ( ) : null} Post link @@ -425,14 +442,7 @@ export function InviteLinkDialog({ ]}> Disable this invite link? - + Anyone who has it will no longer be able to join or request to join. You can always create a new one. @@ -465,6 +475,7 @@ export function InviteLinkDialog({ ) break + } } if (!isOwner && (!joinLink || joinLink.enabledStatus === 'disabled')) { @@ -472,7 +483,7 @@ export function InviteLinkDialog({ content = ( <> - + There is no invite link for this group chat. @@ -503,9 +514,7 @@ export function InviteLinkDialog({ header={ - - {header} - + {header} @@ -517,3 +526,17 @@ export function InviteLinkDialog({ ) } + +function joinLinkToKey(joinLink: ChatBskyGroupDefs.JoinLinkView): string { + return `${joinLink.joinRule}${joinLink.requireApproval ? ':requireApproval' : ''}` +} + +function keyToJoinLink( + key: string, +): Pick { + const [joinRule, requireApproval] = key.split(':') + return { + joinRule, + requireApproval: requireApproval === 'requireApproval', + } +}