feat: add avatar border color customization and improve text contrast across user profile components
This commit is contained in:
@@ -23,7 +23,7 @@ import { useMemberPowerCompare } from '../../hooks/useMemberPowerCompare';
|
||||
import { CreatorChip } from './CreatorChip';
|
||||
import { getDirectCreatePath, withSearchParam } from '../../pages/pathUtils';
|
||||
import { DirectCreateSearchParams } from '../../pages/paths';
|
||||
import { getContrastingTextColor } from '../../utils/common';
|
||||
import { getContrastingTextColor, stripAlphaFromColor, getTextShadowColor } from '../../utils/common';
|
||||
import classNames from 'classnames';
|
||||
import { BreakWord, LineClamp3 } from '../../styles/Text.css';
|
||||
import colorMXID from '../../../util/colorMXID';
|
||||
@@ -87,6 +87,10 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
(canKickUser && membership === Membership.Join) ||
|
||||
(canBanUser && membership !== Membership.Ban);
|
||||
|
||||
const profileColor = profileStyle.avatarBorderColor ? stripAlphaFromColor(profileStyle.avatarBorderColor) : colorMXID(userId);
|
||||
const profileTextShadow = `0 1px 4px ${getTextShadowColor(profileColor)}`;
|
||||
const pillBgColor = profileStyle.avatarBorderColor ? stripAlphaFromColor(profileStyle.avatarBorderColor) : undefined;
|
||||
|
||||
return (
|
||||
<Box direction="Column">
|
||||
<UserHero
|
||||
@@ -111,7 +115,7 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
<Text
|
||||
size="H4"
|
||||
className={classNames(BreakWord, LineClamp3)}
|
||||
style={{ color: getMemberDisplayName(room, userId) !== userId ? (profileStyle.avatarBorderColor || colorMXID(userId)) : undefined }}
|
||||
style={{ color: getMemberDisplayName(room, userId) !== userId ? profileColor : undefined, textShadow: profileTextShadow }}
|
||||
>
|
||||
{getMemberDisplayName(room, userId)}
|
||||
</Text>
|
||||
@@ -120,7 +124,7 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
<Text
|
||||
size="T200"
|
||||
className={BreakWord}
|
||||
style={{ color: profileStyle.avatarBorderColor || colorMXID(userId), opacity: 0.8 }}
|
||||
style={{ color: profileColor, textShadow: profileTextShadow }}
|
||||
>
|
||||
{userId}
|
||||
</Text>
|
||||
@@ -129,8 +133,8 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
{presence?.status && (
|
||||
<Box
|
||||
style={{
|
||||
backgroundColor: profileStyle.avatarBorderColor || color.Surface.Container,
|
||||
border: profileStyle.avatarBorderColor ? 'none' : `${toRem(1)} solid ${color.Surface.ContainerLine}`,
|
||||
backgroundColor: pillBgColor || color.Surface.Container,
|
||||
border: pillBgColor ? 'none' : `${toRem(1)} solid ${color.Surface.ContainerLine}`,
|
||||
padding: `${toRem(6)} ${toRem(10)}`,
|
||||
borderRadius: toRem(16),
|
||||
maxWidth: toRem(250),
|
||||
@@ -140,7 +144,7 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
size="T300"
|
||||
className={BreakWord}
|
||||
style={{
|
||||
color: profileStyle.avatarBorderColor ? getContrastingTextColor(profileStyle.avatarBorderColor) : undefined
|
||||
color: pillBgColor ? getContrastingTextColor(pillBgColor) : undefined
|
||||
}}
|
||||
>
|
||||
{presence.status}
|
||||
@@ -150,9 +154,9 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
|
||||
{/* Chips Row */}
|
||||
<Box alignItems="Center" gap="200" wrap="Wrap" justifyContent="Center">
|
||||
{server && <ServerChip server={server} borderColor={profileStyle.avatarBorderColor} />}
|
||||
<ShareChip userId={userId} borderColor={profileStyle.avatarBorderColor} />
|
||||
{creator ? <CreatorChip borderColor={profileStyle.avatarBorderColor} /> : <PowerChip userId={userId} borderColor={profileStyle.avatarBorderColor} />}
|
||||
{server && <ServerChip server={server} borderColor={pillBgColor} />}
|
||||
<ShareChip userId={userId} borderColor={pillBgColor} />
|
||||
{creator ? <CreatorChip borderColor={pillBgColor} /> : <PowerChip userId={userId} borderColor={pillBgColor} />}
|
||||
</Box>
|
||||
|
||||
{/* Message Button */}
|
||||
@@ -172,8 +176,8 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
{/* Additional Chips if needed */}
|
||||
{userId !== myUserId && (
|
||||
<Box alignItems="Center" gap="200" wrap="Wrap" justifyContent="Center">
|
||||
<MutualRoomsChip userId={userId} borderColor={profileStyle.avatarBorderColor} />
|
||||
<OptionsChip userId={userId} borderColor={profileStyle.avatarBorderColor} />
|
||||
<MutualRoomsChip userId={userId} borderColor={pillBgColor} />
|
||||
<OptionsChip userId={userId} borderColor={pillBgColor} />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user