Skip to content

Commit

Permalink
feat: add the plugin system to the project
Browse files Browse the repository at this point in the history
The PR adds the plugin system proposed in adobe/aem-boilerplate#254.
It also updates a few lib-franklin.js methods that were missing, along with the blocks that are impacted, and the template loading is converted to the new system.

Test URLs:
- Before: https://main--moleculardevices--hlxsites.hlx.page/
- After: https://plugin-system--moleculardevices--hlxsites.hlx.page/
  • Loading branch information
ramboz authored Nov 6, 2023
2 parents 9429a2a + 2be022e commit 45362b5
Show file tree
Hide file tree
Showing 9 changed files with 326 additions and 119 deletions.
4 changes: 1 addition & 3 deletions blocks/breadcrumbs/breadcrumbs-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ function getName(pageIndex, path, part, current) {
}

export default async function createBreadcrumbs(container) {
const breadCrumbsCSS = new Promise((resolve) => {
loadCSS('/blocks/breadcrumbs/breadcrumbs.css', (e) => resolve(e));
});
const breadCrumbsCSS = loadCSS('/blocks/breadcrumbs/breadcrumbs.css');

const path = window.location.pathname;
const pathSplit = skipParts(path.split('/'));
Expand Down
10 changes: 3 additions & 7 deletions blocks/card/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,11 @@ class Card {
}

async loadCSSFiles() {
let defaultCSSPromise;
let defaultCSSPromise = Promise.resolve();
if (Array.isArray(this.cssFiles) && this.cssFiles.length > 0) {
defaultCSSPromise = new Promise((resolve) => {
this.cssFiles.forEach((cssFile) => {
loadCSS(cssFile, (e) => resolve(e));
});
});
defaultCSSPromise = Promise.all(this.cssFiles.map(loadCSS));
}
this.cssFiles && (await defaultCSSPromise);
return defaultCSSPromise;
}
}

Expand Down
6 changes: 1 addition & 5 deletions blocks/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,7 @@ class Carousel {
let defaultCSSPromise;
if (Array.isArray(this.cssFiles) && this.cssFiles.length > 0) {
// add default carousel classes to apply default CSS
defaultCSSPromise = new Promise((resolve) => {
this.cssFiles.forEach((cssFile) => {
loadCSS(cssFile, (e) => resolve(e));
});
});
defaultCSSPromise = Promise.all(this.cssFiles.map(loadCSS));
this.block.parentElement.classList.add('carousel-wrapper');
this.block.classList.add('carousel');
}
Expand Down
Loading

0 comments on commit 45362b5

Please sign in to comment.