Skip to content

Commit

Permalink
fix: show AppBar when Tabs are the only children
Browse files Browse the repository at this point in the history
  • Loading branch information
iisakkirotko committed May 21, 2024
1 parent f35c9bb commit 1f72013
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions solara/components/applayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,6 @@ def AppLayout(
use_drawer = True
title = t.use_title_get() or title
children_appbartitle = apptitle_portal.use_portal()
show_app_bar = (title and (len(routes) > 1 and navigation)) or children_appbar or use_drawer or children_appbartitle

if style is None:
style = {"height": "100%", "max-height": "100%", "overflow": "auto"}
# if style is None, we choose a default style based on whether we are seeing the appbar, etc
if show_app_bar or children_sidebar or len(children) != 1:
style["padding"] = "12px"

def set_path(index):
path = paths[index]
Expand All @@ -272,24 +265,32 @@ def set_path(index):
v_slots = []

tabs = None
tabs_to_render = None
for child_appbar in children_appbar.copy():
if child_appbar.component == solara.lab.Tabs:
if tabs is not None:
raise ValueError("Only one Tabs component is allowed in the AppBar")
tabs = child_appbar
children_appbar.remove(tabs)

show_app_bar = (title and (len(routes) > 1 and navigation)) or bool(children_appbar) or bool(use_drawer) or bool(children_appbartitle) or bool(tabs)

if style is None:
style = {"height": "100%", "max-height": "100%", "overflow": "auto"}
# if style is None, we choose a default style based on whether we are seeing the appbar, etc
if show_app_bar or children_sidebar or len(children) != 1:
style["padding"] = "12px"

if (tabs is None) and routes and navigation and (len(routes) > 1):
with solara.lab.Tabs(value=index, on_value=set_path, align="center") as tabs:
with solara.lab.Tabs(value=index, on_value=set_path, align="center") as tabs_to_render:
for route in routes:
name = route.path if route.path != "/" else "Home"
solara.lab.Tab(name)
# with v.Tabs(v_model=index, on_v_model=set_path, centered=True) as tabs:
# for route in routes:
# name = route.path if route.path != "/" else "Home"
# v.Tab(children=[name])

if tabs is not None:
v_slots = [{"name": "extension", "children": tabs}]
tabs_to_render = tabs
if tabs_to_render is not None:
v_slots = [{"name": "extension", "children": tabs_to_render}]
if embedded_mode and not fullscreen:
# this version doesn't need to run fullscreen
# also ideal in jupyter notebooks
Expand Down

0 comments on commit 1f72013

Please sign in to comment.