Skip to content

Commit

Permalink
Feature/404 (#79)
Browse files Browse the repository at this point in the history
* hero

* initial commit

* errorpage

* Update hero.js

* Revert "Update hero.js"

This reverts commit 5cd8a85.

* Revert "hero"

This reverts commit 5e3525e.

---------

Co-authored-by: Bryan Stopp <[email protected]>
  • Loading branch information
kailasnadh790 and bstopp authored Jan 18, 2024
1 parent d52672a commit d0ca85c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Page not found">
<script src="/cigaradvisor/scripts/cigaradvisor/scripts.js" type="module" crossorigin="use-credentials"></script>
<script src="/cigaradvisor/scripts/scripts.js" type="module" crossorigin="use-credentials"></script>
<script type="module">
import { sampleRUM } from '/cigaradvisor/scripts/aem.js';
import { loadFragment } from '/cigaradvisor/blocks/fragment/fragment.js';

window.addEventListener('load', () => {
window.addEventListener('load', async() => {
if (document.referrer) {
const { origin, pathname } = new URL(document.referrer);
if (origin === window.location.origin) {
Expand All @@ -27,6 +28,8 @@
}
}
sampleRUM('404', { source: document.referrer, target: window.location.href });
const main = document.querySelector('main');
main.replaceWith(await loadFragment('/cigaradvisor/fragments/404'));
});
</script>
<link rel="stylesheet" href="/cigaradvisor/styles/styles.css">
Expand Down
30 changes: 30 additions & 0 deletions cigaradvisor/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -157,6 +186,7 @@ export function decorateMain(main) {
decorateSections(main);
decorateBlocks(main);
buildTwoColumnGrid(main);
buildThreeColumnGrid(main);
}

/**
Expand Down
36 changes: 36 additions & 0 deletions cigaradvisor/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,42 @@ 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;
}

/* stylelint-disable-next-line no-descending-specificity */
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%;
}

/* stylelint-disable-next-line no-descending-specificity */
main .section[data-layout="3-column"] * > div {
padding: 2px;
}

.icon > img {
width: var(--icon-size);
height: var(--icon-size);
Expand Down

0 comments on commit d0ca85c

Please sign in to comment.