From 1f1fccde8dee31ac8428d8b991815b170971ccca Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 30 Apr 2024 17:27:28 -0300 Subject: content: generatePageSidebarBox: collapsible slot Makes collapsibility a function of the boxes in a sidebar, rather than a property of the sidebar (column) itself. --- src/content/dependencies/generatePageSidebar.js | 30 ++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src/content/dependencies/generatePageSidebar.js') diff --git a/src/content/dependencies/generatePageSidebar.js b/src/content/dependencies/generatePageSidebar.js index dda75dd3..43015aa3 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 { -- cgit 1.3.0-6-gf8a5