Skip to content

Instantly share code, notes, and snippets.

@hugoabernier
Last active May 9, 2018 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugoabernier/0e612b61f1fc5dd0e45c74a257383fde to your computer and use it in GitHub Desktop.
Save hugoabernier/0e612b61f1fc5dd0e45c74a257383fde to your computer and use it in GitHub Desktop.
Inject CSS
@override
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);
const cssUrl: string = this.properties.cssurl;
if (cssUrl) {
// inject the style sheet
const head: any = document.getElementsByTagName("head")[0] || document.documentElement;
let customStyle: HTMLLinkElement = document.createElement("link");
customStyle.href = cssUrl;
customStyle.rel = "stylesheet";
customStyle.type = "text/css";
head.insertAdjacentElement("beforeEnd", customStyle);
}
return Promise.resolve();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment