disable font scaling on fixed-height chat invite cards
thread a hasFixedHeight flag through ChatInvite.Root and its context so the card, join button, and profile badges disable font scaling when they live in a fixed-height container, preventing text from overflowing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,7 @@ export function ChatInviteEmbed({
|
|||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<ChatInvite.Root code={code}>
|
<ChatInvite.Root code={code} hasFixedHeight>
|
||||||
<ChatInviteEmbedBody link={link} onOpen={onOpen} style={style} />
|
<ChatInviteEmbedBody link={link} onOpen={onOpen} style={style} />
|
||||||
</ChatInvite.Root>
|
</ChatInvite.Root>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ export function JoinRequestEmbed({
|
|||||||
if (!resolvedCode) return null
|
if (!resolvedCode) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ChatInvite.Root code={resolvedCode} initialPreview={preview}>
|
<ChatInvite.Root
|
||||||
|
code={resolvedCode}
|
||||||
|
initialPreview={preview}
|
||||||
|
hasFixedHeight>
|
||||||
<JoinRequestEmbedBody style={style} onOpen={onOpen} />
|
<JoinRequestEmbedBody style={style} onOpen={onOpen} />
|
||||||
</ChatInvite.Root>
|
</ChatInvite.Root>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ export function ProfileBadges({
|
|||||||
interactive = false,
|
interactive = false,
|
||||||
size,
|
size,
|
||||||
style,
|
style,
|
||||||
|
allowFontScaling = true,
|
||||||
}: ViewStyleProp & {
|
}: ViewStyleProp & {
|
||||||
profile: bsky.profile.AnyProfileView
|
profile: bsky.profile.AnyProfileView
|
||||||
interactive?: boolean
|
interactive?: boolean
|
||||||
size: Size
|
size: Size
|
||||||
|
allowFontScaling?: boolean
|
||||||
}) {
|
}) {
|
||||||
const shadowed = useProfileShadow(profile)
|
const shadowed = useProfileShadow(profile)
|
||||||
const verification = useSimpleVerificationState({profile})
|
const verification = useSimpleVerificationState({profile})
|
||||||
@@ -48,10 +50,12 @@ export function ProfileBadges({
|
|||||||
|
|
||||||
const isOnTheSmallSide = size === 'xs' || size === 'sm'
|
const isOnTheSmallSide = size === 'xs' || size === 'sm'
|
||||||
|
|
||||||
const verificationIconWidth =
|
const scaleMultiplier = allowFontScaling
|
||||||
verificationIconSizes[size] * nativeScaleMultiplier * alfScaleMultiplier
|
? nativeScaleMultiplier * alfScaleMultiplier
|
||||||
const botIconWidth =
|
: 1
|
||||||
botIconSizes[size] * nativeScaleMultiplier * alfScaleMultiplier
|
|
||||||
|
const verificationIconWidth = verificationIconSizes[size] * scaleMultiplier
|
||||||
|
const botIconWidth = botIconSizes[size] * scaleMultiplier
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export function Text({
|
|||||||
title,
|
title,
|
||||||
dataSet,
|
dataSet,
|
||||||
numberOfLines,
|
numberOfLines,
|
||||||
|
allowFontScaling = true,
|
||||||
...rest
|
...rest
|
||||||
}: TextProps) {
|
}: TextProps) {
|
||||||
const {fonts, flags} = useAlf()
|
const {fonts, flags} = useAlf()
|
||||||
@@ -36,7 +37,7 @@ export function Text({
|
|||||||
style,
|
style,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
fontScale: fonts.scaleMultiplier,
|
fontScale: allowFontScaling ? fonts.scaleMultiplier : 1,
|
||||||
fontFamily: fonts.family,
|
fontFamily: fonts.family,
|
||||||
flags,
|
flags,
|
||||||
},
|
},
|
||||||
@@ -57,6 +58,7 @@ export function Text({
|
|||||||
numberOfLines,
|
numberOfLines,
|
||||||
style: s,
|
style: s,
|
||||||
dataSet: Object.assign({tooltip: title}, dataSet || {}),
|
dataSet: Object.assign({tooltip: title}, dataSet || {}),
|
||||||
|
allowFontScaling,
|
||||||
...rest,
|
...rest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {useChatInvite} from './Context'
|
|||||||
*/
|
*/
|
||||||
export function Card({size}: {size: 'large' | 'small'}) {
|
export function Card({size}: {size: 'large' | 'small'}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {preview} = useChatInvite()
|
const {preview, hasFixedHeight} = useChatInvite()
|
||||||
|
|
||||||
if (!preview) return null
|
if (!preview) return null
|
||||||
|
|
||||||
@@ -31,14 +31,15 @@ export function Card({size}: {size: 'large' | 'small'}) {
|
|||||||
<Text
|
<Text
|
||||||
emoji
|
emoji
|
||||||
style={[size === 'large' ? a.text_lg : a.text_md, a.font_bold]}
|
style={[size === 'large' ? a.text_lg : a.text_md, a.font_bold]}
|
||||||
numberOfLines={1}>
|
numberOfLines={1}
|
||||||
|
allowFontScaling={!hasFixedHeight}>
|
||||||
{preview.name}
|
{preview.name}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={[a.flex_row, a.align_center, a.gap_sm]}>
|
<View style={[a.flex_row, a.align_center, a.gap_sm]}>
|
||||||
<Text
|
<Text
|
||||||
style={[a.text_2xs, a.font_medium, t.atoms.text_contrast_high]}
|
style={[a.text_2xs, a.font_medium, t.atoms.text_contrast_high]}
|
||||||
allowFontScaling
|
numberOfLines={1}
|
||||||
numberOfLines={1}>
|
allowFontScaling={!hasFixedHeight}>
|
||||||
<Trans>Group chat</Trans>
|
<Trans>Group chat</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
@@ -48,8 +49,8 @@ export function Card({size}: {size: 'large' | 'small'}) {
|
|||||||
a.font_medium,
|
a.font_medium,
|
||||||
t.atoms.text_contrast_high,
|
t.atoms.text_contrast_high,
|
||||||
]}
|
]}
|
||||||
allowFontScaling
|
numberOfLines={1}
|
||||||
numberOfLines={1}>
|
allowFontScaling={!hasFixedHeight}>
|
||||||
<Trans comment="The number of members in a group chat, in the format '{members}/{total} members'.">
|
<Trans comment="The number of members in a group chat, in the format '{members}/{total} members'.">
|
||||||
{preview.memberCount}/{preview.memberLimit}{' '}
|
{preview.memberCount}/{preview.memberLimit}{' '}
|
||||||
<Plural
|
<Plural
|
||||||
@@ -70,17 +71,21 @@ export function Card({size}: {size: 'large' | 'small'}) {
|
|||||||
<Text
|
<Text
|
||||||
emoji
|
emoji
|
||||||
style={[a.flex_shrink, a.text_sm, a.font_medium]}
|
style={[a.flex_shrink, a.text_sm, a.font_medium]}
|
||||||
allowFontScaling
|
numberOfLines={1}
|
||||||
numberOfLines={1}>
|
allowFontScaling={!hasFixedHeight}>
|
||||||
<Trans comment="The group chat creator, in the format 'By {displayName}'.">
|
<Trans comment="The group chat creator, in the format 'By {displayName}'.">
|
||||||
By <Text style={[a.font_medium]}>{ownerDisplayName}</Text>
|
By <Text style={[a.font_medium]}>{ownerDisplayName}</Text>
|
||||||
</Trans>
|
</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
<ProfileBadges profile={preview.owner} size="sm" />
|
<ProfileBadges
|
||||||
|
profile={preview.owner}
|
||||||
|
size="sm"
|
||||||
|
allowFontScaling={!hasFixedHeight}
|
||||||
|
/>
|
||||||
<Text
|
<Text
|
||||||
style={[a.flex_shrink, t.atoms.text_contrast_medium]}
|
style={[a.flex_shrink, t.atoms.text_contrast_medium]}
|
||||||
allowFontScaling
|
numberOfLines={1}
|
||||||
numberOfLines={1}>
|
allowFontScaling={!hasFixedHeight}>
|
||||||
{ownerHandle}
|
{ownerHandle}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ export type ChatInviteContextValue = {
|
|||||||
* preview to act on.
|
* preview to act on.
|
||||||
*/
|
*/
|
||||||
action: ChatInviteAction | undefined
|
action: ChatInviteAction | undefined
|
||||||
|
/** Whether or not to allow font scaling on text elements. */
|
||||||
|
hasFixedHeight: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChatInviteContext = createContext<ChatInviteContextValue | null>(null)
|
const ChatInviteContext = createContext<ChatInviteContextValue | null>(null)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function JoinButton({
|
|||||||
onPress?: () => void
|
onPress?: () => void
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
}) {
|
}) {
|
||||||
const {action} = useChatInvite()
|
const {action, hasFixedHeight} = useChatInvite()
|
||||||
|
|
||||||
if (!action) return null
|
if (!action) return null
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export function JoinButton({
|
|||||||
disabled={action.disabled}
|
disabled={action.disabled}
|
||||||
style={[a.w_full, style]}>
|
style={[a.w_full, style]}>
|
||||||
{action.side === 'left' && <ButtonIcon icon={action.icon} />}
|
{action.side === 'left' && <ButtonIcon icon={action.icon} />}
|
||||||
<ButtonText>{action.label}</ButtonText>
|
<ButtonText allowFontScaling={!hasFixedHeight}>{action.label}</ButtonText>
|
||||||
{action.side === 'right' && <ButtonIcon icon={action.icon} />}
|
{action.side === 'right' && <ButtonIcon icon={action.icon} />}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export function Root({
|
|||||||
code,
|
code,
|
||||||
initialPreview,
|
initialPreview,
|
||||||
currentConvoId,
|
currentConvoId,
|
||||||
|
hasFixedHeight,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
code: string
|
code: string
|
||||||
@@ -40,6 +41,7 @@ export function Root({
|
|||||||
* open/join (you're already here).
|
* open/join (you're already here).
|
||||||
*/
|
*/
|
||||||
currentConvoId?: string
|
currentConvoId?: string
|
||||||
|
hasFixedHeight: boolean
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}) {
|
}) {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
@@ -137,7 +139,7 @@ export function Root({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ChatInviteProvider
|
<ChatInviteProvider
|
||||||
value={{code, loading, error: !!error, preview, action}}>
|
value={{code, loading, error: !!error, preview, action, hasFixedHeight}}>
|
||||||
{children}
|
{children}
|
||||||
</ChatInviteProvider>
|
</ChatInviteProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ let MessageItemInviteEmbed = ({
|
|||||||
<ChatInvite.Root
|
<ChatInvite.Root
|
||||||
code={embed.joinLinkPreview.code}
|
code={embed.joinLinkPreview.code}
|
||||||
initialPreview={embed.joinLinkPreview}
|
initialPreview={embed.joinLinkPreview}
|
||||||
currentConvoId={convo.convo.view.id}>
|
currentConvoId={convo.convo.view.id}
|
||||||
|
hasFixedHeight={false}>
|
||||||
<ChatInvite.Card size="small" />
|
<ChatInvite.Card size="small" />
|
||||||
<ChatInvite.JoinButton />
|
<ChatInvite.JoinButton />
|
||||||
</ChatInvite.Root>
|
</ChatInvite.Root>
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ function MessageInputInviteEmbed({
|
|||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ChatInvite.Root code={code}>
|
<ChatInvite.Root code={code} hasFixedHeight={false}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.flex_1,
|
a.flex_1,
|
||||||
|
|||||||
Reference in New Issue
Block a user