Skip to content

Commit

Permalink
refactor: Use BaseComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
ochairo committed Mar 27, 2024
1 parent 7883617 commit 639f776
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/app/features/error/presentation/error.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import template from "@error/presentation/error.component.html";
import BaseComponent from "@infrastructure/base-component/base.component";

export class ErrorComponent extends BaseComponent {
_shadowRoot: ShadowRoot;
_template: string;

constructor() {
super();
this._shadowRoot = this.attachShadow({ mode: "open" });
this._template = `<style>${style}</style>${template}`;
}

Expand Down
2 changes: 0 additions & 2 deletions src/app/features/showcase/presentation/showcase.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import template from "@showcase/presentation/showcase.component.html";
import "../../../infrastructure/ui-components/atoms/input/input.component";

class ShowcaseComponent extends BaseComponent {
private _shadowRoot: ShadowRoot;
private _getShowcase: GetShowcase | null;
private _apiData: ShowcaseData[] = [];
router = Router.getInstance();

constructor(getShowcase?: GetShowcase) {
super();
this._getShowcase = getShowcase || null;
this._shadowRoot = this.attachShadow({ mode: "open" });
}

async onInit(): Promise<void> {
Expand Down
6 changes: 6 additions & 0 deletions src/app/infrastructure/base-component/base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
* Base class for custom elements
*/
export default class BaseComponent extends HTMLElement {
protected _shadowRoot: ShadowRoot;

constructor() {
super();
this._shadowRoot = this.attachShadow({ mode: "open" });
}
connectedCallback() {
console.log("[BaseComponent] Element connected to the DOM");
this.onInit();
Expand Down

0 comments on commit 639f776

Please sign in to comment.