jsakamoto / BlazingStory

The clone of "Storybook" for Blazor, a frontend workshop for building UI components and pages in isolation.
https://jsakamoto.github.io/BlazingStory/
Mozilla Public License 2.0
319 stars 16 forks source link

Question about dark theme #29

Closed nekrasov-andrii closed 7 months ago

nekrasov-andrii commented 7 months ago

Hi @jsakamoto,

In my application, I use the ThemeService service to switch themes. For a dark theme via js, I add the class “dark” to the “body” tag, and the variables for the css are registered for the “body.dark” rule. I tried to add the same functionality for displaying components in "BlazingStory", but nothing worked.

Is it possible to add your own classes for the "body" tag?

Could you provide an example?

Or give advice on what direction to look in?

Kind regards, Andrii.

jsakamoto commented 7 months ago

Hi @nekrasov-andrii, Thank you for the good question! By the way, could you explain your requirements in more detail? For example, which areas do you want to control the theme in?

image

And who or what will trigger adding the "dark" CSS class to the <body> tag in your possible scenario? If you already have the sample project you've tried, it will be helpful to provide it to me.

nekrasov-andrii commented 7 months ago

Hi @jsakamoto, Today I found the reason why I couldn't manage theme changes for components. I couldn’t understand why my service that tracks theme changes is always null. Then I noticed that instead of “IFramePage” it is always rendered “IndexPage”. Therefore, all my attempts to observable the change of current theme were fruitless. I created a new project to find the problem, but everything worked fine in it, and the theme change tracking worked. The reason why theme change observable didn't work on my main project was "BlazingStoryServerComponent".

image

The fact is that in my project there is an additional path in the form of the application name. image

I copied your class and changed the code a little. image

And everything started to work.

Please fix this as soon as possible.

Here is my version of how I observable the theme change. This is only example. StoryBook2.zip

Kind regards, Andrii.

jsakamoto commented 7 months ago

@nekrasov-andrii Thank you for the detailed description of the problem. I'm investigating it now. However, I have an urgent matter, so please give me more days. Thank you for your patience.

jsakamoto commented 7 months ago

Hi @nekrasov-andrii, I published a new version of the "Blazing Story", ver.1.0.0 Preview 35.

It must work fine even if the server application has an additional path for its root. Could you try it out? Thank you for your contributions.

nekrasov-andrii commented 7 months ago

Hi @jsakamoto, This morning, I installed a new version of the "Blazing Story". It works) Thank you @jsakamoto!