Set proper darkmode attribute for algolia autocomplete

This commit is contained in:
Jan Böhmer 2024-02-27 00:33:48 +01:00
parent 18eb0467ee
commit 4398b8698c

View file

@ -91,6 +91,9 @@ export default class extends Controller {
_enableDarkmode() { _enableDarkmode() {
//Add data-bs-theme="dark" to the html tag //Add data-bs-theme="dark" to the html tag
document.documentElement.setAttribute('data-bs-theme', 'dark'); document.documentElement.setAttribute('data-bs-theme', 'dark');
//Add data-theme="dark" to the body tag for algolia autocomplete
document.body.setAttribute('data-theme', 'dark');
} }
/** /**
@ -100,6 +103,9 @@ export default class extends Controller {
_disableDarkmode() { _disableDarkmode() {
//Set data-bs-theme to light //Set data-bs-theme to light
document.documentElement.setAttribute('data-bs-theme', 'light'); document.documentElement.setAttribute('data-bs-theme', 'light');
//Add data-theme="dark" to the body tag for algolia autocomplete
document.body.setAttribute('data-theme', 'light');
} }