Fix toggle color schema button on desktop

This commit is contained in:
prototypa
2022-08-19 13:19:15 -04:00
parent 01801b9884
commit 577eb96663
2 changed files with 15 additions and 10 deletions

View File

@ -14,8 +14,12 @@ const {} = Astro.props;
}
function attachEvent(selector, event, fn) {
const elem = document.querySelector(selector);
if (elem) {
const matches = document.querySelectorAll(selector);
console.log(matches);
if (matches && matches.length) {
console.log("Hello");
matches.forEach((elem) => {
console.log(elem);
elem.addEventListener(
event,
function () {
@ -23,6 +27,7 @@ const {} = Astro.props;
},
false
);
});
}
}

View File

@ -78,7 +78,7 @@ const {} = Astro.props;
type="button"
class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-2.5 inline-flex items-center"
aria-label="Toggle between Dark and Light mode"
onclick="window.toggleDarkMode()"
data-aw-toggle-color-scheme
>
<IconSun />
</button>