Skip to content

Commit 4b63023

Browse files
committed
feat: uniq macos entry column position
Signed-off-by: Innei <tukon479@gmail.com>
1 parent eaf33d2 commit 4b63023

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

apps/renderer/src/atoms/dom.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ import { createAtomHooks } from "~/lib/jotai"
44

55
export const [, , useMainContainerElement, , getMainContainerElement, setMainContainerElement] =
66
createAtomHooks(atom<HTMLElement | null>(null))
7+
8+
export const [, , useRootContainerElement, , getRootContainerElement, setRootContainerElement] =
9+
createAtomHooks(atom<HTMLElement | null>(null))

apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { RotatingRefreshIcon } from "@follow/components/ui/loading/index.jsx"
55
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
66
import { FeedViewType, views } from "@follow/constants"
77
import { useIsOnline } from "@follow/hooks"
8-
import { IN_ELECTRON } from "@follow/shared/constants"
98
import { stopPropagation } from "@follow/utils/dom"
10-
import { cn, getOS, isBizId } from "@follow/utils/utils"
9+
import { cn, isBizId } from "@follow/utils/utils"
1110
import type { FC } from "react"
1211
import * as React from "react"
1312
import { useTranslation } from "react-i18next"
@@ -20,6 +19,7 @@ import {
2019
useSetZenMode,
2120
useUISettingKey,
2221
} from "~/atoms/settings/ui"
22+
import { useFeedColumnShow } from "~/atoms/sidebar"
2323
import { useWhoami } from "~/atoms/user"
2424
import { ImpressionView } from "~/components/common/ImpressionTracker"
2525
import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING, ROUTE_FEED_IN_LIST } from "~/constants"
@@ -46,14 +46,12 @@ export const EntryListHeader: FC<{
4646
const { feedId, entryId, view, listId } = routerParams
4747

4848
const headerTitle = useFeedHeaderTitle()
49-
const os = getOS()
5049

51-
const titleAtBottom = IN_ELECTRON && os === "macOS"
5250
const isInCollectionList =
5351
feedId === FEED_COLLECTION_LIST || feedId?.startsWith(ROUTE_FEED_IN_LIST)
5452

5553
const titleInfo = !!headerTitle && (
56-
<div className={!titleAtBottom ? "min-w-0 translate-y-1" : void 0}>
54+
<div className={"min-w-0 translate-y-1"}>
5755
<div className="h-6 min-w-0 break-all text-lg font-bold leading-tight">
5856
<EllipsisHorizontalTextWithTooltip className="inline-block !w-auto max-w-full">
5957
<span className="relative -top-px">{headerTitle}</span>
@@ -78,17 +76,18 @@ export const EntryListHeader: FC<{
7876
const containerRef = React.useRef<HTMLDivElement>(null)
7977
const titleStyleBasedView = ["pl-6", "pl-7", "pl-7", "pl-7", "px-5", "pl-6"]
8078

79+
const feedColumnShow = useFeedColumnShow()
8180
return (
8281
<div
8382
ref={containerRef}
8483
className={cn(
8584
"mb-2 flex w-full flex-col pr-4 pt-2.5 transition-[padding] duration-300 ease-in-out",
85+
!feedColumnShow && "macos:mt-4 macos:pt-margin-macos-traffic-light-y",
8686
titleStyleBasedView[view],
8787
)}
8888
>
89-
<div className={cn("flex w-full", titleAtBottom ? "justify-end" : "justify-between")}>
90-
{!titleAtBottom && titleInfo}
91-
89+
<div className={"flex w-full justify-between"}>
90+
{titleInfo}
9291
<div
9392
className={cn(
9493
"relative z-[1] flex items-center gap-1 self-baseline text-zinc-500",
@@ -163,7 +162,7 @@ export const EntryListHeader: FC<{
163162
)}
164163
</div>
165164
</div>
166-
{titleAtBottom && titleInfo}
165+
167166
{/* <TimelineTabs /> */}
168167
</div>
169168
)

apps/renderer/src/modules/feed-column/index.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useDroppable } from "@dnd-kit/core"
22
import { ActionButton } from "@follow/components/ui/button/index.js"
3+
import { RootPortal } from "@follow/components/ui/portal/index.js"
34
import { Routes, views } from "@follow/constants"
45
import { useTypeScriptHappyCallback } from "@follow/hooks"
56
import { useRegisterGlobalContext } from "@follow/shared/bridge"
@@ -13,8 +14,9 @@ import { startTransition, useCallback, useLayoutEffect, useRef, useState } from
1314
import { isHotkeyPressed, useHotkeys } from "react-hotkeys-hook"
1415
import { useTranslation } from "react-i18next"
1516

17+
import { useRootContainerElement } from "~/atoms/dom"
1618
import { useUISettingKey } from "~/atoms/settings/ui"
17-
import { useFeedColumnShow, useSidebarActiveView } from "~/atoms/sidebar"
19+
import { setFeedColumnShow, useFeedColumnShow, useSidebarActiveView } from "~/atoms/sidebar"
1820
import { HotKeyScopeMap, isElectronBuild } from "~/constants"
1921
import { shortcuts } from "~/constants/shortcuts"
2022
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
@@ -145,19 +147,31 @@ export function FeedColumn({ children, className }: PropsWithChildren<{ classNam
145147

146148
const shouldFreeUpSpace = useShouldFreeUpSpace()
147149
const feedColumnShow = useFeedColumnShow()
150+
const rootContainerElement = useRootContainerElement()
148151

149152
return (
150153
<WindowUnderBlur
151154
data-hide-in-print
152155
className={cn(
153156
"relative flex h-full flex-col space-y-3 pt-2.5",
154157

155-
!feedColumnShow && isElectronBuild && "bg-zinc-200/80 backdrop-blur dark:bg-neutral-800/80",
158+
!feedColumnShow && isElectronBuild && "bg-zinc-200 dark:bg-neutral-800",
156159
className,
157160
)}
158161
onClick={useCallback(() => navigateBackHome(), [navigateBackHome])}
159162
>
160163
<FeedColumnHeader />
164+
{!feedColumnShow && (
165+
<RootPortal to={rootContainerElement}>
166+
<ActionButton
167+
tooltip={"Toggle Feed Column"}
168+
className="center absolute top-2.5 z-0 hidden -translate-x-2 text-zinc-500 left-macos-traffic-light macos:flex"
169+
onClick={() => setFeedColumnShow(true)}
170+
>
171+
<i className="i-mgc-layout-leftbar-open-cute-re" />
172+
</ActionButton>
173+
</RootPortal>
174+
)}
161175

162176
<div
163177
className="flex w-full justify-between px-3 text-xl text-theme-vibrancyFg"

apps/renderer/src/pages/(main)/layout.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Trans, useTranslation } from "react-i18next"
1818
import { useResizable } from "react-resizable-layout"
1919
import { Outlet } from "react-router-dom"
2020

21-
import { setMainContainerElement } from "~/atoms/dom"
21+
import { setMainContainerElement, setRootContainerElement } from "~/atoms/dom"
2222
import { getIsZenMode, getUISettings, setUISetting, useUISettingKey } from "~/atoms/settings/ui"
2323
import {
2424
getFeedColumnTempShow,
@@ -206,9 +206,15 @@ export function Component() {
206206

207207
const RootContainer = forwardRef<HTMLDivElement, PropsWithChildren>(({ children }, ref) => {
208208
const feedColWidth = useUISettingKey("feedColWidth")
209+
const [elementRef, _setElementRef] = useState<HTMLDivElement | null>(null)
210+
const setElementRef = React.useCallback((el: HTMLDivElement | null) => {
211+
_setElementRef(el)
212+
setRootContainerElement(el)
213+
}, [])
214+
React.useImperativeHandle(ref, () => elementRef!)
209215
return (
210216
<div
211-
ref={ref}
217+
ref={setElementRef}
212218
style={
213219
{
214220
"--fo-feed-col-w": `${feedColWidth}px`,

0 commit comments

Comments
 (0)