mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
Add Resize the room sidepanel using a hoverable tool (#768)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description Add the ability to resize the room sidebar, you can either do it in settings as a number of the width of it, or using a hoverable thing. Additionally you can now set whether and when do you want to show the room's icon instead of the default symbol, mainly meant for when the sidebar is not wide enough to display meaningful names to serve as an aid to know which room you are in. A good %age of the changes are just indentation from adding/removing one object (example of holding the bar to drag it) <img width="1033" height="1080" alt="image" src="https://github.com/user-attachments/assets/d7c6f47a-40a6-4199-9258-00f89119afd3" /> (example of smart looks) <img width="1033" height="1080" alt="image" src="https://github.com/user-attachments/assets/287ae643-1178-44b8-96e1-436185c93076" /> <img width="1060" height="1080" alt="image" src="https://github.com/user-attachments/assets/3d915210-fa77-4844-8ce3-64afc244ae8c" /> (settings added here) <img width="810" height="697" alt="image" src="https://github.com/user-attachments/assets/fe925a68-63d7-4ad7-9c90-31243dd386d0" /> <img width="811" height="823" alt="image" src="https://github.com/user-attachments/assets/c2266459-af86-4168-b8e5-aabacb057476" /> (example of the threads being resizeable) <img width="918" height="1080" alt="image" src="https://github.com/user-attachments/assets/d41d6749-489d-46ed-aa78-73aa54af8915" /> <img width="930" height="1080" alt="image" src="https://github.com/user-attachments/assets/07677474-0ef3-4708-8eba-a64a68eac61c" /> <img width="816" height="1080" alt="image" src="https://github.com/user-attachments/assets/23efa84d-c2e4-474b-a85f-d12fadc62b56" /> Fixes: #68 #102 #681 #694 #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> The Pisan cats have helped me implement this
This commit is contained in:
31 files changed
+2493
-1328
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add setting to show icons of the rooms in the Rooms sidebar
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add Resize the sidepanels and the thread height of the original object using hoverable tools.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add toggle to allow one to not join a call in a room by just clicking it in the sidebar.
|
||||
@@ -107,8 +107,8 @@ export const NavItem = recipe({
|
||||
|
||||
export type RoomSelectorVariants = RecipeVariants<typeof NavItem>;
|
||||
export const NavItemContent = style({
|
||||
paddingLeft: config.space.S200,
|
||||
paddingRight: config.space.S300,
|
||||
paddingLeft: config.space.S300,
|
||||
paddingRight: config.space.S200,
|
||||
height: 'inherit',
|
||||
minWidth: 0,
|
||||
flexGrow: 1,
|
||||
|
||||
@@ -6,6 +6,9 @@ import { DefaultReset, color, config, toRem } from 'folds';
|
||||
export const PageNav = recipe({
|
||||
variants: {
|
||||
size: {
|
||||
'100%': {
|
||||
width: '100%',
|
||||
},
|
||||
'400': {
|
||||
width: toRem(256),
|
||||
},
|
||||
@@ -15,7 +18,7 @@ export const PageNav = recipe({
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
size: '400',
|
||||
size: '100%',
|
||||
},
|
||||
});
|
||||
export type PageNavVariants = RecipeVariants<typeof PageNav>;
|
||||
|
||||
@@ -1,26 +1,48 @@
|
||||
import { as, Chip, Icon, Icons, Text } from 'folds';
|
||||
import { as, Chip, Icon, IconButton, Icons, Text } from 'folds';
|
||||
import classNames from 'classnames';
|
||||
import * as css from './styles.css';
|
||||
|
||||
export const RoomNavCategoryButton = as<'button', { closed?: boolean }>(
|
||||
({ className, closed, children, ...props }, ref) => (
|
||||
<Chip
|
||||
className={classNames(css.CategoryButton, className)}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
after={
|
||||
({ className, closed, children, ...props }, ref) => {
|
||||
if (children)
|
||||
return (
|
||||
<Chip
|
||||
className={classNames(css.CategoryButton, className)}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
before={
|
||||
<Icon
|
||||
className={css.CategoryButtonIcon}
|
||||
size="50"
|
||||
src={closed ? Icons.ChevronRight : Icons.ChevronBottom}
|
||||
/>
|
||||
}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
{children && (
|
||||
<Text size="B400" priority="300" truncate>
|
||||
{children}
|
||||
</Text>
|
||||
)}
|
||||
</Chip>
|
||||
);
|
||||
return (
|
||||
<IconButton
|
||||
className={classNames(css.CategoryButton, className)}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
{...props}
|
||||
style={{ padding: '0' }}
|
||||
ref={ref}
|
||||
>
|
||||
<Icon
|
||||
className={css.CategoryButtonIcon}
|
||||
size="50"
|
||||
style={{ padding: '0' }}
|
||||
src={closed ? Icons.ChevronRight : Icons.ChevronBottom}
|
||||
/>
|
||||
}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
<Text size="B400" priority="300" truncate>
|
||||
{children}
|
||||
</Text>
|
||||
</Chip>
|
||||
)
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -73,6 +73,7 @@ import { livekitSupport } from '$hooks/useLivekitSupport';
|
||||
import { Presence, useUserPresence } from '$hooks/useUserPresence';
|
||||
import { AvatarPresence, PresenceBadge } from '$components/presence';
|
||||
import { RoomNavUser } from './RoomNavUser';
|
||||
import { SidebarUnreadBadge } from '$components/sidebar';
|
||||
|
||||
/**
|
||||
* Reactively checks whether a room has unread messages.
|
||||
@@ -252,6 +253,9 @@ const RoomNavItemMenu = forwardRef<HTMLDivElement, RoomNavItemMenuProps>(
|
||||
}
|
||||
);
|
||||
|
||||
export const hideTextStyling = (isHidden: boolean | undefined) =>
|
||||
isHidden ? { width: '100%', height: '100%', padding: '0', paddingTop: '0px' } : {};
|
||||
|
||||
type RoomNavItemProps = {
|
||||
room: Room;
|
||||
selected: boolean;
|
||||
@@ -260,6 +264,8 @@ type RoomNavItemProps = {
|
||||
showAvatar?: boolean;
|
||||
direct?: boolean;
|
||||
customDMCards?: boolean;
|
||||
hideText?: boolean;
|
||||
joinCallOnSingleClick?: boolean;
|
||||
};
|
||||
|
||||
export function RoomNavItem({
|
||||
@@ -270,6 +276,8 @@ export function RoomNavItem({
|
||||
customDMCards,
|
||||
notificationMode,
|
||||
linkPath,
|
||||
hideText,
|
||||
joinCallOnSingleClick,
|
||||
}: RoomNavItemProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
@@ -326,8 +334,8 @@ export function RoomNavItem({
|
||||
if (!livekitSupport(autoDiscoveryInfo) && callMembers.length === 0) return;
|
||||
if (callEmbed && !isActiveCall) return;
|
||||
|
||||
if (!isMobile) {
|
||||
if (!isActiveCall && !callEmbed) {
|
||||
if (!isMobile && !hideText) {
|
||||
if (!isActiveCall && !callEmbed && joinCallOnSingleClick) {
|
||||
startCall(
|
||||
room,
|
||||
new CallControlState(callPref.microphone, callPref.video, callPref.sound)
|
||||
@@ -374,205 +382,256 @@ export function RoomNavItem({
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
|
||||
return (
|
||||
<Box direction="Column" grow="Yes">
|
||||
<NavItem
|
||||
variant="Background"
|
||||
radii="400"
|
||||
highlight={shouldShowUnreadIndicator}
|
||||
aria-selected={selected}
|
||||
data-hover={!!menuAnchor}
|
||||
onContextMenu={handleContextMenu}
|
||||
{...hoverProps}
|
||||
{...focusWithinProps}
|
||||
<>
|
||||
<Box
|
||||
direction="Column"
|
||||
grow="Yes"
|
||||
style={{ ...hideTextStyling(hideText), marginTop: hideText ? toRem(5) : '0' }}
|
||||
>
|
||||
<NavButton onClick={handleNavItemClick} aria-label={ariaLabel}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<AvatarPresence
|
||||
badge={
|
||||
presence &&
|
||||
presence.presence !== Presence.Offline && (
|
||||
<PresenceBadge presence={presence.presence} size="200" />
|
||||
)
|
||||
}
|
||||
<NavItem
|
||||
variant="Background"
|
||||
radii="400"
|
||||
highlight={shouldShowUnreadIndicator}
|
||||
aria-selected={selected}
|
||||
data-hover={!!menuAnchor}
|
||||
onContextMenu={handleContextMenu}
|
||||
{...hoverProps}
|
||||
{...focusWithinProps}
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
<TooltipProvider
|
||||
position="Right"
|
||||
offset={4}
|
||||
tooltip={
|
||||
hideText && (
|
||||
<Tooltip>
|
||||
<Text>{roomName}</Text>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<NavButton
|
||||
onClick={handleNavItemClick}
|
||||
aria-label={ariaLabel}
|
||||
ref={triggerRef}
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
<Avatar size="200" radii="400">
|
||||
{showAvatar ? (
|
||||
<RoomAvatar
|
||||
roomId={room.roomId}
|
||||
src={
|
||||
((!direct || customDMCards) &&
|
||||
getRoomAvatarUrl(mx, room, 96, useAuthentication)) ||
|
||||
getDirectRoomAvatarUrl(mx, room, 96, useAuthentication)
|
||||
<NavItemContent style={hideTextStyling(hideText)}>
|
||||
<Box as="span" grow="Yes" alignItems="Center" style={hideTextStyling(hideText)}>
|
||||
<AvatarPresence
|
||||
badge={
|
||||
presence &&
|
||||
presence.presence !== Presence.Offline && (
|
||||
<PresenceBadge
|
||||
presence={presence.presence}
|
||||
size={hideText ? '300' : '200'}
|
||||
/>
|
||||
)
|
||||
}
|
||||
uniformIcons
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<Text as="span" size="H6">
|
||||
{nameInitials(roomName)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon
|
||||
style={{
|
||||
opacity:
|
||||
unread || hasRoomUnread || isActiveCall
|
||||
? config.opacity.P500
|
||||
: config.opacity.P300,
|
||||
}}
|
||||
filled={selected || isActiveCall}
|
||||
size="100"
|
||||
joinRule={room.getJoinRule()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
</AvatarPresence>
|
||||
<Box as="span" grow="Yes" direction="Column">
|
||||
<Text
|
||||
priority={unread || hasRoomUnread || isActiveCall ? '500' : '400'}
|
||||
as="span"
|
||||
size="Inherit"
|
||||
truncate
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
<Avatar
|
||||
size={hideText ? undefined : '200'}
|
||||
radii="400"
|
||||
style={hideTextStyling(hideText)}
|
||||
>
|
||||
{showAvatar ? (
|
||||
<RoomAvatar
|
||||
roomId={room.roomId}
|
||||
src={
|
||||
((!direct || customDMCards) &&
|
||||
getRoomAvatarUrl(mx, room, 96, useAuthentication)) ||
|
||||
getDirectRoomAvatarUrl(mx, room, 96, useAuthentication)
|
||||
}
|
||||
uniformIcons
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<Text as="span" size="H6">
|
||||
{nameInitials(roomName)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon
|
||||
style={{
|
||||
opacity:
|
||||
unread || hasRoomUnread || isActiveCall
|
||||
? config.opacity.P500
|
||||
: config.opacity.P300,
|
||||
}}
|
||||
filled={selected || isActiveCall}
|
||||
size="100"
|
||||
joinRule={room.getJoinRule()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
</AvatarPresence>
|
||||
{unread && hideText && (
|
||||
<SidebarUnreadBadge
|
||||
highlight={unread.highlight > 0}
|
||||
count={unread.highlight > 0 ? unread.highlight : unread.total}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!hideText && (
|
||||
<>
|
||||
<Box as="span" grow="Yes" direction="Column">
|
||||
<Text
|
||||
priority={unread || hasRoomUnread || isActiveCall ? '500' : '400'}
|
||||
as="span"
|
||||
size="Inherit"
|
||||
truncate
|
||||
>
|
||||
{roomName}
|
||||
</Text>
|
||||
{roomTopic && (
|
||||
<Text
|
||||
truncate
|
||||
size="T200"
|
||||
priority="300"
|
||||
style={{
|
||||
opacity: config.opacity.P300,
|
||||
marginTop: '-2px',
|
||||
}}
|
||||
>
|
||||
{roomTopic}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
{!optionsVisible && !unread && !selected && typingMember.length > 0 && (
|
||||
<Badge size="300" variant="Secondary" fill="Soft" radii="Pill" outlined>
|
||||
<TypingIndicator size="300" disableAnimation />
|
||||
</Badge>
|
||||
)}
|
||||
{!optionsVisible && shouldShowUnreadIndicator && (
|
||||
<UnreadBadgeCenter>
|
||||
<UnreadBadge
|
||||
highlight={!!unread && unread.highlight > 0}
|
||||
count={unreadCount}
|
||||
dm={direct}
|
||||
/>
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
<Icon
|
||||
size="50"
|
||||
src={getRoomNotificationModeIcon(notificationMode)}
|
||||
aria-label={notificationMode}
|
||||
/>
|
||||
)}
|
||||
{(room.isCallRoom() || direct) &&
|
||||
callMembers.length > 0 &&
|
||||
!optionsVisible && (
|
||||
<Badge variant="Critical" fill="Solid" size="400">
|
||||
<Box alignItems="Center" gap="100">
|
||||
<Icon size="50" src={Icons.Phone} color="Inherit" />
|
||||
<Text as="span" size="L400" truncate>
|
||||
{direct ? 'Calling' : `${callMembers.length} Live`}
|
||||
</Text>
|
||||
</Box>
|
||||
</Badge>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
{optionsVisible && !hideText && (
|
||||
<NavItemOptions>
|
||||
{(room.isCallRoom() || (direct && callMembers.length > 0)) && (
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>{isChatOpen ? 'Hide Chat' : 'Show Chat'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{roomName}
|
||||
</Text>
|
||||
{roomTopic && (
|
||||
<Text
|
||||
truncate
|
||||
size="T200"
|
||||
priority="300"
|
||||
style={{
|
||||
opacity: config.opacity.P300,
|
||||
marginTop: '-2px',
|
||||
{(triggerRef) => (
|
||||
<IconButton
|
||||
ref={triggerRef}
|
||||
data-testid="chat-button"
|
||||
onClick={handleChatButtonClick}
|
||||
aria-pressed={isChatOpen && selected}
|
||||
aria-label="Open Chat"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.Message} filled={isChatOpen} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
)}
|
||||
<PopOut
|
||||
id={`menu-${room.roomId}`}
|
||||
aria-expanded={!!menuAnchor}
|
||||
anchor={menuAnchor}
|
||||
offset={menuAnchor?.width === 0 ? 0 : undefined}
|
||||
alignOffset={menuAnchor?.width === 0 ? 0 : -5}
|
||||
position="Bottom"
|
||||
align={menuAnchor?.width === 0 ? 'Start' : 'End'}
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
returnFocusOnDeactivate: false,
|
||||
onDeactivate: () => setMenuAnchor(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
{roomTopic}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
{!optionsVisible && !unread && !selected && typingMember.length > 0 && (
|
||||
<Badge size="300" variant="Secondary" fill="Soft" radii="Pill" outlined>
|
||||
<TypingIndicator size="300" disableAnimation />
|
||||
</Badge>
|
||||
)}
|
||||
{!optionsVisible && shouldShowUnreadIndicator && (
|
||||
<UnreadBadgeCenter>
|
||||
<UnreadBadge
|
||||
highlight={!!unread && unread.highlight > 0}
|
||||
count={unreadCount}
|
||||
dm={direct}
|
||||
/>
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
<Icon
|
||||
size="50"
|
||||
src={getRoomNotificationModeIcon(notificationMode)}
|
||||
aria-label={notificationMode}
|
||||
/>
|
||||
)}
|
||||
{(room.isCallRoom() || direct) && callMembers.length > 0 && !optionsVisible && (
|
||||
<Badge variant="Critical" fill="Solid" size="400">
|
||||
<Box alignItems="Center" gap="100">
|
||||
<Icon size="50" src={Icons.Phone} color="Inherit" />
|
||||
<Text as="span" size="L400" truncate>
|
||||
{direct ? 'Calling' : `${callMembers.length} Live`}
|
||||
</Text>
|
||||
</Box>
|
||||
</Badge>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
{optionsVisible && (
|
||||
<NavItemOptions>
|
||||
{(room.isCallRoom() || (direct && callMembers.length > 0)) && (
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>{isChatOpen ? 'Hide Chat' : 'Show Chat'}</Text>
|
||||
</Tooltip>
|
||||
<RoomNavItemMenu
|
||||
room={room}
|
||||
requestClose={() => setMenuAnchor(undefined)}
|
||||
notificationMode={notificationMode}
|
||||
/>
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
{!hideText && (
|
||||
<IconButton
|
||||
ref={triggerRef}
|
||||
data-testid="chat-button"
|
||||
onClick={handleChatButtonClick}
|
||||
aria-pressed={isChatOpen && selected}
|
||||
aria-label="Open Chat"
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
aria-controls={`menu-${room.roomId}`}
|
||||
aria-label="More Options"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.Message} filled={isChatOpen} />
|
||||
<Icon size="50" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
)}
|
||||
<PopOut
|
||||
id={`menu-${room.roomId}`}
|
||||
aria-expanded={!!menuAnchor}
|
||||
anchor={menuAnchor}
|
||||
offset={menuAnchor?.width === 0 ? 0 : undefined}
|
||||
alignOffset={menuAnchor?.width === 0 ? 0 : -5}
|
||||
position="Bottom"
|
||||
align={menuAnchor?.width === 0 ? 'Start' : 'End'}
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
returnFocusOnDeactivate: false,
|
||||
onDeactivate: () => setMenuAnchor(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<RoomNavItemMenu
|
||||
room={room}
|
||||
requestClose={() => setMenuAnchor(undefined)}
|
||||
notificationMode={notificationMode}
|
||||
/>
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
aria-controls={`menu-${room.roomId}`}
|
||||
aria-label="More Options"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
</PopOut>
|
||||
</NavItemOptions>
|
||||
)}
|
||||
</NavItem>
|
||||
|
||||
</PopOut>
|
||||
</NavItemOptions>
|
||||
)}
|
||||
</NavItem>
|
||||
</Box>
|
||||
{room.isCallRoom() && (
|
||||
<Box direction="Column" style={{ paddingLeft: config.space.S200 }}>
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{ paddingLeft: hideText ? config.space.S0 : config.space.S200 }}
|
||||
>
|
||||
{callMembers.map((callMembership) => (
|
||||
<RoomNavUser
|
||||
key={callMembership.membershipID}
|
||||
room={room}
|
||||
callMembership={callMembership}
|
||||
hideText={hideText}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -16,9 +16,10 @@ import { useCallEmbed } from '$hooks/useCallEmbed';
|
||||
type RoomNavUserProps = {
|
||||
room: Room;
|
||||
callMembership: CallMembership;
|
||||
hideText?: boolean;
|
||||
};
|
||||
|
||||
export function RoomNavUser({ room, callMembership }: RoomNavUserProps) {
|
||||
export function RoomNavUser({ room, callMembership, hideText }: RoomNavUserProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const openProfile = useOpenUserRoomProfile();
|
||||
@@ -45,9 +46,9 @@ export function RoomNavUser({ room, callMembership }: RoomNavUserProps) {
|
||||
return (
|
||||
<NavItem variant="Background" radii="400">
|
||||
<NavButton onClick={handleNavUserClick} aria-label={ariaLabel}>
|
||||
<NavItemContent as="div">
|
||||
<NavItemContent as="div" style={hideText ? { padding: '0' } : {}}>
|
||||
<Box direction="Column" grow="Yes" gap="200" justifyContent="Stretch">
|
||||
<Box alignItems="Center" gap="200">
|
||||
<Box alignItems="Center" gap="200" justifyContent={hideText ? 'Center' : 'Start'}>
|
||||
<Avatar size="200">
|
||||
<UserAvatar
|
||||
userId={userId}
|
||||
@@ -56,9 +57,11 @@ export function RoomNavUser({ room, callMembership }: RoomNavUserProps) {
|
||||
renderFallback={() => <Icon size="50" src={Icons.User} filled />}
|
||||
/>
|
||||
</Avatar>
|
||||
<Text as="span" size="B400" priority="300" truncate>
|
||||
{name}
|
||||
</Text>
|
||||
{!hideText && (
|
||||
<Text as="span" size="B400" priority="300" truncate>
|
||||
{name}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
|
||||
@@ -5,6 +5,11 @@ import { Page, PageHeader } from '../../components/page';
|
||||
import { callChatAtom } from '../../state/callEmbed';
|
||||
import { RoomView } from './RoomView';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export function CallChatView() {
|
||||
const { eventId } = useParams();
|
||||
@@ -13,44 +18,61 @@ export function CallChatView() {
|
||||
|
||||
const handleClose = () => setChat(false);
|
||||
|
||||
const [vcmsgSidebarWidth, setVcmsgSidebarWidth] = useSetting(settingsAtom, 'vcmsgSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(vcmsgSidebarWidth);
|
||||
useEffect(() => {
|
||||
setCurWidth(vcmsgSidebarWidth);
|
||||
}, [vcmsgSidebarWidth]);
|
||||
return (
|
||||
<Page
|
||||
style={{
|
||||
width: screenSize === ScreenSize.Desktop ? toRem(399) : '100%',
|
||||
flexShrink: 0,
|
||||
flexGrow: 0,
|
||||
}}
|
||||
>
|
||||
<PageHeader>
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Box grow="Yes">
|
||||
<Text size="H5" truncate>
|
||||
Chat
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No" alignItems="Center">
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>Close</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton ref={triggerRef} variant="Surface" onClick={handleClose}>
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
<>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={vcmsgSidebarWidth}
|
||||
setSidebarWidth={setVcmsgSidebarWidth}
|
||||
minValue={300}
|
||||
maxValue={1000}
|
||||
isReversed
|
||||
/>
|
||||
)}
|
||||
<Page
|
||||
style={{
|
||||
width: screenSize === ScreenSize.Desktop ? toRem(curWidth) : '100%',
|
||||
flexShrink: 0,
|
||||
flexGrow: 0,
|
||||
}}
|
||||
>
|
||||
<PageHeader>
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Box grow="Yes">
|
||||
<Text size="H5" truncate>
|
||||
Chat
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No" alignItems="Center">
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>Close</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton ref={triggerRef} variant="Surface" onClick={handleClose}>
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<RoomView eventId={eventId} />
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<RoomView eventId={eventId} />
|
||||
</Box>
|
||||
</Page>
|
||||
</Page>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ export const MembersDrawer = style({
|
||||
|
||||
export const MembersDrawerHeader = style({
|
||||
flexShrink: 0,
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S300}`,
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S200}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ChangeEventHandler, MouseEventHandler } from 'react';
|
||||
import { useCallback, useMemo, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import type { RectCords } from 'folds';
|
||||
import {
|
||||
Avatar,
|
||||
@@ -56,21 +56,27 @@ import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useSableCosmetics } from '$hooks/useSableCosmetics';
|
||||
import { formatCompactNumber } from '$utils/formatCompactNumber';
|
||||
import * as css from './MembersDrawer.css';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { useScreenSizeContext, ScreenSize } from '$hooks/useScreenSize';
|
||||
|
||||
type MemberDrawerHeaderProps = {
|
||||
room: Room;
|
||||
hideText?: boolean;
|
||||
};
|
||||
function MemberDrawerHeader({ room }: MemberDrawerHeaderProps) {
|
||||
function MemberDrawerHeader({ room, hideText }: MemberDrawerHeaderProps) {
|
||||
const setPeopleDrawer = useSetSetting(settingsAtom, 'isPeopleDrawer');
|
||||
|
||||
return (
|
||||
<Header className={css.MembersDrawerHeader} variant="Background" size="600">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text title={`${room.getJoinedMemberCount()} Members`} size="H5" truncate>
|
||||
{`${formatCompactNumber(room.getJoinedMemberCount())} Members`}
|
||||
</Text>
|
||||
</Box>
|
||||
{!hideText && (
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text title={`${room.getJoinedMemberCount()} Members`} size="H5" truncate>
|
||||
{`${formatCompactNumber(room.getJoinedMemberCount())} Members`}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
<Box shrink="No" alignItems="Center">
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
@@ -106,6 +112,7 @@ type MemberItemProps = {
|
||||
onClick: MouseEventHandler<HTMLButtonElement>;
|
||||
pressed?: boolean;
|
||||
typing?: boolean;
|
||||
hideText?: boolean;
|
||||
};
|
||||
function MemberItem({
|
||||
mx,
|
||||
@@ -115,6 +122,7 @@ function MemberItem({
|
||||
onClick,
|
||||
pressed,
|
||||
typing,
|
||||
hideText,
|
||||
}: MemberItemProps) {
|
||||
const nicknames = useAtomValue(nicknamesAtom);
|
||||
const name =
|
||||
@@ -130,7 +138,47 @@ function MemberItem({
|
||||
|
||||
const presence = useUserPresence(member.userId);
|
||||
const { color, font } = useSableCosmetics(member.userId, room);
|
||||
const MemberAvatar = (
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: toRem(40),
|
||||
height: toRem(40),
|
||||
transform: 'scale(0.85)',
|
||||
transformOrigin: 'center',
|
||||
}}
|
||||
>
|
||||
<AvatarPresence
|
||||
badge={
|
||||
presence && presence.lastActiveTs !== 0 ? (
|
||||
<PresenceBadge presence={presence.presence} size="200" />
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
<Avatar size="300" radii="400">
|
||||
<UserAvatar
|
||||
userId={member.userId}
|
||||
src={avatarUrl ?? undefined}
|
||||
alt={name}
|
||||
renderFallback={() => <Icon size="100" src={Icons.User} filled />}
|
||||
/>
|
||||
</Avatar>
|
||||
</AvatarPresence>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (hideText)
|
||||
return (
|
||||
<IconButton
|
||||
onClick={onClick}
|
||||
size="300"
|
||||
aria-pressed={pressed}
|
||||
data-user-id={member.userId}
|
||||
style={{ padding: '0' }}
|
||||
>
|
||||
{MemberAvatar}
|
||||
</IconButton>
|
||||
);
|
||||
return (
|
||||
<MenuItem
|
||||
style={{ padding: `0 ${config.space.S200}` }}
|
||||
@@ -139,34 +187,7 @@ function MemberItem({
|
||||
variant="Background"
|
||||
radii="400"
|
||||
onClick={onClick}
|
||||
before={
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: toRem(40),
|
||||
height: toRem(40),
|
||||
transform: 'scale(0.85)',
|
||||
transformOrigin: 'center',
|
||||
}}
|
||||
>
|
||||
<AvatarPresence
|
||||
badge={
|
||||
presence && presence.lastActiveTs !== 0 ? (
|
||||
<PresenceBadge presence={presence.presence} size="200" />
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
<Avatar size="300" radii="400">
|
||||
<UserAvatar
|
||||
userId={member.userId}
|
||||
src={avatarUrl ?? undefined}
|
||||
alt={name}
|
||||
renderFallback={() => <Icon size="100" src={Icons.User} filled />}
|
||||
/>
|
||||
</Avatar>
|
||||
</AvatarPresence>
|
||||
</div>
|
||||
}
|
||||
before={MemberAvatar}
|
||||
after={
|
||||
typing && (
|
||||
<Badge size="300" variant="Secondary" fill="Soft" radii="Pill" outlined>
|
||||
@@ -275,6 +296,8 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) {
|
||||
);
|
||||
|
||||
const handleMemberClick: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
// oxlint-disable-next-line no-console
|
||||
console.log(evt);
|
||||
const btn = evt.currentTarget as HTMLButtonElement;
|
||||
const userId = btn.getAttribute('data-user-id');
|
||||
if (!userId) return;
|
||||
@@ -286,200 +309,237 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) {
|
||||
openUserRoomProfile(room.roomId, space?.roomId, userId, cords, 'Left');
|
||||
};
|
||||
|
||||
const [memberSidebarWidth, setMemberSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'memberSidebarWidth'
|
||||
);
|
||||
const [curWidth, setCurWidth] = useState(memberSidebarWidth);
|
||||
useEffect(() => {
|
||||
setCurWidth(memberSidebarWidth);
|
||||
}, [memberSidebarWidth]);
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
return (
|
||||
<Box
|
||||
className={classNames(css.MembersDrawer, ContainerColor({ variant: 'Background' }))}
|
||||
shrink="No"
|
||||
direction="Column"
|
||||
>
|
||||
<MemberDrawerHeader room={room} />
|
||||
<Box className={css.MemberDrawerContentBase} grow="Yes">
|
||||
<Scroll ref={scrollRef} variant="Background" size="300" visibility="Hover" hideTrack>
|
||||
<Box className={css.MemberDrawerContent} direction="Column" gap="200">
|
||||
<Box ref={scrollTopAnchorRef} className={css.DrawerGroup} direction="Column" gap="200">
|
||||
<Box alignItems="Center" justifyContent="SpaceBetween" gap="200">
|
||||
<UseStateProvider initial={undefined}>
|
||||
{(anchor: RectCords | undefined, setAnchor) => (
|
||||
<PopOut
|
||||
anchor={anchor}
|
||||
position="Bottom"
|
||||
align="Start"
|
||||
offset={4}
|
||||
content={
|
||||
<MembershipFilterMenu
|
||||
selected={membershipFilterIndex}
|
||||
onSelect={setMembershipFilterIndex}
|
||||
requestClose={() => setAnchor(undefined)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Chip
|
||||
onClick={
|
||||
((evt) =>
|
||||
setAnchor(
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
)) as MouseEventHandler<HTMLButtonElement>
|
||||
<>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={memberSidebarWidth}
|
||||
setSidebarWidth={setMemberSidebarWidth}
|
||||
instep={64}
|
||||
outstep={176}
|
||||
minValue={50}
|
||||
maxValue={350}
|
||||
isReversed
|
||||
/>
|
||||
)}
|
||||
<Box
|
||||
className={classNames(css.MembersDrawer, ContainerColor({ variant: 'Background' }))}
|
||||
shrink="No"
|
||||
direction="Column"
|
||||
style={{ width: !mobileOrTablet() ? toRem(curWidth) : '100%' }}
|
||||
>
|
||||
<MemberDrawerHeader room={room} hideText={hideText} />
|
||||
<Box className={css.MemberDrawerContentBase} grow="Yes">
|
||||
<Scroll ref={scrollRef} variant="Background" size="300" visibility="Hover" hideTrack>
|
||||
<Box className={css.MemberDrawerContent} direction="Column" gap="200">
|
||||
{!hideText && (
|
||||
<>
|
||||
<Box
|
||||
ref={scrollTopAnchorRef}
|
||||
className={css.DrawerGroup}
|
||||
direction="Column"
|
||||
gap="200"
|
||||
>
|
||||
<Box alignItems="Center" justifyContent="SpaceBetween" gap="200">
|
||||
<UseStateProvider initial={undefined}>
|
||||
{(anchor: RectCords | undefined, setAnchor) => (
|
||||
<PopOut
|
||||
anchor={anchor}
|
||||
position="Bottom"
|
||||
align="Start"
|
||||
offset={4}
|
||||
content={
|
||||
<MembershipFilterMenu
|
||||
selected={membershipFilterIndex}
|
||||
onSelect={setMembershipFilterIndex}
|
||||
requestClose={() => setAnchor(undefined)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Chip
|
||||
onClick={
|
||||
((evt) =>
|
||||
setAnchor(
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
)) as MouseEventHandler<HTMLButtonElement>
|
||||
}
|
||||
variant="Background"
|
||||
size="400"
|
||||
radii="300"
|
||||
before={<Icon src={Icons.Filter} size="50" />}
|
||||
>
|
||||
<Text size="T200">{membershipFilter.name}</Text>
|
||||
</Chip>
|
||||
</PopOut>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
<UseStateProvider initial={undefined}>
|
||||
{(anchor: RectCords | undefined, setAnchor) => (
|
||||
<PopOut
|
||||
anchor={anchor}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
content={
|
||||
<MemberSortMenu
|
||||
selected={sortFilterIndex}
|
||||
onSelect={setSortFilterIndex}
|
||||
requestClose={() => setAnchor(undefined)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Chip
|
||||
onClick={
|
||||
((evt) =>
|
||||
setAnchor(
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
)) as MouseEventHandler<HTMLButtonElement>
|
||||
}
|
||||
variant="Background"
|
||||
size="400"
|
||||
radii="300"
|
||||
after={<Icon src={Icons.Sort} size="50" />}
|
||||
>
|
||||
<Text size="T200">{memberSort.name}</Text>
|
||||
</Chip>
|
||||
</PopOut>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
</Box>
|
||||
<Box direction="Column" gap="100">
|
||||
<Input
|
||||
ref={searchInputRef}
|
||||
onChange={handleSearchChange}
|
||||
style={{ paddingRight: config.space.S200 }}
|
||||
placeholder="Type name..."
|
||||
variant="Surface"
|
||||
size="400"
|
||||
radii="400"
|
||||
before={<Icon size="50" src={Icons.Search} />}
|
||||
after={
|
||||
result && (
|
||||
<Chip
|
||||
variant={result.items.length > 0 ? 'Success' : 'Critical'}
|
||||
size="400"
|
||||
radii="Pill"
|
||||
aria-pressed
|
||||
onClick={() => {
|
||||
if (searchInputRef.current) {
|
||||
searchInputRef.current.value = '';
|
||||
searchInputRef.current.focus();
|
||||
}
|
||||
resetSearch();
|
||||
}}
|
||||
after={<Icon size="50" src={Icons.Cross} />}
|
||||
>
|
||||
<Text size="B300">{`${result.items.length || 'No'} ${
|
||||
result.items.length === 1 ? 'Result' : 'Results'
|
||||
}`}</Text>
|
||||
</Chip>
|
||||
)
|
||||
}
|
||||
variant="Background"
|
||||
size="400"
|
||||
radii="300"
|
||||
before={<Icon src={Icons.Filter} size="50" />}
|
||||
>
|
||||
<Text size="T200">{membershipFilter.name}</Text>
|
||||
</Chip>
|
||||
</PopOut>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
<UseStateProvider initial={undefined}>
|
||||
{(anchor: RectCords | undefined, setAnchor) => (
|
||||
<PopOut
|
||||
anchor={anchor}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
content={
|
||||
<MemberSortMenu
|
||||
selected={sortFilterIndex}
|
||||
onSelect={setSortFilterIndex}
|
||||
requestClose={() => setAnchor(undefined)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
<ScrollTopContainer scrollRef={scrollRef} anchorRef={scrollTopAnchorRef}>
|
||||
<IconButton
|
||||
onClick={() => virtualizer.scrollToOffset(0)}
|
||||
variant="Surface"
|
||||
radii="Pill"
|
||||
outlined
|
||||
size="300"
|
||||
aria-label="Scroll to Top"
|
||||
>
|
||||
<Chip
|
||||
onClick={
|
||||
((evt) =>
|
||||
setAnchor(
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
)) as MouseEventHandler<HTMLButtonElement>
|
||||
}
|
||||
variant="Background"
|
||||
size="400"
|
||||
radii="300"
|
||||
after={<Icon src={Icons.Sort} size="50" />}
|
||||
>
|
||||
<Text size="T200">{memberSort.name}</Text>
|
||||
</Chip>
|
||||
</PopOut>
|
||||
<Icon src={Icons.ChevronTop} size="300" />
|
||||
</IconButton>
|
||||
</ScrollTopContainer>
|
||||
|
||||
{!fetchingMembers && !result && processMembers.length === 0 && (
|
||||
<Text style={{ padding: config.space.S300 }} align="Center">
|
||||
{`No "${membershipFilter.name}" Members`}
|
||||
</Text>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
</Box>
|
||||
<Box direction="Column" gap="100">
|
||||
<Input
|
||||
ref={searchInputRef}
|
||||
onChange={handleSearchChange}
|
||||
style={{ paddingRight: config.space.S200 }}
|
||||
placeholder="Type name..."
|
||||
variant="Surface"
|
||||
size="400"
|
||||
radii="400"
|
||||
before={<Icon size="50" src={Icons.Search} />}
|
||||
after={
|
||||
result && (
|
||||
<Chip
|
||||
variant={result.items.length > 0 ? 'Success' : 'Critical'}
|
||||
size="400"
|
||||
radii="Pill"
|
||||
aria-pressed
|
||||
onClick={() => {
|
||||
if (searchInputRef.current) {
|
||||
searchInputRef.current.value = '';
|
||||
searchInputRef.current.focus();
|
||||
}
|
||||
resetSearch();
|
||||
}}
|
||||
after={<Icon size="50" src={Icons.Cross} />}
|
||||
>
|
||||
<Text size="B300">{`${result.items.length || 'No'} ${
|
||||
result.items.length === 1 ? 'Result' : 'Results'
|
||||
}`}</Text>
|
||||
</Chip>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
<Box className={css.MembersGroup} direction="Column" gap="100">
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
height: virtualizer.getTotalSize(),
|
||||
}}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const tagOrMember = PLTagOrRoomMember[vItem.index];
|
||||
if (!tagOrMember) return null;
|
||||
if (!('userId' in tagOrMember)) {
|
||||
return (
|
||||
<Text
|
||||
style={{
|
||||
transform: `translateY(${vItem.start}px)`,
|
||||
}}
|
||||
data-index={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
key={`${room.roomId}-${vItem.index}`}
|
||||
className={classNames(css.MembersGroupLabel, css.DrawerVirtualItem)}
|
||||
size="L400"
|
||||
truncate={hideText}
|
||||
>
|
||||
{tagOrMember.name}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
<ScrollTopContainer scrollRef={scrollRef} anchorRef={scrollTopAnchorRef}>
|
||||
<IconButton
|
||||
onClick={() => virtualizer.scrollToOffset(0)}
|
||||
variant="Surface"
|
||||
radii="Pill"
|
||||
outlined
|
||||
size="300"
|
||||
aria-label="Scroll to Top"
|
||||
>
|
||||
<Icon src={Icons.ChevronTop} size="300" />
|
||||
</IconButton>
|
||||
</ScrollTopContainer>
|
||||
|
||||
{!fetchingMembers && !result && processMembers.length === 0 && (
|
||||
<Text style={{ padding: config.space.S300 }} align="Center">
|
||||
{`No "${membershipFilter.name}" Members`}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<Box className={css.MembersGroup} direction="Column" gap="100">
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
height: virtualizer.getTotalSize(),
|
||||
}}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const tagOrMember = PLTagOrRoomMember[vItem.index];
|
||||
if (!tagOrMember) return null;
|
||||
if (!('userId' in tagOrMember)) {
|
||||
return (
|
||||
<Text
|
||||
<div
|
||||
style={{
|
||||
transform: `translateY(${vItem.start}px)`,
|
||||
}}
|
||||
className={css.DrawerVirtualItem}
|
||||
data-index={vItem.index}
|
||||
key={`${room.roomId}-${tagOrMember.userId}`}
|
||||
ref={virtualizer.measureElement}
|
||||
key={`${room.roomId}-${vItem.index}`}
|
||||
className={classNames(css.MembersGroupLabel, css.DrawerVirtualItem)}
|
||||
size="L400"
|
||||
>
|
||||
{tagOrMember.name}
|
||||
</Text>
|
||||
<MemberItem
|
||||
mx={mx}
|
||||
useAuthentication={useAuthentication}
|
||||
room={room}
|
||||
member={tagOrMember}
|
||||
onClick={handleMemberClick}
|
||||
pressed={openProfileUserId === tagOrMember.userId}
|
||||
typing={typingMembers.some(
|
||||
(receipt) => receipt.userId === tagOrMember.userId
|
||||
)}
|
||||
hideText={hideText}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
transform: `translateY(${vItem.start}px)`,
|
||||
}}
|
||||
className={css.DrawerVirtualItem}
|
||||
data-index={vItem.index}
|
||||
key={`${room.roomId}-${tagOrMember.userId}`}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<MemberItem
|
||||
mx={mx}
|
||||
useAuthentication={useAuthentication}
|
||||
room={room}
|
||||
member={tagOrMember}
|
||||
onClick={handleMemberClick}
|
||||
pressed={openProfileUserId === tagOrMember.userId}
|
||||
typing={typingMembers.some(
|
||||
(receipt) => receipt.userId === tagOrMember.userId
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Box>
|
||||
|
||||
{fetchingMembers && (
|
||||
<Box justifyContent="Center">
|
||||
<Spinner />
|
||||
})}
|
||||
</div>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Scroll>
|
||||
|
||||
{fetchingMembers && (
|
||||
<Box justifyContent="Center">
|
||||
<Spinner />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { Transforms } from 'slate';
|
||||
import { Box, Text, config, toRem } from 'folds';
|
||||
import { Box, Text, config } from 'folds';
|
||||
import { EventType } from '$types/matrix-sdk';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
@@ -141,14 +141,7 @@ export function RoomView({ eventId }: { eventId?: string }) {
|
||||
return (
|
||||
<BackRouteHandler>
|
||||
{(onBack) => (
|
||||
<Page
|
||||
ref={roomViewRef}
|
||||
style={
|
||||
room.isCallRoom() && screenSize === ScreenSize.Desktop
|
||||
? { maxWidth: toRem(399), minWidth: toRem(399) }
|
||||
: {}
|
||||
}
|
||||
>
|
||||
<Page ref={roomViewRef}>
|
||||
<SwipeableChatWrapper onOpenSidebar={onBack} onOpenMembers={handleOpenMembers}>
|
||||
<Box grow="Yes" direction="Column">
|
||||
{showCallView && (
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Avatar,
|
||||
config,
|
||||
Chip,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import type { EventTimelineSet, MatrixEvent, Room, Thread } from '$types/matrix-sdk';
|
||||
import { NotificationCountType, RoomEvent, ThreadEvent } from '$types/matrix-sdk';
|
||||
@@ -52,6 +53,8 @@ import {
|
||||
import { UnreadBadge, UnreadBadgeCenter } from '$components/unread-badge';
|
||||
import { EncryptedContent } from './message';
|
||||
import * as css from './ThreadDrawer.css';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
|
||||
type ThreadPreviewProps = {
|
||||
room: Room;
|
||||
@@ -436,130 +439,151 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr
|
||||
setQuery(e.target.value);
|
||||
};
|
||||
|
||||
const [threadSidebarWidth, setThreadSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'threadSidebarWidth'
|
||||
);
|
||||
const [curWidth, setCurWidth] = useState(threadSidebarWidth);
|
||||
useEffect(() => {
|
||||
setCurWidth(threadSidebarWidth);
|
||||
}, [threadSidebarWidth]);
|
||||
return (
|
||||
<Box
|
||||
className={overlay ? css.ThreadDrawerOverlay : css.ThreadDrawer}
|
||||
direction="Column"
|
||||
shrink="No"
|
||||
>
|
||||
<Header className={css.ThreadDrawerHeader} variant="Background" size="600">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Icon size="200" src={Icons.Thread} />
|
||||
<Text size="H4" truncate>
|
||||
Threads
|
||||
</Text>
|
||||
</Box>
|
||||
<Box alignItems="Center" gap="200" shrink="No">
|
||||
<IconButton
|
||||
onClick={onClose}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
aria-label="Close threads"
|
||||
>
|
||||
<Icon size="200" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Header>
|
||||
|
||||
<Box
|
||||
direction="Column"
|
||||
gap="100"
|
||||
style={{ padding: `${config.space.S200} ${config.space.S300}` }}
|
||||
shrink="No"
|
||||
>
|
||||
<Input
|
||||
ref={searchRef}
|
||||
value={query}
|
||||
onChange={handleSearchChange}
|
||||
placeholder="Search threads..."
|
||||
variant="Surface"
|
||||
size="400"
|
||||
radii="400"
|
||||
before={<Icon size="50" src={Icons.Search} />}
|
||||
after={
|
||||
query ? (
|
||||
<IconButton
|
||||
size="300"
|
||||
radii="300"
|
||||
variant="SurfaceVariant"
|
||||
onClick={() => {
|
||||
setQuery('');
|
||||
searchRef.current?.focus();
|
||||
}}
|
||||
aria-label="Clear search"
|
||||
>
|
||||
<Icon size="50" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
) : undefined
|
||||
}
|
||||
<>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={threadSidebarWidth}
|
||||
setSidebarWidth={setThreadSidebarWidth}
|
||||
minValue={150}
|
||||
maxValue={600}
|
||||
isReversed
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
<Box
|
||||
className={overlay ? css.ThreadDrawerOverlay : css.ThreadDrawer}
|
||||
direction="Column"
|
||||
shrink="No"
|
||||
style={{ width: overlay ? '100%' : toRem(curWidth) }}
|
||||
>
|
||||
<Header className={css.ThreadDrawerHeader} variant="Background" size="600">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Icon size="200" src={Icons.Thread} />
|
||||
<Text size="H4" truncate>
|
||||
Threads
|
||||
</Text>
|
||||
</Box>
|
||||
<Box alignItems="Center" gap="200" shrink="No">
|
||||
<IconButton
|
||||
onClick={onClose}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
aria-label="Close threads"
|
||||
>
|
||||
<Icon size="200" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Header>
|
||||
|
||||
<Box className={css.ThreadDrawerContent} grow="Yes" direction="Column">
|
||||
<Scroll
|
||||
variant="Background"
|
||||
visibility="Hover"
|
||||
direction="Vertical"
|
||||
size="300"
|
||||
onScroll={handleThreadsScroll}
|
||||
style={{ flexGrow: 1 }}
|
||||
<Box
|
||||
direction="Column"
|
||||
gap="100"
|
||||
style={{ padding: `${config.space.S200} ${config.space.S300}` }}
|
||||
shrink="No"
|
||||
>
|
||||
{(() => {
|
||||
if (threads.length === 0 && loadingMore)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400, gap: config.space.S200 }}
|
||||
<Input
|
||||
ref={searchRef}
|
||||
value={query}
|
||||
onChange={handleSearchChange}
|
||||
placeholder="Search threads..."
|
||||
variant="Surface"
|
||||
size="400"
|
||||
radii="400"
|
||||
before={<Icon size="50" src={Icons.Search} />}
|
||||
after={
|
||||
query ? (
|
||||
<IconButton
|
||||
size="300"
|
||||
radii="300"
|
||||
variant="SurfaceVariant"
|
||||
onClick={() => {
|
||||
setQuery('');
|
||||
searchRef.current?.focus();
|
||||
}}
|
||||
aria-label="Clear search"
|
||||
>
|
||||
<Spinner variant="Secondary" size="400" />
|
||||
</Box>
|
||||
);
|
||||
if (threads.length === 0)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400, gap: config.space.S200 }}
|
||||
>
|
||||
<Icon size="400" src={Icons.Thread} />
|
||||
<Text size="T300" align="Center">
|
||||
{lowerQuery ? 'No threads match your search.' : 'No threads yet.'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{ padding: `${config.space.S100} ${config.space.S200}` }}
|
||||
>
|
||||
{threads.map((thread: Thread) => (
|
||||
<ThreadPreview
|
||||
key={thread.id}
|
||||
room={room}
|
||||
thread={thread}
|
||||
onClick={onOpenThread}
|
||||
onJump={onClose}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
{loadingMore && (
|
||||
<Icon size="50" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box className={css.ThreadDrawerContent} grow="Yes" direction="Column">
|
||||
<Scroll
|
||||
variant="Background"
|
||||
visibility="Hover"
|
||||
direction="Vertical"
|
||||
size="300"
|
||||
onScroll={handleThreadsScroll}
|
||||
style={{ flexGrow: 1 }}
|
||||
>
|
||||
{(() => {
|
||||
if (threads.length === 0 && loadingMore)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S300, flexShrink: 0 }}
|
||||
style={{ padding: config.space.S400, gap: config.space.S200 }}
|
||||
>
|
||||
<Spinner variant="Secondary" size="400" />
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</Scroll>
|
||||
);
|
||||
if (threads.length === 0)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400, gap: config.space.S200 }}
|
||||
>
|
||||
<Icon size="400" src={Icons.Thread} />
|
||||
<Text size="T300" align="Center">
|
||||
{lowerQuery ? 'No threads match your search.' : 'No threads yet.'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{ padding: `${config.space.S100} ${config.space.S200}` }}
|
||||
>
|
||||
{threads.map((thread: Thread) => (
|
||||
<ThreadPreview
|
||||
key={thread.id}
|
||||
room={room}
|
||||
thread={thread}
|
||||
onClick={onOpenThread}
|
||||
onJump={onClose}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
{loadingMore && (
|
||||
<Box
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S300, flexShrink: 0 }}
|
||||
>
|
||||
<Spinner variant="Secondary" size="400" />
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import { style, globalStyle } from '@vanilla-extract/css';
|
||||
import { config, color, toRem } from 'folds';
|
||||
import { config, color } from 'folds';
|
||||
|
||||
export const ThreadDrawer = style({
|
||||
width: toRem(440),
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
import type { MouseEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Box, Header, Icon, IconButton, Icons, Scroll, Spinner, Text, config } from 'folds';
|
||||
import {
|
||||
Box,
|
||||
Header,
|
||||
Icon,
|
||||
IconButton,
|
||||
Icons,
|
||||
Scroll,
|
||||
Spinner,
|
||||
Text,
|
||||
color,
|
||||
config,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import type { IEvent, Room } from '$types/matrix-sdk';
|
||||
import {
|
||||
Direction,
|
||||
@@ -64,6 +76,8 @@ import { useTimelineEventRenderer } from '$hooks/timeline/useTimelineEventRender
|
||||
import { RoomInput } from './RoomInput';
|
||||
import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollowing';
|
||||
import * as css from './ThreadDrawer.css';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
|
||||
/**
|
||||
* Resolve the list of reply events to show in the thread drawer.
|
||||
@@ -736,172 +750,214 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
|
||||
);
|
||||
const latestThreadEventId = processedEvents.at(-1)?.id ?? rootEvent?.getId();
|
||||
|
||||
const [threadSidebarWidth, setThreadSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'threadSidebarWidth'
|
||||
);
|
||||
const [curWidth, setCurWidth] = useState(threadSidebarWidth);
|
||||
useEffect(() => {
|
||||
setCurWidth(threadSidebarWidth);
|
||||
}, [threadSidebarWidth]);
|
||||
|
||||
const [threadRootHeight, setThreadRootHeight] = useSetting(settingsAtom, 'threadRootHeight');
|
||||
const [curHeight, setCurHeight] = useState(threadRootHeight);
|
||||
useEffect(() => {
|
||||
setCurHeight(threadRootHeight);
|
||||
}, [threadRootHeight]);
|
||||
return (
|
||||
<Box
|
||||
ref={drawerRef}
|
||||
className={overlay ? css.ThreadDrawerOverlay : css.ThreadDrawer}
|
||||
direction="Column"
|
||||
shrink="No"
|
||||
>
|
||||
{/* Header */}
|
||||
<Header className={css.ThreadDrawerHeader} variant="Background" size="600">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Icon size="200" src={Icons.Thread} />
|
||||
<Text size="H4" truncate>
|
||||
Thread
|
||||
</Text>
|
||||
</Box>
|
||||
<Box alignItems="Center" gap="200" shrink="No">
|
||||
<IconButton
|
||||
onClick={onClose}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
aria-label="Close thread"
|
||||
>
|
||||
<Icon size="200" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Header>
|
||||
|
||||
{/* Thread root message */}
|
||||
{rootEvent && (
|
||||
<Scroll
|
||||
variant="Background"
|
||||
visibility="Hover"
|
||||
direction="Vertical"
|
||||
size="300"
|
||||
hideTrack
|
||||
style={{
|
||||
maxHeight: '200px',
|
||||
height: 'fit-content',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
className={css.messageList}
|
||||
direction="Column"
|
||||
style={{
|
||||
padding: `${config.space.S200} 0 ${config.space.S100} 0`,
|
||||
}}
|
||||
>
|
||||
{renderMatrixEvent(
|
||||
rootEvent.getType(),
|
||||
typeof rootEvent.getStateKey() === 'string',
|
||||
rootEvent.getId()!,
|
||||
rootEvent,
|
||||
processedEvents.find((e) => e.id === threadRootId)?.itemIndex ?? 0,
|
||||
thread?.timelineSet ?? room.getUnfilteredTimelineSet(),
|
||||
false
|
||||
)}
|
||||
</Box>
|
||||
</Scroll>
|
||||
<>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={threadSidebarWidth}
|
||||
setSidebarWidth={setThreadSidebarWidth}
|
||||
minValue={150}
|
||||
maxValue={600}
|
||||
isReversed
|
||||
/>
|
||||
)}
|
||||
<Box
|
||||
className={overlay ? css.ThreadDrawerOverlay : css.ThreadDrawer}
|
||||
direction="Column"
|
||||
shrink="No"
|
||||
style={{ width: overlay ? '100%' : toRem(curWidth) }}
|
||||
>
|
||||
{/* Header */}
|
||||
<Header className={css.ThreadDrawerHeader} variant="Background" size="600">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Icon size="200" src={Icons.Thread} />
|
||||
<Text size="H4" truncate>
|
||||
Thread
|
||||
</Text>
|
||||
</Box>
|
||||
<Box alignItems="Center" gap="200" shrink="No">
|
||||
<IconButton
|
||||
onClick={onClose}
|
||||
variant="SurfaceVariant"
|
||||
size="300"
|
||||
radii="300"
|
||||
aria-label="Close thread"
|
||||
>
|
||||
<Icon size="200" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Header>
|
||||
|
||||
{/* Replies */}
|
||||
<Box className={css.ThreadDrawerContent} grow="Yes" direction="Column">
|
||||
<Scroll
|
||||
ref={scrollRef}
|
||||
variant="Background"
|
||||
visibility="Hover"
|
||||
direction="Vertical"
|
||||
size="300"
|
||||
onScroll={handleRepliesScroll}
|
||||
style={{ flexGrow: 1 }}
|
||||
>
|
||||
{(() => {
|
||||
if (isThreadLoading)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400 }}
|
||||
>
|
||||
<Spinner variant="Secondary" size="400" />
|
||||
</Box>
|
||||
);
|
||||
if (processedReplies.length === 0)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400, gap: config.space.S200 }}
|
||||
>
|
||||
<Icon size="400" src={Icons.Thread} />
|
||||
<Text size="T300" align="Center">
|
||||
No replies yet. Start the thread below!
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{loadingOlderReplies && (
|
||||
<Box
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S300, flexShrink: 0 }}
|
||||
>
|
||||
<Spinner variant="Secondary" size="200" />
|
||||
</Box>
|
||||
{/* Thread root message */}
|
||||
{rootEvent && (
|
||||
<>
|
||||
<Scroll
|
||||
variant="Background"
|
||||
visibility="Hover"
|
||||
direction="Vertical"
|
||||
size="300"
|
||||
hideTrack
|
||||
style={{
|
||||
height: toRem(curHeight),
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
className={css.messageList}
|
||||
direction="Column"
|
||||
style={{
|
||||
padding: `${config.space.S200} 0 ${config.space.S100} 0`,
|
||||
}}
|
||||
>
|
||||
{renderMatrixEvent(
|
||||
rootEvent.getType(),
|
||||
typeof rootEvent.getStateKey() === 'string',
|
||||
rootEvent.getId()!,
|
||||
rootEvent,
|
||||
processedEvents.find((e) => e.id === threadRootId)?.itemIndex ?? 0,
|
||||
thread?.timelineSet ?? room.getUnfilteredTimelineSet(),
|
||||
false
|
||||
)}
|
||||
{/* Reply count label inside scroll area */}
|
||||
<Box
|
||||
style={{
|
||||
padding: `${config.space.S200} ${config.space.S400}`,
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Text size="T300" priority="300">
|
||||
{processedReplies.length} {processedReplies.length === 1 ? 'reply' : 'replies'}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box
|
||||
className={css.messageList}
|
||||
direction="Column"
|
||||
style={{ padding: `0 0 ${config.space.S600} 0` }}
|
||||
>
|
||||
{processedReplies.map((e) =>
|
||||
renderMatrixEvent(
|
||||
e.mEvent.getType(),
|
||||
typeof e.mEvent.getStateKey() === 'string',
|
||||
e.id,
|
||||
e.mEvent,
|
||||
e.itemIndex,
|
||||
e.timelineSet,
|
||||
e.collapsed
|
||||
)
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</Scroll>
|
||||
</Box>
|
||||
|
||||
{/* Thread input */}
|
||||
<Box className={css.ThreadDrawerInput} direction="Column" shrink="No">
|
||||
<div style={{ padding: `0 ${config.space.S400}` }}>
|
||||
<RoomInput
|
||||
key={threadRootId}
|
||||
room={room}
|
||||
roomId={room.roomId}
|
||||
threadRootId={threadRootId}
|
||||
editor={editor}
|
||||
fileDropContainerRef={drawerRef}
|
||||
onEditLastMessage={handleEditLastMessage}
|
||||
/>
|
||||
</div>
|
||||
{hideReads ? (
|
||||
<RoomViewFollowingPlaceholder />
|
||||
) : (
|
||||
<RoomViewFollowing
|
||||
room={room}
|
||||
threadEventId={latestThreadEventId}
|
||||
participantIds={threadParticipantIds}
|
||||
/>
|
||||
</Box>
|
||||
</Scroll>
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurHeight}
|
||||
sidebarWidth={threadRootHeight}
|
||||
setSidebarWidth={setThreadRootHeight}
|
||||
minValue={60}
|
||||
maxValue={700}
|
||||
topSided
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: toRem(1),
|
||||
backgroundColor: color.Surface.ContainerLine,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{/* Replies */}
|
||||
<Box className={css.ThreadDrawerContent} grow="Yes" direction="Column">
|
||||
<Scroll
|
||||
ref={scrollRef}
|
||||
variant="Background"
|
||||
visibility="Hover"
|
||||
direction="Vertical"
|
||||
size="300"
|
||||
onScroll={handleRepliesScroll}
|
||||
style={{ flexGrow: 1 }}
|
||||
>
|
||||
{(() => {
|
||||
if (isThreadLoading)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400 }}
|
||||
>
|
||||
<Spinner variant="Secondary" size="400" />
|
||||
</Box>
|
||||
);
|
||||
if (processedReplies.length === 0)
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S400, gap: config.space.S200 }}
|
||||
>
|
||||
<Icon size="400" src={Icons.Thread} />
|
||||
<Text size="T300" align="Center">
|
||||
No replies yet. Start the thread below!
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{loadingOlderReplies && (
|
||||
<Box
|
||||
justifyContent="Center"
|
||||
style={{ padding: config.space.S300, flexShrink: 0 }}
|
||||
>
|
||||
<Spinner variant="Secondary" size="200" />
|
||||
</Box>
|
||||
)}
|
||||
{/* Reply count label inside scroll area */}
|
||||
<Box
|
||||
style={{
|
||||
padding: `${config.space.S200} ${config.space.S400}`,
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Text size="T300" priority="300">
|
||||
{processedReplies.length}{' '}
|
||||
{processedReplies.length === 1 ? 'reply' : 'replies'}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box
|
||||
className={css.messageList}
|
||||
direction="Column"
|
||||
style={{ padding: `0 0 ${config.space.S600} 0` }}
|
||||
>
|
||||
{processedReplies.map((e) =>
|
||||
renderMatrixEvent(
|
||||
e.mEvent.getType(),
|
||||
typeof e.mEvent.getStateKey() === 'string',
|
||||
e.id,
|
||||
e.mEvent,
|
||||
e.itemIndex,
|
||||
e.timelineSet,
|
||||
e.collapsed
|
||||
)
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</Scroll>
|
||||
</Box>
|
||||
|
||||
{/* Thread input */}
|
||||
<Box className={css.ThreadDrawerInput} direction="Column" shrink="No">
|
||||
<div style={{ padding: `0 ${config.space.S400}` }}>
|
||||
<RoomInput
|
||||
key={threadRootId}
|
||||
room={room}
|
||||
roomId={room.roomId}
|
||||
threadRootId={threadRootId}
|
||||
editor={editor}
|
||||
fileDropContainerRef={drawerRef}
|
||||
onEditLastMessage={handleEditLastMessage}
|
||||
/>
|
||||
</div>
|
||||
{hideReads ? (
|
||||
<RoomViewFollowingPlaceholder />
|
||||
) : (
|
||||
<RoomViewFollowing
|
||||
room={room}
|
||||
threadEventId={latestThreadEventId}
|
||||
participantIds={threadParticipantIds}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,21 @@
|
||||
import type { ChangeEventHandler, KeyboardEventHandler } from 'react';
|
||||
import { type MouseEventHandler, useState } from 'react';
|
||||
import { Box, Chip, config, Icon, Icons, Input, Switch, Text, toRem } from 'folds';
|
||||
import { type MouseEventHandler, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
config,
|
||||
Icon,
|
||||
Icons,
|
||||
Input,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
Switch,
|
||||
Text,
|
||||
toRem,
|
||||
type RectCords,
|
||||
} from 'folds';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
|
||||
import { SettingMenuSelector } from '$components/setting-menu-selector';
|
||||
@@ -14,9 +29,15 @@ import {
|
||||
} from '$plugins/arborium';
|
||||
import { ThemeKind, useActiveTheme } from '$hooks/useTheme';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import type { ShowRoomIcon } from '$state/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { SequenceCardStyle } from '$features/settings/styles.css';
|
||||
import { ThemeAppearanceSection } from './ThemeAppearanceSection';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useShowRoomIcon } from '$hooks/useShowRoomIcon';
|
||||
import type { PanelSizetItem } from '$hooks/usePanelSizes';
|
||||
import { usePanelSizeItems } from '$hooks/usePanelSizes';
|
||||
|
||||
const clampIncomingInlineImageHeight = (n: number) => Math.max(1, Math.min(4096, n));
|
||||
|
||||
@@ -508,11 +529,246 @@ function PageZoomInput() {
|
||||
);
|
||||
}
|
||||
|
||||
function PanelSelector({
|
||||
sidebarSelector,
|
||||
setSidebarSelector,
|
||||
}: {
|
||||
sidebarSelector: string;
|
||||
setSidebarSelector: (arg0: string) => void;
|
||||
}) {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const panelSizeItems = usePanelSizeItems();
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (position: PanelSizetItem) => {
|
||||
setSidebarSelector(position.layout);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
outlined
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
after={<Icon size="300" src={Icons.ChevronBottom} />}
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Text size="T300">
|
||||
{panelSizeItems.find((i) => i.layout === sidebarSelector)?.name ?? sidebarSelector}
|
||||
</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
offset={5}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setMenuCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowDown' || evt.key === 'ArrowRight',
|
||||
isKeyBackward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowUp' || evt.key === 'ArrowLeft',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{panelSizeItems.map((item) => (
|
||||
<MenuItem
|
||||
key={item.layout}
|
||||
size="300"
|
||||
variant={sidebarSelector === item.layout ? 'Primary' : 'Surface'}
|
||||
radii="300"
|
||||
onClick={() => handleSelect(item)}
|
||||
>
|
||||
<Text size="T300">{item.name}</Text>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
function SidebarWidth({ sidebarSelector }: { sidebarSelector: string }) {
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [memberSidebarWidth, setMemberSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'memberSidebarWidth'
|
||||
);
|
||||
const [threadSidebarWidth, setThreadSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'threadSidebarWidth'
|
||||
);
|
||||
const [threadRootHeight, setThreadRootHeight] = useSetting(settingsAtom, 'threadRootHeight');
|
||||
const [vcmsgSidebarWidth, setvcmsgSidebarWidth] = useSetting(settingsAtom, 'vcmsgSidebarWidth');
|
||||
const [widgetSidebarWidth, setWidgetSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'widgetSidebarWidth'
|
||||
);
|
||||
|
||||
// Yandere style code but it works and is as straight forward as can be :shrug:
|
||||
const getCurValue = useMemo(() => {
|
||||
if (sidebarSelector === 'roomSidebarWidth') return roomSidebarWidth;
|
||||
if (sidebarSelector === 'memberSidebarWidth') return memberSidebarWidth;
|
||||
if (sidebarSelector === 'threadSidebarWidth') return threadSidebarWidth;
|
||||
if (sidebarSelector === 'threadRootHeight') return threadRootHeight;
|
||||
if (sidebarSelector === 'vcmsgSidebarWidth') return vcmsgSidebarWidth;
|
||||
if (sidebarSelector === 'widgetSidebarWidth') return widgetSidebarWidth;
|
||||
return undefined;
|
||||
}, [
|
||||
sidebarSelector,
|
||||
roomSidebarWidth,
|
||||
memberSidebarWidth,
|
||||
threadSidebarWidth,
|
||||
threadRootHeight,
|
||||
vcmsgSidebarWidth,
|
||||
widgetSidebarWidth,
|
||||
]);
|
||||
const [curValue, setCurValue] = useState(getCurValue);
|
||||
const setValue = (value: number) => {
|
||||
if (sidebarSelector === 'roomSidebarWidth') setRoomSidebarWidth(value);
|
||||
if (sidebarSelector === 'memberSidebarWidth') setMemberSidebarWidth(value);
|
||||
if (sidebarSelector === 'threadSidebarWidth') setThreadSidebarWidth(value);
|
||||
if (sidebarSelector === 'threadRootHeight') setThreadRootHeight(value);
|
||||
if (sidebarSelector === 'vcmsgSidebarWidth') setvcmsgSidebarWidth(value);
|
||||
if (sidebarSelector === 'widgetSidebarWidth') setWidgetSidebarWidth(value);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setInputValue(curValue?.toString());
|
||||
}, [curValue]);
|
||||
useEffect(() => {
|
||||
setCurValue(getCurValue);
|
||||
}, [getCurValue]);
|
||||
|
||||
const [inputValue, setInputValue] = useState(curValue?.toString());
|
||||
|
||||
const handleChange: ChangeEventHandler<HTMLInputElement> = (evt) => {
|
||||
const val = evt.target.value;
|
||||
setInputValue(val);
|
||||
|
||||
const parsed = parseInt(val, 10);
|
||||
if (!Number.isNaN(parsed)) {
|
||||
setValue(parsed);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (evt) => {
|
||||
if (isKeyHotkey('escape', evt)) {
|
||||
evt.stopPropagation();
|
||||
setInputValue(curValue?.toString());
|
||||
(evt.target as HTMLInputElement).blur();
|
||||
}
|
||||
|
||||
if (isKeyHotkey('enter', evt)) {
|
||||
(evt.target as HTMLInputElement).blur();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Input
|
||||
style={{ width: toRem(80) }}
|
||||
variant={parseInt(inputValue ?? '', 10) === curValue ? 'Secondary' : 'Success'}
|
||||
size="300"
|
||||
radii="300"
|
||||
type="number"
|
||||
min="0"
|
||||
max="1000"
|
||||
value={inputValue}
|
||||
onChange={handleChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
outlined
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectShowRoomIcon() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const [showRoomIcon, setShowRoomIcon] = useSetting(settingsAtom, 'showRoomIcon');
|
||||
const showRoomIconItems = useShowRoomIcon();
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (position: ShowRoomIcon) => {
|
||||
setShowRoomIcon(position);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
outlined
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
after={<Icon size="300" src={Icons.ChevronBottom} />}
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Text size="T300">
|
||||
{showRoomIconItems.find((i) => i.layout === showRoomIcon)?.name ?? showRoomIcon}
|
||||
</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
offset={5}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setMenuCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowDown' || evt.key === 'ArrowRight',
|
||||
isKeyBackward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowUp' || evt.key === 'ArrowLeft',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{showRoomIconItems.map((item) => (
|
||||
<MenuItem
|
||||
key={item.layout}
|
||||
size="300"
|
||||
variant={showRoomIcon === item.layout ? 'Primary' : 'Surface'}
|
||||
radii="300"
|
||||
onClick={() => handleSelect(item.layout)}
|
||||
>
|
||||
<Text size="T300">{item.name}</Text>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
export function Appearance({
|
||||
onThemeBrowserOpenChange,
|
||||
}: {
|
||||
onThemeBrowserOpenChange?: (open: boolean) => void;
|
||||
} = {}) {
|
||||
const [sidebarSelector, setSidebarSelector] = useState('roomSidebarWidth');
|
||||
const [twitterEmoji, setTwitterEmoji] = useSetting(settingsAtom, 'twitterEmoji');
|
||||
const [customDMCards, setCustomDMCards] = useSetting(settingsAtom, 'customDMCards');
|
||||
const [showEasterEggs, setShowEasterEggs] = useSetting(settingsAtom, 'showEasterEggs');
|
||||
@@ -596,6 +852,32 @@ export function Appearance({
|
||||
after={<SubnestedSpaceLinkDepthInput />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Room Icons"
|
||||
focusId="show-room-icons"
|
||||
description="When do you want to show the specific room icons in the sidebar as opposed to the default room icons?"
|
||||
after={<SelectShowRoomIcon />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Sidebar Size"
|
||||
focusId="sidebar-size"
|
||||
description="The Size of the sidebar, it can be changed either here numerically or by hovering and dragging the lighting bar"
|
||||
after={
|
||||
<>
|
||||
<PanelSelector
|
||||
sidebarSelector={sidebarSelector}
|
||||
setSidebarSelector={setSidebarSelector}
|
||||
/>
|
||||
<SidebarWidth sidebarSelector={sidebarSelector} />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -845,6 +845,10 @@ function Calls() {
|
||||
settingsAtom,
|
||||
'alwaysShowCallButton'
|
||||
);
|
||||
const [joinCallOnSingleClick, setjoinCallOnSingleClick] = useSetting(
|
||||
settingsAtom,
|
||||
'joinCallOnSingleClick'
|
||||
);
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
@@ -862,6 +866,19 @@ function Calls() {
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Join voice calls by just clicking the room's icon"
|
||||
focusId="join-on-click-voicecalls"
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={joinCallOnSingleClick}
|
||||
onChange={setjoinCallOnSingleClick}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ const settingsLinkFocusIdsBySection: Record<SettingsSectionId, readonly string[]
|
||||
'twenty-four-hour-time-format',
|
||||
'url-preview',
|
||||
'use-sliding-sync',
|
||||
'join-on-click-voicecalls',
|
||||
],
|
||||
account: [
|
||||
'about-you',
|
||||
@@ -120,6 +121,8 @@ const settingsLinkFocusIdsBySection: Record<SettingsSectionId, readonly string[]
|
||||
'system-theme',
|
||||
'twitter-emoji',
|
||||
'underline-links',
|
||||
'show-room-icons',
|
||||
'sidebar-size',
|
||||
'incoming-inline-images-default-height',
|
||||
'incoming-inline-images-max-height',
|
||||
'link-preview-image-max-height',
|
||||
|
||||
@@ -11,9 +11,10 @@ type SpaceNavItemProps = {
|
||||
room: Room;
|
||||
selected: boolean;
|
||||
linkPath: string;
|
||||
hideText?: boolean;
|
||||
};
|
||||
|
||||
export function SpaceNavItem({ room, selected, linkPath }: SpaceNavItemProps) {
|
||||
export function SpaceNavItem({ room, selected, linkPath, hideText }: SpaceNavItemProps) {
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
|
||||
const matrixRoomName = useRoomName(room);
|
||||
@@ -49,7 +50,13 @@ export function SpaceNavItem({ room, selected, linkPath }: SpaceNavItemProps) {
|
||||
>
|
||||
<NavButton onClick={handleNavItemClick} aria-label={ariaLabel}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Box
|
||||
as="span"
|
||||
grow="Yes"
|
||||
alignItems="Center"
|
||||
gap="200"
|
||||
style={{ padding: hideText ? '0' : '1' }}
|
||||
>
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon
|
||||
src={Icons.Space}
|
||||
@@ -58,11 +65,13 @@ export function SpaceNavItem({ room, selected, linkPath }: SpaceNavItemProps) {
|
||||
size="100"
|
||||
/>
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text priority="300" as="span" size="Inherit" truncate>
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text priority="300" as="span" size="Inherit" truncate>
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
import { config } from 'folds';
|
||||
|
||||
export const WidgetsDrawer = style({
|
||||
width: toRem(420),
|
||||
maxWidth: '100vw',
|
||||
minWidth: '20vw',
|
||||
minWidth: '9vw',
|
||||
});
|
||||
|
||||
export const WidgetsDrawerHeader = style({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { FormEventHandler, MouseEventHandler } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Header,
|
||||
@@ -15,13 +15,14 @@ import {
|
||||
config,
|
||||
Button,
|
||||
Line,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import type { RoomWidget } from '$hooks/useRoomWidgets';
|
||||
import { useRoomWidgets, enrichWidgetUrl } from '$hooks/useRoomWidgets';
|
||||
import { useSetSetting } from '$state/hooks/settings';
|
||||
import { useSetSetting, useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { usePowerLevelsContext } from '$hooks/usePowerLevels';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
@@ -32,6 +33,8 @@ import { WidgetIframe } from './WidgetIframe';
|
||||
import * as css from './WidgetsDrawer.css';
|
||||
import { IntegrationManager } from './IntegrationManager';
|
||||
import { CustomStateEvent } from '$types/matrix/room';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
|
||||
type WidgetsDrawerHeaderProps = {
|
||||
activeWidget: RoomWidget | null;
|
||||
@@ -229,6 +232,15 @@ export function WidgetsDrawer({ room }: WidgetsDrawerProps) {
|
||||
const permissions = useRoomPermissions(creators, powerLevels);
|
||||
const canManageWidgets = permissions.stateEvent(CustomStateEvent.RoomWidget, mx.getSafeUserId());
|
||||
|
||||
const [widgetSidebarWidth, setWidgetSidebarWidth] = useSetting(
|
||||
settingsAtom,
|
||||
'widgetSidebarWidth'
|
||||
);
|
||||
const [curWidth, setCurWidth] = useState(widgetSidebarWidth);
|
||||
useEffect(() => {
|
||||
setCurWidth(widgetSidebarWidth);
|
||||
}, [widgetSidebarWidth]);
|
||||
|
||||
const handleRemoveWidget = async (widget: RoomWidget) => {
|
||||
try {
|
||||
await mx.sendStateEvent(room.roomId, CustomStateEvent.RoomWidget, {}, widget.id);
|
||||
@@ -243,74 +255,96 @@ export function WidgetsDrawer({ room }: WidgetsDrawerProps) {
|
||||
const handleBack = () => setActiveWidget(null);
|
||||
|
||||
return (
|
||||
<Box className={css.WidgetsDrawer} direction="Column">
|
||||
<WidgetDrawerHeader activeWidget={activeWidget} onBack={handleBack} />
|
||||
{activeWidget ? (
|
||||
<Box className={css.WidgetIframeContainer} grow="Yes">
|
||||
<WidgetIframe key={activeWidget.id} widget={activeWidget} roomId={room.roomId} mx={mx} />
|
||||
</Box>
|
||||
) : (
|
||||
<Scroll variant="Background" visibility="Hover">
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S200 }}>
|
||||
{widgets.length === 0 && !showAddForm && (
|
||||
<Box style={{ padding: config.space.S300 }}>
|
||||
<Text size="T300" priority="300">
|
||||
No widgets in this room.
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{widgets.map((widget) => (
|
||||
<WidgetListItemView
|
||||
key={widget.id}
|
||||
widget={widget}
|
||||
onSelect={setActiveWidget}
|
||||
onRemove={handleRemoveWidget}
|
||||
canRemove={canManageWidgets}
|
||||
/>
|
||||
))}
|
||||
{canManageWidgets && (
|
||||
<>
|
||||
<Line variant="Surface" size="300" />
|
||||
{showAddForm ? (
|
||||
<AddWidgetForm room={room} onAdded={() => setShowAddForm(false)} />
|
||||
) : (
|
||||
<Box
|
||||
direction="Column"
|
||||
gap="100"
|
||||
style={{
|
||||
padding: `${config.space.S100} ${config.space.S300}`,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Primary"
|
||||
fill="Soft"
|
||||
onClick={() => setShowIntegrationManager(true)}
|
||||
before={<Icon size="100" src={Icons.Category} />}
|
||||
>
|
||||
<Text size="B300">Integration Manager</Text>
|
||||
</Button>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
onClick={() => setShowAddForm(true)}
|
||||
before={<Icon size="100" src={Icons.Plus} />}
|
||||
>
|
||||
<Text size="B300">Add Custom Widget</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</Scroll>
|
||||
<>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={widgetSidebarWidth}
|
||||
setSidebarWidth={setWidgetSidebarWidth}
|
||||
minValue={50}
|
||||
maxValue={1200}
|
||||
isReversed
|
||||
/>
|
||||
)}
|
||||
<IntegrationManager
|
||||
room={room}
|
||||
open={showIntegrationManager}
|
||||
onClose={() => setShowIntegrationManager(false)}
|
||||
/>
|
||||
</Box>
|
||||
<Box
|
||||
className={css.WidgetsDrawer}
|
||||
shrink="No"
|
||||
direction="Column"
|
||||
style={{ width: !mobileOrTablet() ? toRem(curWidth) : 'inherit' }}
|
||||
>
|
||||
<WidgetDrawerHeader activeWidget={activeWidget} onBack={handleBack} />
|
||||
{activeWidget ? (
|
||||
<Box className={css.WidgetIframeContainer} grow="Yes">
|
||||
<WidgetIframe
|
||||
key={activeWidget.id}
|
||||
widget={activeWidget}
|
||||
roomId={room.roomId}
|
||||
mx={mx}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<Scroll variant="Background" visibility="Hover">
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S200 }}>
|
||||
{widgets.length === 0 && !showAddForm && (
|
||||
<Box style={{ padding: config.space.S300 }}>
|
||||
<Text size="T300" priority="300">
|
||||
No widgets in this room.
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{widgets.map((widget) => (
|
||||
<WidgetListItemView
|
||||
key={widget.id}
|
||||
widget={widget}
|
||||
onSelect={setActiveWidget}
|
||||
onRemove={handleRemoveWidget}
|
||||
canRemove={canManageWidgets}
|
||||
/>
|
||||
))}
|
||||
{canManageWidgets && (
|
||||
<>
|
||||
<Line variant="Surface" size="300" />
|
||||
{showAddForm ? (
|
||||
<AddWidgetForm room={room} onAdded={() => setShowAddForm(false)} />
|
||||
) : (
|
||||
<Box
|
||||
direction="Column"
|
||||
gap="100"
|
||||
style={{
|
||||
padding: `${config.space.S100} ${config.space.S300}`,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Primary"
|
||||
fill="Soft"
|
||||
onClick={() => setShowIntegrationManager(true)}
|
||||
before={<Icon size="100" src={Icons.Category} />}
|
||||
>
|
||||
<Text size="B300">Integration Manager</Text>
|
||||
</Button>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
onClick={() => setShowAddForm(true)}
|
||||
before={<Icon size="100" src={Icons.Plus} />}
|
||||
>
|
||||
<Text size="B300">Add Custom Widget</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</Scroll>
|
||||
)}
|
||||
<IntegrationManager
|
||||
room={room}
|
||||
open={showIntegrationManager}
|
||||
onClose={() => setShowIntegrationManager(false)}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export type PanelSizetItem = {
|
||||
layout: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export const usePanelSizeItems = (): PanelSizetItem[] =>
|
||||
useMemo(
|
||||
() => [
|
||||
{
|
||||
layout: 'roomSidebarWidth',
|
||||
name: 'Room Panel Width',
|
||||
},
|
||||
{
|
||||
layout: 'memberSidebarWidth',
|
||||
name: 'Member Panel Width',
|
||||
},
|
||||
{
|
||||
layout: 'threadSidebarWidth',
|
||||
name: 'Thread Panel Width',
|
||||
},
|
||||
{
|
||||
layout: 'threadRootHeight',
|
||||
name: 'Thread Root Height',
|
||||
},
|
||||
{
|
||||
layout: 'vcmsgSidebarWidth',
|
||||
name: 'VoiceCall Msg Panel Width',
|
||||
},
|
||||
{
|
||||
layout: 'widgetSidebarWidth',
|
||||
name: 'Widget Panel Width',
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -0,0 +1,26 @@
|
||||
import { useMemo } from 'react';
|
||||
import { ShowRoomIcon } from '$state/settings';
|
||||
|
||||
export type MessageLayoutItem = {
|
||||
name: string;
|
||||
layout: ShowRoomIcon;
|
||||
};
|
||||
|
||||
export const useShowRoomIcon = (): MessageLayoutItem[] =>
|
||||
useMemo(
|
||||
() => [
|
||||
{
|
||||
layout: ShowRoomIcon.Always,
|
||||
name: 'Always',
|
||||
},
|
||||
{
|
||||
layout: ShowRoomIcon.Smart,
|
||||
name: 'Smart',
|
||||
},
|
||||
{
|
||||
layout: ShowRoomIcon.Never,
|
||||
name: 'Never',
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -53,6 +53,9 @@ import {
|
||||
} from '$hooks/useRoomsNotificationPreferences';
|
||||
import { useDirectCreateSelected } from '$hooks/router/useDirectSelected';
|
||||
import { useDirectRooms } from './useDirectRooms';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { useScreenSizeContext, ScreenSize } from '$hooks/useScreenSize';
|
||||
|
||||
type DirectMenuProps = {
|
||||
requestClose: () => void;
|
||||
@@ -88,7 +91,7 @@ const DirectMenu = forwardRef<HTMLDivElement, DirectMenuProps>(({ requestClose }
|
||||
);
|
||||
});
|
||||
|
||||
function DirectHeader() {
|
||||
function DirectHeader({ hideText }: { hideText?: boolean }) {
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
@@ -98,19 +101,24 @@ function DirectHeader() {
|
||||
return cords;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageNavHeader>
|
||||
<Box alignItems="Center" grow="Yes" gap="300">
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Direct Messages
|
||||
</Text>
|
||||
</Box>
|
||||
<Box alignItems="Center" grow="Yes" gap="300" justifyContent="Center">
|
||||
{!hideText && (
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Direct Messages
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
<Box>
|
||||
<IconButton aria-pressed={!!menuAnchor} variant="Background" onClick={handleOpenMenu}>
|
||||
<Icon src={Icons.VerticalDots} size="200" />
|
||||
<Icon
|
||||
src={hideText ? Icons.User : Icons.VerticalDots}
|
||||
size="200"
|
||||
filled={!!menuAnchor}
|
||||
/>
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -179,6 +187,14 @@ export function Direct() {
|
||||
const roomToUnread = useAtomValue(roomToUnreadAtom);
|
||||
const navigate = useNavigate();
|
||||
const [customDMCards] = useSetting(settingsAtom, 'customDMCards');
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
|
||||
const [joinCallOnSingleClick] = useSetting(settingsAtom, 'joinCallOnSingleClick');
|
||||
|
||||
const createDirectSelected = useDirectCreateSelected();
|
||||
|
||||
@@ -237,81 +253,129 @@ export function Direct() {
|
||||
closedCategories.has(categoryId)
|
||||
);
|
||||
|
||||
return (
|
||||
<PageNav>
|
||||
<DirectHeader />
|
||||
{noRoomToDisplay ? (
|
||||
<DirectEmpty />
|
||||
) : (
|
||||
<PageNavContent scrollRef={scrollRef}>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={createDirectSelected}>
|
||||
<NavButton onClick={() => navigate(getDirectCreatePath())}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Plus} size="100" />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Create Chat
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
</NavItem>
|
||||
</NavCategory>
|
||||
<NavCategory>
|
||||
<NavCategoryHeader>
|
||||
<RoomNavCategoryButton
|
||||
closed={closedCategories.has(DEFAULT_CATEGORY_ID)}
|
||||
data-category-id={DEFAULT_CATEGORY_ID}
|
||||
onClick={handleCategoryClick}
|
||||
>
|
||||
Chats
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
height: virtualizer.getTotalSize(),
|
||||
}}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const roomId = sortedDirects[vItem.index];
|
||||
if (!roomId) return null;
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room) return null;
|
||||
const selected = selectedRoomId === roomId;
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<DirectHeader hideText={hideText} />
|
||||
{noRoomToDisplay ? (
|
||||
<DirectEmpty />
|
||||
) : (
|
||||
<PageNavContent scrollRef={scrollRef}>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={createDirectSelected}>
|
||||
<NavButton onClick={() => navigate(getDirectCreatePath())}>
|
||||
<NavItemContent>
|
||||
<Box
|
||||
as="span"
|
||||
grow="Yes"
|
||||
alignItems="Center"
|
||||
gap="200"
|
||||
justifyContent="Center"
|
||||
>
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Plus} size="100" />
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Create Chat
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
</NavItem>
|
||||
</NavCategory>
|
||||
<NavCategory>
|
||||
<NavCategoryHeader>
|
||||
<RoomNavCategoryButton
|
||||
closed={closedCategories.has(DEFAULT_CATEGORY_ID)}
|
||||
data-category-id={DEFAULT_CATEGORY_ID}
|
||||
onClick={handleCategoryClick}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selected}
|
||||
showAvatar
|
||||
direct
|
||||
customDMCards={customDMCards}
|
||||
linkPath={getDirectRoomPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
/>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
{!hideText && 'Chats'}
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
height: virtualizer.getTotalSize(),
|
||||
overflow: 'clip',
|
||||
}}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const roomId = sortedDirects[vItem.index];
|
||||
if (!roomId) return null;
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room) return null;
|
||||
const selected = selectedRoomId === roomId;
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div
|
||||
style={
|
||||
hideText
|
||||
? {
|
||||
padding: '0',
|
||||
width: '100%',
|
||||
aspectRatio: 1,
|
||||
display: 'flex',
|
||||
}
|
||||
: {}
|
||||
}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selected}
|
||||
showAvatar
|
||||
direct
|
||||
customDMCards={customDMCards}
|
||||
hideText={hideText}
|
||||
linkPath={getDirectRoomPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
joinCallOnSingleClick={joinCallOnSingleClick}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
)}
|
||||
</PageNav>
|
||||
</Box>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={80}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
/>
|
||||
)}
|
||||
</PageNav>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
Text,
|
||||
color,
|
||||
config,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { NavCategory, NavCategoryHeader, NavItem, NavItemContent, NavLink } from '$components/nav';
|
||||
import { getExploreFeaturedPath, getExploreServerPath } from '$pages/pathUtils';
|
||||
@@ -28,9 +29,14 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { useNavToActivePathMapper } from '$hooks/useNavToActivePathMapper';
|
||||
import { PageNav, PageNavContent, PageNavHeader } from '$components/page';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { useScreenSizeContext, ScreenSize } from '$hooks/useScreenSize';
|
||||
|
||||
export function AddServer() {
|
||||
export function AddServer({ hideText }: { hideText?: boolean }) {
|
||||
const mx = useMatrixClient();
|
||||
const navigate = useNavigate();
|
||||
const [dialog, setDialog] = useState(false);
|
||||
@@ -132,17 +138,23 @@ export function AddServer() {
|
||||
</FocusTrap>
|
||||
</OverlayCenter>
|
||||
</Overlay>
|
||||
<Button
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="300"
|
||||
before={<Icon size="100" src={Icons.Plus} />}
|
||||
onClick={() => setDialog(true)}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
Add Server
|
||||
</Text>
|
||||
</Button>
|
||||
{!hideText ? (
|
||||
<Button
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="300"
|
||||
before={<Icon size="100" src={Icons.Plus} />}
|
||||
onClick={() => setDialog(true)}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
Add Server
|
||||
</Text>
|
||||
</Button>
|
||||
) : (
|
||||
<IconButton aria-pressed variant="Background" onClick={() => setDialog(true)}>
|
||||
<Icon src={Icons.Plus} size="200" filled />
|
||||
</IconButton>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -159,101 +171,161 @@ export function Explore() {
|
||||
const featuredSelected = useExploreFeaturedSelected();
|
||||
const selectedServer = useExploreServer();
|
||||
|
||||
return (
|
||||
<PageNav>
|
||||
<PageNavHeader>
|
||||
<Box grow="Yes" gap="300">
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Explore Community
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
<PageNavContent>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={featuredSelected}>
|
||||
<NavLink to={getExploreFeaturedPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Bulb} size="100" filled={featuredSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Featured
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
{userServer && (
|
||||
<NavItem
|
||||
variant="Background"
|
||||
radii="400"
|
||||
aria-selected={selectedServer === userServer}
|
||||
>
|
||||
<NavLink to={getExploreServerPath(userServer)}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon
|
||||
src={Icons.Server}
|
||||
size="100"
|
||||
filled={selectedServer === userServer}
|
||||
/>
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
{userServer}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
)}
|
||||
</NavCategory>
|
||||
{servers.length > 0 && (
|
||||
<NavCategory>
|
||||
<NavCategoryHeader>
|
||||
<Text size="O400" style={{ paddingLeft: config.space.S200 }}>
|
||||
Servers
|
||||
</Text>
|
||||
</NavCategoryHeader>
|
||||
{servers.map((server) => (
|
||||
<NavItem
|
||||
key={server}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
aria-selected={server === selectedServer}
|
||||
>
|
||||
<NavLink to={getExploreServerPath(server)}>
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<PageNavHeader>
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
{!hideText ? (
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Explore Community
|
||||
</Text>
|
||||
</Box>
|
||||
) : (
|
||||
<Icon src={Icons.Explore} size="200" filled />
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
|
||||
<PageNavContent>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={featuredSelected}>
|
||||
<NavLink to={getExploreFeaturedPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Server} size="100" filled={server === selectedServer} />
|
||||
<Avatar
|
||||
size="200"
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Bulb} size="100" filled={featuredSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
{server}
|
||||
</Text>
|
||||
</Box>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Featured
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
))}
|
||||
</NavCategory>
|
||||
)}
|
||||
<Box direction="Column">
|
||||
<AddServer />
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</PageNav>
|
||||
{userServer && (
|
||||
<NavItem
|
||||
variant="Background"
|
||||
radii="400"
|
||||
aria-selected={selectedServer === userServer}
|
||||
>
|
||||
<NavLink to={getExploreServerPath(userServer)}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
size="200"
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
<Icon
|
||||
src={Icons.Server}
|
||||
size="100"
|
||||
filled={selectedServer === userServer}
|
||||
/>
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
{userServer}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
)}
|
||||
</NavCategory>
|
||||
{servers.length > 0 && (
|
||||
<NavCategory>
|
||||
<NavCategoryHeader>
|
||||
{!hideText && (
|
||||
<Text size="O400" style={{ paddingLeft: config.space.S200 }}>
|
||||
Servers
|
||||
</Text>
|
||||
)}
|
||||
</NavCategoryHeader>
|
||||
{servers.map((server) => (
|
||||
<NavItem
|
||||
key={server}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
aria-selected={server === selectedServer}
|
||||
>
|
||||
<NavLink to={getExploreServerPath(server)}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
size="200"
|
||||
radii="400"
|
||||
style={
|
||||
hideText ? { width: '100%', padding: '0' } : { height: '100%' }
|
||||
}
|
||||
>
|
||||
<Icon
|
||||
src={Icons.Server}
|
||||
size="100"
|
||||
filled={server === selectedServer}
|
||||
/>
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
{server}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
))}
|
||||
</NavCategory>
|
||||
)}
|
||||
<Box direction="Column">
|
||||
<AddServer hideText={hideText} />
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</PageNav>
|
||||
</Box>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={80}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
+211
-130
@@ -1,5 +1,5 @@
|
||||
import type { MouseEventHandler } from 'react';
|
||||
import { forwardRef, useMemo, useRef, useState } from 'react';
|
||||
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { RectCords } from 'folds';
|
||||
import {
|
||||
@@ -54,7 +54,7 @@ import { markAsRead } from '$utils/notifications';
|
||||
import { useClosedNavCategoriesAtom } from '$state/hooks/closedNavCategories';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { settingsAtom, ShowRoomIcon } from '$state/settings';
|
||||
import {
|
||||
getRoomNotificationMode,
|
||||
useRoomsNotificationPreferencesContext,
|
||||
@@ -62,6 +62,9 @@ import {
|
||||
import { UseStateProvider } from '$components/UseStateProvider';
|
||||
import { JoinAddressPrompt } from '$components/join-address-prompt';
|
||||
import { useHomeRooms } from './useHomeRooms';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
|
||||
type HomeMenuProps = {
|
||||
requestClose: () => void;
|
||||
@@ -97,7 +100,7 @@ const HomeMenu = forwardRef<HTMLDivElement, HomeMenuProps>(({ requestClose }, re
|
||||
);
|
||||
});
|
||||
|
||||
function HomeHeader() {
|
||||
function HomeHeader({ hideText }: { hideText?: boolean }) {
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
@@ -111,15 +114,21 @@ function HomeHeader() {
|
||||
return (
|
||||
<>
|
||||
<PageNavHeader>
|
||||
<Box alignItems="Center" grow="Yes" gap="300">
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Home
|
||||
</Text>
|
||||
</Box>
|
||||
<Box alignItems="Center" grow="Yes" gap="300" justifyContent="Center">
|
||||
{!hideText && (
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Home
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
<Box>
|
||||
<IconButton aria-pressed={!!menuAnchor} variant="Background" onClick={handleOpenMenu}>
|
||||
<Icon src={Icons.VerticalDots} size="200" />
|
||||
<Icon
|
||||
src={hideText ? Icons.Home : Icons.VerticalDots}
|
||||
size="200"
|
||||
filled={!!menuAnchor}
|
||||
/>
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -200,6 +209,20 @@ export function Home() {
|
||||
const roomToUnread = useAtomValue(roomToUnreadAtom);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
const [showRoomIcon] = useSetting(settingsAtom, 'showRoomIcon');
|
||||
const showIcons = () => {
|
||||
if (showRoomIcon === ShowRoomIcon.Always) return true;
|
||||
if (showRoomIcon === ShowRoomIcon.Never) return false;
|
||||
return curWidth < 96;
|
||||
};
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const [joinCallOnSingleClick] = useSetting(settingsAtom, 'joinCallOnSingleClick');
|
||||
|
||||
const selectedRoomId = useSelectedRoom();
|
||||
const createRoomSelected = useHomeCreateSelected();
|
||||
const searchSelected = useHomeSearchSelected();
|
||||
@@ -233,132 +256,190 @@ export function Home() {
|
||||
closedCategories.has(categoryId)
|
||||
);
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
|
||||
return (
|
||||
<PageNav>
|
||||
<HomeHeader />
|
||||
{noRoomToDisplay ? (
|
||||
<HomeEmpty />
|
||||
) : (
|
||||
<PageNavContent scrollRef={scrollRef}>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={createRoomSelected}>
|
||||
<NavButton onClick={() => navigate(getHomeCreatePath())}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Plus} size="100" />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Create Room
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
</NavItem>
|
||||
<UseStateProvider initial={false}>
|
||||
{(open, setOpen) => (
|
||||
<>
|
||||
<NavItem variant="Background" radii="400">
|
||||
<NavButton onClick={() => setOpen(true)}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Link} size="100" />
|
||||
</Avatar>
|
||||
<>
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<HomeHeader hideText={hideText} />
|
||||
{noRoomToDisplay ? (
|
||||
<HomeEmpty />
|
||||
) : (
|
||||
<PageNavContent scrollRef={scrollRef}>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={createRoomSelected}>
|
||||
<NavButton onClick={() => navigate(getHomeCreatePath())}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Plus} size="100" />
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Join with Address
|
||||
Create Room
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
</NavItem>
|
||||
{open && (
|
||||
<JoinAddressPrompt
|
||||
onCancel={() => setOpen(false)}
|
||||
onOpen={(roomIdOrAlias, viaServers, eventId) => {
|
||||
setOpen(false);
|
||||
const path = getHomeRoomPath(roomIdOrAlias, eventId);
|
||||
navigate(
|
||||
viaServers
|
||||
? withSearchParam(path, {
|
||||
viaServers: encodeSearchParamValueArray(viaServers),
|
||||
})
|
||||
: path
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
<NavItem variant="Background" radii="400" aria-selected={searchSelected}>
|
||||
<NavLink to={getHomeSearchPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Search} size="100" filled={searchSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Message Search
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
</NavCategory>
|
||||
<NavCategory>
|
||||
<NavCategoryHeader>
|
||||
<RoomNavCategoryButton
|
||||
closed={closedCategories.has(DEFAULT_CATEGORY_ID)}
|
||||
data-category-id={DEFAULT_CATEGORY_ID}
|
||||
onClick={handleCategoryClick}
|
||||
>
|
||||
Rooms
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
height: virtualizer.getTotalSize(),
|
||||
}}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const roomId = sortedRooms[vItem.index];
|
||||
if (!roomId) return null;
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room) return null;
|
||||
const selected = selectedRoomId === roomId;
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selected}
|
||||
linkPath={getHomeRoomPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
</NavItem>
|
||||
<UseStateProvider initial={false}>
|
||||
{(open, setOpen) => (
|
||||
<>
|
||||
<NavItem variant="Background" radii="400">
|
||||
<NavButton onClick={() => setOpen(true)}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={
|
||||
hideText ? { width: '100%', padding: '0' } : { height: '100%' }
|
||||
}
|
||||
>
|
||||
<Icon src={Icons.Link} size="100" />
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Join with Address
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavButton>
|
||||
</NavItem>
|
||||
{open && (
|
||||
<JoinAddressPrompt
|
||||
onCancel={() => setOpen(false)}
|
||||
onOpen={(roomIdOrAlias, viaServers, eventId) => {
|
||||
setOpen(false);
|
||||
const path = getHomeRoomPath(roomIdOrAlias, eventId);
|
||||
navigate(
|
||||
viaServers
|
||||
? withSearchParam(path, {
|
||||
viaServers: encodeSearchParamValueArray(viaServers),
|
||||
})
|
||||
: path
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</>
|
||||
)}
|
||||
</UseStateProvider>
|
||||
<NavItem variant="Background" radii="400" aria-selected={searchSelected}>
|
||||
<NavLink to={getHomeSearchPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Search} size="100" filled={searchSelected} />
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Message Search
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
</NavCategory>
|
||||
<NavCategory>
|
||||
<NavCategoryHeader>
|
||||
<RoomNavCategoryButton
|
||||
closed={closedCategories.has(DEFAULT_CATEGORY_ID)}
|
||||
data-category-id={DEFAULT_CATEGORY_ID}
|
||||
onClick={handleCategoryClick}
|
||||
>
|
||||
{!hideText && 'Rooms'}
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
height: virtualizer.getTotalSize(),
|
||||
overflow: 'visible',
|
||||
}}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const roomId = sortedRooms[vItem.index];
|
||||
if (!roomId) return null;
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room) return null;
|
||||
const selected = selectedRoomId === roomId;
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div
|
||||
style={
|
||||
hideText
|
||||
? {
|
||||
padding: '0',
|
||||
width: '100%',
|
||||
aspectRatio: 1,
|
||||
display: 'flex',
|
||||
}
|
||||
: {}
|
||||
}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selected}
|
||||
showAvatar={showIcons()}
|
||||
hideText={hideText}
|
||||
linkPath={getHomeRoomPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
joinCallOnSingleClick={joinCallOnSingleClick}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
)}
|
||||
</PageNav>
|
||||
</Box>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={80}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
/>
|
||||
)}
|
||||
</PageNav>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Avatar, Box, Icon, Icons, Text } from 'folds';
|
||||
import { Avatar, Box, Icon, Icons, Text, toRem } from 'folds';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { NavCategory, NavItem, NavItemContent, NavLink } from '$components/nav';
|
||||
import { getInboxInvitesPath, getInboxNotificationsPath } from '$pages/pathUtils';
|
||||
@@ -7,8 +7,14 @@ import { UnreadBadge } from '$components/unread-badge';
|
||||
import { allInvitesAtom } from '$state/room-list/inviteList';
|
||||
import { useNavToActivePathMapper } from '$hooks/useNavToActivePathMapper';
|
||||
import { PageNav, PageNavContent, PageNavHeader } from '$components/page';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
|
||||
function InvitesNavItem() {
|
||||
function InvitesNavItem({ hideText }: { hideText?: boolean }) {
|
||||
const invitesSelected = useInboxInvitesSelected();
|
||||
const allInvites = useAtomValue(allInvitesAtom);
|
||||
const inviteCount = allInvites.length;
|
||||
@@ -23,14 +29,20 @@ function InvitesNavItem() {
|
||||
<NavLink to={getInboxInvitesPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Avatar
|
||||
size="200"
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Mail} size="100" filled={invitesSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Invites
|
||||
</Text>
|
||||
</Box>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Invites
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{inviteCount > 0 && <UnreadBadge highlight count={inviteCount} />}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
@@ -43,41 +55,85 @@ export function Inbox() {
|
||||
useNavToActivePathMapper('inbox');
|
||||
const notificationsSelected = useInboxNotificationsSelected();
|
||||
|
||||
return (
|
||||
<PageNav>
|
||||
<PageNavHeader>
|
||||
<Box grow="Yes" gap="300">
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Inbox
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
<PageNavContent>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={notificationsSelected}>
|
||||
<NavLink to={getInboxNotificationsPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.MessageUnread} size="100" filled={notificationsSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Notifications
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
<InvitesNavItem />
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</PageNav>
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<PageNavHeader>
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
{!hideText ? (
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate>
|
||||
Inbox
|
||||
</Text>
|
||||
</Box>
|
||||
) : (
|
||||
<Icon src={Icons.Inbox} size="200" filled />
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
|
||||
<PageNavContent>
|
||||
<Box direction="Column" gap="300">
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={notificationsSelected}>
|
||||
<NavLink to={getInboxNotificationsPath()}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
size="200"
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
<Icon
|
||||
src={Icons.MessageUnread}
|
||||
size="100"
|
||||
filled={notificationsSelected}
|
||||
/>
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Notifications
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
<InvitesNavItem hideText={hideText} />
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</PageNav>
|
||||
</Box>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={80}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { color, toRem } from 'folds';
|
||||
|
||||
export const SidebarResizer = style({
|
||||
width: toRem(4),
|
||||
backgroundColor: 'inherit',
|
||||
transition: '0.2s',
|
||||
':hover': {},
|
||||
});
|
||||
export const SidebarResizerHover = style({
|
||||
height: '100%',
|
||||
zIndex: '100',
|
||||
});
|
||||
export const SideBarResizerAnimation = style({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
backgroundColor: color.Surface.ContainerLine,
|
||||
transition: '0.5s',
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
// The disable is because the position should only update whenever the new one is updated
|
||||
// oxlint-disable eslint-plugin-react-hooks/exhaustive-deps
|
||||
import { Box, toRem } from 'folds';
|
||||
import * as css from '$pages/client/sidebar/SidebarResizer.css';
|
||||
import type { Dispatch, SetStateAction } from 'react';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
export function SidebarResizer({
|
||||
sidebarWidth,
|
||||
setSidebarWidth,
|
||||
setCurWidth,
|
||||
minValue,
|
||||
maxValue,
|
||||
instep,
|
||||
outstep,
|
||||
isReversed,
|
||||
topSided,
|
||||
}: {
|
||||
sidebarWidth: number;
|
||||
setSidebarWidth: (arg0: number) => void;
|
||||
setCurWidth?: Dispatch<SetStateAction<number>>;
|
||||
minValue: number;
|
||||
maxValue: number;
|
||||
instep?: number;
|
||||
outstep?: number;
|
||||
isReversed?: boolean;
|
||||
topSided?: boolean;
|
||||
}) {
|
||||
const [isPointerOver, setIsPointerOver] = useState(false);
|
||||
const [isPointerDown, setIsPointerDown] = useState(false);
|
||||
const [oldPos, setOldPos] = useState(0);
|
||||
const [interimPos, setInterimPos] = useState(0);
|
||||
const [newPos, setNewPos] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const change = isReversed ? -(oldPos - newPos) : oldPos - newPos;
|
||||
let newValue = Math.min(Math.max(sidebarWidth - change, minValue), maxValue);
|
||||
if (instep && outstep && newValue > instep && newValue < outstep)
|
||||
newValue = newValue > (instep + outstep) / 2 ? outstep : instep;
|
||||
|
||||
if (change) setSidebarWidth(newValue);
|
||||
}, [newPos]);
|
||||
|
||||
useEffect(() => {
|
||||
const change = isReversed ? -(oldPos - interimPos) : oldPos - interimPos;
|
||||
let newValue = Math.min(Math.max(sidebarWidth - change, minValue), maxValue);
|
||||
if (instep && outstep && newValue > instep && newValue < outstep)
|
||||
newValue = newValue > (instep + outstep) / 2 ? outstep : instep;
|
||||
if (change && setCurWidth) setCurWidth(newValue);
|
||||
}, [interimPos]);
|
||||
|
||||
const onPointerMove = useCallback((e: PointerEvent) => {
|
||||
e.preventDefault();
|
||||
setInterimPos(topSided ? e.clientY : e.clientX);
|
||||
}, []);
|
||||
const onPointerUp = useCallback((e: PointerEvent) => {
|
||||
e.preventDefault();
|
||||
setNewPos(topSided ? e.clientY : e.clientX);
|
||||
setIsPointerDown(false);
|
||||
window.removeEventListener('pointerup', onPointerUp);
|
||||
window.removeEventListener('pointermove', onPointerMove);
|
||||
}, []);
|
||||
|
||||
const onPointerDown = useCallback(
|
||||
(e: React.PointerEvent) => {
|
||||
e.preventDefault();
|
||||
setOldPos(topSided ? e.clientY : e.clientX);
|
||||
setIsPointerDown(true);
|
||||
window.addEventListener('pointerup', onPointerUp);
|
||||
window.addEventListener('pointermove', onPointerMove);
|
||||
},
|
||||
[onPointerUp, onPointerMove]
|
||||
);
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={`${css.SidebarResizer} ${isPointerOver || isPointerDown ? css.SidebarResizerHover : ''}`}
|
||||
onPointerEnter={() => setIsPointerOver(true)}
|
||||
onPointerLeave={() => setIsPointerOver(false)}
|
||||
onPointerDown={onPointerDown}
|
||||
style={{
|
||||
width: topSided ? '100%' : toRem(4),
|
||||
height: topSided ? toRem(4) : '100%',
|
||||
}}
|
||||
shrink="No"
|
||||
>
|
||||
<Box
|
||||
shrink="No"
|
||||
className={css.SideBarResizerAnimation}
|
||||
style={{ opacity: isPointerOver || isPointerDown ? '100%' : '0%' }}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import type { VirtualItem } from '@tanstack/react-virtual';
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { Room, RoomJoinRulesEventContent } from '$types/matrix-sdk';
|
||||
import type { MatrixClient, Room, RoomJoinRulesEventContent } from '$types/matrix-sdk';
|
||||
import { JoinRule, EventType, KnownMembership } from '$types/matrix-sdk';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { mDirectAtom } from '$state/mDirectList';
|
||||
@@ -62,7 +62,7 @@ import { stopPropagation } from '$utils/keyboard';
|
||||
import { getMatrixToRoom } from '$plugins/matrix-to';
|
||||
import { getViaServers } from '$plugins/via-servers';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { settingsAtom, ShowRoomIcon } from '$state/settings';
|
||||
import {
|
||||
getRoomNotificationMode,
|
||||
useRoomsNotificationPreferencesContext,
|
||||
@@ -80,6 +80,12 @@ import { lastVisitedRoomIdAtom } from '$state/room/lastRoom';
|
||||
import { SwipeableOverlayWrapper } from '$components/SwipeableOverlayWrapper';
|
||||
import { useCallEmbed } from '$hooks/useCallEmbed';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { RoomAvatar } from '$components/room-avatar';
|
||||
import { getRoomAvatarUrl } from '$utils/room';
|
||||
import { nameInitials } from '$utils/common';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
|
||||
const debugLog = createDebugLogger('Space');
|
||||
|
||||
@@ -243,10 +249,11 @@ const SpaceMenu = forwardRef<HTMLDivElement, SpaceMenuProps>(({ room, requestClo
|
||||
);
|
||||
});
|
||||
|
||||
function SpaceHeader() {
|
||||
function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient }) {
|
||||
const space = useSpace();
|
||||
const spaceName = useRoomName(space);
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
|
||||
const joinRules = useStateEvent(
|
||||
space,
|
||||
@@ -264,18 +271,40 @@ function SpaceHeader() {
|
||||
return (
|
||||
<>
|
||||
<PageNavHeader>
|
||||
<Box alignItems="Center" grow="Yes" gap="300">
|
||||
<Box grow="Yes" alignItems="Center" gap="100">
|
||||
<Text size="H4" truncate>
|
||||
{spaceName}
|
||||
</Text>
|
||||
{joinRules?.join_rule !== JoinRule.Public && <Icon src={Icons.Lock} size="50" />}
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton aria-pressed={!!menuAnchor} variant="Background" onClick={handleOpenMenu}>
|
||||
<Icon src={Icons.VerticalDots} size="200" />
|
||||
</IconButton>
|
||||
</Box>
|
||||
<Box alignItems="Center" grow="Yes" gap="300" justifyContent="Center">
|
||||
{hideText ? (
|
||||
<Avatar size={hideText ? undefined : '200'} radii="400" onClick={handleOpenMenu}>
|
||||
<RoomAvatar
|
||||
roomId={space.roomId}
|
||||
src={getRoomAvatarUrl(mx, space, 96, useAuthentication)}
|
||||
uniformIcons
|
||||
alt={spaceName}
|
||||
renderFallback={() => (
|
||||
<Text as="span" size="H6">
|
||||
{nameInitials(spaceName)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
) : (
|
||||
<>
|
||||
<Box grow="Yes" alignItems="Center" gap="100">
|
||||
<Text size="H4" truncate>
|
||||
{spaceName}
|
||||
</Text>
|
||||
{joinRules?.join_rule !== JoinRule.Public && <Icon src={Icons.Lock} size="50" />}
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton
|
||||
aria-pressed={!!menuAnchor}
|
||||
variant="Background"
|
||||
onClick={handleOpenMenu}
|
||||
>
|
||||
<Icon src={Icons.VerticalDots} size="200" />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
{menuAnchor && (
|
||||
@@ -389,6 +418,20 @@ export function Space() {
|
||||
const allJoinedRooms = useMemo(() => new Set(allRooms), [allRooms]);
|
||||
const notificationPreferences = useRoomsNotificationPreferencesContext();
|
||||
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
const [showRoomIcon] = useSetting(settingsAtom, 'showRoomIcon');
|
||||
const showIcons = () => {
|
||||
if (showRoomIcon === ShowRoomIcon.Always) return true;
|
||||
if (showRoomIcon === ShowRoomIcon.Never) return false;
|
||||
return curWidth < 144;
|
||||
};
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const [joinCallOnSingleClick] = useSetting(settingsAtom, 'joinCallOnSingleClick');
|
||||
|
||||
const tombstoneEvent = useStateEvent(space, EventType.RoomTombstone);
|
||||
const selectedRoomId = useSelectedRoom();
|
||||
const lobbySelected = useSpaceLobbySelected(spaceIdOrAlias);
|
||||
@@ -710,143 +753,195 @@ export function Space() {
|
||||
}
|
||||
}, [lastRoomId, spaceIdOrAlias, mx, navigate]);
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = mobileOrTablet() || screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
return (
|
||||
<PageNav>
|
||||
<SwipeableOverlayWrapper direction="left" onClose={handleSwipeToRoom}>
|
||||
<SpaceHeader />
|
||||
<PageNavContent scrollRef={scrollRef}>
|
||||
<Box direction="Column" gap="300">
|
||||
{tombstoneEvent && (
|
||||
<SpaceTombstone
|
||||
roomId={space.roomId}
|
||||
replacementRoomId={tombstoneEvent.getContent().replacement_room}
|
||||
/>
|
||||
)}
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={lobbySelected}>
|
||||
<NavLink to={getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, space.roomId))}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Flag} size="100" filled={lobbySelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Lobby
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
<NavItem variant="Background" radii="400" aria-selected={searchSelected}>
|
||||
<NavLink to={getSpaceSearchPath(getCanonicalAliasOrRoomId(mx, space.roomId))}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
<Icon src={Icons.Search} size="100" filled={searchSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Message Search
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
</NavCategory>
|
||||
<NavCategory
|
||||
style={{
|
||||
height: virtualizer.getTotalSize(),
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
{virtualizedItems.map((vItem) => {
|
||||
const hierarchyItem = hierarchy[vItem.index];
|
||||
if (!hierarchyItem) return null;
|
||||
const { roomId, depth: itemDepth } = hierarchyItem;
|
||||
const depth = itemDepth ?? 0;
|
||||
const room = mx.getRoom(roomId);
|
||||
const renderDepth = room?.isSpaceRoom() ? depth - 2 : depth - 1;
|
||||
if (!room) return null;
|
||||
if (depth === subspaceHierarchyLimit && room.isSpaceRoom()) {
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
paddingLeft: `calc(${renderDepth} * ${config.space.S400})`,
|
||||
}}
|
||||
>
|
||||
<SpaceNavItem
|
||||
room={room}
|
||||
selected={selectedRoomId === roomId}
|
||||
linkPath={getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
}
|
||||
|
||||
const paddingTop = getCategoryPadding(depth);
|
||||
const paddingLeft = `calc(${renderDepth} * ${config.space.S400})`;
|
||||
|
||||
if (room.isSpaceRoom()) {
|
||||
const categoryId = makeNavCategoryId(space.roomId, roomId);
|
||||
const closedViaCategory = getInClosedCategories(space.roomId, roomId);
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div style={{ paddingTop, paddingLeft }}>
|
||||
<NavCategoryHeader>
|
||||
<RoomNavCategoryButton
|
||||
data-category-id={categoryId}
|
||||
onClick={handleCategoryClick}
|
||||
closed={closedCategories.has(categoryId) || closedViaCategory}
|
||||
<>
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<SwipeableOverlayWrapper direction="left" onClose={handleSwipeToRoom}>
|
||||
<SpaceHeader hideText={hideText} mx={mx} />
|
||||
<PageNavContent scrollRef={scrollRef}>
|
||||
<Box direction="Column" gap="300">
|
||||
{tombstoneEvent && (
|
||||
<SpaceTombstone
|
||||
roomId={space.roomId}
|
||||
replacementRoomId={tombstoneEvent.getContent().replacement_room}
|
||||
/>
|
||||
)}
|
||||
<NavCategory>
|
||||
<NavItem variant="Background" radii="400" aria-selected={lobbySelected}>
|
||||
<NavLink to={getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, space.roomId))}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%', padding: '0' } : { height: '100%' }}
|
||||
>
|
||||
{roomId === space.roomId ? 'Rooms' : room?.name}
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
}
|
||||
<Icon src={Icons.Flag} size="100" filled={lobbySelected} />
|
||||
</Avatar>
|
||||
{!hideText && (
|
||||
<Box as="span" grow="Yes">
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Lobby
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
<NavItem variant="Background" radii="400" aria-selected={searchSelected}>
|
||||
<NavLink to={getSpaceSearchPath(getCanonicalAliasOrRoomId(mx, space.roomId))}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar
|
||||
radii="400"
|
||||
style={hideText ? { width: '100%' } : { height: '100%' }}
|
||||
>
|
||||
<Icon src={Icons.Search} size="100" filled={searchSelected} />
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
{!hideText && (
|
||||
<Text as="span" size="Inherit" truncate>
|
||||
Message Search
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
</NavCategory>
|
||||
<NavCategory
|
||||
style={{
|
||||
height: virtualizer.getTotalSize(),
|
||||
position: 'relative',
|
||||
overflow: 'visible',
|
||||
}}
|
||||
>
|
||||
{virtualizedItems.map((vItem) => {
|
||||
const hierarchyItem = hierarchy[vItem.index];
|
||||
if (!hierarchyItem) return null;
|
||||
const { roomId, depth: itemDepth } = hierarchyItem;
|
||||
const depth = itemDepth ?? 0;
|
||||
const room = mx.getRoom(roomId);
|
||||
const renderDepth = room?.isSpaceRoom() ? depth - 2 : depth - 1;
|
||||
if (!room) return null;
|
||||
if (depth === subspaceHierarchyLimit && room.isSpaceRoom()) {
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div
|
||||
style={
|
||||
hideText
|
||||
? {}
|
||||
: {
|
||||
paddingLeft: `calc(${renderDepth} * ${config.space.S400})`,
|
||||
}
|
||||
}
|
||||
>
|
||||
<SpaceNavItem
|
||||
room={room}
|
||||
selected={selectedRoomId === roomId}
|
||||
linkPath={getSpaceLobbyPath(getCanonicalAliasOrRoomId(mx, roomId))}
|
||||
hideText={hideText}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div style={{ paddingLeft }}>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selectedRoomId === roomId}
|
||||
showAvatar={mDirects.has(roomId)}
|
||||
direct={mDirects.has(roomId)}
|
||||
linkPath={getToLink(roomId)}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
{getConnectorSVG(hierarchy, virtualizedItems)}
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</SwipeableOverlayWrapper>
|
||||
</PageNav>
|
||||
const paddingTop = getCategoryPadding(depth);
|
||||
const paddingLeft = `calc(${renderDepth} * ${config.space.S400})`;
|
||||
|
||||
if (room.isSpaceRoom()) {
|
||||
const categoryId = makeNavCategoryId(space.roomId, roomId);
|
||||
const closedViaCategory = getInClosedCategories(space.roomId, roomId);
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div style={hideText ? { paddingTop: '0' } : { paddingTop, paddingLeft }}>
|
||||
<NavCategoryHeader style={hideText ? { justifyContent: 'Center' } : {}}>
|
||||
<RoomNavCategoryButton
|
||||
data-category-id={categoryId}
|
||||
onClick={handleCategoryClick}
|
||||
closed={closedCategories.has(categoryId) || closedViaCategory}
|
||||
>
|
||||
{!hideText && (roomId === space.roomId ? 'Rooms' : room?.name)}
|
||||
</RoomNavCategoryButton>
|
||||
</NavCategoryHeader>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
virtualItem={vItem}
|
||||
key={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
>
|
||||
<div
|
||||
style={
|
||||
hideText
|
||||
? {
|
||||
padding: '0',
|
||||
width: '100%',
|
||||
aspectRatio: 1,
|
||||
display: 'flex',
|
||||
}
|
||||
: { paddingLeft }
|
||||
}
|
||||
>
|
||||
<RoomNavItem
|
||||
room={room}
|
||||
selected={selectedRoomId === roomId}
|
||||
showAvatar={mDirects.has(roomId) || showIcons()}
|
||||
direct={mDirects.has(roomId)}
|
||||
linkPath={getToLink(roomId)}
|
||||
hideText={hideText}
|
||||
notificationMode={getRoomNotificationMode(
|
||||
notificationPreferences,
|
||||
room.roomId
|
||||
)}
|
||||
joinCallOnSingleClick={joinCallOnSingleClick}
|
||||
/>
|
||||
</div>
|
||||
</VirtualTile>
|
||||
);
|
||||
})}
|
||||
{getConnectorSVG(hierarchy, virtualizedItems)}
|
||||
</NavCategory>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
</SwipeableOverlayWrapper>
|
||||
</PageNav>
|
||||
</Box>
|
||||
{!mobileOrTablet() && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={80}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -22,6 +22,12 @@ export enum CaptionPosition {
|
||||
Hidden = 'hidden',
|
||||
Below = 'below',
|
||||
}
|
||||
|
||||
export enum ShowRoomIcon {
|
||||
Always = 'always',
|
||||
Smart = 'smart',
|
||||
Never = 'never',
|
||||
}
|
||||
export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge';
|
||||
|
||||
export type ThemeRemoteFavorite = {
|
||||
@@ -146,6 +152,7 @@ export interface Settings {
|
||||
saveStickerEmojiBandwidth: boolean;
|
||||
subspaceHierarchyLimit: number;
|
||||
alwaysShowCallButton: boolean;
|
||||
joinCallOnSingleClick: boolean;
|
||||
faviconForMentionsOnly: boolean;
|
||||
highlightMentions: boolean;
|
||||
pkCompat: boolean;
|
||||
@@ -153,6 +160,13 @@ export interface Settings {
|
||||
mentionInReplies: boolean;
|
||||
showPersonaSetting: boolean;
|
||||
closeFoldersByDefault: boolean;
|
||||
showRoomIcon: ShowRoomIcon;
|
||||
roomSidebarWidth: number;
|
||||
memberSidebarWidth: number;
|
||||
threadSidebarWidth: number;
|
||||
threadRootHeight: number;
|
||||
vcmsgSidebarWidth: number;
|
||||
widgetSidebarWidth: number;
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: boolean;
|
||||
@@ -268,6 +282,7 @@ export const defaultSettings: Settings = {
|
||||
saveStickerEmojiBandwidth: false,
|
||||
subspaceHierarchyLimit: 3,
|
||||
alwaysShowCallButton: false,
|
||||
joinCallOnSingleClick: true,
|
||||
faviconForMentionsOnly: false,
|
||||
highlightMentions: true,
|
||||
pkCompat: false,
|
||||
@@ -275,7 +290,13 @@ export const defaultSettings: Settings = {
|
||||
mentionInReplies: true,
|
||||
showPersonaSetting: false,
|
||||
closeFoldersByDefault: false,
|
||||
|
||||
showRoomIcon: ShowRoomIcon.Smart,
|
||||
roomSidebarWidth: 256,
|
||||
memberSidebarWidth: 262,
|
||||
threadSidebarWidth: 440,
|
||||
threadRootHeight: 220,
|
||||
vcmsgSidebarWidth: 399,
|
||||
widgetSidebarWidth: 420,
|
||||
// furry stuff
|
||||
renderAnimals: true,
|
||||
|
||||
|
||||
Reference in new issue
Block a user