Files
cinny/src/app/pages/client/SidebarNav.tsx
T

100 lines
3.5 KiB
TypeScript
Raw Normal View History

import React, { useEffect, useRef } from 'react';
2025-08-27 17:55:49 +05:30
import { Scroll } from 'folds';
2026-06-04 22:02:18 -04:00
import classNames from 'classnames';
import {
Sidebar,
SidebarContent,
SidebarStackSeparator,
SidebarStack,
} from '../../components/sidebar';
2026-06-04 22:02:18 -04:00
import { SidebarGlass } from '../../components/sidebar/Sidebar.css';
import {
DirectTab,
HomeTab,
SpaceTabs,
InboxTab,
ExploreTab,
SettingsTab,
UnverifiedTab,
2025-08-27 17:55:49 +05:30
SearchTab,
BookmarksTab,
} from './sidebar';
2025-08-05 18:37:07 +05:30
import { CreateTab } from './sidebar/CreateTab';
2026-06-04 22:02:18 -04:00
import { useSetting } from '../../state/hooks/settings';
import { settingsAtom } from '../../state/settings';
import { useTheme, ThemeKind } from '../../hooks/useTheme';
import { getChatBg } from '../../features/lotus/chatBackground';
export function SidebarNav() {
const scrollRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;
2026-06-04 22:02:18 -04:00
const [glassmorphismSidebar] = useSetting(settingsAtom, 'glassmorphismSidebar');
const [chatBackground] = useSetting(settingsAtom, 'chatBackground');
const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal');
const [pauseAnimations] = useSetting(settingsAtom, 'pauseAnimations');
const theme = useTheme();
const isDark = theme.kind === ThemeKind.Dark;
// backdrop-filter only blurs content directly behind the element in the z-axis.
// The sidebar is a flex sibling of the room view, so nothing sits behind it by default.
// Fix: mirror the active chat background onto document.body so the sidebar blurs through it.
useEffect(() => {
const { style } = document.body;
if (!glassmorphismSidebar) {
style.removeProperty('background-image');
style.removeProperty('background-color');
style.removeProperty('background-size');
style.removeProperty('background-position');
style.removeProperty('animation');
return;
}
const effectiveBg = lotusTerminal && chatBackground === 'none' ? 'tactical' : chatBackground;
const bgStyle = getChatBg(effectiveBg, isDark, pauseAnimations);
style.backgroundImage = (bgStyle.backgroundImage as string | undefined) ?? '';
style.backgroundColor = (bgStyle.backgroundColor as string | undefined) ?? '';
style.backgroundSize = (bgStyle.backgroundSize as string | undefined) ?? '';
style.backgroundPosition = (bgStyle.backgroundPosition as string | undefined) ?? '';
style.animation = (bgStyle.animation as string | undefined) ?? '';
return () => {
style.removeProperty('background-image');
style.removeProperty('background-color');
style.removeProperty('background-size');
style.removeProperty('background-position');
style.removeProperty('animation');
};
}, [glassmorphismSidebar, chatBackground, lotusTerminal, isDark, pauseAnimations]);
return (
2026-06-04 22:02:18 -04:00
<Sidebar className={classNames(glassmorphismSidebar && SidebarGlass)}>
<SidebarContent
scrollable={
<Scroll ref={scrollRef} variant="Background" size="0">
<SidebarStack>
<HomeTab />
<DirectTab />
</SidebarStack>
<SpaceTabs scrollRef={scrollRef} />
<SidebarStackSeparator />
<SidebarStack>
<ExploreTab />
2025-08-05 18:37:07 +05:30
<CreateTab />
</SidebarStack>
</Scroll>
}
sticky={
<>
<SidebarStackSeparator />
<SidebarStack>
2025-08-27 17:55:49 +05:30
<SearchTab />
<BookmarksTab />
<UnverifiedTab />
<InboxTab />
<SettingsTab />
</SidebarStack>
</>
}
/>
</Sidebar>
);
}