Skip to content

Commit

Permalink
feat(ui): support hiding footer and header (#4455)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybzky authored Jan 21, 2025
1 parent b55877b commit 54e4378
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/ui/src/controllers/ui/ui-desktop.controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { IMenuManagerService } from '../../services/menu/menu-manager.service';
import { BuiltInUIPart, IUIPartsService } from '../../services/parts/parts.service';
import { FloatDom } from '../../views/components/dom/FloatDom';
import { CanvasPopup } from '../../views/components/popup/CanvasPopup';
import { Ribbon } from '../../views/components/ribbon/Ribbon';
import { DesktopWorkbench } from '../../views/workbench/Workbench';
import { menuSchema } from '../menus/menu.schema';

Expand Down Expand Up @@ -104,6 +105,7 @@ export class DesktopUIController extends Disposable {
this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.FLOATING, () => connectInjector(CanvasPopup, this._injector)));
// this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(ContentDOMPopup, this._injector)));
this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(FloatDom, this._injector)));
this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.TOOLBAR, () => connectInjector(Ribbon, this._injector)));
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/services/parts/parts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum BuiltInUIPart {
CUSTOM_LEFT = 'custom-left',
CUSTOM_RIGHT = 'custom-right',
CUSTOM_FOOTER = 'custom-footer',
TOOLBAR = 'toolbar',
}

export interface IUIPartsService {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/views/components/ComponentContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function ComponentContainer(props: IComponentContainerProps) {
export function useComponentsOfPart(part: string, injector?: Injector): Set<ComponentRenderer> {
const uiPartsService = injector?.get(IUIPartsService) ?? useDependency(IUIPartsService);
const uiVisibleChange$ = useMemo(() => uiPartsService.uiVisibleChange$.pipe(filter((ui) => ui.ui === part)), [part, uiPartsService]);
useObservable(uiVisibleChange$);
const changeInfo = useObservable(uiVisibleChange$);

const updateCounterRef = useRef<number>(0);
const componentPartUpdateCount = useObservable(
Expand All @@ -61,7 +61,7 @@ export function useComponentsOfPart(part: string, injector?: Injector): Set<Comp
),
undefined,
undefined,
[uiPartsService, part]
[uiPartsService, part, changeInfo]
);

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
10 changes: 8 additions & 2 deletions packages/ui/src/views/workbench/Workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { createPortal } from 'react-dom';
import { BuiltInUIPart } from '../../services/parts/parts.service';
import { ComponentContainer, useComponentsOfPart } from '../components/ComponentContainer';
import { DesktopContextMenu } from '../components/context-menu/ContextMenu';
import { Ribbon } from '../components/ribbon/Ribbon';

import { Sidebar } from '../components/sidebar/Sidebar';
import { ZenZone } from '../components/zen-zone/ZenZone';
Expand Down Expand Up @@ -61,6 +60,7 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
const contentComponents = useComponentsOfPart(BuiltInUIPart.CONTENT);
const leftSidebarComponents = useComponentsOfPart(BuiltInUIPart.LEFT_SIDEBAR);
const globalComponents = useComponentsOfPart(BuiltInUIPart.GLOBAL);
const toolbarComponents = useComponentsOfPart(BuiltInUIPart.TOOLBAR);

const [docSnapShot, setDocSnapShot] = useState<Nullable<IDocumentData>>(null);

Expand Down Expand Up @@ -141,7 +141,13 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
{/* header */}
{header && toolbar && (
<header className={styles.workbenchContainerHeader}>
<Ribbon headerMenuComponents={headerMenuComponents} />
<ComponentContainer
key="toolbar"
components={toolbarComponents}
sharedProps={{
headerMenuComponents,
}}
/>
</header>
)}

Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/views/workbench/workbench.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
display: grid;
grid-template-rows: auto 1fr;
flex: 1;

background-color: rgb(var(--bg-color-secondary));
border-bottom: 1px solid rgb(var(--border-color));
}
Expand Down

0 comments on commit 54e4378

Please sign in to comment.