Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sm1pleScr1pt committed Oct 9, 2024
2 parents f9a6aef + 6fec2da commit eadd410
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 123 deletions.
4 changes: 2 additions & 2 deletions blocks/boards/boards.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export default async function decorate(block) {
const tbody = document.createElement('tbody');

const header = !block.classList.contains('no-header');
if (header) table.append(thead);
// if (header) table.append(thead);
table.append(tbody);

[...block.children].forEach((child, i) => {
const row = document.createElement('tr');
// if (header && i === 0) thead.append(row);
// else
tbody.append(row);
// [...child.children].forEach((col) => {
[...child.firstElementChild?.firstElementChild?.children]?.forEach((col) => {
// [...child.children].forEach((col) => {
const cell = buildCell(header ? i : i + 1);
if (col.innerHTML.includes('img') && col.textContent.trim()) {
col.remove();
Expand Down
13 changes: 7 additions & 6 deletions blocks/carousel/embed-banner-carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@

@media (min-width:1025px) and (max-width:1300px) {
.section.banner-carousel-wrapper.banner-video-carousel .carousel-wrapper .teaser.block.video-component-carousel .background {
/* height: 380px; */
height: 529px;
min-height: 529px;
background-size: cover;
background-position: center top;
}
Expand All @@ -265,11 +266,11 @@
padding: 0 14px;
}

.sectio .carousel-wrapper .teaser.blockn.video-component-carousel .background .foreground,
.sectio .carousel-wrapper .teaser.blockn.video-component-carousel {
min-height: 380px;
height: 380px;
}
/* .section .carousel-wrapper .teaser.block.video-component-carousel .background .foreground,
.section .carousel-wrapper .teaser.block.video-component-carousel {
height: 529px;
min-height: 529px;
} */
.section.banner-carousel-wrapper.banner-video-carousel .carousel-wrapper .teaser.block.video-component-carousel.teaser .background .foreground{
margin: calc((100% - 1025px) / 2);
}
Expand Down
4 changes: 3 additions & 1 deletion blocks/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { mobileHeaderAnalytics } from "./code-analytics.js";

export default async function decorate(block) {
block.innerHTML = await decoratePlaceholder(block);

if(block.classList.add('table')){
decorateTable(block)
}
const titleData = block.children[0]?.querySelector('p')?.textContent.trim() || '';
block.innerHTML = '';
if (titleData) {
Expand Down
53 changes: 53 additions & 0 deletions blocks/code/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Table Block
* Recreate a table
* https://www.hlx.live/developer/block-collection/table
*/

function buildCell(rowIndex) {
const cell = rowIndex ? document.createElement('td') : document.createElement('th');
if (!rowIndex) cell.setAttribute('scope', 'col');
return cell;
}

export function decorateTable(block) {
block.classList.add('code');
block.parentElement.classList.add('code-wrapper');
const table = document.createElement('table');
const div = document.createElement('div');
const thead = document.createElement('thead');
const tbody = document.createElement('tbody');

const header = !block.classList.contains('no-header');
// if (header) table.append(thead);
table.append(tbody);

[...block.children].forEach((child, i) => {
const row = document.createElement('tr');
// if (header && i === 0) thead.append(row);
// else
tbody.append(row);
[...child.firstElementChild?.firstElementChild?.children]?.forEach((col) => {
// [...child.children].forEach((col) => {
const cell = buildCell(header ? i : i + 1);
if (col.innerHTML.includes('img') && col.textContent.trim()) {
col.remove();
const p = document.createElement('p');
const span = document.createElement('span');
span.append(col.textContent.trim());
p.append(col.querySelector('img'))
p.append(span)
cell.append(p);
} else if (col.innerHTML.includes('img')) {
col.remove();
cell.append(col.querySelector('img'));
} else {
cell.innerHTML = col.innerHTML;
}
row.append(cell);
});
});
block.innerHTML = '';
div.append(table);
block.append(div);
}
28 changes: 16 additions & 12 deletions blocks/columns/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { decorateViewMore } from "../../scripts/scripts.js";
import { statemasterGetStatesApi } from '../applyloanform/statemasterapi.js';
import { validationJSFunc } from '../applyloanform/validation.js';
import { formOpen } from '../applyloanform/applyloanforms.js';

import decorateTable from "../boards/boards.js";

export default function decorate(block) {
if (block.classList.contains('table')) {
decorateTable(block);
return block;
}
decorateViewMore(block);
const cols = [...block.firstElementChild.children];
block.classList.add(`columns-${cols.length}-cols`);
Expand All @@ -31,16 +35,16 @@ export default function decorate(block) {
}


function openFormColumn(block){
var sectionBlock = block.closest(".section");
if(sectionBlock.classList.contains('open-form-on-click-column')){
sectionBlock.querySelector('.open-form-on-click-column .columns-wrapper').querySelectorAll('.button-container').forEach(function (eachApplyFormClick) {
eachApplyFormClick.addEventListener('click', async (e) => {
statemasterGetStatesApi();
validationJSFunc();
formOpen();
e.preventDefault();
});
function openFormColumn(block) {
var sectionBlock = block.closest(".section");
if (sectionBlock.classList.contains('open-form-on-click-column')) {
sectionBlock.querySelector('.open-form-on-click-column .columns-wrapper').querySelectorAll('.button-container').forEach(function (eachApplyFormClick) {
eachApplyFormClick.addEventListener('click', async (e) => {
statemasterGetStatesApi();
validationJSFunc();
formOpen();
e.preventDefault();
});
}
});
}
}
41 changes: 40 additions & 1 deletion component-models.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"component": "text",
"name": "theme",
"label": "Theme"
},
{
"component": "text",
"name": "twitter-title",
"label": "Twitter Title"
}
]
},
Expand Down Expand Up @@ -133,6 +138,23 @@
{
"id": "columns",
"fields": [
{
"component": "multiselect",
"name": "classes",
"label": "Style",
"valueType": "string",
"options": [
{
"name": "Type",
"children": [
{
"name": "Table",
"value": "table"
}
]
}
]
},
{
"component": "text",
"valueType": "number",
Expand Down Expand Up @@ -2173,6 +2195,23 @@
{
"id": "code",
"fields": [
{
"component": "multiselect",
"name": "classes",
"label": "Style",
"valueType": "string",
"options": [
{
"name": "Type",
"children": [
{
"name": "Table",
"value": "table"
}
]
}
]
},
{
"component": "text-area",
"valueType": "string",
Expand Down Expand Up @@ -2826,4 +2865,4 @@
}
]
}
]
]
5 changes: 5 additions & 0 deletions icons/headset.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ async function loadingCustomCss() {
`${window.hlx.codeBasePath}/styles/e-nach-registration/e-nach-registration.css`,
`${window.hlx.codeBasePath}/styles/support-faq/support-faq.css`,
`${window.hlx.codeBasePath}/styles/embed-carousel-wrapper/embed-carousel-wrapper.css`,
`${window.hlx.codeBasePath}/styles/fixed-headset/fixed-headset.css`,
];

loadCssArray.forEach(async (eachCss) => {
Expand Down
Loading

0 comments on commit eadd410

Please sign in to comment.