Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(project): 收紧工程首页 composer tray 的上下 padding 并让加载骨架与内容同构 (#23290)

Lobehub Coder140370d012cd
diff --git a/src/components/Skeleton/ProjectHome.tsx b/src/components/Skeleton/ProjectHome.tsx
new file mode 100644
index 00000000000..1a6064b9a90
--- /dev/null
+++ b/src/components/Skeleton/ProjectHome.tsx
@@ -0,0 +1,118 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+import SkeletonBar from './Bar';
+
+/**
+ * Mirrors the project home (`features/Projects/Workspace`): a vertically
+ * centered intro column — title, subtitle, then the composer's context tray
+ * tucked behind its rounded card. `RouteLoading` renders this for both the
+ * chunk wait and the page's own data wait, so a project home keeps one shape
+ * while it loads instead of showing the generic detail surface first.
+ *
+ * The onboarding checklist below the composer is left out on purpose: the card
+ * only exists while a project still has onboarding steps open, so a placeholder
+ * for it would be the next mismatch for every project that dismissed it.
+ */
+
+/** Same geometry as `ProjectComposer`: tray row, its visible padding, the overlap. */
+const TRAY_ROW_HEIGHT = 32;
+const TRAY_PADDING_BLOCK = 5;
+const TRAY_OVERLAP = 18;
+
+const styles = stylex.create({
+ card: {
+ position: 'relative',
+ zIndex: 1,
+ boxSizing: 'border-box',
+ minHeight: '88px',
+ marginBlockStart: `-${TRAY_OVERLAP}px`,
+ padding: '12px',
+ borderRadius: '18px',
+ backgroundColor: cssVar.colorBgContainer,
+ boxShadow: cssVar.boxShadowSecondary,
+ },
+ intro: {
+ width: '100%',
+ maxWidth: '760px',
+ marginInline: 'auto',
+ },
+ // Same column as the loaded page: centered vertically, 1060px wide at most.
+ page: {
+ boxSizing: 'border-box',
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'center',
+ width: {
+ 'default': 'min(1060px, calc(100% - 64px))',
+ '@media (width <= 720px)': 'calc(100% - 40px)',
+ },
+ minHeight: '100%',
+ marginInline: 'auto',
+ paddingBlock: { 'default': '48px', '@media (width <= 720px)': '32px' },
+ },
+ tray: {
+ paddingBlockStart: `${TRAY_PADDING_BLOCK}px`,
+ paddingBlockEnd: `${TRAY_OVERLAP + TRAY_PADDING_BLOCK}px`,
+ paddingInline: '10px',
+ borderStartStartRadius: '20px',
+ borderStartEndRadius: '20px',
+ backgroundColor: cssVar.colorFillTertiary,
+ },
+ // Same frame as the composer's: the tray stops 24px short of the card on
+ // each side, so its top corners always stay inside the card's silhouette.
+ trayFrame: {
+ paddingInline: '24px',
+ },
+});
+
+const TraySkeleton = () => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.tray).className}
+ justify={'space-between'}
+ >
+ <Flexbox horizontal align={'center'} gap={4} height={TRAY_ROW_HEIGHT}>
+ <SkeletonBar height={24} radius={12} width={76} />
+ <SkeletonBar height={24} radius={12} width={148} />
+ </Flexbox>
+ <SkeletonBar height={24} radius={12} width={96} />
+ </Flexbox>
+);
+
+// The composer is one block, not two: the intro column's gap must not open a
+// seam between the tray and the card it is tucked behind.
+const ComposerSkeleton = () => (
+ <div>
+ <div {...stylex.props(styles.trayFrame)}>
+ <TraySkeleton />
+ </div>
+ <Flexbox className={stylex.props(styles.card).className} gap={10} justify={'space-between'}>
+ <SkeletonBar height={14} radius={7} width={'46%'} />
+ <Flexbox horizontal align={'center'} justify={'space-between'}>
+ <SkeletonBar height={24} radius={'50%'} width={24} />
+ <SkeletonBar height={28} radius={'50%'} width={28} />
+ </Flexbox>
+ </Flexbox>
+ </div>
+);
+
+const ProjectHomeSkeleton = () => (
+ <Flexbox aria-busy flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ <div {...stylex.props(styles.page)}>
+ <Flexbox className={stylex.props(styles.intro).className} gap={18}>
+ <Flexbox align={'center'} gap={5}>
+ <SkeletonBar height={26} radius={8} width={248} />
+ <SkeletonBar height={14} radius={7} width={412} />
+ </Flexbox>
+ <ComposerSkeleton />
+ </Flexbox>
+ </div>
+ </Flexbox>
+);
+
+export default ProjectHomeSkeleton;
diff --git a/src/features/Projects/Workspace/ProjectComposer.tsx b/src/features/Projects/Workspace/ProjectComposer.tsx
index 71d539c8af6..3ed075fbe2f 100644
--- a/src/features/Projects/Workspace/ProjectComposer.tsx
+++ b/src/features/Projects/Workspace/ProjectComposer.tsx
@@ -64,6 +64,13 @@ const TRAY_OVERLAP = CONTAINER_RADIUS;
*/
const COMPACT_TRAY_WIDTH = 500;
+/**
+ * Visible breathing room above and below the tray's controls. The tray also
+ * carries `TRAY_OVERLAP` at its block-end, but the composer card covers that
+ * band, so this is the padding that actually shows on both sides of the row.
+ */
+const TRAY_PADDING_BLOCK = 5;
+
const styles = stylex.create({
// The composer sits in front of the tray. The tray is inset by more than the
// composer's corner radius on each side, so it only ever meets the
@@ -89,8 +96,8 @@ const styles = stylex.create({
},
tray: {
gap: '8px',
- paddingBlockStart: '8px',
- paddingBlockEnd: `${TRAY_OVERLAP + 8}px`,
+ paddingBlockStart: `${TRAY_PADDING_BLOCK}px`,
+ paddingBlockEnd: `${TRAY_OVERLAP + TRAY_PADDING_BLOCK}px`,
paddingInline: '10px',
borderStartStartRadius: '20px',
borderStartEndRadius: '20px',
diff --git a/src/features/Projects/routeMeta.ts b/src/features/Projects/routeMeta.ts
index af55b2c5d5e..71443d886da 100644
--- a/src/features/Projects/routeMeta.ts
+++ b/src/features/Projects/routeMeta.ts
@@ -2,6 +2,7 @@ import { ClipboardCheckIcon, FolderClosedIcon } from 'lucide-react';
import { lazy } from 'react';
import ConversationSegmentSkeleton from '@/components/Skeleton/Conversation/Segment';
+import ProjectHomeSkeleton from '@/components/Skeleton/ProjectHome';
import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
import { goalsRouteMeta } from '@/features/AgentGoals/routeMeta';
import { tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
@@ -32,10 +33,12 @@ export const projectDirectoriesRouteMeta = routeMeta({
titleKey: 'project:settings.title',
});
+// The home is a centered composer page, not a detail surface: its skeleton keeps
+// the title/subtitle and the tray + card instead of an avatar header and pills.
export const projectHomeRouteMeta = routeMeta({
DynamicMeta: ProjectSectionDynamicMeta,
icon: FolderClosedIcon,
- Skeleton: createSurfaceSkeleton('detail'),
+ Skeleton: ProjectHomeSkeleton,
titleKey: 'project:sections.home',
});
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 3fa33c041c7..29c2c2bacd2 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -17,6 +17,7 @@ import GoalSkeleton from '@/components/Skeleton/Goal';
import GoalDetailSkeleton from '@/components/Skeleton/GoalDetail';
import MemorySkeleton from '@/components/Skeleton/Memory';
import ProfileSkeleton, { GroupProfileRouteSkeleton } from '@/components/Skeleton/Profile';
+import ProjectHomeSkeleton from '@/components/Skeleton/ProjectHome';
import ResourceHomeSkeleton from '@/components/Skeleton/ResourceHome';
import RouteSegmentSkeleton from '@/components/Skeleton/RouteSegment';
import SettingsPageSkeleton from '@/components/Skeleton/Settings/Page';
@@ -194,6 +195,21 @@ describe('desktop router shared definition', () => {
},
);
+ it.each(mainAreaVariants)(
+ '%s renders the project home skeleton on the composer layout',
+ (_, factory) => {
+ // Regression: the home is a centered composer page (title, subtitle, then the
+ // tray + card), but its route skeleton was the generic avatar/detail surface,
+ // so the first paint and the loaded page had different layouts.
+ const matches = matchRoutes(createMainAreaRoutes(factory), '/project/prj_1');
+ const Skeleton = resolveRouteSkeleton(
+ matches?.map(({ route }) => ({ handle: route.handle })) ?? [],
+ );
+
+ expect(Skeleton).toBe(ProjectHomeSkeleton);
+ },
+ );
+
it.each(mainAreaVariants)('%s keeps legacy self-learning deep-links matching', (_, factory) => {
const matches = matchRoutes(
createMainAreaRoutes(factory),