From 3178c0695f51a962d26ff3e566202995524f9d4e Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 3 Jun 2024 18:50:11 +0800 Subject: [PATCH] feat: optimze ui in dark mode, add color themes, replace dark mode impl, add debug inspector (#31) * chore: unify header action button style Signed-off-by: Innei * fix: dark mode Signed-off-by: Innei * chore: fix lockfile Signed-off-by: Innei * fix: page color fresh Signed-off-by: Innei * fix: type error Signed-off-by: Innei * fix: type error Signed-off-by: Innei * fix: disableTransition for jotai-dark (#32) * chore: remove todo Signed-off-by: Innei --------- Signed-off-by: Innei Co-authored-by: Stephen Zhou --- components.json | 2 +- package.json | 5 +- pnpm-lock.yaml | 102 ++++++++++++++- src/renderer/index.html | 13 +- src/renderer/src/App.tsx | 5 +- .../src/components/appearance-switch.tsx | 3 +- .../src/components/entry-column/index.tsx | 87 ++++++------- .../components/entry-column/item-wrapper.tsx | 4 +- .../src/components/entry-content/index.tsx | 2 +- .../src/components/entry-content/share.tsx | 38 +++--- .../src/components/feed-column/index.tsx | 7 +- .../src/components/feed-column/list.tsx | 2 +- src/renderer/src/components/ui/button.tsx | 49 +++++++- src/renderer/src/components/ui/switch.tsx | 2 +- src/renderer/src/components/ui/tooltip.tsx | 4 +- src/renderer/src/hooks/useDark.ts | 8 +- src/renderer/src/main.tsx | 118 +----------------- .../src/pages/(main)/(context)/index.tsx | 6 +- src/renderer/src/router.tsx | 114 +++++++++++++++++ src/renderer/src/{assets => styles}/base.css | 2 +- src/renderer/src/styles/colors.css | 22 ++++ src/renderer/src/{assets => styles}/font.css | 0 src/renderer/src/{assets => styles}/main.css | 1 + .../{assets => styles}/tailwind-extend.css | 0 .../src/{assets => styles}/tailwind.css | 2 +- tailwind.config.cjs | 24 +++- 26 files changed, 406 insertions(+), 216 deletions(-) create mode 100644 src/renderer/src/router.tsx rename src/renderer/src/{assets => styles}/base.css (95%) create mode 100644 src/renderer/src/styles/colors.css rename src/renderer/src/{assets => styles}/font.css (100%) rename src/renderer/src/{assets => styles}/main.css (74%) rename src/renderer/src/{assets => styles}/tailwind-extend.css (100%) rename src/renderer/src/{assets => styles}/tailwind.css (98%) diff --git a/components.json b/components.json index a5eec41d9..fcf21ac23 100644 --- a/components.json +++ b/components.json @@ -5,7 +5,7 @@ "tsx": true, "tailwind": { "config": "tailwind.config.cjs", - "css": "src/renderer/src/assets/main.css", + "css": "src/renderer/src/styles/main.css", "baseColor": "slate", "cssVariables": true, "prefix": "" diff --git a/package.json b/package.json index 619fd1ce9..6e507e87c 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@tanstack/react-query-persist-client": "5.40.0", "@use-gesture/react": "10.3.1", "class-variance-authority": "0.7.0", + "click-to-react-component": "1.1.0", "clsx": "2.1.1", "cmdk": "1.0.0", "dayjs": "1.11.11", @@ -57,8 +58,8 @@ "hast-util-to-jsx-runtime": "2.3.0", "immer": "10.1.1", "jotai": "2.8.2", - "jotai-dark": "^0.3.0", - "jotai-effect": "^1.0.0", + "jotai-dark": "0.3.1", + "jotai-effect": "1.0.0", "lethargy": "1.0.9", "lodash-es": "4.17.21", "lucide-react": "0.381.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad51b66aa..52d9f993b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -83,6 +83,9 @@ importers: class-variance-authority: specifier: 0.7.0 version: 0.7.0 + click-to-react-component: + specifier: 1.1.0 + version: 1.1.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) clsx: specifier: 2.1.1 version: 2.1.1 @@ -111,10 +114,10 @@ importers: specifier: 2.8.2 version: 2.8.2(@types/react@18.3.3)(react@18.3.1) jotai-dark: - specifier: ^0.3.0 - version: 0.3.0(jotai-effect@1.0.0(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1)))(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1))(react@18.3.1) + specifier: 0.3.1 + version: 0.3.1(jotai-effect@1.0.0(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1)))(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1))(react@18.3.1) jotai-effect: - specifier: ^1.0.0 + specifier: 1.0.0 version: 1.0.0(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1)) lethargy: specifier: 1.0.9 @@ -1119,12 +1122,28 @@ packages: resolution: {integrity: sha512-niBqk8iwv96+yuTwjM6bWg8ovzAPF9qkICsGtcoa5/dmqcEMfdwNAX7+/OHcJHc7wj7XqPxH98oAHytFYlw6Sw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@floating-ui/core@0.6.2': + resolution: {integrity: sha512-jktYRmZwmau63adUG3GKOAVCofBXkk55S/zQ94XOorAHhwqFIOFAy1rSp2N0Wp6/tGbe9V3u/ExlGZypyY17rg==} + '@floating-ui/core@1.6.0': resolution: {integrity: sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==} + '@floating-ui/dom@0.4.5': + resolution: {integrity: sha512-b+prvQgJt8pieaKYMSJBXHxX/DYwdLsAWxKYqnO5dO2V4oo/TYBZJAUQCVNjTWWsrs6o4VDrNcP9+E70HAhJdw==} + '@floating-ui/dom@1.6.3': resolution: {integrity: sha512-RnDthu3mzPlQ31Ss/BTwQ1zjzIhr3lk1gZB1OC56h/1vEtaXkESrOqL5fQVMfXpwGtRwX+YsZBdyHtJMQnkArw==} + '@floating-ui/react-dom-interactions@0.3.1': + resolution: {integrity: sha512-tP2KEh7EHJr5hokSBHcPGojb+AorDNUf0NYfZGg/M+FsMvCOOsSEeEF0O1NDfETIzDnpbHnCs0DuvCFhSMSStg==} + deprecated: Package renamed to @floating-ui/react + + '@floating-ui/react-dom@0.6.3': + resolution: {integrity: sha512-hC+pS5D6AgS2wWjbmSQ6UR6Kpy+drvWGJIri6e1EDGADTPsCaa4KzCgmCczHrQeInx9tqs81EyDmbKJYY2swKg==} + peerDependencies: + react: '>=16.8.0' + react-dom: '>=16.8.0' + '@floating-ui/react-dom@2.0.8': resolution: {integrity: sha512-HOdqOt3R3OGeTKidaLvJKcgg75S6tibQ3Tif4eyd91QnIJWr0NLvoXFpJA/j8HqkFSL68GDca9AuyWEHlhyClw==} peerDependencies: @@ -2362,6 +2381,11 @@ packages: resolution: {integrity: sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==} engines: {node: '>=18'} + click-to-react-component@1.1.0: + resolution: {integrity: sha512-/DjZemufS1BkxyRgZL3r7HXVVOFRWVQi5Xd4EBnjxZMwrHEh0OlUVA2N9CjXkZ0x8zMf8dL1cKnnx+xUWUg4VA==} + peerDependencies: + react: '>=16.8.0' + cliui@8.0.1: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} @@ -3328,6 +3352,9 @@ packages: resolution: {integrity: sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==} engines: {node: '>=10'} + htm@3.1.1: + resolution: {integrity: sha512-983Vyg8NwUE7JkZ6NmOqpCZ+sh1bKv2iYTlUkzlWmA5JD2acKoxd4KVxbMmxX/85mtfdnDmTFoNKcg5DGAvxNQ==} + html-void-elements@3.0.0: resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} @@ -3538,8 +3565,8 @@ packages: jose@5.3.0: resolution: {integrity: sha512-IChe9AtAE79ru084ow8jzkN2lNrG3Ntfiv65Cvj9uOCE2m5LNsdHG+9EbxWxAoWRF9TgDOqLN5jm08++owDVRg==} - jotai-dark@0.3.0: - resolution: {integrity: sha512-Vuhymer1VLaAjSW+hLowZBZa0FSKMamo3xajXubCr0Jdnp5P80vrh/5s29EQ2cp3eSa9weuUy+kdoMKEDdp/sA==} + jotai-dark@0.3.1: + resolution: {integrity: sha512-6yW4qk+xG9kv/YkDr4aCWHMPQZHd+q/p1orFzg5NFJwlBCfK/UBlUJfPTRLMdbMf1+U5u4pBQWPGa7ZHOqSFBQ==} peerDependencies: foxact: ^0.2.33 jotai: '>=2.5.0' @@ -4237,6 +4264,9 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} + point-in-polygon@1.1.0: + resolution: {integrity: sha512-3ojrFwjnnw8Q9242TzgXuTD+eKiutbzyslcq1ydfu82Db2y+Ogbmyrkpv0Hgj31qwT3lbS9+QAAO/pIQM35XRw==} + postcss-import@15.1.0: resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==} engines: {node: '>=14.0.0'} @@ -4353,6 +4383,9 @@ packages: react-dom: optional: true + react-merge-refs@1.1.0: + resolution: {integrity: sha512-alTKsjEL0dKH/ru1Iyn7vliS2QRcBp9zZPGoWxUOvRGWPUYgjo+V01is7p04It6KhgrzhJGnIj9GgX8W4bZoCQ==} + react-refresh@0.14.2: resolution: {integrity: sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==} engines: {node: '>=0.10.0'} @@ -4966,6 +4999,15 @@ packages: '@types/react': optional: true + use-isomorphic-layout-effect@1.1.2: + resolution: {integrity: sha512-49L8yCO3iGT/ZF9QttjwLF/ZD9Iwto5LnH5LmEdk/6cFmXddqi2ulF0edxTwjj+7mqvpVVGQWvbXZdn32wRSHA==} + peerDependencies: + '@types/react': '*' + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + use-sidecar@1.1.2: resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==} engines: {node: '>=10'} @@ -6106,15 +6148,41 @@ snapshots: '@eslint/js@9.3.0': {} + '@floating-ui/core@0.6.2': {} + '@floating-ui/core@1.6.0': dependencies: '@floating-ui/utils': 0.2.1 + '@floating-ui/dom@0.4.5': + dependencies: + '@floating-ui/core': 0.6.2 + '@floating-ui/dom@1.6.3': dependencies: '@floating-ui/core': 1.6.0 '@floating-ui/utils': 0.2.1 + '@floating-ui/react-dom-interactions@0.3.1(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@floating-ui/react-dom': 0.6.3(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + aria-hidden: 1.2.4 + point-in-polygon: 1.1.0 + use-isomorphic-layout-effect: 1.1.2(@types/react@18.3.3)(react@18.3.1) + transitivePeerDependencies: + - '@types/react' + - react + - react-dom + + '@floating-ui/react-dom@0.6.3(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@floating-ui/dom': 0.4.5 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + use-isomorphic-layout-effect: 1.1.2(@types/react@18.3.3)(react@18.3.1) + transitivePeerDependencies: + - '@types/react' + '@floating-ui/react-dom@2.0.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@floating-ui/dom': 1.6.3 @@ -7578,6 +7646,16 @@ snapshots: slice-ansi: 5.0.0 string-width: 7.1.0 + click-to-react-component@1.1.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + '@floating-ui/react-dom-interactions': 0.3.1(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + htm: 3.1.1 + react: 18.3.1 + react-merge-refs: 1.1.0 + transitivePeerDependencies: + - '@types/react' + - react-dom + cliui@8.0.1: dependencies: string-width: 4.2.3 @@ -8930,6 +9008,8 @@ snapshots: dependencies: lru-cache: 6.0.0 + htm@3.1.1: {} + html-void-elements@3.0.0: {} http-cache-semantics@4.1.1: {} @@ -9110,7 +9190,7 @@ snapshots: jose@5.3.0: {} - jotai-dark@0.3.0(jotai-effect@1.0.0(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1)))(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1))(react@18.3.1): + jotai-dark@0.3.1(jotai-effect@1.0.0(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1)))(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1))(react@18.3.1): optionalDependencies: jotai: 2.8.2(@types/react@18.3.3)(react@18.3.1) jotai-effect: 1.0.0(jotai@2.8.2(@types/react@18.3.3)(react@18.3.1)) @@ -9912,6 +9992,8 @@ snapshots: pluralize@8.0.0: {} + point-in-polygon@1.1.0: {} + postcss-import@15.1.0(postcss@8.4.38): dependencies: postcss: 8.4.38 @@ -10005,6 +10087,8 @@ snapshots: optionalDependencies: react-dom: 18.3.1(react@18.3.1) + react-merge-refs@1.1.0: {} + react-refresh@0.14.2: {} react-remove-scroll-bar@2.3.6(@types/react@18.3.3)(react@18.3.1): @@ -10685,6 +10769,12 @@ snapshots: optionalDependencies: '@types/react': 18.3.3 + use-isomorphic-layout-effect@1.1.2(@types/react@18.3.3)(react@18.3.1): + dependencies: + react: 18.3.1 + optionalDependencies: + '@types/react': 18.3.3 + use-sidecar@1.1.2(@types/react@18.3.3)(react@18.3.1): dependencies: detect-node-es: 1.1.0 diff --git a/src/renderer/index.html b/src/renderer/index.html index 97192d472..f94cb07d8 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -1,9 +1,20 @@ - + Follow + +
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 8dd5eda08..43b5700ce 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -7,15 +7,14 @@ import { handlers } from "./tipc" function App() { useDark() - useEffect(() => { - const unlisten = handlers?.invalidateQuery.listen((queryKey) => { + const cleanup = handlers?.invalidateQuery.listen((queryKey) => { queryClient.invalidateQueries({ queryKey, }) }) - return unlisten + return cleanup }, []) return ( diff --git a/src/renderer/src/components/appearance-switch.tsx b/src/renderer/src/components/appearance-switch.tsx index 6f9212e91..2f551e51a 100644 --- a/src/renderer/src/components/appearance-switch.tsx +++ b/src/renderer/src/components/appearance-switch.tsx @@ -3,8 +3,7 @@ import { useDark } from "@renderer/hooks/useDark" import { Switch } from "./ui/switch" export function AppearanceSwitch() { - const { toggleDark, isDark } = useDark() - + const { isDark, toggleDark } = useDark() return (

Dark Mode

diff --git a/src/renderer/src/components/entry-column/index.tsx b/src/renderer/src/components/entry-column/index.tsx index ad4f6bee5..5326f79ad 100644 --- a/src/renderer/src/components/entry-column/index.tsx +++ b/src/renderer/src/components/entry-column/index.tsx @@ -1,17 +1,13 @@ -import { Button } from "@renderer/components/ui/button" +import { Button, HeaderActionButton } from "@renderer/components/ui/button" import { Popover, PopoverClose, PopoverContent, PopoverTrigger, } from "@renderer/components/ui/popover" -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@renderer/components/ui/tooltip" import { views } from "@renderer/lib/constants" import { buildStorageNS } from "@renderer/lib/ns" +import type { EntryModel } from "@renderer/lib/types" import { cn, getEntriesParams } from "@renderer/lib/utils" import { apiClient } from "@renderer/queries/api-fetch" import { useEntries } from "@renderer/queries/entries" @@ -110,7 +106,7 @@ export function EntryColumn() { ), ) - const virtusoOptions = { + const virtuosoOptions = { components: { List: ListContent, }, @@ -119,7 +115,7 @@ export function EntryColumn() { totalCount: entries.data?.pages?.[0]?.total, endReached: () => entries.hasNextPage && entries.fetchNextPage(), data: entries.data?.pages.flatMap((page) => page.data) || [], - itemContent: (_, entry) => { + itemContent: useCallback((_, entry: EntryModel | undefined) => { if (!entry) return null return ( ) - }, + }, []), } return ( -
setActiveEntry?.(null)}> +
setActiveEntry?.(null)} + > {activeList?.view && views[activeList.view].gridMode ? ( ) : ( - + )}
) @@ -187,7 +184,7 @@ const ListHeader: FC = () => { return (
-
+
{activeList?.name}
{entries.data?.pages?.[0].total} @@ -195,42 +192,48 @@ const ListHeader: FC = () => { Items
-
- - - - - Refresh - - - - - - {unreadOnly ? "Unread Only" : "All"} - +
+ + + + + setUnreadOnly(!unreadOnly)} + active={unreadOnly} + > + {unreadOnly ? + ( + + ) : + ( + + )} + - - - - - Mark All as Read - + {}} tooltip="Mark All as Read"> + + +
Mark all as read?
- + {/* TODO */} - +
diff --git a/src/renderer/src/components/entry-column/item-wrapper.tsx b/src/renderer/src/components/entry-column/item-wrapper.tsx index 07f9505e5..3f78b54d5 100644 --- a/src/renderer/src/components/entry-column/item-wrapper.tsx +++ b/src/renderer/src/components/entry-column/item-wrapper.tsx @@ -48,8 +48,8 @@ export function EntryItemWrapper({
diff --git a/src/renderer/src/components/entry-content/share.tsx b/src/renderer/src/components/entry-content/share.tsx index 4ca1fd6e4..e5318e442 100644 --- a/src/renderer/src/components/entry-content/share.tsx +++ b/src/renderer/src/components/entry-content/share.tsx @@ -1,9 +1,6 @@ -import { Button } from "@renderer/components/ui/button" +import { HeaderActionButton } from "@renderer/components/ui/button" import { - Tooltip, - TooltipContent, TooltipProvider, - TooltipTrigger, } from "@renderer/components/ui/tooltip" import { useEntryActions } from "@renderer/hooks/useEntryActions" import { useEntry } from "@renderer/store/entry" @@ -29,25 +26,20 @@ export function EntryShare({ {items .filter((item) => !item.disabled) .map((item) => ( - - - - - {item.name} - + + ) : + ( + + ) + } + onClick={item.onClick} + tooltip={item.name} + key={item.name} + /> ))}
diff --git a/src/renderer/src/components/feed-column/index.tsx b/src/renderer/src/components/feed-column/index.tsx index 0a1e70c3c..5b698ca04 100644 --- a/src/renderer/src/components/feed-column/index.tsx +++ b/src/renderer/src/components/feed-column/index.tsx @@ -89,14 +89,14 @@ export function FeedColumn() { -
-
+
{views.map((item, index) => ( @@ -104,6 +104,7 @@ export function FeedColumn() { className={cn( active === index && item.className, "flex items-center text-xl", + "hover:!bg-theme-vibrancyBg", )} variant="ghost" size="sm" diff --git a/src/renderer/src/components/feed-column/list.tsx b/src/renderer/src/components/feed-column/list.tsx index 8c0935094..df2e9c236 100644 --- a/src/renderer/src/components/feed-column/list.tsx +++ b/src/renderer/src/components/feed-column/list.tsx @@ -41,7 +41,7 @@ export function FeedList({ > {view !== undefined && views[view].name}
-
+
{expansion ? ( ( +export const Button = React.forwardRef( ( { className, variant, size, asChild = false, isLoading = false, ...props }, ref, @@ -66,4 +68,45 @@ const Button = React.forwardRef( ) Button.displayName = "Button" -export { Button, buttonVariants } +// BIZ buttons + +interface HeaderActionButtonProps { + onClick: () => void + icon?: React.ReactNode | React.FC + tooltip: string + tooltipSide?: "top" | "bottom" + active?: boolean +} +export const HeaderActionButton = React.forwardRef< + HTMLButtonElement, + ComponentType +>( + ( + { icon, onClick, tooltip, className, tooltipSide, children, active }, + ref, + ) => ( + + + + + {tooltip} + + ), +) diff --git a/src/renderer/src/components/ui/switch.tsx b/src/renderer/src/components/ui/switch.tsx index 88d7403d7..06f33cbfe 100644 --- a/src/renderer/src/components/ui/switch.tsx +++ b/src/renderer/src/components/ui/switch.tsx @@ -16,7 +16,7 @@ const Switch = React.forwardRef< > diff --git a/src/renderer/src/components/ui/tooltip.tsx b/src/renderer/src/components/ui/tooltip.tsx index eb50182c2..86e37511f 100644 --- a/src/renderer/src/components/ui/tooltip.tsx +++ b/src/renderer/src/components/ui/tooltip.tsx @@ -16,7 +16,9 @@ const TooltipContent = React.forwardRef< ref={ref} sideOffset={sideOffset} className={cn( - "z-50 overflow-hidden rounded-md bg-stone-300 px-2 py-1 text-sm text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", + "z-50 overflow-hidden border border-border bg-theme-tooltip-background px-2 py-1 text-theme-tooltip-foreground backdrop-blur", + "animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", + "rounded-lg text-xs shadow shadow-theme-tooltip-background", className, )} {...props} diff --git a/src/renderer/src/hooks/useDark.ts b/src/renderer/src/hooks/useDark.ts index 4d8288c5b..50bdeeae7 100644 --- a/src/renderer/src/hooks/useDark.ts +++ b/src/renderer/src/hooks/useDark.ts @@ -1,7 +1,13 @@ import { useAtom } from "jotai" import { atomDark } from "jotai-dark" -const isDarkAtom = atomDark() +const isDarkAtom = atomDark({ + storageKey: "theme", + disableTransition: true, + applyDarkMode(isDark) { + document.documentElement.dataset.theme = isDark ? "dark" : "light" + }, +}) export function useDark() { const [isDark, setIsDark] = useAtom(isDarkAtom) diff --git a/src/renderer/src/main.tsx b/src/renderer/src/main.tsx index b0b3abd5b..f97a19ac8 100644 --- a/src/renderer/src/main.tsx +++ b/src/renderer/src/main.tsx @@ -1,122 +1,13 @@ -import "./assets/main.css" +import "./styles/main.css" import { authConfigManager } from "@hono/auth-js/react" +import { ClickToComponent } from "click-to-react-component" import * as React from "react" import ReactDOM from "react-dom/client" -import { createBrowserRouter, RouterProvider } from "react-router-dom" +import { RouterProvider } from "react-router-dom" -import App from "./App" import { RootProviders } from "./providers/root-providers" - -const router = createBrowserRouter([ - { - path: "/", - element: , - children: [ - { - path: "", - lazy: () => import("./pages/(main)/layout"), - children: [ - { - path: "", - lazy: () => import("./pages/(main)/(context)/layout"), - children: [ - { - path: "", - lazy: () => import("./pages/(main)/(context)/index"), - }, - { - path: "/discover", - lazy: () => import("./pages/(main)/(context)/discover/layout"), - children: [ - { - path: "", - lazy: () => import("./pages/(main)/(context)/discover/index"), - }, - ], - }, - { - path: "/profile", - lazy: () => import("./pages/(main)/(context)/profile/layout"), - children: [ - { - path: "", - lazy: () => - import("./pages/(main)/(context)/profile/index"), - }, - ], - }, - ], - }, - ], - }, - { - path: "", - lazy: () => import("./pages/(external)/layout"), - children: [ - { - path: "login", - lazy: () => import("./pages/(external)/login"), - }, - { - path: "redirect", - lazy: () => import("./pages/(external)/redirect"), - }, - { - path: "debug", - lazy: () => import("./pages/(external)/debug"), - }, - { - path: "/feed/:id", - lazy: () => import("./pages/(external)/feed/layout"), - children: [ - { - path: "", - lazy: () => import("./pages/(external)/feed/index"), - }, - ], - }, - ], - }, - { - path: "settings", - lazy: () => import("./pages/settings/layout"), - children: [ - { - path: "", - lazy: () => import("./pages/settings/index"), - }, - { - path: "rsshub", - lazy: () => import("./pages/settings/rsshub"), - }, - { - path: "profile", - lazy: () => import("./pages/settings/profile"), - }, - ], - }, - { - path: "add", - children: [ - { - path: "", - lazy: () => import("./pages/add/index"), - }, - ], - }, - { - path: "preview", - children: [ - { - path: "", - lazy: () => import("./pages/preview"), - }, - ], - }, - ], - }, -]) +import { router } from "./router" authConfigManager.setConfig({ baseUrl: import.meta.env.VITE_API_URL, @@ -128,6 +19,7 @@ ReactDOM.createRoot(document.querySelector("#root") as HTMLElement).render( + , ) diff --git a/src/renderer/src/pages/(main)/(context)/index.tsx b/src/renderer/src/pages/(main)/(context)/index.tsx index 05734f288..b51034a02 100644 --- a/src/renderer/src/pages/(main)/(context)/index.tsx +++ b/src/renderer/src/pages/(main)/(context)/index.tsx @@ -2,10 +2,7 @@ import { EntryColumn } from "@renderer/components/entry-column" import { EntryContent } from "@renderer/components/entry-content" import { views } from "@renderer/lib/constants" import { cn } from "@renderer/lib/utils" -import { - feedActions, - useFeedStore, -} from "@renderer/store" +import { feedActions, useFeedStore } from "@renderer/store" import { AnimatePresence } from "framer-motion" import { useEffect } from "react" import { useShallow } from "zustand/react/shallow" @@ -27,7 +24,6 @@ export function Component() {
diff --git a/src/renderer/src/router.tsx b/src/renderer/src/router.tsx new file mode 100644 index 000000000..236891d1d --- /dev/null +++ b/src/renderer/src/router.tsx @@ -0,0 +1,114 @@ +import { createBrowserRouter } from "react-router-dom" + +import App from "./App" + +export const router = createBrowserRouter([ + { + path: "/", + element: , + children: [ + { + path: "", + lazy: () => import("./pages/(main)/layout"), + children: [ + { + path: "", + lazy: () => import("./pages/(main)/(context)/layout"), + children: [ + { + path: "", + lazy: () => import("./pages/(main)/(context)/index"), + }, + { + path: "/discover", + lazy: () => import("./pages/(main)/(context)/discover/layout"), + children: [ + { + path: "", + lazy: () => + import("./pages/(main)/(context)/discover/index"), + }, + ], + }, + { + path: "/profile", + lazy: () => import("./pages/(main)/(context)/profile/layout"), + children: [ + { + path: "", + lazy: () => + import("./pages/(main)/(context)/profile/index"), + }, + ], + }, + ], + }, + ], + }, + { + path: "", + lazy: () => import("./pages/(external)/layout"), + children: [ + { + path: "login", + lazy: () => import("./pages/(external)/login"), + }, + { + path: "redirect", + lazy: () => import("./pages/(external)/redirect"), + }, + { + path: "debug", + lazy: () => import("./pages/(external)/debug"), + }, + { + path: "/feed/:id", + lazy: () => import("./pages/(external)/feed/layout"), + children: [ + { + path: "", + lazy: () => import("./pages/(external)/feed/index"), + }, + ], + }, + ], + }, + { + path: "settings", + lazy: () => import("./pages/settings/layout"), + children: [ + { + path: "", + lazy: () => import("./pages/settings/index"), + }, + { + path: "rsshub", + lazy: () => import("./pages/settings/rsshub"), + }, + { + path: "profile", + lazy: () => import("./pages/settings/profile"), + }, + ], + }, + { + path: "add", + children: [ + { + path: "", + lazy: () => import("./pages/add/index"), + }, + ], + }, + { + path: "preview", + children: [ + { + path: "", + lazy: () => import("./pages/preview"), + }, + ], + }, + ], + }, +]) diff --git a/src/renderer/src/assets/base.css b/src/renderer/src/styles/base.css similarity index 95% rename from src/renderer/src/assets/base.css rename to src/renderer/src/styles/base.css index bd32ea22a..50c11ecd5 100644 --- a/src/renderer/src/assets/base.css +++ b/src/renderer/src/styles/base.css @@ -17,7 +17,7 @@ a { @apply cursor-pointer; } -.dark { +[data-theme="dark"] { color-scheme: dark; } diff --git a/src/renderer/src/styles/colors.css b/src/renderer/src/styles/colors.css new file mode 100644 index 000000000..5ed6f42a4 --- /dev/null +++ b/src/renderer/src/styles/colors.css @@ -0,0 +1,22 @@ +:root { + --fo-vibrancy-foreground: theme(colors.zinc.500); + --fo-vibrancy-background: theme(colors.native.active/10); + + --fo-item-active: theme(colors.native.active/0.4); + --fo-item-hover: theme(colors.native.active/0.2); + + --fo-tooltip-background: theme(colors.zinc.50/0.8); + --fo-tooltip-foreground: theme(colors.neutral.950); +} + +[data-theme="dark"] { + --fo-vibrancy-foreground: theme(colors.zinc.400); + /* --fo-vibrancy-background: theme(colors.zinc.600/10); */ + --fo-vibrancy-background: theme(colors.native.active/10); + + --fo-item-active: theme(colors.neutral.700/0.4); + --fo-item-hover: theme(colors.native.active/0.2); + + --fo-tooltip-background: theme(colors.zinc.800/0.8); + --fo-tooltip-foreground: theme(colors.zinc.100); +} diff --git a/src/renderer/src/assets/font.css b/src/renderer/src/styles/font.css similarity index 100% rename from src/renderer/src/assets/font.css rename to src/renderer/src/styles/font.css diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/styles/main.css similarity index 74% rename from src/renderer/src/assets/main.css rename to src/renderer/src/styles/main.css index 379e204a2..e113da683 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/styles/main.css @@ -1,3 +1,4 @@ @import "./tailwind.css"; @import "./font.css"; @import "./base.css"; +@import "./colors.css"; diff --git a/src/renderer/src/assets/tailwind-extend.css b/src/renderer/src/styles/tailwind-extend.css similarity index 100% rename from src/renderer/src/assets/tailwind-extend.css rename to src/renderer/src/styles/tailwind-extend.css diff --git a/src/renderer/src/assets/tailwind.css b/src/renderer/src/styles/tailwind.css similarity index 98% rename from src/renderer/src/assets/tailwind.css rename to src/renderer/src/styles/tailwind.css index e7dc6b128..fe050df08 100644 --- a/src/renderer/src/assets/tailwind.css +++ b/src/renderer/src/styles/tailwind.css @@ -37,7 +37,7 @@ --radius: 0.5rem; } - .dark { + [data-theme="dark"] { --background: 0, 0%, 11.8%; --foreground: 0 0% 98%; diff --git a/tailwind.config.cjs b/tailwind.config.cjs index f83bf2982..903ca1c1a 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -1,10 +1,13 @@ -const { iconsPlugin, getIconCollections } = require("@egoist/tailwindcss-icons") +const { + iconsPlugin, + getIconCollections, +} = require("@egoist/tailwindcss-icons") require("./cssAsPlugin") /** @type {import('tailwindcss').Config} */ module.exports = { - darkMode: ["class"], + darkMode: ["class", "[data-theme=\"dark\"]"], content: ["./src/**/*.{ts,tsx}"], prefix: "", theme: { @@ -54,6 +57,21 @@ module.exports = { DEFAULT: "hsl(var(--native))", active: "hsl(var(--native-active))", }, + + theme: { + vibrancyFg: "var(--fo-vibrancy-foreground)", + vibrancyBg: "var(--fo-vibrancy-background)", + + item: { + active: "var(--fo-item-active)", + hover: "var(--fo-item-hover)", + }, + + tooltip: { + background: "var(--fo-tooltip-background)", + foreground: "var(--fo-tooltip-foreground)", + }, + }, }, borderRadius: { lg: "var(--radius)", @@ -90,6 +108,6 @@ module.exports = { }), require("tailwindcss-animate"), require("@tailwindcss/typography"), - require("./src/renderer/src/assets/tailwind-extend.css"), + require("./src/renderer/src/styles/tailwind-extend.css"), ], }