Add a custom Web Component¶
Refer to the CanvasComponent.ts
in the frontend for an example.
- Create a class with the name
[Name]Component
, for exampleMyComponent
. - Extend the class from
HTMLElement
. - Add the required logic to render your component.
- Register the component inside
index.ts
with. Make sure the element name exists out of at least two components seperated by a dash, for example:game-my
. - Add your component to the
Page
enumeration inRootComponent.ts
, for exampleMy = "my"
. - Add your component to the
switch (this._currentPage)
inRootComponent.ts
.
To instruct the frontend to switch to your Web Component, return a SwitchPageActionResult
from an action on the backend.