diff --git a/layouts/shortcodes/collapsible.html b/layouts/shortcodes/collapsible.html new file mode 100644 index 0000000..8c48594 --- /dev/null +++ b/layouts/shortcodes/collapsible.html @@ -0,0 +1,4 @@ + +
+

{{ .Inner }}

+
diff --git a/static/css/custom.css b/static/css/custom.css index ffdd0dc..3e2992a 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -53,3 +53,32 @@ color: white; } + +/** Collapsible **/ + + /* Style the button that is used to open and close the collapsible content */ +.collapsible { + background-color: #eee; + color: #444; + cursor: pointer; + padding: 18px; + width: 100%; + border: none; + text-align: left; + outline: none; + font-size: 15px; +} + +/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */ +.active, .collapsible:hover { + background-color: #ccc; +} + +/* Style the collapsible content. Note: hidden by default */ +.content { + padding: 0 18px; + display: none; + overflow: hidden; + background-color: #f1f1f1; +} + diff --git a/static/js/main.js b/static/js/main.js index 223a8d9..50d2438 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,26 +1,40 @@ document.addEventListener("DOMContentLoaded", function() { setDarkMode() + + var coll = document.getElementsByClassName("collapsible") + + for (let i = 0; i < coll.length; i++) { + coll[i].addEventListener("click", function() { + this.classList.toggle("active") + var content = this.nextElementSibling + if (content.style.display === "block") { + content.style.display = "none" + } else { + content.style.display = "block" + } + }) + } }) function setCookie(cname, cvalue, exdays) { - document.cookie = cname + "=" + cvalue + ";path=/"; + document.cookie = cname + "=" + cvalue + ";path=/" } function getCookie(cname) { - let name = cname + "="; - let decodedCookie = decodeURIComponent(document.cookie); - let ca = decodedCookie.split(';'); + let name = cname + "=" + let decodedCookie = decodeURIComponent(document.cookie) + let ca = decodedCookie.split(';') for(let i = 0; i