Skip to content

Commit

Permalink
Get sidebar to deployable state (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alek99 authored Jan 22, 2024
1 parent 42ec6f6 commit 515422b
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 122 deletions.
10 changes: 6 additions & 4 deletions pcweb/components/navbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,12 @@ def search_results(self) -> list[dict[str, dict[str, str]]]:
"sort_by": "_text_match:desc",
"filter_by": f"category: {self.current_category}",
}
typesense_collection_name = os.gentenv("TYPESENSE_COLLECTION_NAME", "search-auto")
return client.collections[typesense_collection_name].documents.search(search_parameters)[
"hits"
]
typesense_collection_name = os.gentenv(
"TYPESENSE_COLLECTION_NAME", "search-auto"
)
return client.collections[typesense_collection_name].documents.search(
search_parameters
)["hits"]


def search_bar():
Expand Down
248 changes: 131 additions & 117 deletions pcweb/components/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ def get_sidebar_items_hosting():
hosting.hosting_cli_commands,
],
),
create_item(hosting.self_hosting),
create_item(
"Self Hosting",
children=[hosting.self_hosting],
),
]
return items

Expand Down Expand Up @@ -464,6 +467,7 @@ def sidebar_item_comp(
},
color="#494369",
width="100%",
min_width="10em",
),
rx.accordion_panel(
rx.accordion(
Expand All @@ -486,6 +490,7 @@ def sidebar_item_comp(
width="100%",
),
border="none",
width="100%",
),
)

Expand Down Expand Up @@ -556,134 +561,142 @@ def sidebar_comp(
other_libs_index: list[int],
):
return rx.vstack(
rx.tabs(
rx.tab_list(
rx.tab(
rx.hstack(
rx.image(src="/icons/doc.svg", height="1em"),
rx.text("Learn"),
on_click=lambda: SidebarState.set_sidebar_index(0),
),
color="#494369",
padding_left="0em",
rx.box(
rx.text(
"Learn",
font_weight= fw["section"],
font_size= styles.TEXT_FONT_SIZE,
color= "#696287",
),
on_click=lambda: SidebarState.set_sidebar_index(0),
background=rx.cond(
SidebarState.sidebar_index == 0,
"#F5EFFE",
"transparent",
),
align_items="left",
padding_y="0.5em",
padding_x="0.5em",
border_radius="0.5em",
border="2px solid #F4F3F6",
width="100%",
),
rx.box(
rx.text(
"Reference",
font_weight= fw["section"],
font_size= styles.TEXT_FONT_SIZE,
color= "#696287",
),
on_click=lambda: SidebarState.set_sidebar_index(1),
background=rx.cond(
SidebarState.sidebar_index == 1,
"#F5EFFE",
"transparent",
),
align_items="left",
padding_y="0.5em",
padding_x="0.5em",
border_radius="0.5em",
border="2px solid #F4F3F6",
width="100%",
),
rx.divider(),
rx.cond(
SidebarState.sidebar_index == 0,
rx.vstack(
sidebar_section("Onboarding"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in learn
],
allow_multiple=True,
default_index=learn_index if learn_index is not None else [],
width="100%",
),
rx.tab(
rx.hstack(
rx.image(src="/icons/ref.svg", height="1em"),
rx.text("Reference"),
on_click=lambda: SidebarState.set_sidebar_index(1),
),
padding_left="0em",
color="#494369",
sidebar_section("UI"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in frontend
],
allow_multiple=True,
default_index=frontend_index if frontend_index is not None else [],
width="100%",
),
color="#494369",
margin_left="1.1em",
align="left",
font_weight="450",
),
rx.tab_panels(
rx.tab_panel(
sidebar_section("Onboarding"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in learn
],
allow_multiple=True,
default_index=learn_index if learn_index is not None else [],
width="100%",
),
sidebar_section("UI"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in frontend
],
allow_multiple=True,
default_index=frontend_index
if frontend_index is not None
else [],
width="100%",
),
sidebar_section("State"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in backend
],
allow_multiple=True,
default_index=backend_index
if backend_index is not None
else [],
width="100%",
),
sidebar_section("Hosting"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in hosting
],
allow_multiple=True,
default_index=hosting_index
if hosting_index is not None
else [],
width="100%",
),
padding_x="0em",
sidebar_section("State"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in backend
],
allow_multiple=True,
default_index=backend_index if backend_index is not None else [],
width="100%",
),
rx.tab_panel(
sidebar_section("Core"),
rx.accordion(
*[
sidebar_item_comp(item=item, url=url, index=reference_index)
for item in reference
],
allow_multiple=True,
default_index=reference_index
if reference_index is not None
else [],
),
sidebar_section("Other Libraries"),
rx.accordion(
*[
sidebar_item_comp(
item=item, url=url, index=other_libs_index
)
for item in other_libs
],
allow_multiple=True,
default_index=other_libs_index
if other_libs_index is not None
else [],
),
padding_x="0em",
sidebar_section("Hosting"),
rx.accordion(
*[
sidebar_item_comp(
item=item,
index=[-1],
url=url,
)
for item in hosting
],
allow_multiple=True,
default_index=hosting_index if hosting_index is not None else [],
width="100%",
),
padding_x="0em",
width="100%",
align_items="start",
),
rx.vstack(
sidebar_section("Core"),
rx.accordion(
*[
sidebar_item_comp(item=item, url=url, index=reference_index)
for item in reference
],
allow_multiple=True,
default_index=reference_index
if reference_index is not None
else [],
),
sidebar_section("Other Libraries"),
rx.accordion(
*[
sidebar_item_comp(item=item, url=url, index=other_libs_index)
for item in other_libs
],
allow_multiple=True,
default_index=other_libs_index
if other_libs_index is not None
else [],
),
padding_x="0em",
width="100%",
align_items="start",
),
index=SidebarState.sidebar_index,
width="100%",
),
align_items="start",
overflow_y="scroll",
max_height="90%",
width="17em",
padding_bottom="6em",
position="fixed",
scroll_padding="1em",
Expand Down Expand Up @@ -717,6 +730,7 @@ def sidebar(url=None) -> rx.Component:
hosting_index=hosting_index,
other_libs_index=other_libs_index,
),
width="100%",
)


Expand Down
4 changes: 3 additions & 1 deletion scripts/search_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,6 @@ def upload_docs(collection_name: str, docs: list[Doc]):
print("\033[92mUpload complete!")
else:
print(json.dumps(docs, indent=4))
print("\033[96m[set --upload and --collection-name to actually publish to Typesense Cloud]")
print(
"\033[96m[set --upload and --collection-name to actually publish to Typesense Cloud]"
)

0 comments on commit 515422b

Please sign in to comment.