Fix double-quoting of defaultColorMode (#3840)

If the user provided an `appearance` or `color_mode` value to `rx.theme`, then
the resulting value ended up being double-double-quoted in the resulting JS
output.

Instead remove the quotes from the context.js.jinja2 and always pass appearance
as a Var.
This commit is contained in:
Masen Furer 2024-08-26 17:17:39 -07:00 committed by GitHub
parent 1d9a154d5b
commit be71254250
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ export const initialState = {{ initial_state|json_dumps }}
export const initialState = {} export const initialState = {}
{% endif %} {% endif %}
export const defaultColorMode = "{{ default_color_mode }}" export const defaultColorMode = {{ default_color_mode }}
export const ColorModeContext = createContext(null); export const ColorModeContext = createContext(null);
export const UploadFilesContext = createContext(null); export const UploadFilesContext = createContext(null);
export const DispatchContext = createContext(null); export const DispatchContext = createContext(null);

View File

@ -17,7 +17,7 @@ from reflex.components.component import (
StatefulComponent, StatefulComponent,
) )
from reflex.config import get_config from reflex.config import get_config
from reflex.ivars.base import ImmutableVar from reflex.ivars.base import LiteralVar
from reflex.state import BaseState from reflex.state import BaseState
from reflex.style import SYSTEM_COLOR_MODE from reflex.style import SYSTEM_COLOR_MODE
from reflex.utils.exec import is_prod_mode from reflex.utils.exec import is_prod_mode
@ -81,8 +81,8 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component | None)
The compiled context file. The compiled context file.
""" """
appearance = getattr(theme, "appearance", None) appearance = getattr(theme, "appearance", None)
if appearance is None or str(ImmutableVar.create_safe(appearance)) == "inherit": if appearance is None or str(LiteralVar.create(appearance)) == '"inherit"':
appearance = SYSTEM_COLOR_MODE appearance = LiteralVar.create(SYSTEM_COLOR_MODE)
last_compiled_time = str(datetime.now()) last_compiled_time = str(datetime.now())
return ( return (