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

ENH: Standardize scrollbar behavior #481

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

myst_enable_extensions = [
"dollarmath",
# "amsmath",
"amsmath",
"deflist",
# "html_admonition",
# "html_image",
Expand Down
34 changes: 14 additions & 20 deletions src/sphinx_book_theme/assets/styles/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
/*********************************************
* SASS Mixins
*********************************************/
// Scrollbar styles to be re-used in a few spots
/**
* Scrollbars should be thinner and slightly rounded, with a grey background
*/
@mixin scrollbar-style() {
&::-webkit-scrollbar {
width: 0.5em;
height: 0.5em;
}

&::-webkit-scrollbar {
background: #f1f1f1;
width: 0.3rem;
height: 0.3rem;
}

&::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 1em;
border-radius: 0.25rem;

&:hover {
background: #a0a0a0;
}
}
}

// Hide the scrollbar until hover on wide screens
@media (min-width: $breakpoint-lg) {
&:not(:hover) {
-ms-overflow-style: none;

&::-webkit-scrollbar {
background: #ffffff;
}

&::-webkit-scrollbar-thumb {
background: #ffffff;
}
/**
* Hide the scrollbar until the element is overed, so keep the page clean
*/
@mixin scrollbar-on-hover() {
&:not(:hover) {
&::-webkit-scrollbar-thumb {
visibility: hidden;
}
}
}
1 change: 1 addition & 0 deletions src/sphinx_book_theme/assets/styles/content/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ code {

pre {
border-radius: $box-border-radius;
@include scrollbar-style();
}

// Over-ride Sphinx default so that content fills whitespace w/ margin content
Expand Down
5 changes: 0 additions & 5 deletions src/sphinx_book_theme/assets/styles/content/_margin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ $content-fullwidth-width: percentage(100% / $content-max-width);
border-left: 1px #a4a6a7 solid;
font-size: 0.9em;

pre {
// Scrollbars in code blocks should be thinner to not overpower content on margin
@include scrollbar-style();
}

@media (min-width: $breakpoint-md) {
border: none;
width: $content-margin-width;
Expand Down
1 change: 1 addition & 0 deletions src/sphinx_book_theme/assets/styles/content/_math.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ span.eqno {
div.math {
overflow-x: auto;
position: relative;
@include scrollbar-style();
}

// Compensate for the extra bottom margin of a preceding paragraph
Expand Down
4 changes: 3 additions & 1 deletion src/sphinx_book_theme/assets/styles/extensions/_myst-nb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ div.cell {
}

div.cell_input,
div.cell_output div.output {
div.cell_output pre {
border-radius: $box-border-radius;
border: 1px #ccc solid;
}

div.cell_output {
Expand All @@ -18,6 +19,7 @@ div.cell {

// On screens, we want to scoll, but on print show all
@mixin cell-scroll {
@include scrollbar-style();
max-height: 24em;
overflow-y: auto;
@media print {
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_book_theme/assets/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@import "sections/sidebar-primary";
@import "sections/sidebar-secondary";
@import "sections/sidebars-toggle";
@import "sections/header-article";

// Re-usable components across the theme
@import "components/buttons";
Expand All @@ -39,6 +38,7 @@
@import "content/glossary";
@import "content/images";
@import "content/margin";
@import "content/math";
@import "content/quotes";
@import "content/sidebar";
@import "content/tableofcontents";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
z-index: 2000 !important;

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

@media (max-width: $breakpoint-md) {
position: fixed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
overflow-y: hidden;
background: white;
@include scrollbar-style();
@include scrollbar-on-hover();

// TOC link color
a:hover,
Expand Down