summaryrefslogtreecommitdiff
path: root/js/toggleTheme.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/toggleTheme.ts')
-rw-r--r--js/toggleTheme.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/toggleTheme.ts b/js/toggleTheme.ts
new file mode 100644
index 0000000..fd15dae
--- /dev/null
+++ b/js/toggleTheme.ts
@@ -0,0 +1,18 @@
+/// <reference path="setTheme.ts" />
+
+function toggleTheme() {
+ let theme = localStorage.getItem("theme");
+
+ if (theme == "light") {
+ theme = "dark";
+ } else if (theme == "dark") {
+ theme = "light";
+ } else {
+ console.log!("invalid theme `" + theme + "`");
+
+ // Use default:
+ theme = "dark";
+ }
+
+ setTheme(theme);
+}