Skip to content

Commit 4213b8f

Browse files
committed
fix: mobile sidebar position
1 parent 35ae94b commit 4213b8f

File tree

5 files changed

+67
-50
lines changed

5 files changed

+67
-50
lines changed

daras_ai_v2/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def render(self):
395395
self.render_report_form()
396396
return
397397

398-
sidebar_mobile_header(self.request.session)
398+
sidebar_mobile_header(self.request)
399399
header_placeholder = gui.div(className="my-1 w-100")
400400
with (
401401
gui.styled(NAV_TABS_CSS),

routers/account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def account_page_wrapper(request: Request, current_tab: TabData):
382382
raise gui.RedirectException(str(redirect_url))
383383

384384
with page_wrapper(request) as current_workspace:
385-
sidebar_mobile_header(request.session)
385+
sidebar_mobile_header(request)
386386
with gui.nav_tabs():
387387
for tab in AccountTabs.get_tabs_for_user(request.user, current_workspace):
388388
with gui.nav_item(tab.url_path, active=tab == current_tab):

routers/root.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ def page_wrapper(
746746
src=settings.GOOEY_LOGO_FACE,
747747
width=settings.SIDEBAR_ICON_SIZE,
748748
height=settings.SIDEBAR_ICON_SIZE,
749-
className=" logo-face d-block",
749+
className=" logo-face d-none d-md-block",
750750
)
751751
open_sidebar_btn = gui.button(
752752
label=icons.sidebar_flip,
@@ -844,36 +844,36 @@ def page_wrapper(
844844
gui.html(templates.get_template("login_scripts.html").render(**context))
845845

846846

847-
# def _render_mobile_search_button(request: Request, search_filters: SearchFilters):
848-
# with gui.div(
849-
# className="d-flex d-md-none flex-grow-1 justify-content-end",
850-
# ):
851-
# gui.button(
852-
# icons.search,
853-
# type="tertiary",
854-
# unsafe_allow_html=True,
855-
# className="m-0",
856-
# onClick=JS_SHOW_MOBILE_SEARCH,
857-
# )
858-
859-
# with (
860-
# gui.styled("@media (min-width: 768px) { & { position: static !important; } }"),
861-
# gui.div(
862-
# className="d-md-flex flex-grow-1 justify-content-center align-items-center bg-white top-0 left-0",
863-
# style={"display": "none", "zIndex": "10"},
864-
# id="mobile_search_container",
865-
# ),
866-
# ):
867-
# render_search_bar_with_redirect(
868-
# request=request,
869-
# search_filters=search_filters or SearchFilters(),
870-
# )
871-
# gui.button(
872-
# "Cancel",
873-
# type="tertiary",
874-
# className="d-md-none fs-6 m-0 ms-1 p-1",
875-
# onClick=JS_HIDE_MOBILE_SEARCH,
876-
# )
847+
def _render_mobile_search_button(request: Request, search_filters: SearchFilters):
848+
with gui.div(
849+
className="d-flex d-md-none flex-grow-1 justify-content-end",
850+
):
851+
gui.button(
852+
icons.search,
853+
type="tertiary",
854+
unsafe_allow_html=True,
855+
className="m-0",
856+
onClick=JS_SHOW_MOBILE_SEARCH,
857+
)
858+
859+
with (
860+
gui.styled("@media (min-width: 768px) { & { position: static !important; } }"),
861+
gui.div(
862+
className="d-md-flex flex-grow-1 justify-content-center align-items-center bg-white top-0 left-0",
863+
style={"display": "none", "zIndex": "10"},
864+
id="mobile_search_container",
865+
),
866+
):
867+
render_search_bar_with_redirect(
868+
request=request,
869+
search_filters=search_filters or SearchFilters(),
870+
)
871+
gui.button(
872+
"Cancel",
873+
type="tertiary",
874+
className="d-md-none fs-6 m-0 ms-1 p-1",
875+
onClick=JS_HIDE_MOBILE_SEARCH,
876+
)
877877

878878

879879
JS_SHOW_MOBILE_SEARCH = """
@@ -904,7 +904,7 @@ def anonymous_login_container(
904904

905905
with popover, gui.div(className="d-flex align-items-center overflow-hidden"):
906906
if not hide_sign_in:
907-
with gui.tag("a", href=login_url, className="pe-2 d-none d-lg-block"):
907+
with gui.tag("a", href=login_url, className="pe-2"):
908908
gui.html("Sign In")
909909
gui.html(
910910
templates.get_template("google_one_tap_button.html").render(**context)

widgets/explore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def build_meta_tags(url: str, search_filters: SearchFilters | None):
5353

5454

5555
def render(request: Request, search_filters: SearchFilters | None):
56-
sidebar_mobile_header(request.session)
56+
sidebar_mobile_header(request)
5757
with gui.div(className="my-4"):
5858
# note: using css instead of `if not search_filters: ...` stops re-render
5959
# of the search bar. this preserves focus/blur between query-param redirects

widgets/sidebar.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from starlette.requests import Request
12
import gooey_gui as gui
23
from daras_ai_v2 import settings
34
from textwrap import dedent
@@ -163,29 +164,39 @@ def render_default_sidebar(sidebar_ref: SidebarRef, request=None):
163164
sidebar_item_list(is_sidebar_open, current_url)
164165

165166

166-
def sidebar_mobile_header(session: dict):
167+
def sidebar_mobile_header(request: Request):
168+
from routers.root import anonymous_login_container
169+
167170
with gui.div(
168171
className="d-flex align-items-center justify-content-between d-md-none me-2 w-100 py-2",
169172
style={"height": "54px"},
170173
):
171-
sidebar_ref = use_sidebar("main-sidebar", session)
174+
sidebar_ref = use_sidebar("main-sidebar", request.session)
172175
gui.tag(
173176
"img",
174-
src=settings.GOOEY_LOGO_FACE,
175-
width=settings.SIDEBAR_ICON_SIZE,
176-
height=settings.SIDEBAR_ICON_SIZE,
177+
src=settings.GOOEY_LOGO_RECT,
178+
width="120px",
179+
height="auto",
177180
className=" logo-face",
178181
)
179-
open_mobile_sidebar = gui.button(
180-
label=icons.sidebar_flip,
181-
className="m-0",
182-
unsafe_allow_html=True,
183-
type="tertiary",
184-
style={"padding": "6px 10px"},
185-
)
186-
if open_mobile_sidebar:
187-
sidebar_ref.set_mobile_open(True)
188-
raise gui.RerunException()
182+
with gui.div(className="d-flex align-items-center gap-2"):
183+
anonymous_login_container(
184+
request,
185+
context={
186+
"request": request,
187+
"block_incognito": True,
188+
},
189+
)
190+
open_mobile_sidebar = gui.button(
191+
label=icons.sidebar_flip,
192+
className="m-0",
193+
unsafe_allow_html=True,
194+
type="tertiary",
195+
style={"padding": "6px 10px"},
196+
)
197+
if open_mobile_sidebar:
198+
sidebar_ref.set_mobile_open(True)
199+
raise gui.RerunException()
189200

190201

191202
# Sidebar width variables
@@ -242,13 +253,19 @@ def sidebar_layout(sidebar_ref: SidebarRef):
242253
@media (max-width: 767px) {{
243254
& .gooey-sidebar-open {{
244255
position: fixed;
256+
right: 0;
257+
left: auto;
245258
min-width: {sidebar_mobile_width};
246259
width: {sidebar_mobile_width};
247260
max-width: {sidebar_mobile_width};
248261
z-index: 2000;
262+
border-left: 1px solid #e0e0e0;
263+
border-right: none;
249264
}}
250265
& .gooey-sidebar-closed {{
251266
position: fixed;
267+
right: 0;
268+
left: auto;
252269
min-width: 0px;
253270
width: 0px;
254271
max-width: 0px;

0 commit comments

Comments
 (0)