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

Update pydata theme to 0.10 #597

Merged
merged 75 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
8ab4c61
update pyproject dependencies, link to prev-next, using announcement …
AakashGfude Jul 26, 2022
fec749a
updating layout.html, header-article, and using sidebar-primary and s…
AakashGfude Jul 26, 2022
9e9ca0b
header-article styles and sidebar-secondary style and html
AakashGfude Jul 26, 2022
d617024
scroll-pixel-helper, js fix, removing sidebar secondary css
AakashGfude Jul 26, 2022
e8aef57
setting sidebar primary styles
AakashGfude Jul 27, 2022
3fdc6ea
styling changes and rtd footer
AakashGfude Jul 28, 2022
f483810
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 28, 2022
7cab01f
changing comment and class name in _readthedocs
AakashGfude Jul 28, 2022
9b4a7f1
adding layout html, scss for sidebars and article width
AakashGfude Jul 30, 2022
e26498d
sidebar secondary styles
AakashGfude Jul 31, 2022
910e808
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Jul 31, 2022
f04e20f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2022
7400de8
sidebar secondary styles, margin, sidebars
AakashGfude Aug 1, 2022
8bead42
Merge branch 'master' into updt-pydata-0.10
AakashGfude Aug 1, 2022
4b25376
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 1, 2022
84dadff
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 1, 2022
6394af5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 1, 2022
df06dbe
removing package-lock.json here, but we should keep it in the repo in…
AakashGfude Aug 1, 2022
c7c7be8
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 1, 2022
5ad3a12
transition css
AakashGfude Aug 2, 2022
97cbe13
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2022
cbac680
sidebar secondary toc
AakashGfude Aug 4, 2022
8906812
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 4, 2022
8342f63
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2022
ef5c9e1
updated pydata version
AakashGfude Aug 15, 2022
b00c966
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 15, 2022
7c093aa
cleaning layout file and empyting block navbar
AakashGfude Aug 17, 2022
9031b2b
correcting header-article and sidebar-secondary styles, html
AakashGfude Aug 17, 2022
1f56581
max width 50em
AakashGfude Aug 18, 2022
82a7467
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 18, 2022
6c60479
footer content style
AakashGfude Aug 18, 2022
4c4a092
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 18, 2022
7d446cc
removing footer and editing primary sidebar
AakashGfude Aug 19, 2022
9f1a7a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 19, 2022
7933831
added some styles
AakashGfude Aug 22, 2022
e38e18e
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 22, 2022
d55232c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 22, 2022
1185d8f
search bar style
AakashGfude Aug 23, 2022
fda71f2
Merge branch 'master' into updt-pydata-0.10
AakashGfude Aug 23, 2022
b7abf67
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 23, 2022
e88c122
css and style changes
AakashGfude Aug 28, 2022
bae766d
some admontion scss
AakashGfude Aug 28, 2022
0592a1c
added some admonition classed and generate_toctree_html
AakashGfude Aug 28, 2022
6b2a1d1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 28, 2022
cad8a51
container widths
AakashGfude Aug 28, 2022
0ef5512
admonition styling
AakashGfude Aug 29, 2022
adade87
added nprint js and css/html changes
AakashGfude Aug 29, 2022
2493713
css and js adjustments
AakashGfude Aug 29, 2022
fff2b7f
tests correction
AakashGfude Aug 29, 2022
16553ee
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 29, 2022
bb90d7b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 29, 2022
34d850f
updating to pydata 10.1
AakashGfude Aug 30, 2022
cb84124
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Aug 30, 2022
4674e96
styles for toggle button
AakashGfude Sep 1, 2022
492062b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2022
95ab90e
changing test to accomodate primary sidebar
AakashGfude Sep 1, 2022
089cef7
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Sep 1, 2022
32216bd
adding variables and comments
AakashGfude Sep 3, 2022
cda1e3d
search related css
AakashGfude Sep 3, 2022
3e56239
secondary sidebar icon and border-left
AakashGfude Sep 8, 2022
562f122
removed admonitions
AakashGfude Sep 21, 2022
80a2694
updating styles in scss
AakashGfude Sep 26, 2022
eb30e64
merging files
AakashGfude Sep 26, 2022
bf32d10
updating links
AakashGfude Sep 27, 2022
341f5d6
changing color codes to rgb
AakashGfude Sep 27, 2022
107ca0e
set default_mode to light
AakashGfude Oct 17, 2022
45c9967
adjusting content width to cater to full-width elements
AakashGfude Oct 18, 2022
e60d56d
config value
AakashGfude Oct 18, 2022
393c13d
default_mode in builder-inited
AakashGfude Oct 19, 2022
abfc613
setting mode to light
AakashGfude Oct 19, 2022
2409962
Merge branch 'master' into updt-pydata-0.10
AakashGfude Oct 19, 2022
71100c0
style edits for small anomalies
AakashGfude Oct 20, 2022
eb58dcf
Merge branch 'master' into updt-pydata-0.10
AakashGfude Oct 20, 2022
5962068
Merge branch 'updt-pydata-0.10' of https://github.com/executablebooks…
AakashGfude Oct 20, 2022
e4f52ba
search input placeholder color
AakashGfude Oct 25, 2022
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ readme = "README.md"

