Skip to content

Commit

Permalink
Created the anniversaty block with sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
teshukatepalli1 committed Dec 6, 2023
1 parent 8edcba1 commit 318da03
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 4 deletions.
9 changes: 9 additions & 0 deletions blocks/connect/connect.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* connet css */
.linkedin-bottom {
padding-top: 80px;
padding-bottom: 80px;
}

.linkedin-bottom .outer {
display: block;
}
2 changes: 1 addition & 1 deletion blocks/connect/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function decorate(block) {
const anchorLink = block.querySelector('a');
const bodytext = block.children[1].textContent.trim();
const container = div(
{ class: 'linkedin-bottom wide-section padding-btm' },
{ class: 'linkedin-bottom padding-btm' },
div(
{ class: 'outer' },
a(
Expand Down
1 change: 1 addition & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const TEMPLATE_LIST = [
'default',
'blog',
'news',
'anniversary',
];

const CATEGORY_LIST = [
Expand Down
4 changes: 4 additions & 0 deletions styles/Typo.css
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,10 @@ body.mrna input[type="submit"]:hover {
padding: 0!important;
}

.no-space a {
width: auto!important;
}

.text-small p {
font-size: 12px!important;
line-height: 1.1em!important;
Expand Down
38 changes: 38 additions & 0 deletions templates/Anniversary/Anniversary.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Default template css */
.default-content-wrapper {
text-align: left!important;
}

.default-content-wrapper h2:first-child {
margin-top: 0px!important;
}

.outer {
display: flex;
justify-content: space-between;
}

#main {
float: none;
}

#sidebar {
position: sticky;
top: 130px;
float: none;
}

@media (max-width: 960px) {
#sidebar {
top: 80px;
}
}

@media (max-width: 860px) {
.outer {
flex-direction: column;
}
#sidebar {
max-height: none;
}
}
61 changes: 61 additions & 0 deletions templates/Anniversary/Anniversary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function setSidebarMaxHeight() {
let height = 0;
const sidebar = document.querySelector('#sidebar');
[...sidebar.children].forEach((element) => {
height += element.offsetHeight;
});
sidebar.style.maxHeight = `${height + 50}px`;
}

function setSidebarHeight() {
window.addEventListener('resize', setSidebarMaxHeight);
window.addEventListener('click', setSidebarMaxHeight);
}

export default function buildAutoBlocks(block) {
// const contentBlocks = block.querySelectorAll('.section');
const sidebarSections = block.querySelector('.sidebar-section');

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

// Creating content wrapper
const content = document.createElement('div');
content.id = 'content';

// Creating outer element
const outerElement = document.createElement('div');
outerElement.className = 'outer';

// Creating main and sidebar elements
const main = document.createElement('div');
main.id = 'main';

const sidebar = document.createElement('div');
sidebar.id = 'sidebar';

// Creating clearfix element
const clearFix = document.createElement('div');
clearFix.className = 'clearfix';

outerElement.appendChild(main);
outerElement.appendChild(sidebar);
content.appendChild(outerElement);
content.appendChild(clearFix);
defaultTemplate.appendChild(content);
// Iterate over each section
if (sidebarSections.children.length > 0) {
const sidebars = sidebarSections.querySelectorAll('[data-block-name^="sidebar-"]');
if (sidebars.length > 0) {
sidebars.forEach((sidebarItem) => {
sidebar.appendChild(sidebarItem);
});
}
sidebarSections.style.display = null;
main.appendChild(sidebarSections.cloneNode(true));
sidebarSections.outerHTML = defaultTemplate.outerHTML;
}
setTimeout(() => setSidebarMaxHeight(), 1000);
setSidebarHeight();
}
2 changes: 1 addition & 1 deletion templates/Blog/Blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function setSidebarMaxHeight() {
[...sidebar.children].forEach((element) => {
height += element.offsetHeight;
});
sidebar.style.maxHeight = `${height}px`;
sidebar.style.maxHeight = `${height + 50}px`;
}

function setSidebarHeight() {
Expand Down
2 changes: 1 addition & 1 deletion templates/Default/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function setSidebarMaxHeight() {
[...sidebar.children].forEach((element) => {
height += element.offsetHeight;
});
sidebar.style.maxHeight = `${height}px`;
sidebar.style.maxHeight = `${height + 50}px`;
}

function setSidebarHeight() {
Expand Down
2 changes: 1 addition & 1 deletion templates/News/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function setSidebarMaxHeight() {
[...sidebar.children].forEach((element) => {
height += element.offsetHeight;
});
sidebar.style.maxHeight = `${height}px`;
sidebar.style.maxHeight = `${height + 50}px`;
}

function setSidebarHeight() {
Expand Down

0 comments on commit 318da03

Please sign in to comment.