Our pure JavaScript Scheduler component


Post by chris@qchi.net »

Hi,

I am having no end of issues trying to sort out what should be a simple changing of theme. I have been thought the docs, examples and other posts and cannot find a workable answer. Please can you provide a docs / or a code example where this can be done in REACT. I am confused to why this is so difficult to achieve and why there are so many posts on this subject and no solid guide in the documents.

The DomHelper seems a bit of a hack and doesn't seem to be able to handle switching between 2 imported themes.
I have attempted putting them in as links in the DOM as switching as per the advised way, with no success. It only crashes. I am also not keen on this way as I don't want to download if the user doesn't have access to the scheduler and doesn't need the style sheets.

It would be even nicer as you have a "material" theme that it would use the material-ui theme provider and this would resolve itself.


Post by marcio »

Hey chris,

You can check on our demos (even the React ones) that we have a header with theme options that update the DOM as we change the combo, all of them use the following snippet:

DomHelper.setTheme(value).then((context: any) => {
                            if (context) {
                                const { theme, prev } = context;
                                document.body.classList.remove(`b-theme-${prev}`);
                                document.body.classList.add(`b-theme-${theme}`);
                            }
                        });

Could you provide more info/an example regarding the switching between 2 imported themes scenario?

Best regards,
Márcio


Post Reply