requires-python = ">=3.7"
dependencies = [
"sphinx>=3,<5",
"pydata-sphinx-theme~=0.8.0",
"sphinx>=3,<6",
"pydata-sphinx-theme~=0.10.1",
"pyyaml",
]

Expand Down
10 changes: 8 additions & 2 deletions src/sphinx_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def hash_html_assets(app, pagename, templatename, context, doctree):
hash_assets_for_files(assets, get_html_theme_path() / "static", context)


def update_thebe_config(app):
def update_mode_thebe_config(app):
"""Update thebe configuration with SBT-specific values"""
theme_options = app.env.config.html_theme_options
if theme_options.get("launch_buttons", {}).get("thebe") is True:
Expand Down Expand Up @@ -144,6 +144,12 @@ def update_thebe_config(app):

app.env.config.thebe_config = thebe_config

# setting default mode to light for now.
# TODO: provide a button, and add css for dark theme.
# sphinx-build command does not call config-inited,
# so setting this in builder-inited.
app.config.html_context["default_mode"] = "light"


class Margin(Sidebar):
"""Goes in the margin to the right of the page."""
Expand Down Expand Up @@ -185,7 +191,7 @@ def setup(app: Sphinx):
app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir)

# Events
app.connect("builder-inited", update_thebe_config)
app.connect("builder-inited", update_mode_thebe_config)
app.connect("config-inited", update_general_config)
app.connect("html-page-context", add_metadata_to_page)
app.connect("html-page-context", hash_html_assets)
Expand Down
49 changes: 25 additions & 24 deletions src/sphinx_book_theme/assets/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,6 @@ var toggleFullScreen = () => {
}
};

/**
* Sidebar scroll on load.
*
* Detect the active page in the sidebar, and scroll so that it is centered on
* the screen.
*/
var scrollToActive = () => {
var navbar = document.getElementById("site-navigation");
var navbar_scrollable = navbar.children[0];
var active_pages = navbar.querySelectorAll(".active");
var active_page = active_pages[active_pages.length - 1];
// Only scroll the navbar if the active link is lower than 50% of the page
if (
active_page !== undefined &&
active_page.offsetTop > $(window).height() * 0.5
) {
navbar_scrollable.scrollTop =
active_page.offsetTop - $(window).height() * 0.2;
}
};

