From 2b4094897b23ec9a673430e37e4efbbb86fb4ad4 Mon Sep 17 00:00:00 2001 From: kailasnadh790 <53608019+kailasnadh790@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:45:04 -0500 Subject: [PATCH] initial commit --- cigaradvisor/scripts/scripts.js | 30 ++++++++++++++++++++++++++++ cigaradvisor/styles/styles.css | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/cigaradvisor/scripts/scripts.js b/cigaradvisor/scripts/scripts.js index 7ebcf2d7..4a0a16ce 100644 --- a/cigaradvisor/scripts/scripts.js +++ b/cigaradvisor/scripts/scripts.js @@ -95,6 +95,35 @@ function buildArticleHeader(mainEl) { mainEl.prepend(div); } +/** + * Builds three column grid. + * @param {Element} main The container element + */ +function buildThreeColumnGrid(main) { + main.querySelectorAll(':scope > .section[data-layout="3-column"]').forEach((section) => { + const leftDiv = document.createElement('div'); + leftDiv.classList.add('left-grid'); + const centerDiv = document.createElement('div'); + centerDiv.classList.add('center-grid'); + const rightDiv = document.createElement('div'); + rightDiv.classList.add('right-grid'); + let current = leftDiv; + [...section.children].forEach((child) => { + if (child.classList.contains('separator-wrapper')) { + if (current === centerDiv) { + current = rightDiv; + } else { + current = centerDiv; + } + child.remove(); + return; + } + current.append(child); + }); + section.append(leftDiv, centerDiv, rightDiv); + }); +} + /** * Builds two column grid. * @param {Element} main The container element @@ -157,6 +186,7 @@ export function decorateMain(main) { decorateSections(main); decorateBlocks(main); buildTwoColumnGrid(main); + buildThreeColumnGrid(main); } /** diff --git a/cigaradvisor/styles/styles.css b/cigaradvisor/styles/styles.css index 4a3f45bf..cafd5a1c 100644 --- a/cigaradvisor/styles/styles.css +++ b/cigaradvisor/styles/styles.css @@ -338,6 +338,41 @@ main .section[data-layout="50/50"] .right-grid > div { padding: 10px; } +/* Three-column grid */ +main .section[data-layout="3-column"] { + padding-left: 0; + padding-right: 0; + width: 100%; + margin-left: auto; + margin-right: auto; + max-width: 1080px; + box-sizing: border-box; + display: flex; +} + +main .section[data-layout="3-column"] ul { + list-style-type: disc; +} + +main .section[data-layout="3-column"] > div { + display: flex; + flex: 1; + flex-direction: column; +} + + +main .section[data-layout="3-column"] > .left-grid { + flex: 0 0 25%; +} + +main .section[data-layout="3-column"] > .center-grid, main .section[data-layout="3-column"] > .right-grid { + flex: 0 0 37.5%; +} + +main .section[data-layout="3-column"] * > div { + padding: 2px; +} + .icon > img { width: var(--icon-size); height: var(--icon-size);