Skip to content

Commit

Permalink
Add custom scrollbar styles for widows OSs (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
andriidudar authored Nov 25, 2024
1 parent 5ea57cd commit 177ae1b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/opik-frontend/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ThemeProvider } from "@/components/theme-provider";
import { Toaster } from "@/components/ui/toaster";
import { QueryParamProvider } from "use-query-params";
import { WindowHistoryAdapter } from "use-query-params/adapters/window";
import useCustomScrollbarClass from "@/hooks/useCustomScrollbarClass";

const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -15,6 +16,8 @@ const queryClient = new QueryClient({
});

function App() {
useCustomScrollbarClass();

return (
<QueryClientProvider client={queryClient}>
<QueryParamProvider adapter={WindowHistoryAdapter}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const FeedbackScoresCell = (context: CellContext<unknown, unknown>) => {
<CellWrapper
metadata={context.column.columnDef.meta}
tableMetadata={context.table.options.meta}
className="py-0"
>
<div
className={cn(
Expand Down
10 changes: 10 additions & 0 deletions apps/opik-frontend/src/hooks/useCustomScrollbarClass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function useCustomScrollbarClass() {
const userAgent = window.navigator.userAgent.toLowerCase();

if (/(win32|win64|windows|wince)/i.test(userAgent)) {
document.body.classList.add("comet-custom-scrollbar");
if (userAgent.includes("firefox")) {
document.body.classList.add("firefox");
}
}
}
26 changes: 26 additions & 0 deletions apps/opik-frontend/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,30 @@
"Courier New",
monospace;
}

.comet-custom-scrollbar {
&.firefox {
scrollbar-color: #babac0 transparent;
scrollbar-width: thin;
}

::-webkit-scrollbar {
background-color: #fff;
width: 16px;
}

::-webkit-scrollbar-track {
background-color: #fff;
}

::-webkit-scrollbar-thumb {
background-color: #babac0;
border-radius: 16px;
border: 4px solid #fff;
}

::-webkit-scrollbar-button {
display: none;
}
}
}

0 comments on commit 177ae1b

Please sign in to comment.