Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site themes pyga.me/docs #3041

Open
Sinus44 opened this issue Aug 6, 2024 · 3 comments
Open

Site themes pyga.me/docs #3041

Sinus44 opened this issue Aug 6, 2024 · 3 comments
Labels

Comments

@Sinus44
Copy link

Sinus44 commented Aug 6, 2024

While change page, site theme reset to light

@oddbookworm
Copy link
Member

Do you have your settings set to block cookies?

@Sinus44
Copy link
Author

Sinus44 commented Aug 6, 2024

cookies allow for "pyga.me". "document.cookie" is empty

Chrome, Win 10

@Sinus44
Copy link
Author

Sinus44 commented Aug 6, 2024


document.addEventListener('DOMContentLoaded', () => {
    const search_buttons = document.querySelectorAll('.searchbar-button');
    const search_submit = document.querySelector('.searchbar-submit');

    // When the icon is clicked, submit the search form
    search_buttons.forEach((button) => {
        button.addEventListener('click', () => {
            search_submit.click();
        });
    });

    const theme_icons = document.querySelectorAll('.theme-icon');
    theme_icons.forEach((icon) => {
        icon.addEventListener('click', () => {
            const theme = icon.getAttribute('data-theme');
            htmlElement.classList.add('light-theme', 'dark-theme');
            htmlElement.classList.remove(theme);
            localStorage.setItem('theme', htmlElement.classList[0]);
        });
    });
});

htmlElement.classList[0] in my case, it turned out to be "...-translated"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants