Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hlxsites/aldevron into feature/dyna…
Browse files Browse the repository at this point in the history
…mic-block
  • Loading branch information
teshukatepalli1 committed Nov 28, 2023
2 parents 5463bf6 + 7a8fb26 commit f189c33
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 54 deletions.
1 change: 1 addition & 0 deletions blocks/footer/footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}

.social-icons.clearfix {
Expand Down
5 changes: 5 additions & 0 deletions styles/Typo.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
--text-color: #fff;
}

html {
scroll-behavior: smooth;
scroll-padding-top: 120px;
}

.img-colorbox-popup::after,
[class*=" icon-"],
[class^="icon-"] {
Expand Down
11 changes: 10 additions & 1 deletion styles/responsive.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#logo {
left: 20px;
width: 190px
}
}

#menu li.hs-menu-depth-1>a {
padding: 0 18px !important;
}
}

@media (max-width: 1024px) {
Expand Down Expand Up @@ -38,6 +42,11 @@
#heading .vertical {
display: block
}

#menu li.hs-menu-depth-1>a {
font-size: 15px !important;
padding: 0 12px !important;
}
}

@media (max-width: 1023px) {
Expand Down
8 changes: 8 additions & 0 deletions styles/template.css
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,21 @@ body.full-width #sidebar {
width: 0%!important;
}

body.full-width #sidebar {
width: 0;
}

#sidebar {
float: right;
font-size: 16px;
line-height: normal;
width: 26%;
}

#sidebar > div {
margin-top: 0;
}

body.sidebar-50 #sidebar {
width: 47%
}
Expand Down
41 changes: 24 additions & 17 deletions templates/Blog/Blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,12 @@ export default async function buildAutoBlocks(block) {
return regex.test(path);
});

const blocks = block.querySelector('.section');
const sidebars = blocks.querySelectorAll('[data-block-name^="sidebar-"]');
const contentBlocks = block.querySelectorAll('.section');

// Creating the default template wrapper
const defaultTemplate = document.createElement('div');
defaultTemplate.id = 'content-wrapper';

// Appending Hero banner
const heroBanner = blocks.querySelector('.hero-wrapper');
defaultTemplate.appendChild(heroBanner);

// Creating content wrapper
const content = document.createElement('div');
content.id = 'content';
Expand All @@ -280,9 +275,24 @@ export default async function buildAutoBlocks(block) {
const sidebar = document.createElement('div');
sidebar.id = 'sidebar';

// Moving remaining blocks to main
[...blocks.children].forEach((child) => {
main.appendChild(child);
// Iterate over each section
contentBlocks.forEach((blocks) => {
// Appending Hero banner from each section
const heroBanner = blocks.querySelector('.hero-wrapper');
if (heroBanner) {
defaultTemplate.appendChild(heroBanner); // Clone to avoid removing the original
}

// Handling sidebars within each section
const sidebars = blocks.querySelectorAll('[data-block-name^="sidebar-"]');
if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem); // Clone to keep the original in place
});
}

main.appendChild(blocks);
blocks.style.display = null;
});

if (searchParams.has('archive')) {
Expand Down Expand Up @@ -325,19 +335,13 @@ export default async function buildAutoBlocks(block) {
const archiveSidebar = generateArchiveBlock(filteredResults);
if (archiveSidebar) {
sideBarVisible = true;
sidebar.appendChild(archiveSidebar);
sidebar.prepend(archiveSidebar);
}

const topicSidebar = generateTopicBlock(filteredResults);
if (topicSidebar) {
sideBarVisible = true;
sidebar.appendChild(topicSidebar);
}

if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem);
});
sidebar.prepend(topicSidebar);
}

