Closed MobCode100 closed 10 months ago
This PR might be unnecessary, but I would love to have a dark mode version of tgcf-web, less pain for my eyes XD. I remembered that Streamlit has already a default dark mode which can be accessed by the app menu. I thought to just enable the app menu, but you might have some reasons to disable it. So I implemented a custom theme switcher.
Actually, I made two versions of the feature:
theme
config and start the Streamlit app with the theme. Once the theme is changed by clicking the save button, tgcf-web
will automatically restart with the new configuration.theme
config but uses JavaScript's localStorage
that simulates the default Streamlit theme switcher on the app menu. The only difference is that a website refresh is required for changes to take effect. I decide to go with the second one, as it is a lot faster to just refresh a website and probably more stable than the first one.
Sorry for the very simple UI tho ๐คฃ, I can't think a better way to do that. Feel free to change anything and please give your feedback if any. Thank you for your time and efforts!
This is awesome ๐๐
I am stuck in some other work.. I will try my best to test and merge everything as soon as possible.
Thanks again for your contributions. ๐๐ฅ
Description:
A function to switch between light/dark mode
Preview:
Key changes:
switch_theme
(web_ui/utils.py
) to display the option to switch themeapply_theme
(web_ui/utils.py
) which will run every time the theme changestheme
config option so the web server will start with the correct theme that was previously chosenI have fully read and understood the terms and conditions laid down in the general Contributor License Agreement