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

Changing theme dynamically #131

Open
MarcinAman opened this issue Sep 1, 2021 · 1 comment
Open

Changing theme dynamically #131

MarcinAman opened this issue Sep 1, 2021 · 1 comment

Comments

@MarcinAman
Copy link

Hi, is it possible to change the theme of sample dynamically (in JS). I have a theme toggler on my page therefore i'd like to also adjust the sample theme from idea to darcula. I've tried to just change the parameter manually but it doesn't seem to update anything (probably the change is not propagated)

Technically i could just render 2 versions and hide one but this results in super bad user experience

@nikpachoo
Copy link
Contributor

nikpachoo commented Sep 2, 2021

Hi, @MarcinAman! Thank you for your feedback.
Unfortunately, now the widget does not support changing the theme dynamically. As a workaround, instead of render 2 versions, you can try to recreate the widget with new parameters.
Something like that:

let instance;

  initPlayground(element, theme) {
    if (instance) {
      instance.destroy();
    }

    playground(element, {
      getInstance: playgroundInstance => instance = playgroundInstance,
      theme: theme
    });
  } 

Most likely, we will add a possibility to change the theme dynamically, but it will take us some time to do this.

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

2 participants