From 9859049a2294aec2b1481347a56335843a5db280 Mon Sep 17 00:00:00 2001 From: Ou Date: Wed, 2 Oct 2024 11:01:02 +0800 Subject: [PATCH] feat: add overlay scrollbar --- package.json | 2 ++ pnpm-lock.yaml | 22 ++++++++++++++++++++++ src/components/section/Card.tsx | 23 ++++++++++++++++++----- src/hooks/useDark.ts | 4 ++-- src/routes/__root.tsx | 21 +++++++++++---------- src/styles/globals.css | 14 ++++++++++++++ 6 files changed, 69 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 98e2076..35928b8 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,8 @@ "h3": "^1.12.0", "jotai": "^2.10.0", "node-fetch": "^3.3.2", + "overlayscrollbars": "^2.10.0", + "overlayscrollbars-react": "^0.5.6", "react": "^18.3.1", "react-dom": "^18.3.1", "react-intersection-observer": "^9.13.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 19be070..a98f9b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,12 @@ importers: node-fetch: specifier: ^3.3.2 version: 3.3.2 + overlayscrollbars: + specifier: ^2.10.0 + version: 2.10.0 + overlayscrollbars-react: + specifier: ^0.5.6 + version: 0.5.6(overlayscrollbars@2.10.0)(react@18.3.1) react: specifier: ^18.3.1 version: 18.3.1 @@ -3291,6 +3297,15 @@ packages: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} + overlayscrollbars-react@0.5.6: + resolution: {integrity: sha512-E5To04bL5brn9GVCZ36SnfGanxa2I2MDkWoa4Cjo5wol7l+diAgi4DBc983V7l2nOk/OLJ6Feg4kySspQEGDBw==} + peerDependencies: + overlayscrollbars: ^2.0.0 + react: '>=16.8.0' + + overlayscrollbars@2.10.0: + resolution: {integrity: sha512-diNMeEafWTE0A4GJfwRpdBp2rE/BEvrhptBdBcDu8/UeytWcdCy9Td8tZWnztJeJ26f8/uHCWfPnPUC/dtgJdw==} + p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -7595,6 +7610,13 @@ snapshots: type-check: 0.4.0 word-wrap: 1.2.5 + overlayscrollbars-react@0.5.6(overlayscrollbars@2.10.0)(react@18.3.1): + dependencies: + overlayscrollbars: 2.10.0 + react: 18.3.1 + + overlayscrollbars@2.10.0: {} + p-limit@2.3.0: dependencies: p-try: 2.2.0 diff --git a/src/components/section/Card.tsx b/src/components/section/Card.tsx index 67da73d..ea15667 100644 --- a/src/components/section/Card.tsx +++ b/src/components/section/Card.tsx @@ -1,4 +1,5 @@ import type { SourceID, SourceInfo } from "@shared/types" +import { OverlayScrollbarsComponent } from "overlayscrollbars-react" import type { UseQueryResult } from "@tanstack/react-query" import { useQuery } from "@tanstack/react-query" import { relativeTime } from "@shared/utils" @@ -44,7 +45,7 @@ export const CardWrapper = forwardRef(({ id, isDragg
-
+
{id} e.currentTarget.hidden = true} /> @@ -101,10 +109,15 @@ export function NewsCard({ id, inView, isOverlay, handleListeners }: NewsCardPro
-
+ -
-
+ +