From 7eb5767f3545f6841952d1f7ff0fd96b4a4a96fb Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Sun, 3 May 2026 23:14:16 +0300 Subject: [PATCH] initial modifiable version --- src/app/components/page/style.css.ts | 3 - src/app/pages/client/direct/Direct.tsx | 155 +++++----- src/app/pages/client/explore/Explore.tsx | 178 +++++------ src/app/pages/client/home/Home.tsx | 256 ++++++++-------- src/app/pages/client/inbox/Inbox.tsx | 83 +++--- .../client/sidebar/SidebarResizer.css.ts | 20 ++ .../pages/client/sidebar/SidebarResizer.tsx | 49 +++ src/app/pages/client/space/Space.tsx | 278 +++++++++--------- src/app/state/settings.ts | 2 + 9 files changed, 571 insertions(+), 453 deletions(-) create mode 100644 src/app/pages/client/sidebar/SidebarResizer.css.ts create mode 100644 src/app/pages/client/sidebar/SidebarResizer.tsx diff --git a/src/app/components/page/style.css.ts b/src/app/components/page/style.css.ts index d35fa651d..6d9343c7e 100644 --- a/src/app/components/page/style.css.ts +++ b/src/app/components/page/style.css.ts @@ -14,9 +14,6 @@ export const PageNav = recipe({ }, }, }, - defaultVariants: { - size: '400', - }, }); export type PageNavVariants = RecipeVariants; diff --git a/src/app/pages/client/direct/Direct.tsx b/src/app/pages/client/direct/Direct.tsx index e84e04daa..6a3f7c3c5 100644 --- a/src/app/pages/client/direct/Direct.tsx +++ b/src/app/pages/client/direct/Direct.tsx @@ -53,6 +53,7 @@ import { } from '$hooks/useRoomsNotificationPreferences'; import { useDirectCreateSelected } from '$hooks/router/useDirectSelected'; import { useDirectRooms } from './useDirectRooms'; +import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer'; type DirectMenuProps = { requestClose: () => void; @@ -179,6 +180,7 @@ export function Direct() { const roomToUnread = useAtomValue(roomToUnreadAtom); const navigate = useNavigate(); const [customDMCards] = useSetting(settingsAtom, 'customDMCards'); + const [roomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); const createDirectSelected = useDirectCreateSelected(); @@ -238,80 +240,85 @@ export function Direct() { ); return ( - - - {noRoomToDisplay ? ( - - ) : ( - - - - - navigate(getDirectCreatePath())}> - - - - - - - - Create Chat - - - - - - - - - - - Chats - - -
- {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 ( - +
+ + + {noRoomToDisplay ? ( + + ) : ( + + + + + navigate(getDirectCreatePath())}> + + + + + + + + Create Chat + + + + + + + + + + - - - ); - })} -
- - - - )} - + Chats + + +
+ {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 ( + + + + ); + })} +
+ + + + )} + +
+ + ); } diff --git a/src/app/pages/client/explore/Explore.tsx b/src/app/pages/client/explore/Explore.tsx index cf4f69297..aa843575a 100644 --- a/src/app/pages/client/explore/Explore.tsx +++ b/src/app/pages/client/explore/Explore.tsx @@ -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'; @@ -29,6 +30,9 @@ 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'; export function AddServer() { const mx = useMatrixClient(); @@ -159,101 +163,111 @@ export function Explore() { const featuredSelected = useExploreFeaturedSelected(); const selectedServer = useExploreServer(); + const [roomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); return ( - - - - - - Explore Community - - - - - - - - - - - - - - - - - - Featured - - - - - - - {userServer && ( - - - - - - - - - - {userServer} - - - - - - - )} - - {servers.length > 0 && ( - - - - Servers + <> +
+ + + + + + Explore Community - - {servers.map((server) => ( - - + + + + + + + + + - + - {server} + Featured - ))} - - )} - - - - - - + {userServer && ( + + + + + + + + + + {userServer} + + + + + + + )} + + {servers.length > 0 && ( + + + + Servers + + + {servers.map((server) => ( + + + + + + + + + + {server} + + + + + + + ))} + + )} + + + + + + +
+ + ); } diff --git a/src/app/pages/client/home/Home.tsx b/src/app/pages/client/home/Home.tsx index afd4de936..e30af0320 100644 --- a/src/app/pages/client/home/Home.tsx +++ b/src/app/pages/client/home/Home.tsx @@ -62,6 +62,7 @@ import { import { UseStateProvider } from '$components/UseStateProvider'; import { JoinAddressPrompt } from '$components/join-address-prompt'; import { useHomeRooms } from './useHomeRooms'; +import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer'; type HomeMenuProps = { requestClose: () => void; @@ -200,6 +201,8 @@ export function Home() { const roomToUnread = useAtomValue(roomToUnreadAtom); const navigate = useNavigate(); + const [roomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); + const selectedRoomId = useSelectedRoom(); const createRoomSelected = useHomeCreateSelected(); const searchSelected = useHomeSearchSelected(); @@ -234,131 +237,136 @@ export function Home() { ); return ( - - - {noRoomToDisplay ? ( - - ) : ( - - - - - navigate(getHomeCreatePath())}> - - - - - - - - Create Room - - - - - - - - {(open, setOpen) => ( - <> - - setOpen(true)}> - - - - - - - - Join with Address - - + <> +
+ + + {noRoomToDisplay ? ( + + ) : ( + + + + + navigate(getHomeCreatePath())}> + + + + + + + + Create Room + - - - - {open && ( - setOpen(false)} - onOpen={(roomIdOrAlias, viaServers, eventId) => { - setOpen(false); - const path = getHomeRoomPath(roomIdOrAlias, eventId); - navigate( - viaServers - ? withSearchParam(path, { - viaServers: encodeSearchParamValueArray(viaServers), - }) - : path - ); - }} - /> - )} - - )} - - - - - - - - - - - Message Search - - - - - - - - - - - Rooms - - -
- {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 ( - - + + + + + {(open, setOpen) => ( + <> + + setOpen(true)}> + + + + + + + + Join with Address + + + + + + + {open && ( + setOpen(false)} + onOpen={(roomIdOrAlias, viaServers, eventId) => { + setOpen(false); + const path = getHomeRoomPath(roomIdOrAlias, eventId); + navigate( + viaServers + ? withSearchParam(path, { + viaServers: encodeSearchParamValueArray(viaServers), + }) + : path + ); + }} + /> )} - /> - - ); - })} -
-
-
-
- )} -
+ + )} + + + + + + + + + + + Message Search + + + + + + + + + + + Rooms + + +
+ {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 ( + + + + ); + })} +
+
+ + + )} + +
+ + ); } diff --git a/src/app/pages/client/inbox/Inbox.tsx b/src/app/pages/client/inbox/Inbox.tsx index 661435513..5d982a39a 100644 --- a/src/app/pages/client/inbox/Inbox.tsx +++ b/src/app/pages/client/inbox/Inbox.tsx @@ -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,6 +7,9 @@ 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'; function InvitesNavItem() { const invitesSelected = useInboxInvitesSelected(); @@ -43,41 +46,51 @@ export function Inbox() { useNavToActivePathMapper('inbox'); const notificationsSelected = useInboxNotificationsSelected(); + const [roomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); return ( - - - - - - Inbox - - - - + <> +
+ + + + + + Inbox + + + + - - - - - - - - - - - - - Notifications - - - - - - - - - - - + + + + + + + + + + + + + Notifications + + + + + + + + + + + +
+ + ); } diff --git a/src/app/pages/client/sidebar/SidebarResizer.css.ts b/src/app/pages/client/sidebar/SidebarResizer.css.ts new file mode 100644 index 000000000..fe0a79eda --- /dev/null +++ b/src/app/pages/client/sidebar/SidebarResizer.css.ts @@ -0,0 +1,20 @@ +import { style } from '@vanilla-extract/css'; +import { color } from 'folds'; + +export const SidebarResizer = style({ + width: '4px', + backgroundColor: 'inherit', + transition: '0.2s', + selectors: { + '&:hover': { + height: '100%', + zIndex: '100', + boxShadow: `0px 0px 32px 8px ${color.Primary.Container}`, + }, + }, +}); +export const SideBarResizerAnimation = style({ + width: '100%', + backgroundColor: color.Primary.Container, + transition: '0.2s', +}); diff --git a/src/app/pages/client/sidebar/SidebarResizer.tsx b/src/app/pages/client/sidebar/SidebarResizer.tsx new file mode 100644 index 000000000..23b26e7e5 --- /dev/null +++ b/src/app/pages/client/sidebar/SidebarResizer.tsx @@ -0,0 +1,49 @@ +import { Box } from 'folds'; +import * as css from '$pages/client/sidebar/SidebarResizer.css'; +import type { SetStateAction } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; +import { settingsAtom } from '$state/settings'; +import { useSetting } from '$state/hooks/settings'; + +export function SidebarResizer() { + const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); + + const [isPointerOver, setIsPointerOver] = useState(false); + const [oldX, setOldX] = useState(0); + const [newX, setNewX] = useState(0); + + useEffect(() => { + const change = oldX - newX; + if (change) setRoomSidebarWidth(Math.max(roomSidebarWidth - change, 0)); + // The disable is because the position should only update whenever the new one is updated + // oxlint-disable-next-line eslint-plugin-react-hooks/exhaustive-deps + }, [newX]); + const onMouseUp = useCallback((e: { clientX: SetStateAction }) => { + setNewX(e.clientX); + window.removeEventListener('pointerup', onMouseUp); + }, []); + + const onMouseDown = useCallback( + (e: React.PointerEvent) => { + e.preventDefault(); + setOldX(e.clientX); + window.addEventListener('pointerup', onMouseUp); + }, + [onMouseUp] + ); + + return ( + setIsPointerOver(true)} + onPointerLeave={() => setIsPointerOver(false)} + onPointerDown={onMouseDown} + onPointerUp={onMouseUp} + > + + + ); +} diff --git a/src/app/pages/client/space/Space.tsx b/src/app/pages/client/space/Space.tsx index c4994d829..ba391fd0c 100644 --- a/src/app/pages/client/space/Space.tsx +++ b/src/app/pages/client/space/Space.tsx @@ -80,6 +80,7 @@ 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'; const debugLog = createDebugLogger('Space'); @@ -389,6 +390,8 @@ export function Space() { const allJoinedRooms = useMemo(() => new Set(allRooms), [allRooms]); const notificationPreferences = useRoomsNotificationPreferencesContext(); + const [roomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth'); + const tombstoneEvent = useStateEvent(space, EventType.RoomTombstone); const selectedRoomId = useSelectedRoom(); const lobbySelected = useSpaceLobbySelected(spaceIdOrAlias); @@ -711,142 +714,147 @@ export function Space() { }, [lastRoomId, spaceIdOrAlias, mx, navigate]); return ( - - - - - - {tombstoneEvent && ( - - )} - - - - - - - - - - - Lobby - - - - - - - - - - - - - - - - Message Search - - - - - - - - - {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 ( - -
- -
-
- ); - } - - 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 ( - -
- - +
+ + + + + + {tombstoneEvent && ( + + )} + + + + + + + + + + + Lobby + + + + + + + + + + + + + + + + Message Search + + + + + + + + + {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 ( + +
- {roomId === space.roomId ? 'Rooms' : room?.name} - - -
-
- ); - } + +
+ + ); + } - return ( - -
- -
-
- ); - })} - {getConnectorSVG(hierarchy, virtualizedItems)} - - - - - + 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 ( + +
+ + + {roomId === space.roomId ? 'Rooms' : room?.name} + + +
+
+ ); + } + + return ( + +
+ +
+
+ ); + })} + {getConnectorSVG(hierarchy, virtualizedItems)} + + + + + +
+ + ); } diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 83532c673..369816115 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -118,6 +118,7 @@ export interface Settings { mentionInReplies: boolean; showPersonaSetting: boolean; closeFoldersByDefault: boolean; + roomSidebarWidth: number; // furry stuff renderAnimals: boolean; @@ -219,6 +220,7 @@ const defaultSettings: Settings = { mentionInReplies: true, showPersonaSetting: false, closeFoldersByDefault: false, + roomSidebarWidth: 400, // furry stuff renderAnimals: true,