Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sm1pleScr1pt committed Oct 10, 2024
2 parents 8f2611d + a66817c commit f015cca
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 86 deletions.
28 changes: 15 additions & 13 deletions blocks/code/code.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { decoratePlaceholder } from '../../scripts/scripts.js';
import { mobileHeaderAnalytics } from './code-analytics.js';
import { decoratePlaceholder } from "../../scripts/scripts.js";
import { mobileHeaderAnalytics } from "./code-analytics.js";
import { decorateTable } from "./table.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) {
const titleElement = document.createElement('div');
titleElement.innerHTML = titleData;
block.append(titleElement);
}
block.innerHTML = await decoratePlaceholder(block);
if(block.classList.contains('table')){
decorateTable(block)
return block
}
const titleData = block.children[0]?.querySelector('p')?.textContent.trim() || '';
block.innerHTML = '';
if (titleData) {
const titleElement = document.createElement('div');
titleElement.innerHTML = titleData;
block.append(titleElement);
}

const iframe = block.querySelectorAll('iframe');
if (iframe.length != 0) {
Expand Down
78 changes: 39 additions & 39 deletions blocks/code/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,49 @@
*/

function buildCell(rowIndex) {
const cell = rowIndex ? document.createElement('td') : document.createElement('th');
if (!rowIndex) cell.setAttribute('scope', 'col');
return cell;
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');
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);
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.querySelector('ul')?.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.querySelector('ul')?.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);
block.innerHTML = '';
div.append(table);
block.append(div);
}
5 changes: 0 additions & 5 deletions blocks/columns/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ 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 Down
21 changes: 4 additions & 17 deletions component-models.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,6 @@
{
"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 @@ -2212,6 +2195,10 @@
{
"name": "Table",
"value": "table"
},
{
"name": "test",
"value": "test"
}
]
}
Expand Down
18 changes: 9 additions & 9 deletions styles/fixed-headset/fixed-headset.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
width: 56px;
overflow: hidden;
transition: width .1s;
background-color: #20303f;
background-color: var(--midnight);
border-radius: 100px;
cursor: pointer;
z-index: 12;
}

.section.fixed-headset-wrapper .default-content-wrapper p {
background-color: #20303f;
background-color: var(--midnight);
height: 56px;
width: 56px;
border-radius: 100px;
Expand All @@ -30,7 +30,7 @@
height: 32px;
}
.section.fixed-headset-wrapper .default-content-wrapper:hover p {
border: 1px solid #999;
border: 1px solid var(--dustygrey);
}

.section.fixed-headset-wrapper .default-content-wrapper ul {
Expand All @@ -44,17 +44,17 @@
font-size: 14px;
padding-left: 12px;
font-weight: 700;
color: #fff;
font-family: Nunito-Regular, 'sans-serif';
color: var(--white);
font-family: 'Nunito-Regular', 'sans-serif';
}

.section.fixed-headset-wrapper .default-content-wrapper ul li a {
color: #fff;
color: var(--white);
text-decoration: none;
font-family: Nunito-Bold, 'sans-serif';
font-family: 'Nunito-Bold', 'sans-serif';
}
.section.fixed-headset-wrapper .default-content-wrapper ul li:first-child a {
color: #f58667;
color: var(--orange);
text-decoration: underline;
}
.section.fixed-headset-wrapper .default-content-wrapper:hover {
Expand All @@ -64,7 +64,7 @@

.section.fixed-headset-wrapper:hover .default-content-wrapper ul {
display: flex;
background-color: #20303f;
background-color: var(--midnight);
}

@media screen and (max-width: 768px) {
Expand Down
6 changes: 3 additions & 3 deletions styles/table/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@
.section.fees-charges-wrapper.three-col-table .code-wrapper .code>div>table>tbody>tr>td>p>img {
width: 12px;
height: 12px;
left: -12px;
top: 2px;
left: -14px;
top: 6px;
border-radius: unset;
}
}
Expand All @@ -507,7 +507,7 @@
.section.fees-charges-wrapper.three-col-table .code-wrapper .code>div>table>tbody>tr>td>p>img {
width: 12px;
height: 12px;
left: 39%;
left: 35%;
top: -12px;
border-radius: unset;
}
Expand Down

0 comments on commit f015cca

Please sign in to comment.