mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
created base layouts and fixed structure
This commit is contained in:
43
src/components/app-link/AppLinkElement.ts
Normal file
43
src/components/app-link/AppLinkElement.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { attr, targets, controller, target } from "@github/catalyst";
|
||||
import { closest, index, update, isTrue } from "core/utils";
|
||||
import { html, render, until } from "@github/jtml";
|
||||
import { PingService } from "services/";
|
||||
import { AppMainElement } from "components/app-main/AppMainElement";
|
||||
import { RouterService } from "core/services";
|
||||
|
||||
@controller
|
||||
class AppLinkElement extends HTMLElement {
|
||||
@closest appMain: AppMainElement;
|
||||
@attr to: string;
|
||||
@attr title: string;
|
||||
@target main: Element;
|
||||
routerService: RouterService;
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public connectedCallback(): void {
|
||||
this.update();
|
||||
this.routerService = this.appMain?.routerService;
|
||||
this.main.addEventListener("click", this.goTo);
|
||||
}
|
||||
|
||||
public disconnectedCallback(): void {
|
||||
this.main.removeEventListener("click", this.goTo);
|
||||
}
|
||||
|
||||
goTo = () => {
|
||||
this.routerService.goTo(this.to);
|
||||
};
|
||||
|
||||
update() {
|
||||
render(
|
||||
html`<span
|
||||
data-target="app-link.main"
|
||||
style="text-decoration: underline; cursor: pointer;"
|
||||
>${this.title}</span
|
||||
>`,
|
||||
this
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user