Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve feedback of new docs navigation #566

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions solara/website/pages/documentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@ def Page(children=[]):
@solara.component
def Sidebar():
route_current, all_routes = solara.use_route()
router = solara.use_router()
if route_current is None:
return solara.Error("Page not found")

with solara.v.NavigationDrawer(
clipped=True, width="20rem", height="unset", style_="min-height: calc(100vh - 215.5px);", class_="d-none d-md-block"
) as main:
with solara.v.List(expand=True, nav=True, style_="height: calc(100vh - 215.5px); display: flex; flex-direction: column;"):
with solara.v.ListItemGroup():
with solara.v.ListItemGroup(v_model=router.path):
for route in all_routes:
if len(route.children) == 1 or route.path == "/":
with solara.Link("/documentation/" + route.path if route.path != "/" else "/documentation"):
with solara.v.ListItem():
with solara.v.ListItem(value="/documentation/" + route.path if route.path != "/" else "/documentation"):
if route.path == "/":
solara.v.ListItemIcon(children=[solara.v.Icon(children=["mdi-home"])])
solara.v.ListItemTitle(style_="padding: 0 20px;", children=[route.label])
Expand All @@ -107,7 +108,8 @@ def Sidebar():
style_="padding: 0 20px;",
),
}
]
],
value=router.path.startswith("/documentation/" + route.path),
):
for item in route.children:
if item.path == "/":
Expand All @@ -124,6 +126,7 @@ def Sidebar():
],
sub_group=True,
no_action=True,
value=router.path.startswith("/documentation/" + route.path + "/" + item.path),
):
for subitem in item.children:
# skip pages that are only used to demonstrate Link or Router usage
Expand All @@ -137,19 +140,19 @@ def Sidebar():
with solara.Link(
path,
):
with solara.v.ListItem(dense=True, style_="padding: 0 20px;"):
with solara.v.ListItem(dense=True, style_="padding: 0 20px;", value=path):
solara.v.ListItemContent(
children=[subitem.label],
)
else:
with solara.v.ListItemGroup():
with solara.Link(
"/documentation/" + route.path + "/" + item.path,
):
with solara.v.ListItem(dense=True, style_="padding: 0 20px;"):
solara.v.ListItemContent(
children=[item.label],
)
else:
with solara.v.ListItemGroup(value="/documentation/" + route.path + "/" + item.path):
with solara.Link(
"/documentation/" + route.path + "/" + item.path,
):
with solara.v.ListItem(dense=True, style_="padding: 0 20px;"):
solara.v.ListItemContent(
children=[item.label],
)
solara.v.Spacer(style_="flex-grow: 1;")
with solara.v.ListItemGroup():
with solara.Link("/contact"):
Expand Down
1 change: 0 additions & 1 deletion tests/integration/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_docs_basics(page_session: playwright.sync_api.Page, solara_server, sola
page_session.locator("text=+/-").wait_for()
page_session.screenshot(path="tmp/screenshot_calculator.png")

page_session.locator("text=Examples").first.click()
page_session.locator("text=Libraries").first.click()
page_session.locator("text=Bqplot").first.click()
page_session.locator("text=Exponent").wait_for()
Expand Down
Loading