From aebc8a830b02647b2816be52b9066e289ae456e7 Mon Sep 17 00:00:00 2001 From: Lasse Liebler Date: Fri, 12 Dec 2025 02:05:10 +0100 Subject: [PATCH] Initialized repo --- .gitignore | 10 ++++++ assets/js/auto-style-switch.js | 15 ++++++++ includes/Config.php | 12 +++++++ includes/Functions.php | 66 ++++++++++++++++++++++++++++++++++ includes/Plugin.php | 43 ++++++++++++++++++++++ theme-style-darkmode.php | 44 +++++++++++++++++++++++ 6 files changed, 190 insertions(+) create mode 100644 .gitignore create mode 100644 assets/js/auto-style-switch.js create mode 100644 includes/Config.php create mode 100644 includes/Functions.php create mode 100644 includes/Plugin.php create mode 100644 theme-style-darkmode.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd61c05 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets +!*.code-workspace + +# Built Visual Studio Code Extensions +*.vsix \ No newline at end of file diff --git a/assets/js/auto-style-switch.js b/assets/js/auto-style-switch.js new file mode 100644 index 0000000..b13101a --- /dev/null +++ b/assets/js/auto-style-switch.js @@ -0,0 +1,15 @@ +/** + * Detects system/browser color scheme and sets the "style_variant" cookie accordingly. + * Reloads the page if the variant changes. + */ + +(function () { + const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; + const cookie = document.cookie.split('; ').find(r => r.startsWith('style_variant=')); + const current = cookie ? cookie.split('=')[1] : ''; + const desired = prefersDark ? '01-evening' : 'default'; // Customize variant names as needed + if (current !== desired) { + document.cookie = "style_variant=" + desired + "; path=/; max-age=31536000"; + location.reload(); + } +})(); \ No newline at end of file diff --git a/includes/Config.php b/includes/Config.php new file mode 100644 index 0000000..e895abd --- /dev/null +++ b/includes/Config.php @@ -0,0 +1,12 @@ +init(); \ No newline at end of file