Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (44 sloc) 1.49 KB
import * as React from "react";
import * as ReactDom from "react-dom";
import { override } from "@microsoft/decorators";
import { Log } from "@microsoft/sp-core-library";
import {
BaseApplicationCustomizer,
PlaceholderContent,
PlaceholderName
} from "@microsoft/sp-application-base";
import GlobalNav from "./components/GlobalNav/GlobalNav";
import * as strings from "SpfxGlobalNavigationApplicationCustomizerStrings";
const LOG_SOURCE: string = "SpfxGlobalNavigationApplicationCustomizer";
export interface ISpfxGlobalNavigationApplicationCustomizerProperties {}
export default class SpfxGlobalNavigationApplicationCustomizer extends BaseApplicationCustomizer<
ISpfxGlobalNavigationApplicationCustomizerProperties
> {
private topPlaceholder: PlaceholderContent | undefined;
@override
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);
this.context.placeholderProvider.changedEvent.add(
this,
this.renderPlaceHolders
);
return Promise.resolve();
}
private renderPlaceHolders(): void {
if (!this.topPlaceholder) {
this.topPlaceholder = this.context.placeholderProvider.tryCreateContent(
PlaceholderName.Top
);
if (!this.topPlaceholder) {
return;
}
if (this.topPlaceholder.domElement) {
const element: React.ReactElement<{}> = React.createElement(
GlobalNav,
{}
);
ReactDom.render(element, this.topPlaceholder.domElement);
}
}
}
}
You can’t perform that action at this time.