9 Commits

Author SHA1 Message Date
gurusabarish 9b9e8a6b84 option to customize search placeholder 2023-03-21 07:30:05 +05:30
gurusabarish de4c1e1a57 Merge branch 'master' into search_placeholder 2023-03-21 07:18:02 +05:30
gurusabarish a36ef35350 fix for #113 2023-03-20 07:25:23 +05:30
gurusabarish 6da60eaa31 fix for #108 2023-03-19 10:43:47 +05:30
Ari Kalfus 84e118a723 fix: provide clearer placeholder for search bar 2023-03-12 14:07:46 -04:00
gurusabarish e26564cde6 added option to disable hero bottom image 2023-03-07 07:37:27 +05:30
gurusabarish 2e8daeaa0d added scroll progress bar in single page template 2023-02-12 00:41:29 +05:30
Guru Sabarish edde3e1123 Merge pull request #101 from pantera-rosa/clean-up-code
clean up code
2023-02-09 23:15:01 +05:30
pantera-rosa 1286527ddd clean up code
Revert "make navbar sticky"

This reverts commit 72d40a3005.

clean up code

make navbar sticky
2023-02-08 22:44:35 -08:00
7 changed files with 91 additions and 35 deletions
+5
View File
@@ -105,6 +105,7 @@ params:
# showBrandLogo: false # Show brand logo in nav bar | default is true # showBrandLogo: false # Show brand logo in nav bar | default is true
brandName: "Hugo Profile" # Brand name for the brand | default is the title variable brandName: "Hugo Profile" # Brand name for the brand | default is the title variable
disableSearch: false disableSearch: false
# searchPlaceholder: "Search"
menus: menus:
disableAbout: false disableAbout: false
disableExperience: false disableExperience: false
@@ -121,6 +122,8 @@ params:
subtitle: "I build things for the web" subtitle: "I build things for the web"
content: "A passionate web app developer. I tend to make use of modern web technologies to build websites that looks great, feels fantastic, and functions correctly." content: "A passionate web app developer. I tend to make use of modern web technologies to build websites that looks great, feels fantastic, and functions correctly."
image: /images/hero.svg image: /images/hero.svg
bottomImage:
enable: true
# roundImage: true # Make hero image circular | default false # roundImage: true # Make hero image circular | default false
button: button:
enable: true enable: true
@@ -371,6 +374,8 @@ params:
readTime: readTime:
enable: true enable: true
content: "min read" content: "min read"
scrollprogress:
enable: true
# For translations # For translations
terms: terms:
+7
View File
@@ -102,6 +102,13 @@
</button> </button>
</section> </section>
{{ if or (.Site.Params.singlePages.scrollprogress.enable | default true) (.Params.enableScrollProgress) }}
<div class="progress">
<div id="scroll-progress-bar" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<Script src="{{.Site.Params.staticPath}}/js/scrollProgressBar.js"></script>
{{ end }}
<script> <script>
var topScroll = document.getElementById("topScroll"); var topScroll = document.getElementById("topScroll");
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {scrollFunction()};
+16 -19
View File
@@ -1,25 +1,22 @@
{{- /* theme-toggle is enabled */}}
{{- if (not .Site.Params.theme.disableThemeToggle | default false) }}
{{- /* theme is auto */}} {{- /* theme is auto */}}
<script> <script>
if (localStorage.getItem("pref-theme") === "dark") { let localStorageValue = localStorage.getItem("pref-theme");
document.body.classList.add('dark'); let mediaQuery = window.matchMedia('(prefers-color-scheme: dark)').matches;
} else if (localStorage.getItem("pref-theme") === "light") {
document.body.classList.remove('dark')
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark');
}
</script> switch (localStorageValue) {
{{- /* theme-toggle is disabled and theme is auto */}} case "dark":
{{- else if (and (ne .Site.Params.theme.defaultTheme "light") (ne .Site.Params.theme.defaultTheme "dark"))}} document.body.classList.add('dark');
<script> break;
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { case "light":
document.body.classList.add('dark'); document.body.classList.remove('dark');
break;
default:
if (mediaQuery) {
document.body.classList.add('dark');
}
break;
} }
</script> </script>
{{- end }}
<!-- Navbar --> <!-- Navbar -->
@@ -39,7 +36,7 @@
{{ if not (.Site.Params.navbar.disableSearch | default false) }} {{ if not (.Site.Params.navbar.disableSearch | default false) }}
<div> <div>
<input id="search" autocomplete="off" class="form-control mr-sm-2 d-none d-md-block" placeholder="Ctrl + k" <input id="search" autocomplete="off" class="form-control mr-sm-2 d-none d-md-block" placeholder='{{ .Site.Params.navbar.searchPlaceholder | default "Ctrl + k to Search..."}}'
aria-label="Search" oninput="searchOnChange(event)"> aria-label="Search" oninput="searchOnChange(event)">
</div> </div>
{{ end }} {{ end }}
@@ -58,7 +55,7 @@
{{ if not (.Site.Params.navbar.disableSearch | default false) }} {{ if not (.Site.Params.navbar.disableSearch | default false) }}
<li class="nav-item navbar-text d-block d-md-none"> <li class="nav-item navbar-text d-block d-md-none">
<div class="nav-link"> <div class="nav-link">
<input id="search" autocomplete="off" class="form-control mr-sm-2" placeholder="Ctrl + k" aria-label="Search" oninput="searchOnChange(event)"> <input id="search" autocomplete="off" class="form-control mr-sm-2" placeholder='{{ .Site.Params.navbar.searchPlaceholder | default "Ctrl + k to Search..."}}' aria-label="Search" oninput="searchOnChange(event)">
</div> </div>
</li> </li>
{{ end }} {{ end }}
@@ -43,6 +43,7 @@
</div> </div>
</div> </div>
</div> </div>
{{ if .Site.Params.hero.bottomImage.enable | default true }}
<div class="hero-bottom-svg d-md-block d-lg-block d-none"> <div class="hero-bottom-svg d-md-block d-lg-block d-none">
<svg xmlns="http://www.w3.org/2000/svg" width="201" height="201" viewBox="0 0 201 201"> <svg xmlns="http://www.w3.org/2000/svg" width="201" height="201" viewBox="0 0 201 201">
<g id="Group_1168" data-name="Group 1168" transform="translate(-384 -1392)"> <g id="Group_1168" data-name="Group 1168" transform="translate(-384 -1392)">
@@ -305,5 +306,6 @@
</g> </g>
</svg> </svg>
</div> </div>
{{ end }}
</section> </section>
{{ end }} {{ end }}
+27
View File
@@ -25,6 +25,11 @@
background-color: var(--secondary-color); background-color: var(--secondary-color);
} }
#single .page-content img {
max-width: 100%;
border-radius: 1rem;
}
#single .page-content a { #single .page-content a {
display: inline-block; display: inline-block;
text-decoration: none; text-decoration: none;
@@ -282,3 +287,25 @@
transition: .5s; transition: .5s;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
} }
/* Singlepage scroll progress start */
.progress {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 2px;
background-color: var(--background-color);
z-index: 999;
}
.progress-bar {
position: absolute;
top: 0;
left: 0;
height: 100%;
background-color: var(--primary-color);
transition: width .2s;
}
/* Singlepage scroll progress end */
+12
View File
@@ -0,0 +1,12 @@
function getScrollPercent() {
const totalHeight = document.body.scrollHeight - window.innerHeight;
const scrolled = window.scrollY;
return (scrolled / totalHeight) * 100;
}
const scrollProgressBar = document.getElementById("scroll-progress-bar");
document.onscroll = function () {
var scrollPercent = Math.round(getScrollPercent());
scrollProgressBar.style.width = scrollPercent + "%";
scrollProgressBar.ariaValueNow = scrollPercent;
};
+22 -16
View File
@@ -6,7 +6,10 @@ async function searchOnChange(evt) {
}); });
if (searchQuery !== "") { if (searchQuery !== "") {
let searchJson = await fetch("/index.json").then((res) => res.json()); if (!window.searchJson) {
window.searchJson = await fetch("/index.json").then((res) => res.json());
}
let searchResults = searchJson.filter((item) => { let searchResults = searchJson.filter((item) => {
let res = false; let res = false;
if (item.title && item.description && item.content) { if (item.title && item.description && item.content) {
@@ -64,22 +67,25 @@ async function searchOnChange(evt) {
function alignSearchContent() { function alignSearchContent() {
const searchButtonEle = document.querySelectorAll("#search"); const searchButtonEle = document.querySelectorAll("#search");
if (searchButtonEle.value !== "") { // check if search value is not empty
let searchButtonPosition; for (let i = 0; i < searchButtonEle.length; i++) {
if (window.innerWidth > 768) { if (searchButtonEle[i].value !== "") {
searchButtonPosition = searchButtonEle[0].getBoundingClientRect(); let searchButtonPosition;
document.getElementById("search-content").style.width = "500px"; if (window.innerWidth > 768) {
} else { searchButtonPosition = searchButtonEle[0].getBoundingClientRect();
var navbarCollapse = document.querySelector("#navbarContent"); document.getElementById("search-content").style.width = "500px";
navbarCollapse.classList.add("show"); } else {
searchButtonPosition = searchButtonEle[1].getBoundingClientRect(); var navbarCollapse = document.querySelector("#navbarContent");
document.getElementById("search-content").style.width = "300px"; navbarCollapse.classList.add("show");
} searchButtonPosition = searchButtonEle[1].getBoundingClientRect();
document.getElementById("search-content").style.width = "300px";
}
document.getElementById("search-content").style.top = document.getElementById("search-content").style.top =
searchButtonPosition.top + 50 + "px"; searchButtonPosition.top + 50 + "px";
document.getElementById("search-content").style.left = document.getElementById("search-content").style.left =
searchButtonPosition.left + "px"; searchButtonPosition.left + "px";
}
} }
} }