Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sangam14 committed Nov 25, 2023
1 parent 6373047 commit b556ab0
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 130 deletions.
Binary file modified .DS_Store
Binary file not shown.
30 changes: 22 additions & 8 deletions assets/js/component/article-nav.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
const body = document.body;

const btnArticleNavMenu = document.querySelector("#article-nav-menu-btn")
if (btnArticleNavMenu) {
btnArticleNavMenu.addEventListener('click', function () {
document.body.classList.remove('offcanvas-toc-on');
document.body.classList.add('offcanvas-sidebar-on')
body.classList.add('offcanvas-sidebar-on')
});
}

const btnArticleNavToc = document.querySelector("#article-nav-toc-btn")
if (btnArticleNavToc) {
btnArticleNavToc.addEventListener('click', function () {
document.body.classList.remove('offcanvas-sidebar-on');
document.body.classList.add('offcanvas-toc-on')
body.classList.add('offcanvas-toc-on')
});
}

const btnCloseArticleNavMenu = document.querySelector("#sidebar .btn-close")
if (btnCloseArticleNavMenu) {
btnCloseArticleNavMenu.addEventListener('click', function () {
document.body.classList.remove('offcanvas-sidebar-on')
body.classList.remove('offcanvas-sidebar-on')
});
}

const btnCloseArticleNavToc = document.querySelector("#toc .btn-close")
if (btnCloseArticleNavToc) {
btnCloseArticleNavToc.addEventListener('click', function () {
document.body.classList.remove('offcanvas-toc-on')
body.classList.remove('offcanvas-toc-on')
});

const tocLinks = document.querySelectorAll("#toc ul a");
tocLinks.forEach(link => {
link.addEventListener('click', function () {
document.body.classList.remove('offcanvas-toc-on')
body.classList.remove('offcanvas-toc-on')
});
});
}
}

body.addEventListener('click', e => {
const isBtnArticleNavMenu = e.target.closest('#article-nav-menu-btn');
const isSidebar = e.target.closest('#sidebar');
if (!isBtnArticleNavMenu && !isSidebar && body.classList.contains('offcanvas-sidebar-on')) {
body.classList.remove('offcanvas-sidebar-on');
}

const isBtnArticleNavToc = e.target.closest('#article-nav-toc-btn');
const toc = e.target.closest('#toc');
if (!isBtnArticleNavToc && !toc && body.classList.contains('offcanvas-toc-on')) {
body.classList.remove('offcanvas-toc-on');
}
});
13 changes: 13 additions & 0 deletions assets/js/component/sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fromDesktop = window.matchMedia('(min-width: 1280px)');
const sidebarSticky = document.querySelector("#sidebar .sticky")
if (fromDesktop && sidebarSticky) {
window.addEventListener("scroll", function () {
if (document.body.scrollTop > 80 || document.documentElement.scrollTop > 80) {
sidebarSticky.style.top = "20px";
sidebarSticky.style.bottom = "65px";
} else {
sidebarSticky.style.top = null;
sidebarSticky.style.bottom = null;
}
});
}
46 changes: 32 additions & 14 deletions assets/js/component/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,44 @@ if (fromLargeTablet && tocSticky) {
window.addEventListener("scroll", function () {
if (document.body.scrollTop > 80 || document.documentElement.scrollTop > 80) {
tocSticky.style.top = "20px";
tocSticky.style.bottom = "65px";
} else {
tocSticky.style.top = null;
tocSticky.style.bottom = null;
}
});
}

function updateActiveClasses() {
const headers = document.querySelectorAll('#article h2, #article h3');
const links = document.querySelectorAll('#TableOfContents a');
if ('IntersectionObserver' in window) {
document.addEventListener('DOMContentLoaded', function () {
const links = document.querySelectorAll('#TableOfContents a');
let activeLink = null;
const linksById = {};

for (let i = 0; i < headers.length; i++) {
const rect = headers[i].getBoundingClientRect();
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
if (activeLink) {
activeLink.classList.remove('active');
}

if (rect.top >= 0 && rect.top <= window.innerHeight) {
links[i].classList.add('active');
} else {
links[i].classList.remove('active');
}
}
activeLink = linksById[entry.target.id];
if (activeLink) {
activeLink.classList.add('active');
}
}
});
}, {rootMargin: `0% 0% -80% 0%`});

