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

Add default dark mode to config.toml #973

Closed
wants to merge 0 commits into from
Closed

Conversation

hayescode
Copy link
Contributor

@hayescode hayescode commented May 8, 2024

Adds option to config.toml to set default theme:

  • Options: "dark", "light", "system"
  • Default: "system"

Relevant Discord Thread

Python portion works. This prints the config selection, and "system" if left un-configured.

from chainlit.config import config

@cl.on_chat_start
async def main():
    print(config.ui.default_theme)

@hayescode hayescode marked this pull request as ready for review May 9, 2024 13:07
@zboyles
Copy link

zboyles commented May 18, 2024

Does preferredTheme start off as null or undefined? If so, I think the priorities should be slightly adjusted to avoid forcing the server-configured theme. Consider using the following order of precedence:

const theme = preferredTheme ?? serverDefaultTheme ?? defaultTheme;

This change should prioritize the user's preferred theme, then the server-configured theme, and finally the default theme. This approach should also maintain existing user preferences and allow new users to change their theme.

Copy link
Collaborator

@tpatel tpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution ✨

I've added a comment for the frontend implementation

@@ -8,7 +8,10 @@ const preferredTheme = localStorage.getItem(
'themeVariant'
) as ThemeVariant | null;

const theme = preferredTheme ? preferredTheme : defaultTheme;
const serverDefaultTheme = localStorage.getItem('serverDefaultTheme') as ThemeVariant | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an issue here, the server value shouldn't be read from the browser localstorage. It should be read from projectSettings?.ui.default_theme, I think this should happen in a hook when we get the project settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Would you be able to to commit the change I'm still running into permission issues on my companies computer preventing full testing.

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

Successfully merging this pull request may close these issues.

None yet

3 participants