« get me outta code hell

content: generatePageSidebarBox: collapsible slot - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generatePageSidebar.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-30 17:27:28 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-01 20:22:38 -0300
commit1f1fccde8dee31ac8428d8b991815b170971ccca (patch)
tree2d3200ad2df5a8aa8ebe61a59c923d6809c6d9b6 /src/content/dependencies/generatePageSidebar.js
parent97f587966f6239821589bd5c137b9875e7ae29b0 (diff)
content: generatePageSidebarBox: collapsible slot
Makes collapsibility a function of the boxes in a sidebar,
rather than a property of the sidebar (column) itself.
Diffstat (limited to 'src/content/dependencies/generatePageSidebar.js')
-rw-r--r--src/content/dependencies/generatePageSidebar.js30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/content/dependencies/generatePageSidebar.js b/src/content/dependencies/generatePageSidebar.js
index dda75dd..43015aa 100644
--- a/src/content/dependencies/generatePageSidebar.js
+++ b/src/content/dependencies/generatePageSidebar.js
@@ -30,16 +30,6 @@ export default {
       default: 'static',
     },
 
-    // Collapsing sidebars disappear when the viewport is sufficiently
-    // thin. (This is the default.) Override as false to make the sidebar
-    // stay visible in thinner viewports, where the page layout will be
-    // reflowed so the sidebar is as wide as the screen and appears below
-    // nav, above the main content.
-    collapse: {
-      type: 'boolean',
-      default: true,
-    },
-
     // Wide sidebars generally take up more horizontal space in the normal
     // page layout, and should be used if the content of the sidebar has
     // a greater than typical focus compared to main content.
@@ -58,22 +48,26 @@ export default {
 
     attributes.add(slots.attributes);
 
-    if (slots.class) {
-      attributes.add('class', slots.class);
-    }
-
     if (slots.wide) {
       attributes.add('class', 'wide');
     }
 
-    if (!slots.collapse) {
-      attributes.add('class', 'no-hide');
-    }
-
     if (slots.stickyMode !== 'static') {
       attributes.add('class', `sticky-${slots.stickyMode}`);
     }
 
+    const {content: boxes} = html.smooth(slots.boxes);
+
+    const allBoxesCollapsible =
+      boxes.every(box =>
+        html.resolve(box)
+          .attributes
+          .has('class', 'collapsible'));
+
+    if (allBoxesCollapsible) {
+      attributes.add('class', 'all-boxes-collapsible');
+    }
+
     if (html.isBlank(slots.boxes)) {
       return html.blank();
     } else {