'fix' resizing

Signed-off-by: Shea <[email protected]>
This commit is contained in:
Shea committed 2026-06-21 10:25:23 +03:00
1 parent 856cbb7ef7
commit b06f55fffd
19 files changed
+353 -274

No files matched your search

@@ -27,6 +27,7 @@ export const SidebarStack = style([
alignItems: 'center',
gap: config.space.S300,
padding: `${config.space.S300} 0`,
paddingBottom: config.space.S200,
},
]);
+23 -4
View File
@@ -24,11 +24,30 @@ export const SidebarItemLeft = as<'div', css.SidebarItemVariants>(
)
);
export const SidebarItem = ({className, active, isBottom, children, ...props} : {className?: string, active?: boolean, isBottom?: boolean, children: ReactNode}) => {
if(isBottom)
return <SidebarItemBottom className={className} active={active} {...props}>{children}</SidebarItemBottom>
export const SidebarItem = ({
className,
active,
isBottom,
children,
...props
}: {
className?: string;
active?: boolean;
isBottom?: boolean;
children: ReactNode;
}) => {
if (isBottom)
return (
<SidebarItemBottom className={className} active={active} {...props}>
{children}
</SidebarItemBottom>
);
else
return <SidebarItemLeft className={className} active={active} {...props}>{children}</SidebarItemLeft>
return (
<SidebarItemLeft className={className} active={active} {...props}>
{children}
</SidebarItemLeft>
);
};
export const SidebarItemBadge = as<'div', css.SidebarItemBadgeVariants>(
+116 -154
View File
@@ -1,18 +1,6 @@
import type { MouseEventHandler } from 'react';
import { useRef, useState } from 'react';
import {
Box,
Checkbox,
color,
config,
Line,
Menu,
MenuItem,
PopOut,
Scroll,
Text,
toRem,
} from 'folds';
import { Box, Checkbox, config, Line, Menu, MenuItem, PopOut, Scroll, Text, toRem } from 'folds';
import FocusTrap from 'focus-trap-react';
import { stopPropagation } from '$utils/keyboard';
import { useSetting } from '$state/hooks/settings';
@@ -30,6 +18,7 @@ import {
import { CreateTab } from './sidebar/CreateTab';
import { SearchTab } from './sidebar/SearchTab';
import { SettingsTab } from './sidebar/SettingsTab';
import { UserQuickTools } from './sidebar/UserQuickTools';
export function SidebarNav() {
const scrollRef = useRef<HTMLDivElement>(null);
@@ -39,11 +28,12 @@ export function SidebarNav() {
const [showUnreadCounts, setShowUnreadCounts] = useSetting(settingsAtom, 'showUnreadCounts');
const [badgeCountDMsOnly, setBadgeCountDMsOnly] = useSetting(settingsAtom, 'badgeCountDMsOnly');
const [showPingCounts, setShowPingCounts] = useSetting(settingsAtom, 'showPingCounts');
const [roomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const width = roomSidebarWidth + 66;
const underOutstep = width < (190 + 66);
const isCollapsed = width < (50 + 66);
const underOutstep = width < 190 + 66;
const isCollapsed = width < 50 + 66;
const handleContextMenu: MouseEventHandler<HTMLDivElement> = (evt) => {
const target = evt.target as HTMLElement;
@@ -54,146 +44,118 @@ export function SidebarNav() {
};
return (
<Sidebar onContextMenu={handleContextMenu}>
{menuAnchor && (
<PopOut
anchor={menuAnchor}
position="Right"
align="Start"
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,
}}
>
<Menu style={{ maxWidth: toRem(208), width: '100vw' }}>
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
<MenuItem
size="300"
radii="300"
aria-pressed={showUnreadCounts}
onClick={() => setShowUnreadCounts(!showUnreadCounts)}
after={
<Checkbox size="100" checked={showUnreadCounts} readOnly tabIndex={-1} />
}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Show Room Counts
</Text>
</MenuItem>
<MenuItem
size="300"
radii="300"
aria-pressed={badgeCountDMsOnly}
onClick={() => setBadgeCountDMsOnly(!badgeCountDMsOnly)}
after={
<Checkbox size="100" checked={badgeCountDMsOnly} readOnly tabIndex={-1} />
}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Show DM Counts
</Text>
</MenuItem>
<MenuItem
size="300"
radii="300"
aria-pressed={showPingCounts}
onClick={() => setShowPingCounts(!showPingCounts)}
after={<Checkbox size="100" checked={showPingCounts} readOnly tabIndex={-1} />}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Show Mention Counts
</Text>
</MenuItem>
</Box>
<Line variant="Surface" size="300" />
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
<MenuItem
size="300"
radii="300"
aria-pressed={uniformIcons}
onClick={() => setUniformIcons(!uniformIcons)}
after={<Checkbox size="100" checked={uniformIcons} readOnly tabIndex={-1} />}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Consistent Icon Style
</Text>
</MenuItem>
</Box>
</Menu>
</FocusTrap>
<>
<Sidebar onContextMenu={handleContextMenu}>
{menuAnchor && (
<PopOut
anchor={menuAnchor}
position="Right"
align="Start"
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,
}}
>
<Menu style={{ maxWidth: toRem(208), width: '100vw' }}>
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
<MenuItem
size="300"
radii="300"
aria-pressed={showUnreadCounts}
onClick={() => setShowUnreadCounts(!showUnreadCounts)}
after={
<Checkbox size="100" checked={showUnreadCounts} readOnly tabIndex={-1} />
}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Show Room Counts
</Text>
</MenuItem>
<MenuItem
size="300"
radii="300"
aria-pressed={badgeCountDMsOnly}
onClick={() => setBadgeCountDMsOnly(!badgeCountDMsOnly)}
after={
<Checkbox size="100" checked={badgeCountDMsOnly} readOnly tabIndex={-1} />
}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Show DM Counts
</Text>
</MenuItem>
<MenuItem
size="300"
radii="300"
aria-pressed={showPingCounts}
onClick={() => setShowPingCounts(!showPingCounts)}
after={
<Checkbox size="100" checked={showPingCounts} readOnly tabIndex={-1} />
}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Show Mention Counts
</Text>
</MenuItem>
</Box>
<Line variant="Surface" size="300" />
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
<MenuItem
size="300"
radii="300"
aria-pressed={uniformIcons}
onClick={() => setUniformIcons(!uniformIcons)}
after={<Checkbox size="100" checked={uniformIcons} readOnly tabIndex={-1} />}
>
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
Consistent Icon Style
</Text>
</MenuItem>
</Box>
</Menu>
</FocusTrap>
}
/>
)}
<SidebarContent
scrollable={
<Scroll ref={scrollRef} variant="Background" size="0">
<SidebarStack>
<HomeTab />
<DirectTab />
<DirectDMsList />
</SidebarStack>
<SpaceTabs scrollRef={scrollRef} />
<SidebarStack>
<CreateTab />
</SidebarStack>
</Scroll>
}
sticky={
<SidebarStack>
{underOutstep && (
<>
<SearchTab />
<UnverifiedTab />
<InboxTab />
</>
)}
{isCollapsed && <SettingsTab />}
<AccountSwitcherTab />
</SidebarStack>
}
/>
)}
<SidebarContent
scrollable={
<Scroll ref={scrollRef} variant="Background" size="0">
<SidebarStack>
<HomeTab />
<DirectTab />
<DirectDMsList />
</SidebarStack>
<SpaceTabs scrollRef={scrollRef} />
<SidebarStack>
<CreateTab />
</SidebarStack>
</Scroll>
}
sticky={
<SidebarStack>
{underOutstep && (
<>
<UnverifiedTab />
<InboxTab />
<SearchTab />
</>
)}
{isCollapsed && <SettingsTab />}
<AccountSwitcherTab />
</SidebarStack>
}
/>
{/* Doing it properly and nicely would require a major rewrite that would cause more trouble*/}
{!isCollapsed && (
<Box
direction="Row"
justifyContent="SpaceBetween"
style={{
backgroundColor: color.SurfaceVariant.Container,
position: 'fixed',
zIndex: '1000',
width: toRem(width),
height: toRem(58),
bottom: '0',
left: '0',
padding: config.space.S300,
paddingRight: underOutstep ? config.space.S200 : config.space.S300,
borderTop: `${config.borderWidth.B300} solid ${color.Background.ContainerLine}`,
}}
>
<AccountSwitcherTab isBottom/>
<Box
style={{
gap: config.space.S300,
}}
>
{!underOutstep && (
<>
<UnverifiedTab isBottom/>
<InboxTab isBottom/>
<SearchTab isBottom/>
</>
)}
<SettingsTab isBottom />
</Box>
</Box>
)}
</Sidebar>
</Sidebar>
<UserQuickTools width={width} />
</>
);
}
+88 -22
View File
@@ -1,32 +1,98 @@
import { Box, Scroll } from 'folds';
import { Box, Scroll, toRem, Text, color, config } from 'folds';
import { SquaresFour, sizedIcon } from '$components/icons/phosphor';
import { Page, PageContent, PageContentCenter, PageHero, PageHeroSection } from '$components/page';
import {
Page,
PageContent,
PageContentCenter,
PageHero,
PageHeroSection,
PageNav,
PageNavHeader,
} from '$components/page';
import { CreateSpaceForm } from '$features/create-space';
import { useRoomNavigate } from '$hooks/useRoomNavigate';
import { useEffect, useState } from 'react';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
import { useSetting } from '$state/hooks/settings';
import { settingsAtom } from '$state/settings';
import { SidebarResizer } from '../sidebar/SidebarResizer';
import { useSetAtom } from 'jotai';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
export function Create() {
const { navigateSpace } = useRoomNavigate();
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
useEffect(() => {
setCurWidth(roomSidebarWidth);
}, [roomSidebarWidth]);
const screenSize = useScreenSizeContext();
const isMobile = screenSize === ScreenSize.Mobile;
const hideText = curWidth <= 80 && !isMobile;
return (
<Page>
<Box grow="Yes">
<Scroll hideTrack visibility="Hover">
<PageContent>
<PageContentCenter>
<PageHeroSection>
<Box direction="Column" gap="700">
<PageHero
icon={sizedIcon(SquaresFour, '600')}
title="Create Space"
subTitle="Build a space for your community."
/>
<CreateSpaceForm onCreate={navigateSpace} />
</Box>
</PageHeroSection>
</PageContentCenter>
</PageContent>
</Scroll>
</Box>
</Page>
<>
{!isMobile && (
<Box
shrink="No"
style={{
position: 'relative',
width: toRem(curWidth),
borderRight: 'solid',
borderColor: color.SurfaceVariant.ContainerLine,
borderWidth: `0 ${config.borderWidth.B300} 0 0`,
}}
>
<PageNav>
<PageNavHeader size="600">
<Box grow="Yes" gap="300" justifyContent="Center">
{!hideText ? (
<Box grow="Yes">
<Text size="H4" truncate align="Center">
Create Space
</Text>
</Box>
) : (
sizedIcon(SquaresFour, '200', { filled: true })
)}
</Box>
</PageNavHeader>
<SidebarResizer
setCurWidth={setCurWidth}
sidebarWidth={roomSidebarWidth}
setSidebarWidth={setRoomSidebarWidth}
instep={80}
outstep={190}
minValue={50}
maxValue={500}
setAnnouncement={setIsResizingSidebar}
/>
</PageNav>
</Box>
)}
<Page>
<Box grow="Yes">
<Scroll hideTrack visibility="Hover">
<PageContent>
<PageContentCenter>
<PageHeroSection>
<Box direction="Column" gap="700">
<PageHero
icon={sizedIcon(SquaresFour, '600')}
title="Create Space"
subTitle="Build a space for your community."
/>
<CreateSpaceForm onCreate={navigateSpace} />
</Box>
</PageHeroSection>
</PageContentCenter>
</PageContent>
</Scroll>
</Box>
</Page>
</>
);
}
+7 -6
View File
@@ -1,6 +1,6 @@
import type { MouseEventHandler } from 'react';
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
import { useAtom, useAtomValue } from 'jotai';
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import type { RectCords } from 'folds';
import {
Avatar,
@@ -21,7 +21,7 @@ import {
DotsThreeOutlineVerticalIcon,
dropzoneIcon,
menuIcon,
getPhosphorIconSize,
getPhosphorSize,
Plus,
User,
} from '$components/icons/phosphor';
@@ -64,6 +64,7 @@ import { useDirectCreateSelected } from '$hooks/router/useDirectSelected';
import { useDirectRooms } from './useDirectRooms';
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
import { useScreenSizeContext, ScreenSize } from '$hooks/useScreenSize';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
type DirectMenuProps = {
requestClose: () => void;
@@ -115,10 +116,7 @@ function DirectHeader({ hideText }: { hideText?: boolean }) {
{hideText ? (
<Box alignItems="Center" grow="Yes" justifyContent="Center">
<IconButton aria-pressed={!!menuAnchor} variant="Background" onClick={handleOpenMenu}>
<User
size={getPhosphorIconSize('toolbar')}
weight={menuAnchor ? 'fill' : 'regular'}
/>
<User size={getPhosphorSize().toolbar} weight={menuAnchor ? 'fill' : 'regular'} />
</IconButton>
</Box>
) : (
@@ -202,6 +200,7 @@ export function Direct() {
const roomToUnread = useAtomValue(roomToUnreadAtom);
const navigate = useNavigate();
const [customDMCards] = useSetting(settingsAtom, 'customDMCards');
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
@@ -376,6 +375,7 @@ export function Direct() {
})}
</div>
</NavCategory>
<div style={{ height: toRem(40) }} />
</Box>
</PageNavContent>
)}
@@ -389,6 +389,7 @@ export function Direct() {
outstep={190}
minValue={50}
maxValue={500}
setAnnouncement={setIsResizingSidebar}
/>
)}
</Box>
+5 -1
View File
@@ -52,6 +52,8 @@ import { useSetting } from '$state/hooks/settings';
import { getMxIdServer } from '$utils/mxIdHelper';
import { isServerName } from '$utils/matrix';
import { useScreenSizeContext, ScreenSize } from '$hooks/useScreenSize';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
import { useSetAtom } from 'jotai';
type AddServerProps = {
hideText?: boolean;
@@ -255,6 +257,7 @@ export function Explore() {
handleRemoveServer(server);
};
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
@@ -274,7 +277,7 @@ export function Explore() {
}}
>
<PageNav>
<PageNavHeader>
<PageNavHeader size="600">
<Box grow="Yes" gap="300" justifyContent="Center">
{!hideText ? (
<Box grow="Yes">
@@ -411,6 +414,7 @@ export function Explore() {
outstep={190}
minValue={50}
maxValue={500}
setAnnouncement={setIsResizingSidebar}
/>
)}
</Box>
+9 -5
View File
@@ -15,7 +15,7 @@ import {
toRem,
} from 'folds';
import { useVirtualizer } from '@tanstack/react-virtual';
import { useAtom, useAtomValue } from 'jotai';
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import FocusTrap from 'focus-trap-react';
import { factoryRoomIdByActivity, factoryRoomIdByAtoZ } from '$utils/sort';
import {
@@ -80,6 +80,8 @@ import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
import { useClientConfig } from '$hooks/useClientConfig';
import { getMxIdServer } from '$utils/mxIdHelper';
import { UserQuickTools } from '../sidebar/UserQuickTools';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
type HomeMenuProps = {
requestClose: () => void;
@@ -236,7 +238,7 @@ const DEFAULT_CATEGORY_ID = makeNavCategoryId('home', 'room');
export function Home() {
const mx = useMatrixClient();
useNavToActivePathMapper('home');
const clientConfig = useClientConfig();
const clientConfig = useClientConfig();
const scrollRef = useRef<HTMLDivElement>(null);
const [isShowingAllRoomsInHome] = useSetting(settingsAtom, 'isShowingAllRoomsInHome');
const rooms = useHomeRooms(isShowingAllRoomsInHome);
@@ -244,6 +246,7 @@ export function Home() {
const roomToUnread = useAtomValue(roomToUnreadAtom);
const navigate = useNavigate();
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
useEffect(() => {
@@ -295,7 +298,6 @@ export function Home() {
closedCategories.has(categoryId)
);
const handleExploreClick = () => {
if (screenSize === ScreenSize.Mobile) {
navigate(getExplorePath());
@@ -413,7 +415,7 @@ export function Home() {
</>
)}
</UseStateProvider>
<NavItem variant="Background" radii="400" aria-selected={searchSelected}>
<NavItem variant="Background" radii="400">
<NavButton onClick={handleExploreClick}>
<NavItemContent>
<Box
@@ -429,7 +431,7 @@ export function Home() {
style={hideText ? { width: '100%' } : undefined}
>
{menuIcon(UsersThree, {
weight: searchSelected ? 'fill' : 'regular',
weight: 'regular',
})}
</Avatar>
{!hideText && (
@@ -549,8 +551,10 @@ export function Home() {
outstep={190}
minValue={50}
maxValue={500}
setAnnouncement={setIsResizingSidebar}
/>
)}
<UserQuickTools width={curWidth + 66} />
</Box>
);
}
+5 -1
View File
@@ -12,6 +12,8 @@ import { settingsAtom } from '$state/settings';
import { useEffect, useState } from 'react';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
import { useInviteCount } from '$hooks/useInviteCount';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
import { useSetAtom } from 'jotai';
function InvitesNavItem({ hideText }: { hideText?: boolean }) {
const invitesSelected = useInboxInvitesSelected();
@@ -53,6 +55,7 @@ export function Inbox() {
useNavToActivePathMapper('inbox');
const notificationsSelected = useInboxNotificationsSelected();
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
@@ -72,7 +75,7 @@ export function Inbox() {
}}
>
<PageNav>
<PageNavHeader>
<PageNavHeader size="600">
<Box grow="Yes" gap="300" justifyContent="Center">
{!hideText ? (
<Box grow="Yes">
@@ -125,6 +128,7 @@ export function Inbox() {
outstep={190}
minValue={50}
maxValue={500}
setAnnouncement={setIsResizingSidebar}
/>
)}
</Box>
@@ -134,7 +134,7 @@ function AccountRow({
);
}
export function AccountSwitcherTab({isBottom}:{isBottom?: boolean}) {
export function AccountSwitcherTab({ isBottom }: { isBottom?: boolean }) {
const mx = useMatrixClient();
const navigate = useNavigate();
const sessions = useAtomValue(sessionsAtom);
@@ -253,7 +253,7 @@ export function AccountSwitcherTab({isBottom}:{isBottom?: boolean}) {
return (
<SidebarItem active={!!menuAnchor} isBottom={isBottom}>
<SidebarItemTooltip tooltip={label} position={isBottom ? "Top" : "Right"}>
<SidebarItemTooltip tooltip={label} position={isBottom ? 'Top' : 'Right'}>
{(triggerRef) => (
<SidebarAvatar
as="button"
@@ -279,7 +279,7 @@ export function AccountSwitcherTab({isBottom}:{isBottom?: boolean}) {
<PopOut
anchor={menuAnchor}
position={isBottom ? "Top" : "Right"}
position={isBottom ? 'Top' : 'Right'}
align="End"
offset={6}
content={
@@ -1,66 +0,0 @@
import { useNavigate } from 'react-router-dom';
import { useAtomValue } from 'jotai';
import { SidebarAvatar, SidebarItem, SidebarItemTooltip } from '$components/sidebar';
import { useExploreSelected } from '$hooks/router/useExploreSelected';
import {
getExploreFeaturedPath,
getExplorePath,
getExploreServerPath,
joinPathComponent,
} from '$pages/pathUtils';
import { useClientConfig } from '$hooks/useClientConfig';
import { useMatrixClient } from '$hooks/useMatrixClient';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
import { getMxIdServer } from '$utils/mxIdHelper';
import { Compass, getPhosphorIconSize } from '$components/icons/phosphor';
export function ExploreTab() {
const mx = useMatrixClient();
const screenSize = useScreenSizeContext();
const clientConfig = useClientConfig();
const navigate = useNavigate();
const navToActivePath = useAtomValue(useNavToActivePathAtom());
const exploreSelected = useExploreSelected();
const handleExploreClick = () => {
if (screenSize === ScreenSize.Mobile) {
navigate(getExplorePath());
return;
}
const activePath = navToActivePath.get('explore');
if (activePath) {
navigate(joinPathComponent(activePath));
return;
}
if (clientConfig.featuredCommunities?.openAsDefault) {
navigate(getExploreFeaturedPath());
return;
}
const userId = mx.getUserId();
const userServer = userId ? getMxIdServer(userId) : undefined;
if (userServer) {
navigate(getExploreServerPath(userServer));
return;
}
navigate(getExplorePath());
};
return (
<SidebarItem active={exploreSelected}>
<SidebarItemTooltip tooltip="Explore Community">
{(triggerRef) => (
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={handleExploreClick}>
<Compass
size={getPhosphorIconSize('toolbar')}
weight={exploreSelected ? 'fill' : 'regular'}
/>
</SidebarAvatar>
)}
</SidebarItemTooltip>
</SidebarItem>
);
}
+6 -3
View File
@@ -18,7 +18,7 @@ import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
import { useInviteCount } from '$hooks/useInviteCount';
import { getPhosphorIconSize, Tray } from '$components/icons/phosphor';
export function InboxTab({isBottom}:{isBottom?: boolean}) {
export function InboxTab({ isBottom }: { isBottom?: boolean }) {
const screenSize = useScreenSizeContext();
const navigate = useNavigate();
const navToActivePath = useAtomValue(useNavToActivePathAtom());
@@ -42,7 +42,7 @@ export function InboxTab({isBottom}:{isBottom?: boolean}) {
return (
<SidebarItem active={inboxSelected} isBottom={isBottom}>
<SidebarItemTooltip tooltip="Inbox" position={isBottom ? "Top" : "Right"}>
<SidebarItemTooltip tooltip="Inbox" position={isBottom ? 'Top' : 'Right'}>
{(triggerRef) => (
<SidebarAvatar
as="button"
@@ -51,7 +51,10 @@ export function InboxTab({isBottom}:{isBottom?: boolean}) {
onClick={handleInboxClick}
size="300"
>
<Tray size={getPhosphorIconSize('inline')} weight={inboxSelected ? 'fill' : 'regular'} />
<Tray
size={getPhosphorIconSize('inline')}
weight={inboxSelected ? 'fill' : 'regular'}
/>
</SidebarAvatar>
)}
</SidebarItemTooltip>
+2 -2
View File
@@ -4,14 +4,14 @@ import { searchModalAtom } from '$state/searchModal';
import { ListMagnifyingGlassIcon } from '@phosphor-icons/react';
import { getPhosphorIconSize } from '$components/icons/phosphor';
export function SearchTab({isBottom}:{isBottom?: boolean}) {
export function SearchTab({ isBottom }: { isBottom?: boolean }) {
const [opened, setOpen] = useAtom(searchModalAtom);
const open = () => setOpen(true);
return (
<SidebarItem active={opened} isBottom={isBottom}>
<SidebarItemTooltip tooltip="Search" position={isBottom ? "Top" : "Right"}>
<SidebarItemTooltip tooltip="Search" position={isBottom ? 'Top' : 'Right'}>
{(triggerRef) => (
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={open} size="300">
<ListMagnifyingGlassIcon
+2 -2
View File
@@ -4,13 +4,13 @@ import { useOpenSettings } from '$features/settings';
import { matchPath } from 'react-router-dom';
import { SETTINGS_PATH } from '$pages/paths';
export function SettingsTab({isBottom}:{isBottom?: boolean}) {
export function SettingsTab({ isBottom }: { isBottom?: boolean }) {
const opened = !!matchPath(SETTINGS_PATH, location.pathname);
const openSettings = useOpenSettings();
return (
<SidebarItem active={opened} isBottom={isBottom}>
<SidebarItemTooltip tooltip="Search" position={isBottom ? "Top" : "Right"}>
<SidebarItemTooltip tooltip="Search" position={isBottom ? 'Top' : 'Right'}>
{(triggerRef) => (
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={openSettings} size="300">
<GearSix size={getPhosphorSize().inline} weight={opened ? 'fill' : 'regular'} />
@@ -15,6 +15,7 @@ export function SidebarResizer({
outstep,
isReversed,
topSided,
setAnnouncement,
}: {
sidebarWidth: number;
setSidebarWidth: (arg0: number) => void;
@@ -25,6 +26,7 @@ export function SidebarResizer({
outstep?: number;
isReversed?: boolean;
topSided?: boolean;
setAnnouncement?: (announcement: boolean) => void;
}) {
const [isPointerOver, setIsPointerOver] = useState(false);
const [isPointerDown, setIsPointerDown] = useState(false);
@@ -57,6 +59,7 @@ export function SidebarResizer({
e.preventDefault();
setNewPos(topSided ? e.clientY : e.clientX);
setIsPointerDown(false);
setAnnouncement?.(false);
window.removeEventListener('pointerup', onPointerUp);
window.removeEventListener('pointermove', onPointerMove);
}, []);
@@ -67,6 +70,7 @@ export function SidebarResizer({
e.currentTarget.setPointerCapture(e.pointerId);
setOldPos(topSided ? e.clientY : e.clientX);
setIsPointerDown(true);
setAnnouncement?.(true);
window.addEventListener('pointerup', onPointerUp);
window.addEventListener('pointermove', onPointerMove);
},
@@ -17,7 +17,7 @@ import { useOpenSettings } from '$features/settings';
import { getPhosphorIconSize, ShieldWarning } from '$components/icons/phosphor';
import * as css from './UnverifiedTab.css';
function UnverifiedIndicator({isBottom}:{isBottom?: boolean}) {
function UnverifiedIndicator({ isBottom }: { isBottom?: boolean }) {
const mx = useMatrixClient();
const openSettings = useOpenSettings();
@@ -48,7 +48,7 @@ function UnverifiedIndicator({isBottom}:{isBottom?: boolean}) {
<SidebarItem className={css.UnverifiedTab} isBottom={isBottom}>
<SidebarItemTooltip
tooltip={unverified ? 'Unverified Device' : 'Unverified Devices'}
position={isBottom ? "Top" : "Right"}
position={isBottom ? 'Top' : 'Right'}
>
{(triggerRef) => (
<SidebarAvatar
@@ -83,10 +83,10 @@ function UnverifiedIndicator({isBottom}:{isBottom?: boolean}) {
);
}
export function UnverifiedTab({isBottom}:{isBottom?: boolean}) {
export function UnverifiedTab({ isBottom }: { isBottom?: boolean }) {
const crossSigningActive = useCrossSigningActive();
if (!crossSigningActive) return null;
return <UnverifiedIndicator isBottom={isBottom}/>;
return <UnverifiedIndicator isBottom={isBottom} />;
}
@@ -0,0 +1,14 @@
import { style } from '@vanilla-extract/css';
import { color, config, toRem } from 'folds';
export const UserQuickTools = style({
backgroundColor: color.SurfaceVariant.Container,
color: color.SurfaceVariant.OnContainer,
position: 'fixed',
zIndex: '1000',
height: toRem(58),
bottom: '0',
left: '0',
padding: config.space.S300,
borderTop: `${config.borderWidth.B300} solid ${color.Background.ContainerLine}`,
});
@@ -0,0 +1,56 @@
import { Box, config, toRem } from 'folds';
import { AccountSwitcherTab } from './AccountSwitcherTab';
import { UnverifiedTab } from './UnverifiedTab';
import { InboxTab } from './InboxTab';
import { SearchTab } from './SearchTab';
import { SettingsTab } from './SettingsTab';
import { useAtom } from 'jotai';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
import * as css from './UserQuickTools.css';
export function UserQuickTools({
width,
}: {
isCollapsed?: boolean;
underOutstep?: boolean;
width: number;
}) {
const [isResizingSidebar] = useAtom(isResizingSidebarAtom);
const underOutstep = width < 190 + 66;
const isCollapsed = width < 50 + 66;
return (
<>
{/* Doing it properly and nicely would require a major rewrite that would cause more trouble*/}
{!isCollapsed && (
<Box
direction="Row"
justifyContent="SpaceBetween"
className={css.UserQuickTools}
style={{
opacity: isResizingSidebar ? '0%' : '100%',
transition: isResizingSidebar ? 'opacity 0.2s ease' : 'opacity 0.5s ease',
width: toRem(width),
paddingRight: underOutstep ? config.space.S200 : config.space.S300,
}}
>
<AccountSwitcherTab isBottom />
<Box
style={{
gap: config.space.S300,
}}
>
{!underOutstep && (
<>
<UnverifiedTab isBottom />
<InboxTab isBottom />
<SearchTab isBottom />
</>
)}
<SettingsTab isBottom />
</Box>
</Box>
)}
</>
);
}
+5 -1
View File
@@ -1,6 +1,6 @@
import type { MouseEventHandler, ReactElement } from 'react';
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useAtom, useAtomValue } from 'jotai';
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import type { RectCords } from 'folds';
import {
Avatar,
@@ -108,6 +108,7 @@ import type { RoomBannerContent } from '$types/matrix-sdk-events';
import { ModalWide } from '$styles/Modal.css';
import { ImageViewer } from '$components/image-viewer';
import * as css from './styles.css';
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
const debugLog = createDebugLogger('Space');
@@ -522,6 +523,7 @@ export function Space() {
const allJoinedRooms = useMemo(() => new Set(allRooms), [allRooms]);
const notificationPreferences = useRoomsNotificationPreferencesContext();
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
useEffect(() => {
@@ -1044,6 +1046,7 @@ export function Space() {
})}
{getConnectorSVG(hierarchy, virtualizedItems)}
</NavCategory>
<div style={{ height: toRem(40) }} />
</Box>
</PageNavContent>
</SwipeableOverlayWrapper>
@@ -1057,6 +1060,7 @@ export function Space() {
outstep={190}
minValue={50}
maxValue={500}
setAnnouncement={setIsResizingSidebar}
/>
)}
</Box>
+3
View File
@@ -0,0 +1,3 @@
import { atom } from 'jotai';
export const isResizingSidebarAtom = atom(false);