Skip to content

Commit

Permalink
enhance(ux): better MacOS scrollbar for the auto scrolling mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 authored and tiensonqin committed Feb 26, 2024
1 parent ab74c1e commit d4dca4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/main/frontend/components/theme.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@
[rum.core :as rum]
[frontend.context.i18n :refer [t]]))

(rum/defc scrollbar-measure
[]
(let [*el (rum/use-ref nil)]
(rum/use-effect!
(fn []
(when-let [el (rum/deref *el)]
(let [w (- (.-offsetWidth el) (.-clientWidth el))
c "custom-scrollbar"
l (.-classList js/document.documentElement)]
(if (or (not util/mac?) (> w 2))
(.add l c) (.remove l c)))))
[])
[:div.fixed.w-16.h-16.overflow-scroll.opacity-0
{:ref *el
:class "top-1/2 -left-1/2 z-[-999]"}]))

(rum/defc ^:large-vars/cleanup-todo container
[{:keys [route theme accent-color on-click current-repo nfs-granted? db-restoring?
settings-open? sidebar-open? system-theme? sidebar-blocks-len onboarding-state preferred-language]} child]
Expand Down Expand Up @@ -117,4 +133,5 @@
{:on-click on-click}
child

(pdf/default-embed-playground)]))
(pdf/default-embed-playground)
(scrollbar-measure)]))
2 changes: 1 addition & 1 deletion src/main/frontend/components/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
}

.visible-scrollbar, html:not(.is-mac) {
.visible-scrollbar , html.custom-scrollbar {
::-webkit-scrollbar-thumb {
background-color: var(--lx-gray-05, var(--ls-scrollbar-foreground-color, var(--rx-gray-05)));
}
Expand Down

0 comments on commit d4dca4f

Please sign in to comment.