Skip to content

Commit d0d2ea8

Browse files
committed
Lint
1 parent 58e3a84 commit d0d2ea8

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

src/Scripts/onboarding-restart-button/onboarding-restart-button.js

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,87 +2,91 @@ let buildWithAIInserted = false; // Flag to track if the Build with AI element i
22

33
// Function to create an SVG icon element
44
function createSVGIcon() {
5-
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
6-
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
7-
svg.setAttribute('viewBox', '0 0 384 512');
8-
svg.setAttribute('width', '50px');
9-
svg.setAttribute('height', '50px');
10-
11-
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
5+
const svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' );
6+
svg.setAttribute( 'xmlns', 'http://www.w3.org/2000/svg' );
7+
svg.setAttribute( 'viewBox', '0 0 384 512' );
8+
svg.setAttribute( 'width', '50px' );
9+
svg.setAttribute( 'height', '50px' );
10+
11+
const path = document.createElementNS(
12+
'http://www.w3.org/2000/svg',
13+
'path'
14+
);
1215
path.setAttribute(
1316
'd',
1417
'M162.4 6c-1.5-3.6-5-6-8.9-6l-19 0c-3.9 0-7.5 2.4-8.9 6L104.9 57.7c-3.2 8-14.6 8-17.8 0L66.4 6c-1.5-3.6-5-6-8.9-6L48 0C21.5 0 0 21.5 0 48L0 224l0 22.4L0 256l9.6 0 364.8 0 9.6 0 0-9.6 0-22.4 0-176c0-26.5-21.5-48-48-48L230.5 0c-3.9 0-7.5 2.4-8.9 6L200.9 57.7c-3.2 8-14.6 8-17.8 0L162.4 6zM0 288l0 32c0 35.3 28.7 64 64 64l64 0 0 64c0 35.3 28.7 64 64 64s64-28.7 64-64l0-64 64 0c35.3 0 64-28.7 64-64l0-32L0 288zM192 432a16 16 0 1 1 0 32 16 16 0 1 1 0-32z'
1518
);
16-
path.setAttribute('fill', '#8c8f94');
17-
svg.appendChild(path);
19+
path.setAttribute( 'fill', '#8c8f94' );
20+
svg.appendChild( path );
1821

1922
return svg;
2023
}
2124

2225
// Function to create the 'Build with AI' element
23-
function createBuildWithAIElement(themeDiv) {
24-
const buildWithAIElement = document.createElement('div');
25-
buildWithAIElement.classList.add('theme', 'build-with-ai');
26-
buildWithAIElement.style.height = `${themeDiv.offsetHeight}px`;
26+
function createBuildWithAIElement( themeDiv ) {
27+
const buildWithAIElement = document.createElement( 'div' );
28+
buildWithAIElement.classList.add( 'theme', 'build-with-ai' );
29+
buildWithAIElement.style.height = `${ themeDiv.offsetHeight }px`;
2730

28-
const newLink = document.createElement('span');
29-
newLink.classList.add('build-with-ai__link');
31+
const newLink = document.createElement( 'span' );
32+
newLink.classList.add( 'build-with-ai__link' );
3033

31-
const themeScreenshot = document.createElement('div');
32-
themeScreenshot.classList.add('build-with-ai__icon');
34+
const themeScreenshot = document.createElement( 'div' );
35+
themeScreenshot.classList.add( 'build-with-ai__icon' );
3336

34-
const iconSpan = document.createElement('span');
35-
iconSpan.classList.add('build-with-ai__icon-span');
36-
iconSpan.appendChild(createSVGIcon());
37-
themeScreenshot.appendChild(iconSpan);
37+
const iconSpan = document.createElement( 'span' );
38+
iconSpan.classList.add( 'build-with-ai__icon-span' );
39+
iconSpan.appendChild( createSVGIcon() );
40+
themeScreenshot.appendChild( iconSpan );
3841

39-
const themeName = document.createElement('h2');
40-
themeName.classList.add('build-with-ai__text');
42+
const themeName = document.createElement( 'h2' );
43+
themeName.classList.add( 'build-with-ai__text' );
4144
themeName.textContent = window.nfdOnboardingRestartMeta?.buttonText;
4245

43-
newLink.appendChild(themeScreenshot);
44-
newLink.appendChild(themeName);
45-
buildWithAIElement.appendChild(newLink);
46+
newLink.appendChild( themeScreenshot );
47+
newLink.appendChild( themeName );
48+
buildWithAIElement.appendChild( newLink );
4649

47-
buildWithAIElement.addEventListener('click', () => {
50+
buildWithAIElement.addEventListener( 'click', () => {
4851
window.location.href =
4952
window.nfdOnboardingRestartMeta?.buttonHref + '&restart=theme';
50-
});
53+
} );
5154

5255
return buildWithAIElement;
5356
}
5457

5558
// Function to handle the appearance of the themeDiv
5659
function handleThemeDivAppearance() {
57-
const themeDiv = document.querySelector('.add-new-theme');
60+
const themeDiv = document.querySelector( '.add-new-theme' );
5861

59-
if (themeDiv && !buildWithAIInserted) {
62+
if ( themeDiv && ! buildWithAIInserted ) {
6063
// Check if the element exists and hasn't been inserted yet
6164

62-
const buildWithAIElement = createBuildWithAIElement(themeDiv);
63-
themeDiv.parentNode.insertBefore(buildWithAIElement, themeDiv);
65+
const buildWithAIElement = createBuildWithAIElement( themeDiv );
66+
themeDiv.parentNode.insertBefore( buildWithAIElement, themeDiv );
6467

6568
buildWithAIInserted = true; // Set the flag to true after insertion
6669
}
6770
}
6871

6972
// Setting up MutationObserver to detect the appearance of the themeDiv element
7073
function observeForThemeDiv() {
71-
const observer = new MutationObserver((mutationsList, observer) => {
72-
mutationsList.forEach((mutation) => {
73-
if (mutation.type === 'childList') {
74+
// eslint-disable-next-line no-undef
75+
const observerObj = new MutationObserver( ( mutationsList ) => {
76+
mutationsList.forEach( ( mutation ) => {
77+
if ( mutation.type === 'childList' ) {
7478
handleThemeDivAppearance(); // Check for the element whenever the DOM changes
7579
}
76-
});
77-
});
80+
} );
81+
} );
7882

79-
observer.observe(document.body, {
83+
observerObj.observe( document.body, {
8084
childList: true,
8185
subtree: true,
82-
});
86+
} );
8387
}
8488

8589
// Wait for the DOM to be fully loaded and then start observing
86-
window.addEventListener('DOMContentLoaded', function () {
90+
window.addEventListener( 'DOMContentLoaded', function () {
8791
observeForThemeDiv();
88-
});
92+
} );

0 commit comments

Comments
 (0)