diff --git a/.changeset/add_better_misc_data_styling.md b/.changeset/add_better_misc_data_styling.md new file mode 100644 index 000000000..b71cd2949 --- /dev/null +++ b/.changeset/add_better_misc_data_styling.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Change Misc. data styling in users profile pages diff --git a/src/app/components/UserRoomProfileRenderer.tsx b/src/app/components/UserRoomProfileRenderer.tsx index 97489d277..e8b247c01 100644 --- a/src/app/components/UserRoomProfileRenderer.tsx +++ b/src/app/components/UserRoomProfileRenderer.tsx @@ -23,7 +23,7 @@ function UserRoomProfileContextMenu({ state }: { state: UserRoomProfileState }) window.innerHeight / 2 ? 'End' : 'Start'} content={ - + Blocked User diff --git a/src/app/components/user-profile/UserModeration.tsx b/src/app/components/user-profile/UserModeration.tsx index a6f8c796e..fb7b679da 100644 --- a/src/app/components/user-profile/UserModeration.tsx +++ b/src/app/components/user-profile/UserModeration.tsx @@ -256,7 +256,9 @@ export function UserModeration({ userId, canKick, canBan, canInvite }: UserModer - Moderation + + Moderation + ) { - const clamp = (str: any, len: number) => { - const stringified = String(str ?? ''); - return stringified.length > len ? `${stringified.slice(0, len)}...` : stringified; - }; - const [showMore, setShowMore] = useState(false); + const [showMisc, setShowMisc] = useState(false); + const [miscDataIndex, setMiscDataIndex] = useState(-1); const [renderAnimals] = useSetting(settingsAtom, 'renderAnimals'); const isCat = profile.isCat === true; @@ -148,6 +146,73 @@ function UserExtendedSection({ ([key]) => !KNOWN_KEYS.includes(key) ); + function handleMiscSelector(index: number) { + setMiscDataIndex(index); + setShowMisc(false); + } + + const miscSelector = useMemo(() => { + if (unknownFields.length === 1 && showMisc) { + setShowMisc(false); + setMiscDataIndex(miscDataIndex === -1 ? 0 : -1); + return null; + } + return ( + + handleMiscSelector(-1)} + > + + Show less + + {unknownFields.map(([key], index) => ( + handleMiscSelector(index)} + > + {key} + + ))} + + ); + }, [miscDataIndex, showMisc, unknownFields]); + const miscHeader = useMemo( + () => ( + + + {showMisc && miscSelector} + + ), + [miscSelector, miscDataIndex, showMisc, unknownFields] + ); + return ( {(pronouns || localTime) && ( @@ -209,39 +274,66 @@ function UserExtendedSection({ {unknownFields.length > 0 && ( - - - {showMore && ( - -1 && ( +
- {unknownFields.map(([key, value]) => ( - - - {key} - - - {clamp(renderValue(value), 128)} - + + {unknownFields.length > 1 && ( + + )} + {miscHeader} + {unknownFields.length > 1 && ( + + )} + + + + - ))} - + +
)}
)} @@ -382,7 +474,7 @@ export function UserRoomProfile({ userId, initialProfile }: Readonly - + {server && } {creator ? : } diff --git a/src/app/features/room/MembersDrawer.tsx b/src/app/features/room/MembersDrawer.tsx index 0a74acfda..2f4849288 100644 --- a/src/app/features/room/MembersDrawer.tsx +++ b/src/app/features/room/MembersDrawer.tsx @@ -282,7 +282,12 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) { const btn = evt.currentTarget as HTMLButtonElement; const userId = btn.getAttribute('data-user-id'); if (!userId) return; - openUserRoomProfile(room.roomId, space?.roomId, userId, btn.getBoundingClientRect(), 'Left'); + + const cords = btn.getBoundingClientRect(); + // BODGE, dependent on menuItem height staying at toRem(40) + cords.y = Math.min(cords.y, window.innerHeight - 42); + + openUserRoomProfile(room.roomId, space?.roomId, userId, cords, 'Left'); }; return (