Skip to content

Commit f44a4c4

Browse files
committed
fix(timeline): adjust layout for AIEnhancedTimeline to ensure minimum width
- Updated the AIEnhancedTimelineLayout component to set a minimum width of 300px for better layout consistency. - Enhanced the flex properties to improve responsiveness and visual structure. Signed-off-by: Innei <[email protected]>
1 parent 14c3d95 commit f44a4c4

File tree

5 files changed

+59
-19
lines changed

5 files changed

+59
-19
lines changed

apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ const AIEnhancedTimelineLayoutImpl = () => {
119119
const showCompactTimelineColumn = useGeneralSettingKey("showCompactTimelineInSub")
120120
return (
121121
<div className="relative flex min-w-0 grow">
122-
<div className={cn("h-full flex-1", aiPanelStyle === AIChatPanelStyle.Fixed && "border-r")}>
122+
<div
123+
className={cn(
124+
"h-full min-w-[300px] flex-1",
125+
aiPanelStyle === AIChatPanelStyle.Fixed && "border-r",
126+
)}
127+
>
123128
<AppLayoutGridContainerProvider>
124129
<div className="relative h-full">
125130
{/* Entry list - always rendered to prevent animation */}

apps/desktop/layer/renderer/src/modules/entry-content/actions/more-actions.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ import type { FollowCommandId } from "~/modules/command/types"
2626
export const MoreActions = ({
2727
entryId,
2828
view,
29-
29+
showMainAction = false,
3030
hideCustomizeToolbar = false,
3131
}: {
3232
entryId: string
3333
view: FeedViewType
34-
34+
showMainAction?: boolean
3535
hideCustomizeToolbar?: boolean
3636
}) => {
37-
const { moreAction } = useSortedEntryActions({ entryId, view })
37+
const { moreAction, mainAction } = useSortedEntryActions({ entryId, view })
3838

3939
const actionConfigs = useMemo(
4040
() =>
@@ -81,7 +81,25 @@ export const MoreActions = ({
8181
<ActionButton icon={<i className="i-mingcute-more-1-fill" />} />
8282
</DropdownMenuTrigger>
8383
<RootPortal>
84-
<DropdownMenuContent>
84+
<DropdownMenuContent align="end">
85+
{showMainAction && (
86+
<div>
87+
{mainAction
88+
.filter((config) => config instanceof MenuItemText)
89+
.map((config) => {
90+
return (
91+
<CommandDropdownMenuItem
92+
key={config.id}
93+
commandId={config.id}
94+
onClick={config.onClick!}
95+
active={config.active}
96+
/>
97+
)
98+
})}
99+
<DropdownMenuSeparator />
100+
</div>
101+
)}
102+
85103
{availableActions.map((config) => {
86104
// Handle EntryActionI with sub-menu
87105
if (config instanceof EntryActionDropdownItem && config.hasChildren) {

apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo } from "react"
1+
import { memo, useLayoutEffect, useRef, useState } from "react"
22

33
import { useEntryContentScrollToTop } from "../../atoms"
44
import { EntryHeaderRoot } from "./internal/context"
@@ -8,16 +8,32 @@ import type { EntryHeaderProps } from "./types"
88

99
function EntryHeaderImpl({ entryId, className, compact }: EntryHeaderProps) {
1010
const isAtTop = useEntryContentScrollToTop()
11+
const headerRef = useRef<HTMLDivElement>(null)
12+
const [isSmallWidth, setIsSmallWidth] = useState(false)
13+
useLayoutEffect(() => {
14+
const $header = headerRef.current
15+
if (!$header) return
16+
const handler = () => setIsSmallWidth($header.clientWidth <= 500)
17+
18+
const observer = new ResizeObserver(handler)
19+
observer.observe($header)
20+
handler()
21+
22+
return () => {
23+
observer.disconnect()
24+
}
25+
}, [headerRef])
1126
return (
1227
<EntryHeaderRoot entryId={entryId} className={className} compact={compact}>
13-
<div
14-
className="bg-background h-top-header relative z-10 flex w-full items-center justify-between gap-3 px-4"
28+
<nav
29+
className="bg-background @container h-top-header relative z-10 flex w-full items-center justify-between gap-3 px-4"
1530
data-at-top={isAtTop}
1631
data-hide-in-print
32+
ref={headerRef}
1733
>
1834
<EntryHeaderBreadcrumb />
19-
<EntryHeaderActionsContainer />
20-
</div>
35+
<EntryHeaderActionsContainer isSmallWidth={isSmallWidth} />
36+
</nav>
2137
</EntryHeaderRoot>
2238
)
2339
}

apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderActionsContainer.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import clsx from "clsx"
12
import { memo } from "react"
23

34
import { useRouteParams } from "~/hooks/biz/useRouteParams"
@@ -6,14 +7,14 @@ import { EntryHeaderActions } from "../../../actions/header-actions"
67
import { MoreActions } from "../../../actions/more-actions"
78
import { useEntryHeaderContext } from "./context"
89

9-
function EntryHeaderActionsContainerImpl() {
10+
function EntryHeaderActionsContainerImpl({ isSmallWidth }: { isSmallWidth: boolean }) {
1011
const { entryId } = useEntryHeaderContext()
1112
const { view } = useRouteParams()
1213

1314
return (
14-
<div className="relative flex shrink-0 items-center justify-end gap-2">
15-
<EntryHeaderActions entryId={entryId} view={view} />
16-
<MoreActions entryId={entryId} view={view} />
15+
<div className={clsx("relative flex shrink-0 items-center justify-end gap-2")}>
16+
{!isSmallWidth && <EntryHeaderActions entryId={entryId} view={view} />}
17+
<MoreActions entryId={entryId} view={view} showMainAction={isSmallWidth} />
1718
</div>
1819
)
1920
}

apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderBreadcrumb.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export function EntryHeaderBreadcrumb() {
246246
<i className="i-mingcute-close-line size-5" />
247247
</button>
248248
{viewName && (
249-
<div className="flex items-center">
249+
<div className="@[700px]:flex hidden items-center">
250250
<button
251251
type="button"
252252
className={cn(
@@ -262,8 +262,8 @@ export function EntryHeaderBreadcrumb() {
262262
)}
263263
{meta && (
264264
<>
265-
{Slash}
266-
<div className="flex items-center">
265+
<span className="@[700px]:inline hidden">{Slash}</span>
266+
<div className="@[700px]:flex hidden min-w-[120px] shrink items-center">
267267
<button
268268
type="button"
269269
className={cn(
@@ -284,9 +284,9 @@ export function EntryHeaderBreadcrumb() {
284284

285285
{!!meta.entryTitle && (
286286
<>
287-
{Slash}
287+
<span className="@[700px]:inline hidden shrink-0">{Slash}</span>
288288
<span
289-
className="text-text truncate px-1.5 py-0.5 text-sm"
289+
className="text-text min-w-0 max-w-[30vw] truncate px-1.5 py-0.5 text-sm"
290290
title={meta.entryTitle}
291291
>
292292
{meta.entryTitle}

0 commit comments

Comments
 (0)