diff --git a/App.tsx b/App.tsx index 43a44a4..5a98b86 100644 --- a/App.tsx +++ b/App.tsx @@ -60,7 +60,7 @@ import { DonationNagModal } from './components/donation-nag-modal'; import { createWebNavigator } from './components/navigation/web-navigator'; import { isMobile } from './util/util'; import { Logo16 } from './components/logo'; -import './global.css'; +import { useScrollbarStyle } from './components/navigation/scroll-bar-hooks'; // TODO: Onboarding works @@ -464,6 +464,8 @@ const App = () => { })(); }, [isLoading]); + useScrollbarStyle(); + if (serverStatus !== "ok") { return } diff --git a/components/navigation/scroll-bar-hooks.tsx b/components/navigation/scroll-bar-hooks.tsx index 713482f..596879a 100644 --- a/components/navigation/scroll-bar-hooks.tsx +++ b/components/navigation/scroll-bar-hooks.tsx @@ -135,6 +135,42 @@ const useScrollbar = (controller: string) => { }).current; }; +const useScrollbarStyle = () => { + const desktopScrollbarCSS = ` + ::-webkit-scrollbar { + width: 14px; + } + + ::-webkit-scrollbar-track { + background: #ddd; + } + + ::-webkit-scrollbar-thumb { + background-color: #70f; + border-radius: 99px; + } + + @-moz-document url-prefix() { + * { + scrollbar-color: #70f #ddd; + } + + *::-moz-scrollbar-thumb { + border-radius: 99px; + } + } + `; + + useEffect(() => { + if (!isMobile()) { + const styleEl = document.createElement('style'); + styleEl.textContent = desktopScrollbarCSS; + document.head.appendChild(styleEl); + } + }, []); +}; + export { useScrollbar, + useScrollbarStyle, }; diff --git a/components/navigation/scroll-bar.tsx b/components/navigation/scroll-bar.tsx index f7c3ca5..c8201a3 100644 --- a/components/navigation/scroll-bar.tsx +++ b/components/navigation/scroll-bar.tsx @@ -19,7 +19,7 @@ type ScrollViewData = { controller: string | null; // A callback to call when the Scrollbar's thumb is dragged - onThumbDrag?: (offset: number) => void; + onThumbDrag?: null | ((offset: number) => void); // The height of the controlling Scrollview's content contentHeight?: number; diff --git a/global.css b/global.css deleted file mode 100644 index f42af5d..0000000 --- a/global.css +++ /dev/null @@ -1,25 +0,0 @@ -@media (hover: hover) { - ::-webkit-scrollbar { - width: 14px; - } - - ::-webkit-scrollbar-track { - background: #ddd; - } - - ::-webkit-scrollbar-thumb { - background-color: #70f; - border-radius: 99px; - } - - @-moz-document url-prefix() { - * { - scrollbar-color: #70f #ddd; - } - - *::-moz-scrollbar-thumb { - border-radius: 99px; - } - } -} -