Skip to content

Commit b5de977

Browse files
committed
Sticky tweaks: only show in prod mode (#4789)
* Sticky tweaks: only show in prod mode Only display the sticky badge in prod mode. Display the mini-badge for mobile and tablet; full badge only displayed at desktop width. * Remove localhost checking
1 parent f9d3fb3 commit b5de977

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

reflex/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ def get_compilation_time() -> str:
10231023
self._validate_var_dependencies()
10241024
self._setup_overlay_component()
10251025
self._setup_error_boundary()
1026-
if config.show_built_with_reflex:
1026+
if is_prod_mode() and config.show_built_with_reflex:
10271027
self._setup_sticky_badge()
10281028

10291029
progress.advance(task)

reflex/components/core/sticky.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
from reflex.components.component import ComponentNamespace
44
from reflex.components.core.colors import color
5-
from reflex.components.core.cond import color_mode_cond, cond
6-
from reflex.components.core.responsive import tablet_and_desktop
5+
from reflex.components.core.cond import color_mode_cond
6+
from reflex.components.core.responsive import desktop_only
77
from reflex.components.el.elements.inline import A
88
from reflex.components.el.elements.media import Path, Rect, Svg
99
from reflex.components.radix.themes.typography.text import Text
10-
from reflex.experimental.client_state import ClientStateVar
1110
from reflex.style import Style
12-
from reflex.vars.base import Var, VarData
1311

1412

1513
class StickyLogo(Svg):
@@ -87,7 +85,7 @@ def create(cls):
8785
"""
8886
return super().create(
8987
StickyLogo.create(),
90-
tablet_and_desktop(StickyLabel.create()),
88+
desktop_only(StickyLabel.create()),
9189
href="https://reflex.dev",
9290
target="_blank",
9391
width="auto",
@@ -102,36 +100,12 @@ def add_style(self):
102100
Returns:
103101
The style of the component.
104102
"""
105-
is_localhost_cs = ClientStateVar.create(
106-
"is_localhost",
107-
default=True,
108-
global_ref=False,
109-
)
110-
localhost_hostnames = Var.create(
111-
["localhost", "127.0.0.1", "[::1]"]
112-
).guess_type()
113-
is_localhost_expr = localhost_hostnames.contains(
114-
Var("window.location.hostname", _var_type=str).guess_type(),
115-
)
116-
check_is_localhost = Var(
117-
f"useEffect(({is_localhost_cs}) => {is_localhost_cs.set}({is_localhost_expr}), [])",
118-
_var_data=VarData(
119-
imports={"react": "useEffect"},
120-
),
121-
)
122-
is_localhost = is_localhost_cs.value._replace(
123-
merge_var_data=VarData.merge(
124-
check_is_localhost._get_all_var_data(),
125-
VarData(hooks={str(check_is_localhost): None}),
126-
),
127-
)
128103
return Style(
129104
{
130105
"position": "fixed",
131106
"bottom": "1rem",
132107
"right": "1rem",
133-
# Do not show the badge on localhost.
134-
"display": cond(is_localhost, "none", "flex"),
108+
"display": "flex",
135109
"flex-direction": "row",
136110
"gap": "0.375rem",
137111
"align-items": "center",

0 commit comments

Comments
 (0)