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

FIX: Scroll padding on top for anchor links #669

Merged
merged 10 commits into from
Jan 6, 2023
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
9 changes: 6 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,22 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9]
sphinx: [">=4,<5", ">=5,<6"]
# Only test the latest major release of Sphinx because otherwise we need to
# keep multiple versions of regression tests on file and this creates lots of
# noise in the tests.
sphinx: [">=5,<6"]
include:
- os: windows-latest
python-version: 3.9
sphinx: ">=4,<5"
sphinx: ">=5,<6"
- os: macos-latest
python-version: 3.9
sphinx: ">=5,<6"
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} and Sphinx ${{ matrix.sphinx }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
Expand Down
14 changes: 12 additions & 2 deletions src/sphinx_book_theme/assets/styles/base/_base.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/*********************************************
/**
* General structural things
*/
html {
// The PyData theme value for this is based on `header-height` variable.
// We set the variable to 0 and have our own $article-header-height SCSS variable.
// So here we follow the same pattern but now using our variable.
scroll-padding-top: $header-article-height + 1rem;
}

/**
* Utility classes used in a few places
*********************************************/
*/
// For the helper pixel that we can watch to decide whether we've scrolled
.sbt-scroll-pixel-helper {
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_book_theme/assets/styles/base/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
h3,
h4,
h5 {
color: var(--pst-color-text-muted);
color: var(--pst-color-text);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

.navbar-brand {
height: unset;
// Auto-center the image and title
justify-content: center;
}

// Remove the header items that pop into the sidebar in the pydata theme
Expand Down
2 changes: 1 addition & 1 deletion tests/test_build/test_marginnote.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h2>
2.2.
</span>
Marginnotes
<a class="headerlink" href="#marginnotes" title="Permalink to this headline">
<a class="headerlink" href="#marginnotes" title="Permalink to this heading">
#
</a>
</h2>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_build/test_sidenote.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h2>
2.1.
</span>
Sidenotes
<a class="headerlink" href="#sidenotes" title="Permalink to this headline">
<a class="headerlink" href="#sidenotes" title="Permalink to this heading">
#
</a>
</h2>
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete`

[tox]
envlist = py39-sphinx4
envlist = py39-sphinx5

[testenv]
usedevelop=true
Expand Down