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

Prepare rel 0.3.0 #22

Merged
merged 3 commits into from
Mar 10, 2024
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
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [0.3.0] - 2024-03-10

- When producing the HTML static site, create a file called `doc_versions.js`, containing the list of versions (name and url) specified in the `version` entry of the `html_theme_options`.
- Change the CSS layout so that the grid centers itself, regardless of whether the toc at the right side is visible or not.

## [0.2.3] - 2024-02-20

- Use a fluid layout (Bootstrap's `container-fluid`) to allow expanding the TOC
Expand Down
5 changes: 4 additions & 1 deletion js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MenuHandler } from "./menu.js";
import { updateRepoMetrics } from "./repometrics.js";
import { TocObserver } from "./pagetoc.js";
import { resizeAsides, updateScrollPaddingTop } from "./tocresize.js";
import { updateVersion } from "./versions.js";
import { feedVersionsMenu, updateVersion } from "./versions.js";


function agentHas(keyword) {
Expand Down Expand Up @@ -56,6 +56,9 @@ window.addEventListener('DOMContentLoaded', (_) => {
const luz_handler = new LuzHandler();
luz_handler.registerClickEvents();

// Feed the versions dropdown element.
feedVersionsMenu();

// The updateVersion function controls the display of the version
// in the header, adding the CSS class "current" to display the
// tick symbol near the version selected.
Expand Down
16 changes: 1 addition & 15 deletions js/src/tocresize.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,7 @@ export function resizeAsides() {
nftt_toc?.setAttribute("style", height);
}

// Compute new 'grid-template-columns' for nftt-layout.
const max = (window.innerWidth - nftt_content.offsetWidth);
const newmax = nftt_toc
? Math.floor(max / 2)
: (
nftt_sidebar_content
? Math.floor((max + nftt_sidebar_content.offsetWidth) / 2)
: undefined
);
if (newmax) {
const newgtcols = `minmax(300px, ${newmax}px) 5fr`;
nftt_layout?.setAttribute("style", `grid-template-columns: ${newgtcols}`);
}

return [height, newmax];
return height;
}


Expand Down
36 changes: 36 additions & 0 deletions js/src/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,39 @@ export function updateVersion() {
}
}
}

export function feedVersionsMenu() {
const vermenu = document.getElementById("versions-dropdown-menu");
if (!vermenu) {
console.log("Did not find the versions dropdown menu.");
return;
}
// Use the variable 'doc_versions', loaded as a script in layout.html.
// The file doc_versions.js is produced by versions.py when building
// the site (make html).
console.log("Found the versions dropdown menu!");
console.log("doc_versions are:");
console.dir(doc_versions);

for (const item of doc_versions) {
const li = document.createElement("li");
const anchor = document.createElement("a");
anchor.classList.add(
"dropdown-item", "d-flex", "align-items-center",
"justify-content-between"
);
anchor.setAttribute("aria-pressed", "false");
anchor.setAttribute("href", item.url);
anchor.dataset.snfttVersionUrl = item.url;
anchor.dataset.snfttVersion = item.name;
const span = document.createElement("span");
span.classList.add("small", "ms-2");
span.textContent = item.name;
const i = document.createElement("i");
i.classList.add("bi", "bi-check", "ms-auto");
anchor.append(span);
anchor.append(i);
li.append(anchor);
vermenu.append(li);
}
}
8 changes: 4 additions & 4 deletions js/tests/unit/tocresize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('resize', () => {
}
);

const results = resizeAsides();
expect(results[0]).toEqual("height: calc(100vh - 7rem)");
const result = resizeAsides();
expect(result).toEqual("height: calc(100vh - 7rem)");
});

it('checks resizeAsides when nftt_content shorter than body', () => {
Expand All @@ -90,7 +90,7 @@ describe('resize', () => {
}
);

const results = resizeAsides();
expect(results[0]).toEqual(expected_height);
const result = resizeAsides();
expect(result).toEqual(expected_height);
});
});
80 changes: 44 additions & 36 deletions scss/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,52 @@ body {
padding-top: 63px;
}

.nftt-layout {
.nftt-page {
flex: 1 0 auto;
margin-top: 2.5rem;
margin-bottom: 1.5rem;

@include media-breakpoint-up(xl) {
display: grid;
grid-template-areas: "sidebar main";
grid-template-columns: minmax(300px, 1.5fr) 5fr;
grid-template-areas: "sidebar content toc";
grid-template-columns: minmax(300px, 1.5fr) minmax(570px, 760px) minmax(190px, 1.3fr);
gap: 25px;
}

@include media-breakpoint-down(xl) {
display: grid;
grid-template-areas: "content toc";
grid-template-columns: minmax(570px, 5fr) minmax(190px, 1fr);
gap: 25px;
}

@include media-breakpoint-down(lg) {
grid-template-areas:
"toc"
"content";
grid-template-rows: 1fr auto;
grid-template-columns: none;
max-width: 892px;
margin-inline: auto;
}
}

.nftt-page-wo-toc {
flex: 1 0 auto;
margin-top: 2.5rem;
margin-bottom: 1.5rem;

@include media-breakpoint-up(xl) {
display: grid;
grid-template-areas: "sidebar content toc";
grid-template-columns: minmax(300px, 1.5fr) minmax(570px, 760px) minmax(190px, 1.3fr);
gap: 25px;
}

@include media-breakpoint-down(xl) {
max-width: 92%;
margin-inline: auto;
}
}

.nftt-sidebar {
Expand All @@ -59,39 +94,6 @@ body {
}
}

.nftt-main-wo-toc {
display: grid;
grid-area: main;
grid-template-areas: "content";
grid-template-columns: minmax(570px, 860px);
padding-right: 48px;

@include media-breakpoint-down(xl) {
grid-template-columns: none;
padding-right: 0;
}
}

.nftt-main {
display: grid;
grid-area: main;
grid-template-areas:
"toc"
"content";
grid-template-rows: 1fr auto;
gap: inherit;

@include media-breakpoint-down(xl) {
max-width: 1100px;
margin-inline: auto;
}

@include media-breakpoint-up(lg) {
grid-template-areas: "content toc";
grid-template-columns: minmax(570px, 760px) minmax(190px, 1.3fr);
}
}

.nftt-toc {
grid-area: toc;

Expand All @@ -100,6 +102,12 @@ body {
font-family: var(--#{$prefix}font-monospace);
font-size: .7rem;
}

@include media-breakpoint-down(lg) {
padding-right: 2rem;
padding-left: 2rem;
}

}


Expand Down
2 changes: 1 addition & 1 deletion scss/components/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
display: flex;
align-items: center;

@include media-breakpoint-down(sm) {
@include media-breakpoint-down(md) {
justify-content: space-between;
width: 100%;
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name="sphinx-nefertiti",
version="0.2.3",
version="0.3.0",
packages=find_packages(),
include_package_data=True,
license="MIT",
Expand Down
Loading
Loading