Skip to content

Commit bf22c10

Browse files
authored
feature: scrollbars (#240)
1 parent a832c20 commit bf22c10

7 files changed

Lines changed: 74 additions & 35 deletions

File tree

assets/css/tailwind.css

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,27 +131,6 @@
131131
}
132132
}
133133

134-
135-
136-
@layer base {
137-
/* Hide scrollbars globally (macOS-style); scrolling still works */
138-
/* WebKit (Chrome, Safari, Edge) */
139-
::-webkit-scrollbar {
140-
width: 0;
141-
height: 0;
142-
}
143-
144-
/* Firefox */
145-
* {
146-
scrollbar-width: none;
147-
}
148-
149-
/* IE / legacy Edge */
150-
* {
151-
-ms-overflow-style: none;
152-
}
153-
}
154-
155134
@layer base {
156135
html {
157136
touch-action: manipulation;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { computed } from "vue";
2+
import type { PartialOptions } from "overlayscrollbars";
3+
4+
export function useOverlayScrollbarsOptions() {
5+
const colorMode = useColorMode();
6+
7+
const options = computed<PartialOptions>(() => ({
8+
scrollbars: {
9+
theme: colorMode.value === "dark" ? "os-theme-light" : "os-theme-dark",
10+
autoHide: "scroll",
11+
},
12+
}));
13+
14+
return { options };
15+
}

layouts/components/MainContent.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
44
import { useRightSidebar } from "@/composables/useRightSidebar";
55
import SidebarMobileSync from "./SidebarMobileSync.vue";
66
import { inject, computed } from "vue";
7+
import { useOverlayScrollbarsOptions } from "~/composables/useOverlayScrollbarsOptions";
78
89
const { rightSidebarOpen, setRightSidebarOpen } = useRightSidebar();
10+
const { options: scrollbarOptions } = useOverlayScrollbarsOptions();
911
1012
// Inject values from default.vue
1113
const showLeftNav = inject<ReturnType<typeof computed<boolean>>>("showLeftNav");
@@ -26,17 +28,23 @@ const containContentValue = computed(() => containContent?.value ?? true);
2628
class="min-h-0 h-full"
2729
>
2830
<SidebarMobileSync />
29-
<SidebarInset class="overflow-scroll min-h-0 h-full">
30-
<!-- todo fix bg color bg-muted/10 -->
31-
<div
32-
class="p-4 w-full self-center"
33-
:class="{
34-
'mx-auto': !showLeftNavValue,
35-
'lg:max-w-7xl': containContentValue,
36-
}"
31+
<SidebarInset class="overflow-hidden min-h-0 h-full">
32+
<OverlayScrollbars
33+
element="div"
34+
:options="scrollbarOptions"
35+
defer
36+
class="h-full"
3737
>
38-
<slot></slot>
39-
</div>
38+
<div
39+
class="p-4 w-full self-center"
40+
:class="{
41+
'mx-auto': !showLeftNavValue,
42+
'lg:max-w-7xl': containContentValue,
43+
}"
44+
>
45+
<slot></slot>
46+
</div>
47+
</OverlayScrollbars>
4048
</SidebarInset>
4149

4250
<AppSidebar side="right" class="main-content-sidebar" />

layouts/default.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import { useAuthStore } from "~/stores/AuthStore";
1010
import { e_player_roles_enum } from "~/generated/zeus";
1111
import { useGtm } from "@/layouts/composables/useGtm";
1212
import { useChatTabSetup } from "~/composables/useChatTabSetup";
13+
import { useOverlayScrollbarsOptions } from "~/composables/useOverlayScrollbarsOptions";
1314
1415
useGtm();
1516
useChatTabSetup();
1617
18+
const { options: scrollbarOptions } = useOverlayScrollbarsOptions();
19+
1720
const route = useRoute();
1821
const authStore = useAuthStore();
1922
@@ -51,15 +54,22 @@ provide("containContent", containContent);
5154
<AppSidebar v-if="showLeftNav" />
5255

5356
<SidebarInset
54-
class="flex flex-col overflow-y-auto overflow-x-hidden"
57+
class="flex flex-col overflow-hidden"
5558
style="height: 100svh"
5659
>
5760
<TopNav v-if="!showLeftNav" />
5861
<AppHeader class="px-6" v-if="showLeftNav" />
5962

60-
<MainContent class="flex-1">
61-
<slot></slot>
62-
</MainContent>
63+
<OverlayScrollbars
64+
element="div"
65+
:options="scrollbarOptions"
66+
defer
67+
class="flex-1 overflow-auto"
68+
>
69+
<MainContent>
70+
<slot></slot>
71+
</MainContent>
72+
</OverlayScrollbars>
6373
</SidebarInset>
6474
</SidebarProvider>
6575

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
"minisearch": "^7.1.2",
6969
"monaco-editor": "^0.55.1",
7070
"node-fetch": "^3.3.2",
71+
"overlayscrollbars": "^2.14.0",
72+
"overlayscrollbars-vue": "^0.5.9",
7173
"pev2": "^1.20.1",
7274
"pinia": "^3.0.2",
7375
"reka-ui": "^2.8.0",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
2+
import "overlayscrollbars/overlayscrollbars.css";
3+
4+
export default defineNuxtPlugin((nuxtApp) => {
5+
nuxtApp.vueApp.component("OverlayScrollbars", OverlayScrollbarsComponent);
6+
});

yarn.lock

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ __metadata:
4949
monaco-editor: "npm:^0.55.1"
5050
node-fetch: "npm:^3.3.2"
5151
nuxt: "npm:^3.17.2"
52+
overlayscrollbars: "npm:^2.14.0"
53+
overlayscrollbars-vue: "npm:^0.5.9"
5254
pev2: "npm:^1.20.1"
5355
pinia: "npm:^3.0.2"
5456
postcss: "npm:^8.5.3"
@@ -11787,6 +11789,23 @@ __metadata:
1178711789
languageName: node
1178811790
linkType: hard
1178911791

11792+
"overlayscrollbars-vue@npm:^0.5.9":
11793+
version: 0.5.9
11794+
resolution: "overlayscrollbars-vue@npm:0.5.9"
11795+
peerDependencies:
11796+
overlayscrollbars: ^2.0.0
11797+
vue: ^3.2.25
11798+
checksum: 10c0/bd40df4e29b90e26570d5a321fe6c8ea6d7983250ddfcc8b06767434c5c2f08b393db1434c83e0e4a369aeb17cfb65360e5ce1e0430cd72ce85cb59ed16424b4
11799+
languageName: node
11800+
linkType: hard
11801+
11802+
"overlayscrollbars@npm:^2.14.0":
11803+
version: 2.14.0
11804+
resolution: "overlayscrollbars@npm:2.14.0"
11805+
checksum: 10c0/e08d188733032aadb258b6ddf56249c6747b7e5ac745dd34ae402320a5f8d4cd832a3a73baff29f8a64a6faf334be719617725972fab8c29fb708a9fd96bc3e8
11806+
languageName: node
11807+
linkType: hard
11808+
1179011809
"own-keys@npm:^1.0.1":
1179111810
version: 1.0.1
1179211811
resolution: "own-keys@npm:1.0.1"

0 commit comments

Comments
 (0)