diff --git a/icons/mgc/information_cute_re copy.svg b/icons/mgc/information_cute_re copy.svg new file mode 100644 index 000000000..1de415665 --- /dev/null +++ b/icons/mgc/information_cute_re copy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/package.json b/package.json index 1551c6ae2..173ee7e6b 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@hookform/resolvers": "3.9.0", "@iconify/tools": "4.0.4", "@mozilla/readability": "^0.5.0", + "@radix-ui/react-accordion": "1.2.0", "@radix-ui/react-alert-dialog": "1.1.1", "@radix-ui/react-avatar": "1.1.0", "@radix-ui/react-checkbox": "1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ae1d8d19e..4673a31c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,6 +46,9 @@ importers: '@mozilla/readability': specifier: ^0.5.0 version: 0.5.0(patch_hash=fgkvsbckled47trggkhdkimzbm) + '@radix-ui/react-accordion': + specifier: 1.2.0 + version: 1.2.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@radix-ui/react-alert-dialog': specifier: 1.1.1 version: 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -1383,6 +1386,19 @@ packages: '@radix-ui/primitive@1.1.0': resolution: {integrity: sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA==} + '@radix-ui/react-accordion@1.2.0': + resolution: {integrity: sha512-HJOzSX8dQqtsp/3jVxCU3CXEONF7/2jlGAB28oX8TTw1Dz8JYbEI1UcL8355PuLBE41/IRRMvCw7VkiK/jcUOQ==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-alert-dialog@1.1.1': resolution: {integrity: sha512-wmCoJwj7byuVuiLKqDLlX7ClSUU0vd9sdCeM+2Ls+uf13+cpSJoMgwysHq1SGVVkJj5Xn0XWi1NoRCdkMpr6Mw==} peerDependencies: @@ -8261,6 +8277,23 @@ snapshots: '@radix-ui/primitive@1.1.0': {} + '@radix-ui/react-accordion@1.2.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@radix-ui/primitive': 1.1.0 + '@radix-ui/react-collapsible': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-collection': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-direction': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-id': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.3)(react@18.3.1) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + optionalDependencies: + '@types/react': 18.3.3 + '@types/react-dom': 18.3.0 + '@radix-ui/react-alert-dialog@1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@radix-ui/primitive': 1.1.0 diff --git a/src/hono.ts b/src/hono.ts index 4b3e756af..22b39b6b0 100644 --- a/src/hono.ts +++ b/src/hono.ts @@ -2723,6 +2723,22 @@ declare const _routes: hono_hono_base.HonoBase, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AccordionItem.displayName = "AccordionItem" + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + svg]:rotate-180", + className, + )} + {...props} + > + {children} + {/* */} + + +)) +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + +
{children}
+
+)) +AccordionContent.displayName = AccordionPrimitive.Content.displayName + +export { Accordion, AccordionContent, AccordionItem, AccordionTrigger } diff --git a/src/renderer/src/modules/entry-content/daily.tsx b/src/renderer/src/modules/entry-content/daily.tsx new file mode 100644 index 000000000..42fb499ab --- /dev/null +++ b/src/renderer/src/modules/entry-content/daily.tsx @@ -0,0 +1,173 @@ +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from "@renderer/components/ui/accordion" +import { Card, CardHeader } from "@renderer/components/ui/card" +import { LoadingCircle } from "@renderer/components/ui/loading" +import { Markdown } from "@renderer/components/ui/markdown" +import { ScrollArea } from "@renderer/components/ui/scroll-area" +import { Tooltip, TooltipContent, TooltipTrigger } from "@renderer/components/ui/tooltip" +import { useAuthQuery } from "@renderer/hooks/common" +import { apiClient } from "@renderer/lib/api-fetch" +import { defineQuery } from "@renderer/lib/defineQuery" +import { cn } from "@renderer/lib/utils" +import { MarkAllButton } from "@renderer/modules/entry-column/mark-all-button" +import { useState } from "react" + +export const DailyItem = ({ + value, + index, + view, +}: { + value?: string + index: 0 | 1 + view: 0 | 1 +}) => { + const dateObj = new Date() + + const nowHour = dateObj.getHours() + let startDate: number + let endDate: number + let title: string + + const today8AM = dateObj.setHours(8, 0, 0, 0) + const today8PM = dateObj.setHours(20, 0, 0, 0) + dateObj.setDate(dateObj.getDate() - 1) + const yesterday8AM = dateObj.setHours(8, 0, 0, 0) + const yesterday8PM = dateObj.setHours(20, 0, 0, 0) + dateObj.setDate(dateObj.getDate() - 1) + const dayBeforeYesterday8PM = dateObj.setHours(20, 0, 0, 0) + + // For index 0, get the last past 8 AM or 8 PM; for index 1, get the second last past 8 AM or 8 PM. + if (nowHour >= 20) { + if (index === 0) { + endDate = today8PM - 1 + startDate = today8AM + title = "Today" + } else { + endDate = today8AM - 1 + startDate = yesterday8PM + title = "Last Night" + } + } else if (nowHour >= 8) { + if (index === 0) { + endDate = today8AM - 1 + startDate = yesterday8PM + title = "Last Night" + } else { + endDate = yesterday8PM - 1 + startDate = yesterday8AM + title = "Yesterday" + } + } else { + if (index === 0) { + endDate = yesterday8PM - 1 + startDate = yesterday8AM + title = "Yesterday" + } else { + endDate = yesterday8AM - 1 + startDate = dayBeforeYesterday8PM + title = "The Night Before Last" + } + } + + const content = useAuthQuery( + defineQuery(["daily", view, startDate, endDate], async () => { + const res = await apiClient.ai.daily.$get({ + query: { + startDate: `${+startDate}`, + view: `${view}`, + }, + }) + return res.data + }), + { + enabled: value === `${index}`, + }, + ) + + return ( + + + + +
+ +
+ {title} + 's Top News +
+ + + + + +
    +
  • + Here is news selected by AI from your timeline + {" ("} + {new Date(startDate).toLocaleTimeString("en-US", { weekday: "short", hour: "numeric", minute: "numeric" })} + {" "} + - + {" "} + {new Date(endDate + 1).toLocaleTimeString("en-US", { weekday: "short", hour: "numeric", minute: "numeric" })} + {") "} + that may be important to you. +
  • +
  • Update daily at 8 AM and 8 PM.
  • +
+
+
+
+
+ + + {content.isLoading ? ( + + ) : ( + content.data && ( + {content.data} + ) + )} + +
+ + Mark all as read +
+
+
+
+
+ ) +} + +export const Daily = ({ + view, + className, +}: { + view: 0 | 1 + className?: string +}) => { + const [value, setValue] = useState() + + return ( +
+ + + + +
+ ) +} diff --git a/src/renderer/src/modules/entry-content/index.tsx b/src/renderer/src/modules/entry-content/index.tsx index 60e7a6ae8..c350e215b 100644 --- a/src/renderer/src/modules/entry-content/index.tsx +++ b/src/renderer/src/modules/entry-content/index.tsx @@ -11,10 +11,12 @@ import { Logo } from "@renderer/components/icons/logo" import { AutoResizeHeight } from "@renderer/components/ui/auto-resize-height" import { StyledButton } from "@renderer/components/ui/button" import { ScrollArea } from "@renderer/components/ui/scroll-area" +import { ROUTE_FEED_PENDING } from "@renderer/constants" import { useEntryReadabilityToggle } from "@renderer/hooks/biz/useEntryActions" -import { useRouteParamsSelector } from "@renderer/hooks/biz/useRouteParams" +import { useRouteParamsSelector, useRouteParms } from "@renderer/hooks/biz/useRouteParams" import { useAuthQuery, useTitle } from "@renderer/hooks/common" import { stopPropagation } from "@renderer/lib/dom" +import { FeedViewType } from "@renderer/lib/enum" import { parseHtml } from "@renderer/lib/parse-html" import type { ActiveEntryId } from "@renderer/models" import { @@ -30,23 +32,32 @@ import { useEffect, useLayoutEffect, useState } from "react" import { LoadingCircle } from "../../components/ui/loading" import { EntryTranslation } from "../entry-column/translation" import { setEntryContentScrollToTop, setEntryTitleMeta } from "./atoms" +import { Daily } from "./daily" import { EntryHeader } from "./header" import { EntryContentProvider } from "./provider" export const EntryContent = ({ entryId }: { entryId: ActiveEntryId }) => { const title = useFeedHeaderTitle() + const { feedId, view } = useRouteParms() useTitle(title) if (!entryId) { return ( - - {title} +
+ + {title} +
+ {feedId === ROUTE_FEED_PENDING && view === FeedViewType.Articles && ( + + )}
) }