/**
* Called when the "print to PDF" button is clicked.
* This is a hack to prevent tooltips from showing up in the printed PDF.
Expand Down Expand Up @@ -118,9 +97,9 @@ var initTocHide = () => {

// Hide the TOC if any margin content is displayed on the screen
if (onScreenItems.length > 0) {
$("div.bd-toc").removeClass("show");
$("div.bd-sidebar-secondary").removeClass("show");
} else {
$("div.bd-toc").addClass("show");
$("div.bd-sidebar-secondary").addClass("show");
}
};
let manageScrolledClassOnBody = (entries, observer) => {
Expand Down Expand Up @@ -218,6 +197,27 @@ function initRTDObserver() {
observer.observe(document.body, config);
}

/**
* Add no print class to certain DOM elements
*/

function addNoPrint() {
$("div.bd-sidebar-primary").addClass("noprint");
$("div.bd-header-article").addClass("noprint");
$("div.bd-header-announcement").addClass("noprint");
$("footer.bd-footer-article").addClass("noprint");
}

/**
* Set Mode of the theme
* Remove this function once all modes are supported.
*/

function setMode() {
document.documentElement.dataset.mode = "light";
document.documentElement.dataset.theme = "light";
}

/**
* Set up callback functions for UI click actions
*/
Expand All @@ -229,6 +229,7 @@ window.toggleFullScreen = toggleFullScreen;
* Set up functions to load when the DOM is ready
*/
sbRunWhenDOMLoaded(initTooltips);
sbRunWhenDOMLoaded(scrollToActive);
sbRunWhenDOMLoaded(initTocHide);
sbRunWhenDOMLoaded(initRTDObserver);
sbRunWhenDOMLoaded(addNoPrint);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work if we print via headless chromium? That's what we use for HTML-to-PDF in jupyter book

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @choldgraf , seems to be working. Primary sidebars and announcement banners etc. are hidden in pdfhtml build.

sbRunWhenDOMLoaded(setMode);
30 changes: 12 additions & 18 deletions src/sphinx_book_theme/assets/styles/abstracts/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $leftbar-width-mobile: 75%;
$leftbar-width-wide: 275px;
$toc-width-mobile: 75%;
// Main content, to leave room for the margin
$content-max-width: 70%;
$content-max-width: 75%;

// Consistent styling for page elements
$box-border-radius: 0.4em;
Expand All @@ -35,26 +35,13 @@ $border-thin: 1px solid rgba(0, 0, 0, 0.1);

// Overrides for pydata sphinx theme.
// See https://github.com/pydata/pydata-sphinx-theme/blob/master/pydata_sphinx_theme/static/css/theme.css
:root {
:root[data-theme="light"] {
// Over-ride the pydata theme so that readers can use their system base
--pst-font-size-base: none;

// Pulling colors from the Binder logo since they are complementary and on-brand
--pst-color-primary: 87, 154, 202;
--pst-color-admonition-note: var(--pst-color-primary);
--pst-color-admonition-default: var(--pst-color-primary);

--pst-color-info: 255, 193, 7;
--pst-color-admonition-tip: var(--pst-color-info);
--pst-color-admonition-hint: var(--pst-color-info);
--pst-color-admonition-important: var(--pst-color-info);

--pst-color-warning: 245, 162, 82;

--pst-color-danger: 230, 101, 129;
--pst-color-admonition-warning: var(--pst-color-danger);

--pst-color-link: 0, 113, 188;
--pst-color-primary: rgb(87, 154, 202);
--pst-color-link: rgb(0, 113, 188);
--pst-color-border: rgb(238, 238, 238);

// Font sizes
--sbt-font-size-regular: 100%;
Expand All @@ -67,4 +54,11 @@ $border-thin: 1px solid rgba(0, 0, 0, 0.1);
--sbt-header-article-font-size: var(--sbt-font-size-small-1);
--sbt-prevnext-font-size: var(--sbt-font-size-small-1);
--sbt-footer-font-size: var(--sbt-font-size-small-1);

// Search variables
--sbt-color-search-highlighted: rgb(243, 119, 38);
--sbt-color-search-icon: rgb(164, 166, 167);

// Announcement
--sbt-color-announcement: rgb(97, 97, 97);
}
5 changes: 5 additions & 0 deletions src/sphinx_book_theme/assets/styles/base/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
display: none;
}

