mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
cfe81d6d3f
* Add tailwind and esbuild
* Remove unused images
* Move unprocessed assets to priv directory
* Fix applyTheme script
* Remove autoprefixer
* Update bundlemon
* Remove babel config
* Revert "Remove autoprefixer"
This reverts commit fc60c31c73
.
* Make dashboard react file work
* Fix app.css imports
* Remove autoprefixer
* Add back in robots.txt
* Go back to css/ and js/ folders as opposed to assets/
* Bundle embed.host.js and embed.content.js
* Add components folder to live reload paths
* Remove bundlemon
* Use mix assets task in Dockerfil
* Add assets setup to CONTRIBUTING.md
38 lines
949 B
JavaScript
38 lines
949 B
JavaScript
var pref = document.currentScript.dataset.pref;
|
|
|
|
function reapplyTheme() {
|
|
var userPref = pref || "system";
|
|
var mediaPref = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
var htmlRef = document.querySelector('html');
|
|
var hcaptchaRefs = document.getElementsByClassName('h-captcha');
|
|
|
|
htmlRef.classList.remove('dark');
|
|
for (let i = 0; i < hcaptchaRefs.length; i++) {
|
|
hcaptchaRefs[i].dataset.theme = "light";
|
|
}
|
|
|
|
switch (userPref) {
|
|
case "dark":
|
|
htmlRef.classList.add('dark');
|
|
for (let i = 0; i < hcaptchaRefs.length; i++) {
|
|
hcaptchaRefs[i].dataset.theme = "dark";
|
|
}
|
|
break;
|
|
case "system":
|
|
if (mediaPref) {
|
|
htmlRef.classList.add('dark');
|
|
for (let i = 0; i < hcaptchaRefs.length; i++) {
|
|
hcaptchaRefs[i].dataset.theme = "dark";
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
reapplyTheme();
|
|
window.matchMedia('(prefers-color-scheme: dark)').addListener(reapplyTheme);
|
|
|
|
window.onload = function() {
|
|
reapplyTheme();
|
|
};
|