MCPcopy
hub / github.com/element-hq/element-web / BannerModule

Class BannerModule

modules/banner/src/index.tsx:18–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16import style from "./style.css" with { type: "css" };
17
18class BannerModule implements Module {
19 public static readonly moduleApiVersion = "^1.0.0";
20
21 private config?: ModuleConfig;
22
23 public constructor(private api: Api) {}
24
25 public async load(): Promise<void> {
26 const rawConfig = this.api.config.get(CONFIG_KEY);
27 if (!rawConfig) {
28 console.debug(`No configuration found for module "${ModuleName}", skipping initialization.`);
29 return;
30 }
31
32 document.adoptedStyleSheets.push(compound);
33 document.adoptedStyleSheets.push(style);
34
35 this.api.i18n.register(Translations);
36
37 try {
38 this.config = ModuleConfig.parse(rawConfig);
39 } catch (e) {
40 console.error("Failed to init module", e);
41 throw new Error(`Errors in module configuration for "${ModuleName}"`);
42 }
43
44 const div = document.createElement("div");
45 div.dataset.testid = "banner";
46 this.api.rootNode.before(div);
47
48 const root = this.api.createRoot(div);
49 root.render(
50 <ThemeProvider theme={this.config.theme}>
51 <Banner
52 api={this.api}
53 logoUrl={this.config.logo_url}
54 href={this.config.logo_link_url}
55 menu={this.config.menu}
56 title={this.config.title ?? this.api.config.get("brand")}
57 />
58 </ThemeProvider>,
59 );
60 }
61}
62
63export default BannerModule satisfies ModuleFactory;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected