MCPcopy Create free account
hub / github.com/utterance/utterances / loadTheme

Function loadTheme

src/theme.ts:1–16  ·  view source on GitHub ↗
(theme: string, origin: string)

Source from the content-addressed store, hash-verified

1export function loadTheme(theme: string, origin: string) {
2 return new Promise(resolve => {
3 const link = document.createElement('link');
4 link.rel = 'stylesheet';
5 link.setAttribute('crossorigin', 'anonymous');
6 link.onload = resolve;
7 link.href = `/stylesheets/themes/${theme}/utterances.css`;
8 document.head.appendChild(link);
9
10 addEventListener('message', event => {
11 if (event.origin === origin && event.data.type === 'set-theme') {
12 link.href = `/stylesheets/themes/${event.data.theme}/utterances.css`;
13 }
14 });
15 });
16}

Callers 1

bootstrapFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected