2026-06-05 11:25:19 -04:00
|
|
|
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';
|
2024-05-31 19:49:46 +05:30
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
Sidebar,
|
|
|
|
|
SidebarContent,
|
|
|
|
|
SidebarStackSeparator,
|
|
|
|
|
SidebarStack,
|
|
|
|
|
} from '../../components/sidebar';
|
2026-06-04 22:02:18 -04:00
|
|
|
import { SidebarGlass } from '../../components/sidebar/Sidebar.css';
|
2024-08-04 09:49:37 +05:30
|
|
|
import {
|
|
|
|
|
DirectTab,
|
|
|
|
|
HomeTab,
|
|
|
|
|
SpaceTabs,
|
|
|
|
|
InboxTab,
|
|
|
|
|
ExploreTab,
|
2025-02-10 16:49:47 +11:00
|
|
|
SettingsTab,
|
2024-08-04 09:49:37 +05:30
|
|
|
UnverifiedTab,
|
2025-08-27 17:55:49 +05:30
|
|
|
SearchTab,
|
2026-06-04 10:26:08 -04:00
|
|
|
BookmarksTab,
|
2024-08-04 09:49:37 +05:30
|
|
|
} 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';
|
2026-06-05 11:25:19 -04:00
|
|
|
import { useTheme, ThemeKind } from '../../hooks/useTheme';
|
|
|
|
|
import { getChatBg } from '../../features/lotus/chatBackground';
|
2024-05-31 19:49:46 +05:30
|
|
|
|
|
|
|
|
export function SidebarNav() {
|
2026-05-22 13:24:07 -04:00
|
|
|
const scrollRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;
|
2026-06-04 22:02:18 -04:00
|
|
|
const [glassmorphismSidebar] = useSetting(settingsAtom, 'glassmorphismSidebar');
|
2026-06-05 11:25:19 -04:00
|
|
|
const [chatBackground] = useSetting(settingsAtom, 'chatBackground');
|
|
|
|
|
const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal');
|
2026-06-05 11:46:16 -04:00
|
|
|
const [pauseAnimations] = useSetting(settingsAtom, 'pauseAnimations');
|
2026-06-05 11:25:19 -04:00
|
|
|
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');
|
2026-06-05 11:46:16 -04:00
|
|
|
style.removeProperty('animation');
|
2026-06-05 11:25:19 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const effectiveBg = lotusTerminal && chatBackground === 'none' ? 'tactical' : chatBackground;
|
2026-06-05 11:46:16 -04:00
|
|
|
const bgStyle = getChatBg(effectiveBg, isDark, pauseAnimations);
|
2026-06-05 11:25:19 -04:00
|
|
|
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) ?? '';
|
2026-06-05 11:46:16 -04:00
|
|
|
style.animation = (bgStyle.animation as string | undefined) ?? '';
|
2026-06-05 11:25:19 -04:00
|
|
|
return () => {
|
|
|
|
|
style.removeProperty('background-image');
|
|
|
|
|
style.removeProperty('background-color');
|
|
|
|
|
style.removeProperty('background-size');
|
|
|
|
|
style.removeProperty('background-position');
|
2026-06-05 11:46:16 -04:00
|
|
|
style.removeProperty('animation');
|
2026-06-05 11:25:19 -04:00
|
|
|
};
|
2026-06-05 11:46:16 -04:00
|
|
|
}, [glassmorphismSidebar, chatBackground, lotusTerminal, isDark, pauseAnimations]);
|
2024-05-31 19:49:46 +05:30
|
|
|
|
|
|
|
|
return (
|
2026-06-04 22:02:18 -04:00
|
|
|
<Sidebar className={classNames(glassmorphismSidebar && SidebarGlass)}>
|
2024-05-31 19:49:46 +05:30
|
|
|
<SidebarContent
|
|
|
|
|
scrollable={
|
2026-06-05 13:41:29 -04:00
|
|
|
<Scroll
|
|
|
|
|
ref={scrollRef}
|
|
|
|
|
variant={glassmorphismSidebar ? undefined : 'Background'}
|
|
|
|
|
size="0"
|
|
|
|
|
>
|
2024-05-31 19:49:46 +05:30
|
|
|
<SidebarStack>
|
|
|
|
|
<HomeTab />
|
|
|
|
|
<DirectTab />
|
|
|
|
|
</SidebarStack>
|
|
|
|
|
<SpaceTabs scrollRef={scrollRef} />
|
|
|
|
|
<SidebarStackSeparator />
|
|
|
|
|
<SidebarStack>
|
|
|
|
|
<ExploreTab />
|
2025-08-05 18:37:07 +05:30
|
|
|
<CreateTab />
|
2024-05-31 19:49:46 +05:30
|
|
|
</SidebarStack>
|
|
|
|
|
</Scroll>
|
|
|
|
|
}
|
|
|
|
|
sticky={
|
|
|
|
|
<>
|
|
|
|
|
<SidebarStackSeparator />
|
|
|
|
|
<SidebarStack>
|
2025-08-27 17:55:49 +05:30
|
|
|
<SearchTab />
|
2026-06-04 10:26:08 -04:00
|
|
|
<BookmarksTab />
|
2024-08-04 09:49:37 +05:30
|
|
|
<UnverifiedTab />
|
2024-05-31 19:49:46 +05:30
|
|
|
<InboxTab />
|
2025-02-10 16:49:47 +11:00
|
|
|
<SettingsTab />
|
2024-05-31 19:49:46 +05:30
|
|
|
</SidebarStack>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</Sidebar>
|
|
|
|
|
);
|
|
|
|
|
}
|