AFFiNE/packages/frontend/electron/renderer/shell/shell.tsx
pengx17 6b8f99c013
fix: using width atom for syncing app headers position (#7666)
may use global state to replace these sidebar state atoms

fix AF-1109
2024-07-31 07:03:30 +00:00

40 lines
971 B
TypeScript

import { useAppSettingHelper } from '@affine/core/hooks/affine/use-app-setting-helper';
import { AppTabsHeader } from '@affine/core/modules/app-tabs-header';
import { events } from '@affine/electron-api';
import { useEffect, useState } from 'react';
import * as styles from './shell.css';
const useIsShellActive = () => {
const [active, setActive] = useState(false);
useEffect(() => {
const unsub = events?.ui.onTabShellViewActiveChange(active => {
setActive(active);
});
return () => {
unsub?.();
};
});
return active;
};
export function ShellRoot() {
const active = useIsShellActive();
const { appSettings } = useAppSettingHelper();
const translucent =
environment.isDesktop &&
environment.isMacOs &&
appSettings.enableBlurBackground;
return (
<div
className={styles.root}
data-translucent={translucent}
data-active={active}
>
<AppTabsHeader mode="shell" />
</div>
);
}