Skip to content

Commit

Permalink
Merge pull request dipy#4 from skoudoro/update-menu
Browse files Browse the repository at this point in the history
Menu update 5ce7f48
  • Loading branch information
github-actions[bot] committed Sep 9, 2023
1 parent 43d44e3 commit 1d592ec
Show file tree
Hide file tree
Showing 62 changed files with 20,454 additions and 1,434 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 4f4926e84c5e9b7b19185b2601b9c80c
config: 7f0696966261c11bdd0c3656aa633dcc
tags: 645f666f9bcd5a90fca523b33c5a78b7
7 changes: 7 additions & 0 deletions _static/macros.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% macro head_assets() %}
<link rel="stylesheet" href="{{ pathto('_static/styles/grg-sphinx-theme.css', 1) }}"/>
{% endmacro %}

{% macro body_scripts() %}
<script type="module" src="{{ pathto('_static/scripts/grg-sphinx-theme.js', 1) }}"></script>
{% endmacro %}
64 changes: 64 additions & 0 deletions _static/scripts/components/toctree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* This method introduces a click function to click the
* underlying "a" tag for "li" element with toctree-l2 of the design.
*/
export const toctreeClick = () => {
const toctreeSubtopics = document.querySelectorAll(
".toctree-wrapper li.toctree-l2"
);

toctreeSubtopics.forEach((toctreel2) => {
const link = toctreel2.querySelector("a");
toctreel2.addEventListener("click", () => {
link.click();
});
});
};

/**
* This method introduces calculations for grid for toc tree
* not letting the grid to overflow the space provided by
* sphinx on different platforms
*/
export const gridCalculation = () => {
const toctrees = document.querySelectorAll(".toctree-wrapper li.toctree-l1");

toctrees.forEach((toctree) => {
const containerWidth = toctree.clientWidth;
const subtrees = toctree.querySelectorAll("li.toctree-l2 a");
const subtreeContainer = toctree.querySelector("ul");

let width = 0;
let noOfElements = 0;
const MAX_ELEMENTS = 3;
const UNIT_SPACE = 16;

// handling the empty case
if (subtrees.length === 0) {
return;
}

// handling the single element case
if (subtrees.length === 1) {
subtreeContainer.classList.add("grid-3");
return;
}

for (let i = 0; i < Math.min(MAX_ELEMENTS, subtrees.length); i++) {
// Getting the size of text in the list
// considering the padding applied on right and left side
width += subtrees[i].offsetWidth + 2 * UNIT_SPACE;

if (width > containerWidth) {
break;
} else {
noOfElements++;
}

// considering the gap applied
width += UNIT_SPACE;
}

subtreeContainer.classList.add(`grid-${noOfElements}`);
});
};
6 changes: 6 additions & 0 deletions _static/scripts/grg-sphinx-theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { toctreeClick, gridCalculation } from "./components/toctree.js";

document.addEventListener("DOMContentLoaded", () => {
toctreeClick();
gridCalculation();
});
21 changes: 21 additions & 0 deletions _static/styles/animations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@keyframes slideUp {
from {
transform: translateY(5%);
opacity: 0;
}
to {
transform: translateY(0%);
opacity: 1;
}
}

@keyframes slideDown {
from {
transform: translateY(-5%);
opacity: 0;
}
to {
transform: translateY(0%);
opacity: 1;
}
}
50 changes: 50 additions & 0 deletions _static/styles/components/navbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* Customizing the navbar dropdown */
.bd-header .navbar-nav .dropdown .dropdown-menu {
box-shadow: var(--pst-shadow);
border: 0;
animation: 0.1s slideDown;
min-width: 10rem;
padding: 0.5rem 0;
}

/* Overriding the CSS for section title in drop down */
ol li>p:first-child, ul li>p:first-child {
margin-top: 0;
margin-bottom: 0;
}

/* Making sure font behavior is same across the pages for navbar */
.nav-link,
.bd-header .navbar-nav li a.nav-link,
.bd-header .navbar-nav .dropdown button,
.bd-sidebar-primary,
.bd-sidebar-primary .nav-link {
color: var(--pst-color-text-base);
font-size: 14px;
font-weight: 400;
}

.nav-section-title.nav-link,
.bd-sidebar-primary .nav-section-title.nav-link {
color: var(--pst-color-text-muted);
font-weight: bold;
}

.nav-section-title:not(:first-of-type) {
border-top: 1px solid var(--pst-color-border);
}

.nav-link.nav-external:after {
transform: rotate(-45deg);
color: var(--pst-color-shadow);
}

.dropdown-toggle:after {
position: absolute;
border: 0;
content: "\f078";
font: var(--fa-font-solid);
font-size: .75em;
margin-top: 0.4rem;
margin-left: 0.5em;
}
48 changes: 48 additions & 0 deletions _static/styles/components/toctree.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.toctree-wrapper li.toctree-l1 {
margin-bottom: 2em;
}

.toctree-wrapper li.toctree-l1 a {
font-size: 1.8em;
font-weight: 600;
color: var(--pst-color-text-base);
}

.toctree-wrapper li.toctree-l2 {
border: 1px solid var(--pst-color-border);
border-radius: 4px;
padding: 1em;
}

.toctree-wrapper li.toctree-l2 a {
font-size: 16px;
font-weight: 600;
color: var(--pst-color-primary);
text-decoration: none;
}

.toctree-wrapper li.toctree-l2:hover {
border: 1px solid var(--pst-color-secondary);
cursor: pointer;
}

.toctree-wrapper li.toctree-l2:hover a {
color: var(--pst-color-secondary);
}

.toctree-wrapper li.toctree-l1 ul {
display: grid;
gap: 1em;
padding-inline-start: 0;
padding: 1em 0;
}

.toctree-wrapper li.toctree-l2 ul {
display: none;
}

@media only screen and (max-width: 767px) {
.toctree-wrapper li.toctree-l1 ul {
grid-template-columns: repeat(1, 1fr);
}
}
5 changes: 5 additions & 0 deletions _static/styles/grg-sphinx-theme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "./animations.css";
@import "./variables.css";
@import "./components/toctree.css";
@import "./components/navbar.css";
@import url("https://cdn.jsdelivr.net/gh/GRG-projects/CDN@latest/util.min.css");
4 changes: 4 additions & 0 deletions _static/styles/variables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
html {
--pst-icon-external-link: "\f178";
--pst-shadow: 0 12px 32px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .08);
}
Loading

0 comments on commit 1d592ec

Please sign in to comment.