// default color for all the links
a {
color: var(--pst-color-link);
}

// Print-specific utility classes
.onlyprint {
display: none;
Expand Down
123 changes: 72 additions & 51 deletions src/sphinx_book_theme/assets/styles/base/_print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,86 @@
* Print-specific CSS *
*********************************************/
@media print {
// Structural elements
#jb-print-docs-body {
max-width: 90%;
margin: auto;
.bd-main {
.bd-content {
margin-left: 3rem;
height: auto;
// Structural elements
#jb-print-docs-body {
margin-left: 0rem;

h1 {
font-size: 3em;
text-align: center;
margin-bottom: 0;
}
}
h1 {
font-size: 3em;
text-align: center;
margin-bottom: 0;
}
}
// Main content adjustments
.bd-article {
padding-top: 0;

// Main content adjustments to center it a bit more
#main-content {
max-width: 67% !important;
margin-left: 5% !important;
padding-top: 0;
// The first H1 is the title, we've already displayed above
h1:first-of-type {
display: none;
}
}

// The first H1 is the title, we've already displayed above
h1:first-of-type {
display: none;
}
}
// HACK: Without this, some code cells take the whole width
.container {
min-width: 0% !important;
}

// HACK: Without this, some code cells take the whole width
.container {
min-width: 0% !important;
}
// Content
h1 {
margin-top: 1em;
margin-bottom: 1em;
}
h1,
h2,
h3,
h4 {
break-after: avoid;
color: black;
}

// Content
h1 {
margin-top: 1em;
margin-bottom: 1em;
}
h1,
h2,
h3,
h4 {
break-after: avoid;
color: black;
}
table {
break-inside: avoid;
}

table {
break-inside: avoid;
}

pre {
word-wrap: break-word;
}
pre {
word-wrap: break-word;
}

a.headerlink {
display: none;
}
a.headerlink {
display: none;
}

blockquote.epigraph {
border: none;
}
blockquote.epigraph {
border: none;
}

.footer {
margin-top: 1em;
.footer {
margin-top: 1em;
}
// Print-only table of contents
#jb-print-toc {
margin-bottom: 1.5rem;
margin-left: 0rem;
.section-nav {
border-left: 0px !important;
list-style-type: disc !important;
margin-left: 3em !important;
a {
text-decoration: none !important;
}
li {
display: list-item !important;
}
.nav {
display: none;
}
}
}
}
}
}
13 changes: 4 additions & 9 deletions src/sphinx_book_theme/assets/styles/base/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
* Basic text formatting and content structure *
*********************************************/

.content-container {
.bd-article-container {
// Content links and link color
a.headerlink {
opacity: 0;
margin-left: 0.2em;

&:hover {
background-color: transparent;
color: rgba(var(--pst-color-link), 1);
color: var(--pst-color-link);
opacity: 1 !important;
}
}

a,
a.nav-link, // to be more specific, so that pst style doesn't override
a:visited {
color: rgba(var(--pst-color-link), 1);
color: var(--pst-color-link);
}

h1,
Expand Down Expand Up @@ -55,10 +56,4 @@
p.centered {
text-align: center;
}

// Footnotes and Citations
.footnote-reference,
a.bibtex.internal {
font-size: 1em;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ div.header-article-main {
/**
* In-page table of contents
*/
.headerbtn-page-toc {
.headerbtn-secondary {
// Hide the button on wide screens since we display the TOC.
display: block;
@media (min-width: $breakpoint-md) {
Expand Down
11 changes: 10 additions & 1 deletion src/sphinx_book_theme/assets/styles/components/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@
// Highlighted search items are a slightly lighter version of Jupyter orange
dt:target,
span.highlighted {
background-color: #f3772642;
background-color: var(--sbt-color-search-highlighted);
}

.bd-search {
.icon {
color: var(--sbt-color-search-icon);
}
.search-button__kbd-shortcut {
display: none;
}
}
Loading