Add mobile view to pronouns and refactor

This commit is contained in:
ranidspace committed 2026-02-27 20:52:20 -05:00
1 parent f50f20052a
commit fa16edbbc7
3 files changed
+37 -36

No files matched your search

@@ -28,6 +28,10 @@ export const UsernameBold = as<'b'>(({ as: AsUsernameBold = 'b', className, ...p
<AsUsernameBold className={classNames(css.UsernameBold, className)} {...props} ref={ref} />
));
export const PronounPill = as<'span'>(({ as: AsPronounPill = 'span', className, ...props }, ref) => (
<AsPronounPill className={classNames(css.PronounPill, className)} {...props} ref={ref} />
));
export const MessageTextBody = as<'div', css.MessageTextBodyVariants & { notice?: boolean }>(
({ as: asComp = 'div', className, preWrap, jumboEmoji, emote, notice, ...props }, ref) => (
<Text
@@ -181,6 +181,16 @@ export const UsernameBold = style({
fontWeight: 550,
});
export const PronounPill = style({
borderRadius: config.radii.Pill,
backgroundColor: 'var(--sable-surface-var-container)',
paddingInline: toRem(5),
opacity: 0.8,
fontSize: '0.7rem',
whiteSpace: 'nowrap',
textTransform: 'lowercase',
});
export const MessageTextBody = recipe({
base: {
wordBreak: 'break-word',
+23 -36
View File
@@ -35,6 +35,7 @@ import {
CompactLayout,
MessageBase,
ModernLayout,
PronounPill,
Time,
Username,
UsernameBold,
@@ -249,47 +250,33 @@ function useMobileDoubleTap(callback: () => void, delay = 300) {
);
}
function PronounPill({ summary, tagColor }: { summary: string; tagColor: string }) {
return (
<Box
alignItems="Center"
style={{
backgroundColor: 'var(--sable-surface-var-container)',
padding: '0 5px',
borderRadius: config.radii.Pill,
height: '16px',
display: 'inline-flex',
}}
>
<Text
style={{
color: tagColor,
fontSize: '0.7rem',
lineHeight: '1',
textTransform: 'lowercase',
opacity: 0.8,
}}
>
{summary}
</Text>
</Box>
);
}
function PronounTag({ pronouns, tagColor }: { pronouns?: any[]; tagColor: string }) {
const Pronouns = as<
'div',
{
pronouns?: any[];
tagColor: string;
}
>(({ pronouns, tagColor, ...props }, ref) => {
if (!pronouns || pronouns.length === 0) return null;
const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str);
const limit = mobileOrTablet() ? 1 : 3;
const display = pronouns
.slice(0, 3)
.map((p) => <PronounPill summary={clamp(p.summary, 16)} tagColor={tagColor} />);
const display = pronouns.slice(0, limit).map((p) => (
<PronounPill style={{ color: tagColor }} {...props} ref={ref}>
{clamp(p.summary, 16)}
</PronounPill>
));
if (pronouns.length > 3) {
display.push(<PronounPill summary="..." tagColor={tagColor} />);
if (pronouns.length > limit) {
display.push(
<PronounPill style={{ color: tagColor }} {...props} ref={ref}>
...
</PronounPill>
);
}
return display;
}
return <>{display}</>;
});
function MessageInternal(
{
@@ -405,7 +392,7 @@ function MessageInternal(
</Text>
</Username>
{showPronouns && (
<PronounTag pronouns={profile.pronouns} tagColor={usernameColor ?? 'currentColor'} />
<Pronouns pronouns={profile.pronouns} tagColor={usernameColor ?? 'currentColor'} />
)}
{tagIconSrc && <PowerIcon size="100" iconSrc={tagIconSrc} />}
</Box>