Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(editor): route the remaining panels through the shared EmptyState

yhh1347a2b40a00
diff --git a/desktop/src/i18n/messages/content.ts b/desktop/src/i18n/messages/content.ts
index 831efa7d5..29dc7f441 100644
--- a/desktop/src/i18n/messages/content.ts
+++ b/desktop/src/i18n/messages/content.ts
@@ -40,10 +40,12 @@ export const contentMessages = defineMessages({
'cb.name': { en: 'Name', zh: '名称' },
'cb.type': { en: 'Type', zh: '类型' },
'cb.noMatch': { en: 'No assets match.', zh: '没有匹配的资产。' },
+ 'cb.emptyFolderTitle': { en: 'Empty folder', zh: '空文件夹' },
'cb.emptyFolder': {
- en: 'Empty folder — drag files here or use Import.',
- zh: '空文件夹——将文件拖到此处,或使用导入。',
+ en: 'Drag files here, or use Import to add assets.',
+ zh: '将文件拖到此处,或使用导入添加资产。',
},
+ 'cb.noProjectTitle': { en: 'No project open', zh: '未打开项目' },
'cb.openProjectPrompt': { en: 'Open a project to browse its assets.', zh: '打开一个项目以浏览其资产。' },
'cb.startupScene': { en: 'Startup scene', zh: '启动场景' },
'cb.excludedFromExport': { en: 'Excluded from export', zh: '已从导出中排除' },
diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsx
index 5bceb1c96..bfdbc1c5a 100644
--- a/desktop/src/panels/ContentBrowser.tsx
+++ b/desktop/src/panels/ContentBrowser.tsx
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
import { Fragment, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
-import { ChevronRight, LayoutGrid, List, Import, FolderOpen, FolderPlus, ArrowLeft, ArrowRight, ArrowUp, ArrowDownUp, Play, EyeOff, Plus } from 'lucide-react';
+import { ChevronRight, LayoutGrid, List, Import, FolderOpen, Folder, FolderPlus, ArrowLeft, ArrowRight, ArrowUp, ArrowDownUp, Play, EyeOff, Plus, Search } from 'lucide-react';
import { AssetIcon, assetTint } from '@/components/icons';
+import { EmptyState } from '@/components/EmptyState';
import { IconButton } from '@/components/IconButton';
import { ConfirmDialog } from '@/components/ConfirmDialog';
import { SearchField } from '@/components/SearchField';
@@ -942,10 +943,7 @@ export function ContentBrowser() {
if (!project) {
return (
<div className="panel">
- <div className="empty">
- <FolderOpen size={24} strokeWidth={1.4} />
- <p>{t('cb.openProjectPrompt')}</p>
- </div>
+ <EmptyState icon={FolderOpen} title={t('cb.noProjectTitle')} hint={t('cb.openProjectPrompt')} />
</div>
);
}
@@ -1085,7 +1083,13 @@ export function ContentBrowser() {
setCtx({ x: e.clientX, y: e.clientY, target: null });
}}
>
- {view === 'grid' ? (
+ {!listLoading && items.length === 0 ? (
+ q ? (
+ <EmptyState icon={Search} title={t('cb.noMatch')} />
+ ) : (
+ <EmptyState icon={Folder} title={t('cb.emptyFolderTitle')} hint={t('cb.emptyFolder')} />
+ )
+ ) : view === 'grid' ? (
<div className="cb-grid" style={{ ['--tile' as string]: `${tileSize}px` } as React.CSSProperties}>
{listLoading &&
Array.from({ length: 8 }, (_, i) => (
@@ -1145,11 +1149,6 @@ export function ContentBrowser() {
</div>
);
})}
- {!listLoading && items.length === 0 && (
- <div className="empty-line cb-empty" style={{ gridColumn: '1 / -1' }}>
- {q ? t('cb.noMatch') : t('cb.emptyFolder')}
- </div>
- )}
</div>
) : (
<div className="cb-list">
@@ -1201,9 +1200,6 @@ export function ContentBrowser() {
</div>
);
})}
- {!listLoading && items.length === 0 && (
- <div className="empty-line cb-empty">{q ? t('cb.noMatch') : t('cb.emptyFolder')}</div>
- )}
</div>
)}
</div>
diff --git a/desktop/src/panels/FlipbookEditor.tsx b/desktop/src/panels/FlipbookEditor.tsx
index 03d41c96a..8e6c158a9 100644
--- a/desktop/src/panels/FlipbookEditor.tsx
+++ b/desktop/src/panels/FlipbookEditor.tsx
@@ -13,11 +13,12 @@ import {
useEffect, useRef, useState, useSyncExternalStore,
type CSSProperties, type DragEvent,
} from 'react';
-import { Plus, Trash2, X } from 'lucide-react';
+import { Plus, Trash2, X, Film } from 'lucide-react';
import {
animClipSheetCols, animClipSheetRows,
type AnimClipFrameData, type AnimClipSheetData,
} from 'esengine';
+import { EmptyState } from '@/components/EmptyState';
import { GridField } from '@/components/GridField';
import { Transport } from '@/components/Transport';
import { SaveButton } from '@/components/SaveButton';
@@ -94,12 +95,7 @@ export function FlipbookEditor() {
}, [playing, playFrames, playFps]);
if (!asset) {
- return (
- <div className="fb-empty">
- <p>{t('fb.noOpen')}</p>
- <p className="fb-hint">{t('fb.noOpenHint')}</p>
- </div>
- );
+ return <EmptyState icon={Film} title={t('fb.noOpen')} hint={t('fb.noOpenHint')} />;
}
const fps = asset.fps ?? 12;
diff --git a/desktop/src/panels/Outliner.tsx b/desktop/src/panels/Outliner.tsx
index c3cb7b1e7..3ce3ae58a 100644
--- a/desktop/src/panels/Outliner.tsx
+++ b/desktop/src/panels/Outliner.tsx
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
-import { Search, Plus, FolderPlus, ArrowDownUp } from 'lucide-react';
+import { Search, Plus, FolderPlus, ArrowDownUp, Boxes } from 'lucide-react';
import { SearchField } from '@/components/SearchField';
+import { EmptyState } from '@/components/EmptyState';
import { useEditorStore } from '@/store/editorStore';
import { useSelection } from '@/store/selectionStore';
import { EngineHost } from '@/engine/EngineHost';
@@ -723,18 +724,21 @@ export function Outliner() {
)}
{sceneCount === 0 ? (
<div className="pbody" onDragOver={onBodyDragOver} onDrop={onBodyDrop} onContextMenu={onBodyContextMenu}>
- <div className="empty">
- <Search size={22} strokeWidth={1.4} />
- <p>{engine.status === 'ready' ? t('out.emptyScene') : t('out.waitingEngine')}</p>
- {engine.status === 'ready' && <small>{t('out.emptyHint')}</small>}
- </div>
+ <EmptyState
+ icon={Boxes}
+ title={engine.status === 'ready' ? t('out.emptyScene') : t('out.waitingEngine')}
+ hint={engine.status === 'ready' ? t('out.emptyHint') : undefined}
+ >
+ {engine.status === 'ready' && (
+ <button type="button" className="empty-state__action" onClick={() => setCreateFor({ parent: null })}>
+ <Plus size={14} /> {t('out.addEntity')}
+ </button>
+ )}
+ </EmptyState>
</div>
) : items.length === 0 ? (
<div className="pbody" onDragOver={onBodyDragOver} onDrop={onBodyDrop} onContextMenu={onBodyContextMenu}>
- <div className="empty">
- <Search size={22} strokeWidth={1.4} />
- <p>{t('out.noMatch', { query })}</p>
- </div>
+ <EmptyState icon={Search} title={t('out.noMatch', { query })} />
</div>
) : (
<VirtualTree
diff --git a/desktop/src/panels/Sequencer.tsx b/desktop/src/panels/Sequencer.tsx
index 5b541c079..99cb09a71 100644
--- a/desktop/src/panels/Sequencer.tsx
+++ b/desktop/src/panels/Sequencer.tsx
@@ -28,6 +28,7 @@ import { useSequencerStore } from '@/store/sequencerStore';
import { useSelection } from '@/store/selectionStore';
import { SceneModel } from '@/engine/SceneModel';
import { ContextMenu, type MenuItem } from '@/components/Menu';
+import { EmptyState } from '@/components/EmptyState';
import { eventWindow } from '@/components/PanelWindow';
import { IconButton } from '@/components/IconButton';
import { NumField } from '@/components/NumField';
@@ -88,24 +89,6 @@ function buildAddTrackItems(asset: { tracks: unknown } | null, rootSourceId: num
return items;
}
-function EmptyState() {
- return (
- <div className="seq-empty">
- <Film size={30} strokeWidth={1.3} />
- <div className="seq-empty__title">{t('seq.empty.title')}</div>
- <div className="seq-empty__hint">{t('seq.empty.hint')}</div>
- <button type="button" className="seq-btn seq-btn--text on" onClick={() => void createAnimationClip('')}>
- <Plus size={14} /><span>{t('seq.empty.new')}</span>
- </button>
- <ol className="seq-empty__steps">
- <li>{t('seq.empty.step1')}</li>
- <li>{t('seq.empty.step2')}</li>
- <li>{t('seq.empty.step3')}</li>
- </ol>
- </div>
- );
-}
-
export function Sequencer() {
// Re-read the document on every revision bump (open / edit / close).
useSyncExternalStore(TimelineDocument.subscribe, TimelineDocument.getRevision);
@@ -144,7 +127,22 @@ export function Sequencer() {
return () => { useSelection.getState().setInspectSource(null); };
}, [timelineOpen, timelinePath, keyframeSel]);
- if (!asset) return <div className="seq"><EmptyState /></div>;
+ if (!asset) {
+ return (
+ <div className="seq">
+ <EmptyState icon={Film} title={t('seq.empty.title')} hint={t('seq.empty.hint')}>
+ <button type="button" className="empty-state__action" onClick={() => void createAnimationClip('')}>
+ <Plus size={14} /> {t('seq.empty.new')}
+ </button>
+ <ol className="seq-empty__steps">
+ <li>{t('seq.empty.step1')}</li>
+ <li>{t('seq.empty.step2')}</li>
+ <li>{t('seq.empty.step3')}</li>
+ </ol>
+ </EmptyState>
+ </div>
+ );
+ }
return <SequencerBody />;
}
diff --git a/desktop/src/theme/app.css b/desktop/src/theme/app.css
index 947c59317..82d0dd77b 100644
--- a/desktop/src/theme/app.css
+++ b/desktop/src/theme/app.css
@@ -188,6 +188,25 @@
}
.empty-state__title { font-size: var(--fs-md); color: var(--text-dim); font-weight: 600; }
.empty-state__hint { font-size: var(--fs-sm); line-height: 1.5; max-width: 260px; }
+/* An optional primary action inside the empty state (e.g. "Add Entity" / "New
+ animation") — outlined accent, matching the Save button's restraint (the accent
+ fill stays reserved for Play). */
+.empty-state__action {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 2px;
+ padding: 5px 12px;
+ font: inherit;
+ font-weight: 600;
+ color: var(--acc-hi);
+ background: transparent;
+ border: 1px solid var(--acc);
+ border-radius: var(--r-sm);
+ cursor: pointer;
+ transition: background var(--t-fast), color var(--t-fast);
+}
+.empty-state__action:hover { background: var(--srf-4); color: var(--acc-hi); }
/* -------------------------------------------------------------- viewport --- */
.viewport {