Skip to content

Commit

Permalink
added banner block
Browse files Browse the repository at this point in the history
  • Loading branch information
eKrausedivae committed Feb 2, 2024
1 parent df3684c commit 03b7735
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions dist/banner/banner.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/banner/banner.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main/main.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/blocks/banner/banner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function (block: HTMLElement) {
const org_content = block.innerHTML;
console.log(block);
block.innerHTML = `<div>hi</div>`;
block.style.removeProperty("display");
}
18 changes: 9 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,26 @@ class Main {
main.setAttribute('id', 'main');
this.addSidebarContainer(main);
this.sectionService.init(main);
this.addInnerContainer(main); // TODO refactor initializing
this.blockService.decorateBlocks(main);
this.loadComponents();
await this.loadComponents();
document.body.classList.add("appear");
this.addInnerContainer(main);
// await this.waitForLCP(LCP_BLOCKS);
}
};

private addInnerContainer(main: HTMLElement) {
const children = main.innerHTML;
main.innerHTML = `<div class="inner">${children}</div>`;
}


private addSidebarContainer(main: HTMLElement) {
const sidebarContainer = document.createElement("div");
sidebarContainer.classList.add("sidebar");
sidebarContainer.setAttribute("id", "sidebar");
main.after(sidebarContainer);
}

private addInnerContainer(main: HTMLElement) {
const children = main.innerHTML;
main.innerHTML = `<div class="inner">${children}</div>`;
}

// private loadLazy = async () => {};

private decorateTemplateAndTheme() {
Expand Down Expand Up @@ -232,7 +232,7 @@ class Main {
if (components.length) {
components.forEach(async (component) => {
const componentModule = await import(
`${window.hlx.codeBasePath}/blocks/${component.name}/__compiled__/${component.name}.js`
`${window.hlx.codeBasePath}/dist/${component.name}/${component.name}.js`
);
if (componentModule.default) {
await componentModule.default(component.element);
Expand Down
1 change: 1 addition & 0 deletions types/blocks/banner/banner.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function (block: HTMLElement): void;
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default defineConfig(({ command, mode }) => {
styles: resolve(__dirname, "src/styles/sass/main.scss"),
main: resolve(__dirname, "src/main.ts"),
counter: resolve(__dirname, "src/blocks/counter/counter.ts"),
banner: resolve(__dirname, "src/blocks/banner/banner.ts"),
},
output: {
dir: "dist",
Expand Down

0 comments on commit 03b7735

Please sign in to comment.