Skip to content

Commit

Permalink
feat(docs): add gray background color to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Sep 21, 2024
1 parent d8b9271 commit 8f40a37
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
22 changes: 11 additions & 11 deletions packages/engine-render/src/components/docs/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
* limitations under the License.
*/

import './extensions';

import { CellValueType, HorizontalAlign, VerticalAlign, WrapStrategy } from '@univerjs/core';
import type { IDocumentRenderConfig, IScale, Nullable } from '@univerjs/core';

import { Subject } from 'rxjs';
import type { IDocumentRenderConfig, IScale, Nullable } from '@univerjs/core';
import { BORDER_TYPE, drawLineByBorderType } from '../../basics';
import { calculateRectRotate, getRotateOffsetAndFarthestHypotenuse } from '../../basics/draw';
import type { IDocumentSkeletonGlyph, IDocumentSkeletonLine, IDocumentSkeletonPage, IDocumentSkeletonTable } from '../../basics/i-document-skeleton-cached';
import { LineType } from '../../basics/i-document-skeleton-cached';
import { VERTICAL_ROTATE_ANGLE } from '../../basics/text-rotation';
import { degToRad } from '../../basics/tools';
import { Vector2 } from '../../basics/vector2';
import { DocumentsSpanAndLineExtensionRegistry } from '../extension';
import { DocComponent } from './doc-component';
import { DOCS_EXTENSION_TYPE } from './doc-extension';
import { Liquid } from './liquid';
import type { IDocumentSkeletonGlyph, IDocumentSkeletonLine, IDocumentSkeletonPage, IDocumentSkeletonTable } from '../../basics/i-document-skeleton-cached';
import type { Transform } from '../../basics/transform';
import type { IBoundRectNoAngle, IViewportInfo } from '../../basics/vector2';
import { Vector2 } from '../../basics/vector2';
import type { UniverRenderingContext } from '../../context';
import type { Scene } from '../../scene';
import type { ComponentExtension, IExtensionConfig } from '../extension';
import { DocumentsSpanAndLineExtensionRegistry } from '../extension';
import { VERTICAL_ROTATE_ANGLE } from '../../basics/text-rotation';
import { BORDER_TYPE, drawLineByBorderType } from '../../basics';
import { Liquid } from './liquid';
import type { IDocumentsConfig, IPageMarginLayout } from './doc-component';
import { DocComponent } from './doc-component';
import { DOCS_EXTENSION_TYPE } from './doc-extension';
import type { DocumentSkeleton } from './layout/doc-skeleton';
import './extensions';

export interface IPageRenderConfig {
page: IDocumentSkeletonPage;
Expand Down
38 changes: 33 additions & 5 deletions packages/ui/src/views/workbench/Workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

import { LocaleService, ThemeService, useDependency } from '@univerjs/core';
import type { ILocale } from '@univerjs/design';
import { IUniverInstanceService, LocaleService, ThemeService, UniverInstanceType, useDependency } from '@univerjs/core';
import { ConfigContext, ConfigProvider, defaultTheme, themeInstance } from '@univerjs/design';
import clsx from 'clsx';
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';

import { createPortal } from 'react-dom';
import type { IWorkbenchOptions } from '../../controllers/ui/ui.controller';
import type { ILocale } from '@univerjs/design';
import { IMessageService } from '../../services/message/message.service';
import { BuiltInUIPart } from '../../services/parts/parts.service';
import { ComponentContainer, useComponentsOfPart } from '../components/ComponentContainer';
Expand All @@ -31,6 +31,7 @@ import { ZenZone } from '../components/zen-zone/ZenZone';
import { builtInGlobalComponents } from '../parts';

import styles from './workbench.module.less';
import type { IWorkbenchOptions } from '../../controllers/ui/ui.controller';

export interface IUniverWorkbenchProps extends IWorkbenchOptions {
mountContainer: HTMLElement;
Expand All @@ -51,6 +52,7 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
const localeService = useDependency(LocaleService);
const themeService = useDependency(ThemeService);
const messageService = useDependency(IMessageService);
const instanceService = useDependency(IUniverInstanceService);
const contentRef = useRef<HTMLDivElement>(null);

const footerComponents = useComponentsOfPart(BuiltInUIPart.FOOTER);
Expand All @@ -60,6 +62,24 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
const leftSidebarComponents = useComponentsOfPart(BuiltInUIPart.LEFT_SIDEBAR);
const globalComponents = useComponentsOfPart(BuiltInUIPart.GLOBAL);

const [focusUnitType, setFocusUnitType] = useState<UniverInstanceType>(UniverInstanceType.UNIVER_UNKNOWN);

useEffect(() => {
const sub = instanceService.focused$.subscribe((id) => {
if (id == null) {
return;
}
const instanceType = instanceService.getUnitType(id);

setFocusUnitType(instanceType);
});

return () => {
sub.unsubscribe();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (!themeService.getCurrentTheme()) {
themeService.setTheme(defaultTheme);
Expand Down Expand Up @@ -88,7 +108,9 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
}),
themeService.currentTheme$.subscribe((theme) => {
themeInstance.setTheme(mountContainer, theme);
portalContainer && themeInstance.setTheme(portalContainer, theme);
if (portalContainer) {
themeInstance.setTheme(portalContainer, theme);
}
}),
];

Expand Down Expand Up @@ -123,7 +145,13 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
<ComponentContainer key="left-sidebar" components={leftSidebarComponents} />
</aside>

<section className={styles.workbenchContainerContent}>
<section className={clsx(
styles.workbenchContainerContent,
{
[styles.workbenchContainerDocContent]: focusUnitType === UniverInstanceType.UNIVER_DOC,
}
)}
>
<header>
{header && <ComponentContainer key="header" components={headerComponents} />}
</header>
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/views/workbench/workbench.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
border-bottom: 1px solid rgb(var(--border-color));
}

&-doc-content {
background: rgb(var(--grey-50));
}

&-canvas {
position: relative;
overflow: hidden;
Expand Down

0 comments on commit 8f40a37

Please sign in to comment.