Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanharikr committed Sep 26, 2024
1 parent 446e7e1 commit 9c2d4e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 34 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="light-favicon.png" />
<link href="dark-favicon.png" rel="icon" media="(prefers-color-scheme: light)" />
<link href="light-favicon.png" rel="icon" media="(prefers-color-scheme: dark)" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#303030" />
<title>Hellō Playground</title>
Expand Down
48 changes: 15 additions & 33 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,16 @@
}
onMount(async () => {
const theme = createCssVariablesTheme({
name: 'css-variables',
variablePrefix: '--shiki-',
variableDefaults: {},
fontStyle: true
});
highlighter = await createHighlighterCore({
themes: [theme],
langs: [import('shiki/langs/json.mjs'), import('shiki/langs/http.mjs')],
loadWasm: getWasm //TBD: does not work without importin this
});
if (!getStatesFromLocalStorage()) {
//states not found in local storage, save default states to local storage
const _states = JSON.stringify(states);
localStorage.setItem('states', _states);
}
isHelloMode = !!localStorage.plausible_ignore;
readFromLocalStorage = true;
processFragmentOrQuery();
updateFavicon();
sendEvent();
sendPlausibleEvent();
if (
!['https://wallet.hello.coop/authorize', ...states.custom_authorization_servers].includes(
Expand All @@ -128,6 +111,19 @@
custom_authorization_server = states.selected_authorization_server;
}
const theme = createCssVariablesTheme({
name: 'css-variables',
variablePrefix: '--shiki-',
variableDefaults: {},
fontStyle: true
});
highlighter = await createHighlighterCore({
themes: [theme],
langs: [import('shiki/langs/json.mjs'), import('shiki/langs/http.mjs')],
loadWasm: getWasm //TBD: does not work without importing this
});
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
darkMode = true;
}
Expand Down Expand Up @@ -301,20 +297,6 @@
//detect chanes in state -> save to local storage
$: states, saveStatesToLocalStorage();
function updateFavicon() {
const ref = document.querySelector("link[rel='icon']");
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
ref.href = 'dark-favicon.png';
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (event) => {
if (event.matches) {
ref.href = 'light-favicon.png';
} else {
ref.href = 'dark-favicon.png';
}
});
}
async function processFragmentOrQuery() {
if (!window.location.hash && !window.location.search) return;
Expand Down Expand Up @@ -710,7 +692,7 @@
type: 'invite'
});
async function sendEvent() {
async function sendPlausibleEvent() {
if (isHelloMode) {
console.info('Ignoring Event: localStorage flag');
return;
Expand Down

0 comments on commit 9c2d4e1

Please sign in to comment.