links.forEach(link => {
const id = link.getAttribute('href') ? link.getAttribute('href').slice(1) : null; // Checking if href exists before slicing #
if (id) {
const target = document.getElementById(id);
if (target) {
linksById[id] = link;
observer.observe(target);
}
}
});
});
}
window.addEventListener('load', updateActiveClasses);
window.addEventListener('resize', updateActiveClasses);
window.addEventListener('scroll', updateActiveClasses);
8 changes: 5 additions & 3 deletions assets/scss/base.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Docura (https://docura.github.io/)
* Copyright 2022 Dumindu Madunuwan
* Copyright 2022-2023 Dumindu Madunuwan
* Licensed under the MIT License.
*/

Expand All @@ -18,8 +18,10 @@
@import "component/dropdown";
@import "component/chroma";

body{
html {
font-family: var(--font-family);
background: var(--background);
color: var(--color);
}
scroll-behavior: smooth;
scroll-padding: 2em;
}
50 changes: 0 additions & 50 deletions assets/scss/component/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,53 +40,3 @@
border-radius: 4px;
cursor: pointer;
}


.button {
display: inline-block;
text-align: center;
vertical-align: middle;
padding: 12px 24px;
border: 1px solid #295291;
border-radius: 8px;
background: #4d9bff;
background: -webkit-gradient(linear, left top, left bottom, from(#4d9bff), to(#295291));
background: -moz-linear-gradient(top, #4d9bff, #295291);
background: linear-gradient(to bottom, #4d9bff, #295291);
-webkit-box-shadow: #5cbaff 0px 0px 40px 0px;
-moz-box-shadow: #5cbaff 0px 0px 40px 0px;
box-shadow: #5cbaff 0px 0px 40px 0px;
text-shadow: #183156 1px 1px 1px;
font: normal normal bold 20px arial;
color: #ffffff;
text-decoration: none;
}
.button:hover,
.button:focus {
border: 1px solid #3061ab;
background: #5cbaff;
background: -webkit-gradient(linear, left top, left bottom, from(#5cbaff), to(#3162ae));
background: -moz-linear-gradient(top, #5cbaff, #3162ae);
background: linear-gradient(to bottom, #5cbaff, #3162ae);
color: #ffffff;
text-decoration: none;
}
.button:active {
background: #295291;
background: -webkit-gradient(linear, left top, left bottom, from(#295291), to(#295291));
background: -moz-linear-gradient(top, #295291, #295291);
background: linear-gradient(to bottom, #295291, #295291);
}
.button:before{
content: "\0000a0";
display: inline-block;
height: 24px;
width: 24px;
line-height: 24px;
margin: 0 4px -6px -4px;
position: relative;
top: 0px;
left: 0px;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAA7EAAAOxAGVKw4bAAACRklEQVRIie2UP2iTYRDGf08NIZSShhI6lFLEQST4JzqoiHVwECfpKKVU7SAd6qSDi5NI3Yqoc1ErdFVBHfwDLRkEFQQpYkUklGKsGIsVaxTO4bskb8uXRJ178PG93713z909393BhrSQTc0uJWUk5SXtkVQCVgP9EUmdkr4BP/8pqqQDkh5I+iHJ/BkL7scC/XdJ9yTtj8WKAR8EJoHPwE2gACwCK0AWSPg5BXQB/cCwn0+Y2XQrSkqSnkrqljQk6Y6k5SDj6vNLUsGr6XWfkqR0iJlYF2PIM3kMvAB6gXfAlH8vAhWvZBdwFLgCXACuAwe9mmuxFEl6BXwC5oDtwCVgxsx+Nyi6TdJe4KL75ICsme2OoyfnpZ9syGELkTTiGLlaBsH9AFH5D/83AHDfMQZqQYPos0DSzPYFuiRw3j8vm1mlmd7vngEVM+sPS8t4P4+H6QQlm6SRVnq/G3esNNQp2gm0A7PrSk4F5+Rf6CGam3YgD/U2zfv7ZQCwSjRoO1w3FYDE6as+z4OkZ6plTUgq+3nUB2tYUtgEsSKpTdKgpLKkUdeVJU1AnaIUsOI/bwFIAzeAgk9zNga4S9JxIlpvAxlgwTGqq6RGUQE47cZngWmiad0C3AIqkorAR7fvBvoc5D3wiGh3fXWMHsdc06bHgKvu+IRo4b0FDgGdwDaiNQLwBXgDLDvPW4FTwGGgCJwxs7txfHZIOidpPmjDpVjyI/ulwG7efTvW2DRwTBDtlT7gtZl9aGC3mWhnFYG5JjtrQxrLH3oToqtg0Za+AAAAAElFTkSuQmCC") no-repeat left center transparent;
background-size: 100% 100%;
}
26 changes: 6 additions & 20 deletions assets/scss/component/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.dropdown-btn {
display: flex;
flex-direction: row;
border: 1px solid var(--border-color);
box-shadow: var(--box-shadow);
border-radius: 6px;
padding: 6px;
cursor: pointer;
Expand All @@ -20,11 +20,13 @@
display: none;
position: absolute;
right: 0;
top: 34px;
min-width: 100px;
max-height: 240px;
overflow-x: auto;
border: 1px solid var(--border-color);
background: white;
background: var(--background);
color: var(--color3);
box-shadow: var(--box-shadow2);
z-index: 1;
border-radius: 6px;
padding: 3px;
Expand All @@ -45,21 +47,5 @@
}

.dropdown-menu button:hover, .dropdown-menu a:hover {
background: rgba(0, 0, 0, 0.05);
}

:root[data-color="dark"] .dropdown-menu button:hover, .dropdown-menu a:hover {
background: rgba(255, 255, 255, 0.05);
}

:root[data-color="night"] .dropdown-menu button:hover, .dropdown-menu a:hover {
background: rgba(255, 255, 255, 0.05);
}

:root[data-color="dark"] .dropdown-menu{
background: #121212;
}

:root[data-color="night"] .dropdown-menu {
background: #333333;
background: var(--background-fg);
}
2 changes: 1 addition & 1 deletion assets/scss/component/article.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#article-content table,
#article-content ul {
margin-top: 1em;
line-height: 1.8;
line-height: 1.8rem;
letter-spacing: -.1px;
}

Expand Down
13 changes: 7 additions & 6 deletions assets/scss/component/docsearch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--docsearch-icon-stroke-width: 1.4;
--docsearch-highlight-color: var(--docsearch-primary-color);
--docsearch-muted-color: #969faf;
--docsearch-container-background: rgba(101, 108, 133, 0.8);
--docsearch-container-background: rgba(255, 255, 255, 0.1);
--docsearch-logo-color: #5468ff;
--docsearch-modal-width: 560px;
--docsearch-modal-height: 600px;
Expand All @@ -23,7 +23,6 @@
}

:root[data-color="dark"] {
--docsearch-container-background: rgba(9, 10, 17, 0.8);
--docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
--docsearch-searchbox-focus-background: #000;
--docsearch-hit-color: #bec3c9;
Expand All @@ -34,7 +33,6 @@
}

:root[data-color="night"] {
--docsearch-container-background: rgba(9, 10, 17, 0.8);
--docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
--docsearch-searchbox-focus-background: #000;
--docsearch-hit-color: #bec3c9;
Expand All @@ -48,7 +46,7 @@
width: 100%;
line-height: 1.6em;
align-items: center;
border: 1px solid var(--border-color);
box-shadow: var(--box-shadow);
border-radius: 24px;
color: var(--color);
cursor: pointer;
Expand Down Expand Up @@ -77,7 +75,8 @@

.DocSearch-Button-Placeholder {
font-size: 1rem;
padding: 0 12px 0 6px
padding: 0 12px 0 6px;
color: var(--color3)
}

.DocSearch-Button-Keys {
Expand Down Expand Up @@ -132,7 +131,9 @@
position: fixed;
top: 0;
width: 100vw;
z-index: 200
z-index: 200;
backdrop-filter: blur(var(--blur));
-webkit-backdrop-filter: blur(var(--blur));
}

.DocSearch-Container a {
Expand Down
14 changes: 13 additions & 1 deletion assets/scss/component/sidebar.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#sidebar {
padding: 40px 0;
}

#sidebar .sticky {
display: flex;
flex-direction: column;
padding: 0 20px;
overflow: auto;
}

.sidebar-section, .sidebar-link {
Expand All @@ -12,6 +19,10 @@
color: var(--color2)
}

#sidebar .sidebar-section:first-child {
margin-top: 0;
}

.sidebar-link {
padding-left: 10px;
color: var(--color3);
Expand All @@ -24,7 +35,8 @@
display: inline-block;
width: 6px;
height: 6px;
background: var(--border-color);
background: var(--background);
box-shadow: var(--box-shadow);
border-radius: 50%;
position: relative;
left: -13.5px;
Expand Down
1 change: 1 addition & 0 deletions assets/scss/component/site-footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
display: flex;
align-items: center;
justify-content: center;
color: var(--color3)
}

#site-footer-copyright a {
Expand Down
Loading

0 comments on commit b556ab0

Please sign in to comment.