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(sidebar): unify Favorites and Recents headers and rows at 32px (#23276)

Rdmclin2f7af96e6054d
diff --git a/src/features/Home/Recents/Item.tsx b/src/features/Home/Recents/Item.tsx
index e9f45c73423..6ba59e819ce 100644
--- a/src/features/Home/Recents/Item.tsx
+++ b/src/features/Home/Recents/Item.tsx
@@ -13,8 +13,8 @@ import { usePrefetchPage } from '@/hooks/usePrefetchPage';
import { useRecentItemDropdownMenu } from './useDropdownMenu';
-/** Same density as the Favorites rows above. */
-const ICON_SIZE = 14;
+/** Same size as the Favorites row icons above. */
+const ICON_SIZE = 16;
const TYPE_ICON_MAP: Partial<Record<'document' | 'task' | 'topic', typeof FileTextIcon>> = {
document: FileTextIcon,
@@ -47,8 +47,8 @@ const RecentListItem = memo<RecentItem>((item) => {
return (
<Flexbox style={{ position: 'relative' }}>
<NavItem
- compact
contextMenuItems={dropdownMenu}
+ height={32}
title={title}
actions={
<DropdownMenu items={dropdownMenu()}>
diff --git a/src/features/Home/Recents/List.tsx b/src/features/Home/Recents/List.tsx
index 87e17dc1315..fb54d22c1aa 100644
--- a/src/features/Home/Recents/List.tsx
+++ b/src/features/Home/Recents/List.tsx
@@ -56,7 +56,12 @@ const RecentsList = memo<RecentsListProps>(({ error, onRetry }) => {
return <ConnectedItem itemRef={itemRef} key={itemRef} queryKey={queryKey} />;
})}
{hasMore && (
- <NavItem compact icon={MoreHorizontalIcon} title={t('input.more')} onClick={openDrawer} />
+ <NavItem
+ height={32}
+ icon={MoreHorizontalIcon}
+ title={t('input.more')}
+ onClick={openDrawer}
+ />
)}
<AllRecentsDrawer open={drawerOpen} onClose={closeDrawer} />
</Flexbox>
diff --git a/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx b/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx
index 7f79417f90b..e69d76c6347 100644
--- a/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/FavoriteItem.tsx
@@ -38,9 +38,9 @@ const FavoriteItem = memo<FavoriteItemProps>(({ active, item }) => {
return (
<WorkspaceLink to={item.path}>
<NavItem
- compact
active={active}
contextMenuItems={menuItems}
+ height={32}
icon={<FavoriteItemIcon item={item} />}
title={item.title}
actions={() => (
diff --git a/src/features/HomeSidebar/Body/Favorites/FavoriteItemIcon.tsx b/src/features/HomeSidebar/Body/Favorites/FavoriteItemIcon.tsx
index a24ecfe8aec..1c81354321f 100644
--- a/src/features/HomeSidebar/Body/Favorites/FavoriteItemIcon.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/FavoriteItemIcon.tsx
@@ -9,7 +9,7 @@ import RunningGlyph from '@/features/Home/components/RunningGlyph';
import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
-const ICON_SIZE = 14;
+const ICON_SIZE = 16;
/**
* Leading icon of a favorite row. A task wears its status, the way Recents
diff --git a/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx b/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx
index 50168e2a650..b7897e299af 100644
--- a/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/SortableFavoriteList.tsx
@@ -18,7 +18,7 @@ import {
} from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
import type { FavoriteItem as FavoriteItemType } from '@lobechat/types';
-import { toast } from '@lobehub/ui';
+import { Flexbox, toast } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { memo, useMemo, useState } from 'react';
@@ -129,16 +129,18 @@ const SortableFavoriteList = memo<{ items: FavoriteItemType[] }>(({ items }) =>
onDragStart={handleDragStart}
>
<SortableContext items={ids} strategy={verticalListSortingStrategy}>
- {items.map((item) => (
- <SortableFavoriteItem active={item.path === currentPath} item={item} key={item.id} />
- ))}
+ <Flexbox gap={1}>
+ {items.map((item) => (
+ <SortableFavoriteItem active={item.path === currentPath} item={item} key={item.id} />
+ ))}
+ </Flexbox>
</SortableContext>
{createPortal(
<DragOverlay dropAnimation={sortableRowDropAnimation}>
{activeItem ? (
<div {...stylex.props(styles.overlay)}>
<NavItem
- compact
+ height={32}
icon={<FavoriteItemIcon item={activeItem} />}
// The card itself is the surface: no hover tint on top of the white.
style={{ backgroundColor: 'transparent' }}
diff --git a/src/features/HomeSidebar/Body/Favorites/index.tsx b/src/features/HomeSidebar/Body/Favorites/index.tsx
index 0be232dade8..749ae627e6c 100644
--- a/src/features/HomeSidebar/Body/Favorites/index.tsx
+++ b/src/features/HomeSidebar/Body/Favorites/index.tsx
@@ -38,7 +38,10 @@ const Favorites = memo<FavoritesProps>(({ itemKey }) => {
return (
<AccordionItem value={itemKey}>
- <AccordionHeader>
+ {/* Recents and Agents carry a header action that sets their height at
+ 32px; Favorites has none, so pin the same height to keep the
+ section headers aligned. */}
+ <AccordionHeader style={{ minHeight: 32 }}>
<AccordionTrigger style={{ paddingBlock: 4, paddingInline: '8px 4px' }}>
<Text ellipsis fontSize={12} type="secondary" weight={500}>
{t('favorite.section')}
diff --git a/src/features/NavPanel/components/NavItem.tsx b/src/features/NavPanel/components/NavItem.tsx
index 835908bc70f..ebc09e0ff09 100644
--- a/src/features/NavPanel/components/NavItem.tsx
+++ b/src/features/NavPanel/components/NavItem.tsx
@@ -100,8 +100,8 @@ const styles = createStaticStyles(({ css }) => ({
mask-image: linear-gradient(
to right,
transparent,
- #000 var(${TITLE_MARQUEE_FADE_START_VAR}, 0px),
- #000 calc(100% - var(${TITLE_MARQUEE_FADE_END_VAR})),
+ black var(${TITLE_MARQUEE_FADE_START_VAR}, 0px),
+ black calc(100% - var(${TITLE_MARQUEE_FADE_END_VAR})),
transparent
);
`,
@@ -125,12 +125,6 @@ export interface NavItemProps extends Omit<BlockProps, 'children' | 'title'> {
*/
actions?: LazyActions;
active?: boolean;
- /**
- * Denser single-line row for long lists of shortcuts (e.g. Favorites): 28px
- * tall with 13px text and a 16px icon, instead of 36px / 14px / 18px. The
- * icon column keeps its width, so titles still line up with the other rows.
- */
- compact?: boolean;
contextMenuItems?: DropdownItem[] | (() => DropdownItem[]);
/**
* Optional second line rendered under the title (e.g. a topic's project
@@ -172,10 +166,9 @@ const NavItem = memo<NavItemProps>(
actions,
contextMenuItems,
active,
- compact,
href,
icon,
- iconSize = compact ? 16 : 18,
+ iconSize = 18,
title,
titleColor,
titleMarquee,
@@ -244,11 +237,10 @@ const NavItem = memo<NavItemProps>(
}
: undefined;
- const titleFontSize = compact ? 13 : undefined;
// A description stacks the title in a column, where `flex: 1` would grow it vertically.
const titleStyle = description ? undefined : { flex: 1 };
const titleNode = marquee ? (
- <Text color={textColor} fontSize={titleFontSize} style={{ ...titleStyle, minWidth: 0 }}>
+ <Text color={textColor} style={{ ...titleStyle, minWidth: 0 }}>
<span className={styles.marqueeViewport} ref={titleViewportRef}>
<span className={styles.marqueeText} ref={titleTextRef}>
{title}
@@ -256,12 +248,7 @@ const NavItem = memo<NavItemProps>(
</span>
</Text>
) : (
- <Text
- color={textColor}
- ellipsis={{ tooltipWhenOverflow: true }}
- fontSize={titleFontSize}
- style={titleStyle}
- >
+ <Text color={textColor} ellipsis={{ tooltipWhenOverflow: true }} style={titleStyle}>
{title}
</Text>
);
@@ -292,7 +279,7 @@ const NavItem = memo<NavItemProps>(
clickable={!disabled}
data-nav-item=""
gap={8}
- height={description ? undefined : compact ? 28 : 36}
+ height={description ? undefined : 36}
paddingBlock={description ? 8 : undefined}
paddingInline={4}
style={mergedStyle}