Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore(web): add theme-script.js public asset

Richie McIlroyee603ac0231e
diff --git a/apps/web/public/theme-script.js b/apps/web/public/theme-script.js
new file mode 100644
index 000000000..f57f7a3c2
--- /dev/null
+++ b/apps/web/public/theme-script.js
@@ -0,0 +1,24 @@
+(() => {
+ var cookie = (() => {
+ if (!document.cookie) return undefined;
+ var match = document.cookie.match(/\W?theme=(\w+)/);
+ return match ? match[1] : undefined;
+ })();
+
+ var pathname = window.location.pathname;
+ var isDashboardPath =
+ pathname.indexOf("/dashboard") === 0 ||
+ pathname.indexOf("/login") === 0 ||
+ pathname.indexOf("/onboarding") === 0;
+ var applyTheme = () => {
+ document.body.classList.add(cookie || "light");
+ };
+
+ if (isDashboardPath) {
+ if (document.body) {
+ applyTheme();
+ } else {
+ window.addEventListener("DOMContentLoaded", applyTheme, { once: true });
+ }
+ }
+})();