fix initial value for color_mode (#2741)

* fix initial value for color_mode

* better fix
This commit is contained in:
Thomas Brandého 2024-02-28 03:31:38 +01:00 committed by GitHub
parent 7ec7f031a3
commit 2062c1dd05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
"""Compiler for the reflex apps.""" """Compiler for the reflex apps."""
from __future__ import annotations from __future__ import annotations
import os import os
@ -78,18 +79,21 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component) -> str
Returns: Returns:
The compiled context file. The compiled context file.
""" """
appearance = getattr(theme, "appearance", None)
if appearance is None:
appearance = LIGHT_COLOR_MODE
return ( return (
templates.CONTEXT.render( templates.CONTEXT.render(
initial_state=utils.compile_state(state), initial_state=utils.compile_state(state),
state_name=state.get_name(), state_name=state.get_name(),
client_storage=utils.compile_client_storage(state), client_storage=utils.compile_client_storage(state),
is_dev_mode=_is_dev_mode(), is_dev_mode=_is_dev_mode(),
default_color_mode=getattr(theme, "appearance", LIGHT_COLOR_MODE), default_color_mode=appearance,
) )
if state if state
else templates.CONTEXT.render( else templates.CONTEXT.render(
is_dev_mode=_is_dev_mode(), is_dev_mode=_is_dev_mode(),
default_color_mode=getattr(theme, "appearance", LIGHT_COLOR_MODE), default_color_mode=appearance,
) )
) )