Skip to content

Commit

Permalink
fix: optimize some styles
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Oct 30, 2024
1 parent fdc547a commit 9b99bf4
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 10 deletions.
7 changes: 5 additions & 2 deletions apps/renderer/src/hooks/biz/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ export const useEntryActions = ({
view,
entry,
type,
inList,
}: {
view?: number
entry?: FlatEntryModel | null
type?: "toolbar" | "entryList"
inList?: boolean
}) => {
const { t } = useTranslation()

Expand Down Expand Up @@ -624,7 +626,7 @@ export const useEntryActions = ({
name: t("entry_actions.mark_as_read"),
shortcut: shortcuts.entry.toggleRead.key,
className: "i-mgc-round-cute-fi",
hide: !!(!!populatedEntry.read || populatedEntry.collections),
hide: !!(!!populatedEntry.read || populatedEntry.collections) || inList,
onClick: () => {
read.mutate(populatedEntry)
},
Expand All @@ -634,7 +636,7 @@ export const useEntryActions = ({
name: t("entry_actions.mark_as_unread"),
shortcut: shortcuts.entry.toggleRead.key,
className: "i-mgc-round-cute-re",
hide: !!(!populatedEntry.read || populatedEntry.collections),
hide: !!(!populatedEntry.read || populatedEntry.collections) || inList,
onClick: () => {
unread.mutate(populatedEntry)
},
Expand Down Expand Up @@ -662,6 +664,7 @@ export const useEntryActions = ({
feed?.ownerUserId,
type,
showSourceContent,
inList,
saveToObsidian,
obsidianVaultPath,
openTipModal,
Expand Down
2 changes: 1 addition & 1 deletion apps/renderer/src/modules/boost/boost-progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const BoostProgress = ({
<i className="i-mgc-train-cute-fi mr-2 shrink-0" />
{numberFormater.format(boostCount)}
</span>
<div className="relative flex h-3 w-full overflow-hidden rounded-3xl bg-gray-200 dark:bg-gray-800">
<div className="relative flex h-3 w-full overflow-hidden rounded-3xl bg-gray-200 dark:bg-zinc-800">
<div
role="progressbar"
aria-valuenow={boostCount}
Expand Down
21 changes: 16 additions & 5 deletions apps/renderer/src/modules/boost/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
import { useI18n } from "~/hooks/common"
import { useBoostFeedMutation, useBoostStatusQuery } from "~/modules/boost/query"
import { useWallet } from "~/queries/wallet"
import { useFeedById } from "~/store/feed"
import { feedIconSelector } from "~/store/feed/selector"

import { FeedIcon } from "../feed/feed-icon"
import { BoostProgress } from "./boost-progress"
import { BoostingContributors } from "./boosting-contributors"
import { LevelBenefits } from "./level-benefits"
Expand All @@ -36,6 +39,8 @@ export const BoostModalContent = ({ feedId }: { feedId: string }) => {
boostFeedMutation.mutate({ feedId, amount: amountBigInt.toString() })
}, [amountBigInt, boostFeedMutation, feedId])

const feed = useFeedById(feedId, feedIconSelector)

if (isLoading || !boostStatus) {
return (
<div className="center pointer-events-none grow -translate-y-16">
Expand All @@ -46,12 +51,18 @@ export const BoostModalContent = ({ feedId }: { feedId: string }) => {

return (
<div className="flex w-[80vw] max-w-[350px] flex-col gap-3">
<div className="relative flex w-full grow flex-col items-center gap-3">
<div className="center mt-4 flex text-xl font-bold">
<i className="i-mgc-rocket-cute-fi mr-1.5 text-lg" />
{t("boost.boost_feed")}
</div>
<div className="center flex flex-col gap-2">
<FeedIcon className="mr-0" feed={feed} size={50} />

<h1 className="center mt-2 flex text-lg font-bold">
<div className="center flex">
<i className="i-mgc-rocket-cute-fi mr-1.5 text-lg" />
{t("boost.boost_feed")}
</div>
<span>{feed?.title}</span>
</h1>
</div>
<div className="relative flex w-full grow flex-col items-center gap-3">
<small className="center -mt-1 mb-2 gap-1 text-theme-vibrancyFg">
{t("boost.boost_feed_description")}
</small>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ export const EntryItemWrapper: FC<
style?: React.CSSProperties
} & PropsWithChildren
> = ({ entry, view, children, itemClassName, style }) => {
const listId = useRouteParamsSelector((s) => s.listId)
const { items } = useEntryActions({
view,
entry,
type: "entryList",
inList: !!listId,
})

const { items: feedItems } = useFeedActions({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { setGeneralSetting, useGeneralSettingKey } from "~/atoms/settings/genera
import { setUISetting, useUISettingKey } from "~/atoms/settings/ui"
import { useWhoami } from "~/atoms/user"
import { ImpressionView } from "~/components/common/ImpressionTracker"
import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING } from "~/constants"
import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING, ROUTE_FEED_IN_LIST } from "~/constants"
import { shortcuts } from "~/constants/shortcuts"
import { useRouteParams } from "~/hooks/biz/useRouteParams"
import { useAIDailyReportModal } from "~/modules/ai/ai-daily/useAIDailyReportModal"
Expand All @@ -42,7 +42,8 @@ export const EntryListHeader: FC<{
const os = getOS()

const titleAtBottom = IN_ELECTRON && os === "macOS"
const isInCollectionList = feedId === FEED_COLLECTION_LIST
const isInCollectionList =
feedId === FEED_COLLECTION_LIST || feedId?.startsWith(ROUTE_FEED_IN_LIST)

const titleInfo = !!headerTitle && (
<div className={!titleAtBottom ? "min-w-0 translate-y-1" : void 0}>
Expand Down
3 changes: 3 additions & 0 deletions apps/renderer/src/modules/entry-content/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { useUISettingKey } from "~/atoms/settings/ui"
import { shortcuts } from "~/constants/shortcuts"
import { useEntryActions, useEntryReadabilityToggle } from "~/hooks/biz/useEntryActions"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { tipcClient } from "~/lib/client"
import { parseHtml } from "~/lib/parse-html"
import type { FlatEntryModel } from "~/store/entry"
Expand All @@ -41,10 +42,12 @@ function EntryHeaderImpl({
}) {
const entry = useEntry(entryId)

const listId = useRouteParamsSelector((s) => s.listId)
const { items } = useEntryActions({
view,
entry,
type: "toolbar",
inList: !!listId,
})

const entryTitleMeta = useEntryTitleMeta()
Expand Down
13 changes: 13 additions & 0 deletions apps/renderer/src/store/feed/selector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FeedModel } from "@follow/models"

export const feedIconSelector = (feed: FeedModel) => {
return {
type: feed.type,
ownerUserId: feed.ownerUserId,
id: feed.id,
title: feed.title,
url: (feed as any).url || "",
image: feed.image,
siteUrl: feed.siteUrl,
}
}

0 comments on commit 9b99bf4

Please sign in to comment.