mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 11:06:25 +08:00
9465d0dc73
Closes: [BS-3555](https://linear.app/affine-design/issue/BS-3555/ui-attachment-loading-变量更新) Closes: [BS-3559](https://linear.app/affine-design/issue/BS-3559/ui-图片-loading-变量更新) ### Dark <img width="625" alt="Screenshot 2025-05-26 at 20 32 36" src="https://github.com/user-attachments/assets/93501e3d-8fc6-45f9-84a0-ac147e5c5f9f" /> ### Light <img width="623" alt="Screenshot 2025-05-26 at 20 32 25" src="https://github.com/user-attachments/assets/7d5bc128-6667-45b5-982d-dab3a22706a7" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Loading icons are now invoked as functions, allowing for more flexible and customizable rendering with parameters like size and progress. - **Refactor** - Replaced theme-dependent and static loading icon references with a unified `LoadingIcon()` component across multiple components and blocks. - Removed legacy icon variants and simplified icon import statements, centralizing icon rendering logic. - **Style** - Updated styles for loading and reload buttons to use theme-aware CSS variables. - Enlarged and repositioned loading indicators in image blocks for better visibility. - **Bug Fixes** - Achieved consistent loading icon rendering across various blocks and components by standardizing icon invocation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
import {
|
|
EmbedEdgelessIcon,
|
|
EmbedPageIcon,
|
|
} from '@blocksuite/affine-components/icons';
|
|
import { ColorScheme } from '@blocksuite/affine-model';
|
|
import type { BlockComponent } from '@blocksuite/std';
|
|
import type { TemplateResult } from 'lit';
|
|
|
|
import { EmbedEdgelessSyncedDocBlockComponent } from './embed-edgeless-synced-doc-block.js';
|
|
import {
|
|
DarkSyncedDocDeletedBanner,
|
|
DarkSyncedDocEmptyBanner,
|
|
DarkSyncedDocErrorBanner,
|
|
LightSyncedDocDeletedBanner,
|
|
LightSyncedDocEmptyBanner,
|
|
LightSyncedDocErrorBanner,
|
|
SyncedDocDeletedIcon,
|
|
SyncedDocErrorIcon,
|
|
} from './styles.js';
|
|
|
|
type SyncedCardImages = {
|
|
SyncedDocIcon: TemplateResult<1>;
|
|
SyncedDocErrorIcon: TemplateResult<1>;
|
|
SyncedDocDeletedIcon: TemplateResult<1>;
|
|
SyncedDocEmptyBanner: TemplateResult<1>;
|
|
SyncedDocErrorBanner: TemplateResult<1>;
|
|
SyncedDocDeletedBanner: TemplateResult<1>;
|
|
};
|
|
|
|
export function getSyncedDocIcons(
|
|
theme: ColorScheme,
|
|
editorMode: 'page' | 'edgeless'
|
|
): SyncedCardImages {
|
|
if (theme === ColorScheme.Light) {
|
|
return {
|
|
SyncedDocIcon: editorMode === 'page' ? EmbedPageIcon : EmbedEdgelessIcon,
|
|
SyncedDocErrorIcon,
|
|
SyncedDocDeletedIcon,
|
|
SyncedDocEmptyBanner: LightSyncedDocEmptyBanner,
|
|
SyncedDocErrorBanner: LightSyncedDocErrorBanner,
|
|
SyncedDocDeletedBanner: LightSyncedDocDeletedBanner,
|
|
};
|
|
} else {
|
|
return {
|
|
SyncedDocIcon: editorMode === 'page' ? EmbedPageIcon : EmbedEdgelessIcon,
|
|
SyncedDocErrorIcon,
|
|
SyncedDocDeletedIcon,
|
|
SyncedDocEmptyBanner: DarkSyncedDocEmptyBanner,
|
|
SyncedDocErrorBanner: DarkSyncedDocErrorBanner,
|
|
SyncedDocDeletedBanner: DarkSyncedDocDeletedBanner,
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function will return the height of the synced doc block
|
|
*/
|
|
export function calcSyncedDocFullHeight(block: BlockComponent) {
|
|
if (!(block instanceof EmbedEdgelessSyncedDocBlockComponent)) {
|
|
return 0;
|
|
}
|
|
const headerHeight = block.headerWrapper?.getBoundingClientRect().height ?? 0;
|
|
// When the content is not found, we use a default height to display empty information
|
|
const contentHeight =
|
|
block.contentElement?.getBoundingClientRect().height ?? 200;
|
|
|
|
const bottomPadding = 8;
|
|
|
|
return (
|
|
(headerHeight + contentHeight + bottomPadding) /
|
|
block.gfx.viewport.zoom /
|
|
(block.model.props.scale ?? 1)
|
|
);
|
|
}
|