aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/layouts/partials/adaptive_details.html
diff options
context:
space:
mode:
authorJean-Pierre Appel <jeanpierre.appel01@gmail.com>2023-12-25 17:17:21 -0500
committerJean-Pierre Appel <jeanpierre.appel01@gmail.com>2023-12-25 17:17:21 -0500
commitcc1220bfd794dff1fc28bd39cafb63c4b1093cf8 (patch)
tree8d51983970fc62457ed97599d784cfa150b5c766 /layouts/partials/adaptive_details.html
parenta181759e4a108c35fcf6898abbf17f2a424d85dc (diff)
rewrite layouts
Diffstat (limited to 'layouts/partials/adaptive_details.html')
-rw-r--r--layouts/partials/adaptive_details.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/layouts/partials/adaptive_details.html b/layouts/partials/adaptive_details.html
new file mode 100644
index 0000000..2180325
--- /dev/null
+++ b/layouts/partials/adaptive_details.html
@@ -0,0 +1,26 @@
+<script>
+function setDetailsOpen() {
+ const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
+
+ // Adjust this value based on your preferred viewport size for default open
+ const viewportThreshold = 768;
+
+ // Get all details elements
+ const detailsElements = document.querySelectorAll('details');
+
+ // Loop through details elements and set open attribute conditionally
+ detailsElements.forEach(function(details) {
+ if (viewportWidth >= viewportThreshold) {
+ details.setAttribute('open', true);
+ } else {
+ details.removeAttribute('open');
+ }
+ });
+}
+
+// Initial call on page load
+setDetailsOpen();
+
+// Attach the function to the window resize event to handle changes dynamically
+window.addEventListener('resize', setDetailsOpen);
+</script>