if (!sideBarVisible) {
Expand All @@ -350,6 +354,9 @@ export default async function buildAutoBlocks(block) {

outerElement.appendChild(main);
outerElement.appendChild(sidebar);
if (!sidebar.children.length > 0) {
document.body.classList.add('full-width');
}
content.appendChild(outerElement);
content.appendChild(clearFix);
defaultTemplate.appendChild(content);
Expand Down
41 changes: 22 additions & 19 deletions templates/Default/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ function setSidebarHeight() {
}

export default function buildAutoBlocks(block) {
const blocks = block.querySelector('.section');
const sidebars = blocks.querySelectorAll('[data-block-name^="sidebar-"]');
const contentBlocks = block.querySelectorAll('.section');

// Creating the default template wrapper
const defaultTemplate = document.createElement('div');
defaultTemplate.id = 'content-wrapper';

// Appending Hero banner
const heroBanner = blocks.querySelector('.hero-wrapper');
if (heroBanner) {
defaultTemplate.appendChild(heroBanner);
}

// Creating content wrapper
const content = document.createElement('div');
content.id = 'content';
Expand All @@ -40,18 +34,24 @@ export default function buildAutoBlocks(block) {
const sidebar = document.createElement('div');
sidebar.id = 'sidebar';

// Adding sidebars if available
if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem);
});
} else {
document.body.classList.add('full-width');
}
// Iterate over each section
contentBlocks.forEach((blocks) => {
// Appending Hero banner from each section
const heroBanner = blocks.querySelector('.hero-wrapper');
if (heroBanner) {
defaultTemplate.appendChild(heroBanner); // Clone to avoid removing the original
}

// Handling sidebars within each section
const sidebars = blocks.querySelectorAll('[data-block-name^="sidebar-"]');
if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem); // Clone to keep the original in place
});
}

// Moving remaining blocks to main
[...blocks.children].forEach((child) => {
main.appendChild(child);
main.appendChild(blocks);
blocks.style.display = null;
});

// Creating clearfix element
Expand All @@ -60,6 +60,9 @@ export default function buildAutoBlocks(block) {

outerElement.appendChild(main);
outerElement.appendChild(sidebar);
if (!sidebar.children.length > 0) {
document.body.classList.add('full-width');
}
content.appendChild(outerElement);
content.appendChild(clearFix);
defaultTemplate.appendChild(content);
Expand Down
40 changes: 23 additions & 17 deletions templates/News/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,12 @@ export default async function buildAutoBlocks(block) {
return regex.test(path);
});

const blocks = block.querySelector('.section');
const sidebars = blocks.querySelectorAll('[data-block-name^="sidebar-"]');
const contentBlocks = block.querySelectorAll('.section');

// Creating the default template wrapper
const defaultTemplate = document.createElement('div');
defaultTemplate.id = 'content-wrapper';

// Appending Hero banner
const heroBanner = blocks.querySelector('.hero-wrapper');
defaultTemplate.appendChild(heroBanner);

// Creating content wrapper
const content = document.createElement('div');
content.id = 'content';
Expand All @@ -278,9 +273,23 @@ export default async function buildAutoBlocks(block) {
const sidebar = document.createElement('div');
sidebar.id = 'sidebar';

// Moving remaining blocks to main
[...blocks.children].forEach((child) => {
main.appendChild(child);
contentBlocks.forEach((blocks) => {
// Appending Hero banner from each section
const heroBanner = blocks.querySelector('.hero-wrapper');
if (heroBanner) {
defaultTemplate.appendChild(heroBanner); // Clone to avoid removing the original
}

// Handling sidebars within each section
const sidebars = blocks.querySelectorAll('[data-block-name^="sidebar-"]');
if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem); // Clone to keep the original in place
});
}

main.appendChild(blocks);
blocks.style.display = null;
});

if (searchParams.has('archive')) {
Expand Down Expand Up @@ -323,19 +332,13 @@ export default async function buildAutoBlocks(block) {
const archiveSidebar = generateArchiveBlock(filteredResults);
if (archiveSidebar) {
sideBarVisible = true;
sidebar.appendChild(archiveSidebar);
sidebar.prepend(archiveSidebar);
}

const topicSidebar = generateTopicBlock(filteredResults);
if (topicSidebar) {
sideBarVisible = true;
sidebar.appendChild(topicSidebar);
}

if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem);
});
sidebar.prepend(topicSidebar);
}

if (!sideBarVisible) {
Expand All @@ -348,6 +351,9 @@ export default async function buildAutoBlocks(block) {

outerElement.appendChild(main);
outerElement.appendChild(sidebar);
if (!sidebar.children.length > 0) {
document.body.classList.add('full-width');
}
content.appendChild(outerElement);
content.appendChild(clearFix);
defaultTemplate.appendChild(content);
Expand Down

0 comments on commit f189c33

Please sign in to comment.