Skip to content

Commit

Permalink
js clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
rrusher committed Nov 9, 2023
1 parent 4f41a4e commit d93ab2f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions blocks/hero/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ export default async function decorate(block) {
}

const headline = block.querySelectorAll('div.hero > div > div');
const filteredList = Array.from(headline).filter(node => {
const innerHTML = node.innerHTML.trim().toLowerCase();
return innerHTML === 'headline' || innerHTML === 'description' || innerHTML === 'cta';
});
const validInnerHtml = new Set(['headline', 'description', 'cta']);
const filteredList = Array.from(headline).filter(node => validInnerHtml.has(node.innerHTML.trim().toLowerCase()));

Check failure on line 61 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

This line has a length of 116. Maximum allowed is 100

Check failure on line 61 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected parentheses around arrow function argument

const headlineWrapper = document.createElement('div');
if (filteredList.length) {
headlineWrapper.classList.add('headline');
filteredList.forEach((div) => {
if (div.innerHTML === 'Headline') div.nextElementSibling.classList.add('title');
if (div.innerHTML === 'Description') div.nextElementSibling.classList.add('desc');
if (div.innerHTML === 'CTA') {
const button = document.createElement('p');
button.innerHTML = div.nextElementSibling.innerHTML;
button.classList.add('button-container');
div.parentNode.replaceChild(button, div.nextElementSibling);
}
headlineWrapper.append(div.nextElementSibling);
});
headlineWrapper.classList.add('headline');

Check failure on line 65 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6
filteredList.forEach((div) => {

Check failure on line 66 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6
const nextElement = div.nextElementSibling;

Check failure on line 67 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 10
const innerHTML = div.innerHTML;

Check failure on line 68 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 10

Check failure on line 68 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Use object destructuring
if (innerHTML === 'Headline' || innerHTML === 'Description') nextElement.classList.add('title', 'desc');

Check failure on line 69 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 10
if (innerHTML === 'CTA') {

Check failure on line 70 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 10
const button = document.createElement('p');

Check failure on line 71 in blocks/hero/hero.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 12
button.innerHTML = nextElement.innerHTML;
button.classList.add('button-container');
div.parentNode.replaceChild(button, nextElement);
}
headlineWrapper.append(nextElement);
});
}

const wrapper = document.createElement('div');
Expand Down

0 comments on commit d93ab2f

Please sign in to comment.