Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control scrollbar styling #637

Merged
merged 10 commits into from
May 11, 2022
32 changes: 32 additions & 0 deletions src/pydata_sphinx_theme/assets/styles/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*********************************************
* SASS Mixins
*********************************************/
/**
* Scrollbars should be thinner and slightly rounded, with a grey background
*/
@mixin scrollbar-style() {
&::-webkit-scrollbar {
width: 0.3rem;
height: 0.3rem;
}

&::-webkit-scrollbar-thumb {
background: var(--pst-color-deactivate);
border-radius: 0.25rem;
}

&::-webkit-scrollbar-track {
background: transparent;
}
}

/**
* Hide the scrollbar until the element is overed, so keep the page clean
*/
@mixin scrollbar-on-hover() {
&:not(:hover) {
&::-webkit-scrollbar-thumb {
visibility: hidden;
}
}
}
11 changes: 11 additions & 0 deletions src/pydata_sphinx_theme/assets/styles/base/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ body {
font-weight: 400;
line-height: 1.65;
color: var(--pst-color-text-base);

@include scrollbar-style();
@include scrollbar-on-hover();

// hack to avoid the black background on some browser including Safari
&::-webkit-scrollbar-track {
background: var(--pst-color-background);
}
}

p {
Expand Down Expand Up @@ -128,6 +136,9 @@ pre {
border-radius: 0.2rem;
box-shadow: 1px 1px 1px var(--pst-color-preformatted-shadow);

@include scrollbar-style();
@include scrollbar-on-hover();

.linenos {
opacity: 0.5;
padding-right: 10px;
Expand Down
3 changes: 3 additions & 0 deletions src/pydata_sphinx_theme/assets/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $grid-breakpoints: (
);
@import "~bootstrap/scss/bootstrap";

// Variables and re-usable SCSS functions
@import "abstracts/mixins";

// Basic styling applied throughout site
@import "./base/base";
@import "./base/color";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
}
}

@include scrollbar-style();
@include scrollbar-on-hover();

&.no-sidebar {
border-right: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
.onthispage {
color: var(--pst-color-text-base);
}

@include scrollbar-style();
@include scrollbar-on-hover();
}

// Each entry of the in-page TOC
Expand Down