10f6544e2e
- UserHero: move AvatarDecoration inside AvatarPresence so the decoration inline-flex container sizes to the avatar only, not the presence badge - SidebarNav: add will-change: background-position, background-size on document.body for animated backgrounds, promoting them to a compositor layer so overlaid text/UI doesn't repaint on every animation frame - scheduledMessages: back the atom with atomWithStorage so the scheduled message tray survives page refreshes via localStorage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
117 lines
4.1 KiB
TypeScript
117 lines
4.1 KiB
TypeScript
import React, { useEffect, useRef } from 'react';
|
|
import { Scroll } from 'folds';
|
|
import classNames from 'classnames';
|
|
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarStackSeparator,
|
|
SidebarStack,
|
|
} from '../../components/sidebar';
|
|
import { SidebarGlass } from '../../components/sidebar/Sidebar.css';
|
|
import {
|
|
DirectTab,
|
|
HomeTab,
|
|
SpaceTabs,
|
|
InboxTab,
|
|
ExploreTab,
|
|
SettingsTab,
|
|
UnverifiedTab,
|
|
SearchTab,
|
|
BookmarksTab,
|
|
} from './sidebar';
|
|
import { CreateTab } from './sidebar/CreateTab';
|
|
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>;
|
|
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;
|
|
const hasBg = chatBackground !== 'none' || glassmorphismSidebar || lotusTerminal;
|
|
|
|
if (!hasBg) {
|
|
style.removeProperty('background-image');
|
|
style.removeProperty('background-color');
|
|
style.removeProperty('background-size');
|
|
style.removeProperty('background-position');
|
|
style.removeProperty('animation');
|
|
style.removeProperty('will-change');
|
|
return;
|
|
}
|
|
|
|
const effectiveBg = chatBackground !== 'none' ? chatBackground : 'tactical';
|
|
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) ?? '';
|
|
// Promote animated backgrounds to their own compositor layer so the browser
|
|
// doesn't repaint the overlaid text/UI content on every animation frame.
|
|
if (bgStyle.animation) {
|
|
style.willChange = 'background-position, background-size';
|
|
} else {
|
|
style.removeProperty('will-change');
|
|
}
|
|
|
|
return () => {
|
|
style.removeProperty('background-image');
|
|
style.removeProperty('background-color');
|
|
style.removeProperty('background-size');
|
|
style.removeProperty('background-position');
|
|
style.removeProperty('animation');
|
|
style.removeProperty('will-change');
|
|
};
|
|
}, [glassmorphismSidebar, chatBackground, lotusTerminal, isDark, pauseAnimations]);
|
|
|
|
return (
|
|
<Sidebar className={classNames(glassmorphismSidebar && SidebarGlass)}>
|
|
<SidebarContent
|
|
scrollable={
|
|
<Scroll
|
|
ref={scrollRef}
|
|
variant={glassmorphismSidebar ? undefined : 'Background'}
|
|
size="0"
|
|
>
|
|
<SidebarStack>
|
|
<HomeTab />
|
|
<DirectTab />
|
|
</SidebarStack>
|
|
<SpaceTabs scrollRef={scrollRef} />
|
|
<SidebarStackSeparator />
|
|
<SidebarStack>
|
|
<ExploreTab />
|
|
<CreateTab />
|
|
</SidebarStack>
|
|
</Scroll>
|
|
}
|
|
sticky={
|
|
<>
|
|
<SidebarStackSeparator />
|
|
<SidebarStack>
|
|
<SearchTab />
|
|
<BookmarksTab />
|
|
<UnverifiedTab />
|
|
<InboxTab />
|
|
<SettingsTab />
|
|
</SidebarStack>
|
|
</>
|
|
}
|
|
/>
|
|
</Sidebar>
|
|
);
|
|
}
|