From 756a7c3dac401f531d0ce941f7e0e09c3773634d Mon Sep 17 00:00:00 2001 From: Tom Gotsman Date: Thu, 16 Nov 2023 17:18:16 -0800 Subject: [PATCH 1/4] update sidebar structure --- pcweb/components/sidebar.py | 118 +++++++++++++++++++++++++++--------- 1 file changed, 89 insertions(+), 29 deletions(-) diff --git a/pcweb/components/sidebar.py b/pcweb/components/sidebar.py index dd0afa3f5..2dde93de3 100644 --- a/pcweb/components/sidebar.py +++ b/pcweb/components/sidebar.py @@ -106,17 +106,11 @@ def get_sidebar_items_learn(): return items -def get_sidebar_items_concepts(): +def get_sidebar_items_frontend(): from pcweb.pages.docs import ( - advanced_guide, components, - database, - hosting, - state, styling, - wrapping_react, ) - items = [ create_item( components, @@ -128,6 +122,25 @@ def get_sidebar_items_concepts(): components.library, ], ), + create_item( + styling, + children=[ + styling.styling_overview, + styling.responsive, + styling.custom_stylesheets, + styling.theming, + ], + ), + ] + return items + +def get_sidebar_items_backend(): + from pcweb.pages.docs import ( + state, + database, + ) + + items = [ create_item( state, children=[ @@ -138,15 +151,6 @@ def get_sidebar_items_concepts(): state.utility_methods, ], ), - create_item( - styling, - children=[ - styling.styling_overview, - styling.responsive, - styling.custom_stylesheets, - styling.theming, - ], - ), create_item( database, children=[ @@ -156,6 +160,17 @@ def get_sidebar_items_concepts(): database.relationships, ], ), + ] + return items + +def get_sidebar_items_other(): + from pcweb.pages.docs import ( + advanced_guide, + hosting, + wrapping_react, + ) + + items = [ create_item( hosting, children=[ @@ -369,13 +384,15 @@ def calculate_index(sidebar_items, url): learn = get_sidebar_items_learn() -concepts = get_sidebar_items_concepts() reference = get_sidebar_items_reference() +frontend = get_sidebar_items_frontend() +backend = get_sidebar_items_backend() +other = get_sidebar_items_other() def get_prev_next(url): """Get the previous and next links in the sidebar.""" - sidebar_items = learn + concepts + reference + sidebar_items = learn + frontend + backend + other + reference # Flatten the list of sidebar items flat_items = [] @@ -408,8 +425,10 @@ def append_to_items(items): def sidebar_comp( url: str, learn_index: list[int], - concepts_index: list[int], reference_index: list[int], + frontend_index: list[int], + backend_index: list[int], + other_index: list[int], ): from pcweb.pages.docs.gallery import gallery @@ -417,13 +436,13 @@ def sidebar_comp( rx.tabs( rx.tab_list( rx.tab("Learn"), - rx.tab("Concepts"), + rx.tab("API Reference"), ), rx.tab_panels( rx.tab_panel( rx.heading( rx.span("[ ", color="#DACEEE"), - "Learn", + "Onboarding", rx.span(" ]", color="#DACEEE"), style=heading_style3, ), @@ -440,9 +459,10 @@ def sidebar_comp( allow_multiple=True, default_index=learn_index, ), + rx.heading( rx.span("[ ", color="#DACEEE"), - "Concepts", + "Frontend", rx.span(" ]", color="#DACEEE"), style=heading_style3, margin_top="1em", @@ -455,20 +475,56 @@ def sidebar_comp( url=url, first=True, ) - for item in concepts + for item in frontend ], allow_multiple=True, - default_index=concepts_index, + default_index=frontend_index, ), - ), - rx.tab_panel( + + rx.heading( + rx.span("[ ", color="#DACEEE"), + "Backend", + rx.span(" ]", color="#DACEEE"), + style=heading_style3, + margin_top="1em", + ), + rx.accordion( + *[ + sidebar_item_comp( + item=item, + index=[-1], + url=url, + first=True, + ) + for item in backend + ], + allow_multiple=True, + default_index=backend_index, + ), + rx.heading( rx.span("[ ", color="#DACEEE"), - "Reference", + "Other", rx.span(" ]", color="#DACEEE"), style=heading_style3, margin_top="1em", ), + rx.accordion( + *[ + sidebar_item_comp( + item=item, + index=[-1], + url=url, + first=True, + ) + for item in other + ], + allow_multiple=True, + default_index=other_index, + ), + ), + + rx.tab_panel( rx.accordion( *[ sidebar_item_comp( @@ -503,14 +559,18 @@ def sidebar_comp( def sidebar(url=None) -> rx.Component: """Render the sidebar.""" learn_index = calculate_index(learn, url) - concepts_index = calculate_index(concepts, url) reference_index = calculate_index(reference, url) + frontend_index = calculate_index(frontend, url) + backend_index = calculate_index(backend, url) + other_index = calculate_index(other, url) return rx.box( sidebar_comp( url=url, learn_index=learn_index, - concepts_index=concepts_index, reference_index=reference_index, + frontend_index=frontend_index, + backend_index=backend_index, + other_index=other_index, ), padding_right="2em", ) From 28a93e18a9529dc8d3cf9e882441701b0a89dc0d Mon Sep 17 00:00:00 2001 From: Tom Gotsman Date: Tue, 28 Nov 2023 15:58:35 -0800 Subject: [PATCH 2/4] minor bug fix --- pcweb/components/sidebar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcweb/components/sidebar.py b/pcweb/components/sidebar.py index 75c7946b9..202e9ea39 100644 --- a/pcweb/components/sidebar.py +++ b/pcweb/components/sidebar.py @@ -524,7 +524,7 @@ def sidebar_comp( for item in frontend ], allow_multiple=True, - default_index=frontend_index if frontend is not None else [], + default_index=frontend_index if frontend_index is not None else [], ), rx.heading( From c575db6551656e58d204ab5d79585eda4d56ee89 Mon Sep 17 00:00:00 2001 From: Tom Gotsman Date: Tue, 28 Nov 2023 16:05:44 -0800 Subject: [PATCH 3/4] minor naming change --- pcweb/components/sidebar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcweb/components/sidebar.py b/pcweb/components/sidebar.py index 202e9ea39..98a5521de 100644 --- a/pcweb/components/sidebar.py +++ b/pcweb/components/sidebar.py @@ -471,7 +471,7 @@ def sidebar_comp( rx.tab( rx.hstack( rx.image(src="/icons/ref.svg", height="1em"), - rx.text("API Reference"), + rx.text("Reference"), on_click=lambda: SidebarState.set_sidebar_index(1), ), padding_left="0em", From 11a3b677fe999054bc571009e7caaf567209e7af Mon Sep 17 00:00:00 2001 From: Tom Gotsman Date: Tue, 28 Nov 2023 16:16:14 -0800 Subject: [PATCH 4/4] minor naming change2 --- pcweb/components/sidebar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcweb/components/sidebar.py b/pcweb/components/sidebar.py index 98a5521de..369172ec2 100644 --- a/pcweb/components/sidebar.py +++ b/pcweb/components/sidebar.py @@ -358,7 +358,7 @@ def sidebar_item_comp( rx.text( item.names, font_family=styles.SANS, - font_weight="600", + font_weight="500", ), _hover={ "color": styles.ACCENT_COLOR,