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

Way to change theme options after the initial load? #87

Open
caendesilva opened this issue Sep 20, 2024 · 0 comments
Open

Way to change theme options after the initial load? #87

caendesilva opened this issue Sep 20, 2024 · 0 comments

Comments

@caendesilva
Copy link

Hey! Amazed with this library so far. I'm wondering if there is a way to update the options after the initial render?

I confirmed with a console log that the options are changed, but it's not reacting to the state change. Is there a way to manually trigger a redraw?

// Listen for changes in dark mode
const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
            const isDarkMode = document.documentElement.classList.contains('dark');
            console.log(player.options)
            player.options.themeColor = isDarkMode ? '#6366f1' : '#4A5568';
            player.options.theme = isDarkMode ? 'dark' : 'light';
        }
    });
});

observer.observe(document.documentElement, {
    attributes: true,
    attributeFilter: ['class']
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant