44
55import reflex as rx
66from pcweb .components .docpage .navbar .state import NavbarState
7+ from .sidebar_items .cloud import cloud_items
78from .state import SidebarState , SideBarItem , SideBarBase
89
910from .sidebar_items .learn import learn , frontend , backend , hosting
1011from .sidebar_items .component_lib import (
1112 component_lib ,
1213 graphing_libs ,
1314)
15+ from .sidebar_items .ai_builder import ai_builder_items
1416from .sidebar_items .reference import api_reference
1517from .sidebar_items .recipes import recipes
1618from pcweb .styles .colors import c_color
@@ -217,6 +219,7 @@ def append_to_items(items, flat_items):
217219 + component_lib
218220 + graphing_libs
219221 + recipes
222+ + ai_builder_items
220223 + api_reference ,
221224 flat_items ,
222225)
@@ -342,6 +345,9 @@ def sidebar_comp(
342345 graphing_libs_index : list [int ],
343346 api_reference_index : list [int ],
344347 recipes_index : list [int ],
348+ #
349+ ai_builder_index : list [int ],
350+ cloud_index : list [int ],
345351 tutorials_index : list [int ],
346352 width : str = "100%" ,
347353):
@@ -355,110 +361,153 @@ def sidebar_comp(
355361 hosting as hosting_page ,
356362 )
357363 from pcweb .pages .docs .apiref import pages
364+ from pcweb .pages .docs .ai_builder import pages as ai_pages
365+ from pcweb .pages .docs .cloud import pages as cloud_pages
358366
359367 return rx .box (
360- rx .el .ul (
361- sidebar_category (
362- "Learn" , getting_started .introduction .path , "graduation-cap" , 0
368+ # ... hide/show the sidebar pills based on which product documentation we are on
369+ # ... ... main docs for the framework
370+ rx .cond (
371+ rx .State .router .page .path .contains ("docs" ),
372+ rx .el .ul (
373+ sidebar_category (
374+ "Learn" , getting_started .introduction .path , "graduation-cap" , 0
375+ ),
376+ sidebar_category ("Components" , library .path , "layout-panel-left" , 1 ),
377+ sidebar_category ("API Reference" , pages [0 ].path , "book-text" , 2 ),
378+ class_name = "flex flex-col items-start gap-1 w-full list-none" ,
363379 ),
364- sidebar_category ("Components" , library .path , "layout-panel-left" , 1 ),
365- sidebar_category (
366- "Deploy" , hosting_page .deploy_quick_start .path , "cloud" , 2
380+ ),
381+ # ... ... main docs for the ai builder
382+ rx .cond (
383+ rx .State .router .page .path .contains ("ai-builder" ),
384+ rx .el .ul (
385+ sidebar_category ("Quickstart" , ai_pages [0 ].path , "trending-up" , 0 ),
386+ sidebar_category ("Integrations" , ai_pages [1 ].path , "blocks" , 1 ),
387+ class_name = "flex flex-col items-start gap-1 w-full list-none" ,
367388 ),
368- sidebar_category ("API Reference" , pages [0 ].path , "book-text" , 3 ),
369- class_name = "flex flex-col items-start gap-1 w-full list-none" ,
370389 ),
371- rx .match (
372- SidebarState .sidebar_index ,
373- (
374- 0 ,
375- rx .el .ul (
376- create_sidebar_section (
377- "Onboarding" ,
378- getting_started .introduction .path ,
379- learn ,
380- learn_index ,
381- url ,
382- ),
383- create_sidebar_section (
384- "User Interface" ,
385- ui .overview .path ,
386- filter_out_non_sidebar_items (frontend ),
387- frontend_index ,
388- url ,
389- ),
390- create_sidebar_section (
391- "State" ,
392- state .overview .path ,
393- filter_out_non_sidebar_items (backend ),
394- backend_index ,
395- url ,
396- ),
397- create_sidebar_section (
398- "Recipes" , overview .path , recipes , recipes_index , url
399- ),
400- class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
390+ # ... ... main docs for the cloud
391+ rx .cond (
392+ rx .State .router .page .path .contains ("cloud" ),
393+ rx .el .ul (
394+ sidebar_category ("Cloud" , cloud_pages [0 ].path , "cloud" , 0 ),
395+ sidebar_category ("CLI Reference" , cloud_pages [0 ].path , "cloud" , 1 ),
396+ class_name = "flex flex-col items-start gap-1 w-full list-none" ,
397+ ),
398+ ),
399+ # ... hide/show the sidebar items (accordions etc...) based on which pill is selected
400+ rx .cond (
401+ rx .State .router .page .path .contains ("ai-builder" ),
402+ rx .el .ul (
403+ create_sidebar_section (
404+ "AI Builder" ,
405+ ai_pages [0 ].path ,
406+ ai_builder_items ,
407+ ai_builder_index ,
408+ url ,
401409 ),
410+ class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
402411 ),
403- (
404- 1 ,
405- rx .el .ul (
406- create_sidebar_section (
407- "Core" , library .path , component_lib , component_lib_index , url
408- ),
409- create_sidebar_section (
410- "Graphing" ,
411- library .path ,
412- graphing_libs ,
413- graphing_libs_index ,
414- url ,
412+ ),
413+ rx .cond (
414+ rx .State .router .page .path .contains ("cloud" ),
415+ rx .el .ul (
416+ create_sidebar_section (
417+ "Cloud" ,
418+ cloud_pages [0 ].path ,
419+ cloud_items ,
420+ cloud_index ,
421+ url ,
422+ ),
423+ class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
424+ ),
425+ ),
426+ rx .cond (
427+ rx .State .router .page .path .contains ("docs" ),
428+ rx .match (
429+ SidebarState .sidebar_index ,
430+ (
431+ 0 ,
432+ rx .el .ul (
433+ create_sidebar_section (
434+ "Onboarding" ,
435+ getting_started .introduction .path ,
436+ learn ,
437+ learn_index ,
438+ url ,
439+ ),
440+ create_sidebar_section (
441+ "User Interface" ,
442+ ui .overview .path ,
443+ filter_out_non_sidebar_items (frontend ),
444+ frontend_index ,
445+ url ,
446+ ),
447+ create_sidebar_section (
448+ "State" ,
449+ state .overview .path ,
450+ filter_out_non_sidebar_items (backend ),
451+ backend_index ,
452+ url ,
453+ ),
454+ create_sidebar_section (
455+ "Recipes" , overview .path , recipes , recipes_index , url
456+ ),
457+ class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
415458 ),
416- rx .link (
417- rx .box (
459+ ),
460+ (
461+ 1 ,
462+ rx .el .ul (
463+ create_sidebar_section (
464+ "Core" ,
465+ library .path ,
466+ component_lib ,
467+ component_lib_index ,
468+ url ,
469+ ),
470+ create_sidebar_section (
471+ "Graphing" ,
472+ library .path ,
473+ graphing_libs ,
474+ graphing_libs_index ,
475+ url ,
476+ ),
477+ rx .link (
418478 rx .box (
419- rx .icon ("atom" , size = 16 ),
420- rx .el .h5 (
421- "Custom Components" ,
422- class_name = "font-smbold text-[0.875rem] text-slate-12 leading-5 tracking-[-0.01313rem] transition-color" ,
479+ rx .box (
480+ rx .icon ("atom" , size = 16 ),
481+ rx .el .h5 (
482+ "Custom Components" ,
483+ class_name = "font-smbold text-[0.875rem] text-slate-12 leading-5 tracking-[-0.01313rem] transition-color" ,
484+ ),
485+ class_name = "flex flex-row items-center gap-3 text-slate-12" ,
423486 ),
424- class_name = "flex flex-row items-center gap-3 text-slate-12" ,
425- ) ,
426- rx . text (
427- "See what components people have made with Reflex!" ,
428- class_name = "font-small text- slate-9 " ,
487+ rx . text (
488+ "See what components people have made with Reflex!" ,
489+ class_name = "font-small text-slate-9" ,
490+ ) ,
491+ class_name = "flex flex-col gap-2 border- slate-5 bg-slate-1 hover:bg-slate-3 shadow-large px-3.5 py-2 border rounded-xl transition-bg " ,
429492 ),
430- class_name = "flex flex-col gap-2 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-large px-3.5 py-2 border rounded-xl transition-bg" ,
493+ underline = "none" ,
494+ href = custom_components .path ,
431495 ),
432- underline = "none" ,
433- href = custom_components .path ,
434- ),
435- class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
436- ),
437- ),
438- (
439- 2 ,
440- rx .el .ul (
441- create_sidebar_section (
442- "Hosting" ,
443- hosting_page .deploy_quick_start .path ,
444- hosting ,
445- hosting_index ,
446- url ,
496+ class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
447497 ),
448- class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
449498 ),
450- ),
451- (
452- 3 ,
453- rx .el .ul (
454- create_sidebar_section (
455- "Reference" ,
456- pages [0 ].path ,
457- api_reference ,
458- api_reference_index ,
459- url ,
499+ (
500+ 2 ,
501+ rx .el .ul (
502+ create_sidebar_section (
503+ "Reference" ,
504+ pages [0 ].path ,
505+ api_reference ,
506+ api_reference_index ,
507+ url ,
508+ ),
509+ class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
460510 ),
461- class_name = "flex flex-col items-start gap-6 p-[0px_1rem_0px_0.5rem] w-full list-none list-style-none" ,
462511 ),
463512 ),
464513 ),
@@ -485,6 +534,9 @@ def sidebar(url=None, width: str = "100%") -> rx.Component:
485534 api_reference_index = calculate_index (api_reference , url )
486535 recipes_index = calculate_index (recipes , url )
487536
537+ cloud_index = calculate_index (cloud_items , url )
538+ ai_builder_index = calculate_index (ai_builder_items , url )
539+
488540 return rx .box (
489541 sidebar_comp (
490542 url = url ,
@@ -496,6 +548,10 @@ def sidebar(url=None, width: str = "100%") -> rx.Component:
496548 graphing_libs_index = graphing_libs_index ,
497549 api_reference_index = api_reference_index ,
498550 recipes_index = recipes_index ,
551+ #
552+ cloud_index = cloud_index ,
553+ ai_builder_index = ai_builder_index ,
554+ #
499555 width = width ,
500556 ),
501557 class_name = "flex justify-end w-full h-full" ,
0 commit comments