instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
.HTTPError, json.JSONDecodeError) as ex:
print(f"Internal error: failed to fetch components list due to: {ex}")
return
for c in component_list:
c["downloads_last_month"] = c["downloads"]["last_month"]
c["keywords"] = [
keyword
for keyword in c["keywords"] or []
if "reflex" not in keyword.lower()
]
c["download_url"] = package_url(c["package_name"])
async with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
|
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.sel | self.current_page = (self.offset // self.current_limit) + 1 |
return
for c in component_list:
c["downloads_last_month"] = c["downloads"]["last_month"]
c["keywords"] = [
keyword
for keyword in c["keywords"] or []
if "reflex" not in keyword.lower()
]
c["download_url"] = package_url(c["package_name"])
async with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
|
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_fu | self.current_limit = int(limit) |
_list:
c["downloads_last_month"] = c["downloads"]["last_month"]
c["keywords"] = [
keyword
for keyword in c["keywords"] or []
if "reflex" not in keyword.lower()
]
c["download_url"] = package_url(c["package_name"])
async with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
|
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
| self.offset = 0 |
wnloads_last_month"] = c["downloads"]["last_month"]
c["keywords"] = [
keyword
for keyword in c["keywords"] or []
if "reflex" not in keyword.lower()
]
c["download_url"] = package_url(c["package_name"])
async with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
|
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.so | self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit |
[]
if "reflex" not in keyword.lower()
]
c["download_url"] = package_url(c["package_name"])
async with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
|
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is | def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate() |
in keyword.lower()
]
c["download_url"] = package_url(c["package_name"])
async with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
|
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first | if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0 |
with self:
self.original_components_list = component_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
|
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first | self.offset = 0 |
ponent_list
self.number_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
|
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1 | def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate() |
ber_of_rows = len(component_list)
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
|
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows | if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit |
f.current_limit
yield CustomComponentGalleryState.paginate()
@rx.event
def paginate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
|
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-fu | def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate() |
inate(self) -> None:
start = self.offset
end = start + self.current_limit
self.paginated_data = self.original_components_list[start:end]
self.current_page = (self.offset // self.current_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
|
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, | sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
) |
_limit) + 1
@rx.event
def delta_limit(self, limit: str) -> None:
self.current_limit = int(limit)
self.offset = 0
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit
self.paginate()
@rx.event
def previous(self) -> None:
if self.offset >= self.current_limit:
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
|
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
| if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False) |
self.offset -= self.current_limit
else:
self.offset = 0
self.paginate()
@rx.event
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
| # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" if border else "none",
on_click=on_click,
)
chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-s | def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() |
def next(self) -> None:
if self.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
|
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap over | self.selected_filter = filter_text |
.offset + self.current_limit < self.number_of_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
| # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px] | self.offset = 0 |
f_rows:
self.offset += self.current_limit
self.paginate()
@rx.event
def sort_components(self):
# Get the sorting function based on the selected filter
sorting_function = SORTING_CRITERIA.get(
self.selected_filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
| # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" i | self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit |
filter, lambda x: x["updated_at"]
)
# Both "Recent" and "Downloads" should be sorted in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
|
chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-sizing": "border-box",
"display": "flex",
"flex-direction": "row",
"align_items": "center",
"padding": "6px 12px",
"cursor": "pointer",
"box-shadow": shadows["large"],
"border-radius": "1000px",
"transition": "background 0.075s ease-out, color 0.075s ease-out, border 0.075s ease-out",
}
# Sorting
sorting_box_style = {
"gap": "12px",
"outline": "none",
"_focus": {
"outline": "none",
},
**chips_box_style,
}
menu_item_style = {
"box-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
}
def sorting_filters() -> rx.Component:
return rx.vstack(
| def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" if border else "none",
on_click=on_click,
) |
in reverse order (newest/highest first)
if self.selected_filter in ["Recent", "Downloads"]:
self.original_components_list.sort(key=sorting_function, reverse=True)
else:
# Default sorting behavior, if no filter selected
self.original_components_list.sort(key=sorting_function, reverse=False)
# After sorting, paginate the data
self.paginate()
@rx.event
def set_selected_filter(self, filter_text: str):
# Reset to the first page when the filter is changed
self.selected_filter = filter_text
self.offset = 0 # Reset pagination
self.total_pages = (
self.number_of_rows + self.current_limit - 1
) // self.current_limit # Recalculate total pages
self.sort_components() # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
|
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" if border else "none",
on_click=on_click,
)
chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-sizing": "border-box",
"display": "flex",
"flex-direction": "row",
"align_items": "center",
"padding": "6px 12px",
"cursor": "pointer",
"box-shadow": shadows["large"],
| is_selected = CustomComponentGalleryState.selected_filter == text |
) # Sort components based on selected filter
self.paginate() # Update paginated data
def filter_item(
icon: str, text: str, border: bool = False, on_click=None
) -> rx.Component:
is_selected = CustomComponentGalleryState.selected_filter == text
return rx.box(
get_icon(icon, class_name="py-[2px]", opacity=rx.cond(is_selected, 0.64, 1)),
rx.text(text, opacity=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" if border else "none",
on_click=on_click,
)
|
# Sorting
sorting_box_style = {
"gap": "12px",
"outline": "none",
"_focus": {
"outline": "none",
},
**chips_box_style,
}
menu_item_style = {
"box-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
}
def sorting_filters() -> rx.Component:
return rx.vstack(
filter_item(
"history",
"Recent",
on_click=lambda: CustomComponentGalleryState.set_selected_filter("Recent"),
),
filter_item(
"arrow_down_big",
"Downloads",
border=True,
on_click=lambda: CustomComponentGalleryState.set_selected_filter(
"Downloads"
),
| chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-sizing": "border-box",
"display": "flex",
"flex-direction": "row",
"align_items": "center",
"padding": "6px 12px",
"cursor": "pointer",
"box-shadow": shadows["large"],
"border-radius": "1000px",
"transition": "background 0.075s ease-out, color 0.075s ease-out, border 0.075s ease-out",
} |
=rx.cond(is_selected, 0.64, 1), class_name="font-small"),
rx.spacer(),
rx.cond(
is_selected,
rx.box(
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" if border else "none",
on_click=on_click,
)
chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-sizing": "border-box",
"display": "flex",
"flex-direction": "row",
"align_items": "center",
"padding": "6px 12px",
"cursor": "pointer",
"box-shadow": shadows["large"],
"border-radius": "1000px",
"transition": "background 0.075s ease-out, color 0.075s ease-out, border 0.075s ease-out",
}
# Sorting
|
menu_item_style = {
"box-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
}
def sorting_filters() -> rx.Component:
return rx.vstack(
filter_item(
"history",
"Recent",
on_click=lambda: CustomComponentGalleryState.set_selected_filter("Recent"),
),
filter_item(
"arrow_down_big",
"Downloads",
border=True,
on_click=lambda: CustomComponentGalleryState.set_selected_filter(
"Downloads"
),
),
gap="0px",
width="100%",
)
def sorting_filters_dropdown_menu() -> rx.Component:
condition = CustomComponentGallerySta | sorting_box_style = {
"gap": "12px",
"outline": "none",
"_focus": {
"outline": "none",
},
**chips_box_style,
} |
class_name="size-2 justify-end bg-violet-9 rounded-full",
),
),
class_name="flex flex-row gap-[14px] items-center justify-start w-full cursor-pointer hover:bg-slate-3 transition-bg text-nowrap overflow-hidden p-[8px_14px]",
border_top=f"1px solid {c_color('slate', 5)}" if border else "none",
border_bottom=f"1px solid {c_color('slate', 5)}" if border else "none",
on_click=on_click,
)
chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-sizing": "border-box",
"display": "flex",
"flex-direction": "row",
"align_items": "center",
"padding": "6px 12px",
"cursor": "pointer",
"box-shadow": shadows["large"],
"border-radius": "1000px",
"transition": "background 0.075s ease-out, color 0.075s ease-out, border 0.075s ease-out",
}
# Sorting
sorting_box_style = {
"gap": "12px",
"outline": "none",
"_focus": {
"outline": "none",
},
**chips_box_style,
}
|
def sorting_filters() -> rx.Component:
return rx.vstack(
filter_item(
"history",
"Recent",
on_click=lambda: CustomComponentGalleryState.set_selected_filter("Recent"),
),
filter_item(
"arrow_down_big",
"Downloads",
border=True,
on_click=lambda: CustomComponentGalleryState.set_selected_filter(
"Downloads"
),
),
gap="0px",
width="100%",
)
def sorting_filters_dropdown_menu() -> rx.Component:
condition = CustomComponentGalleryState.selected_filter != ""
conditional_style = {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 1),
),
"color": rx.cond(
condition,
"white",
c_color("slate", 9),
),
"border": rx.cond(
condition,
f"1px solid {c_color('violet', 9)}", | menu_item_style = {
"box-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
} |
, 5)}" if border else "none",
on_click=on_click,
)
chips_box_style = {
"width": ["100%", "100%", "auto"],
"box-sizing": "border-box",
"display": "flex",
"flex-direction": "row",
"align_items": "center",
"padding": "6px 12px",
"cursor": "pointer",
"box-shadow": shadows["large"],
"border-radius": "1000px",
"transition": "background 0.075s ease-out, color 0.075s ease-out, border 0.075s ease-out",
}
# Sorting
sorting_box_style = {
"gap": "12px",
"outline": "none",
"_focus": {
"outline": "none",
},
**chips_box_style,
}
menu_item_style = {
"box-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
}
|
def sorting_filters_dropdown_menu() -> rx.Component:
condition = CustomComponentGalleryState.selected_filter != ""
conditional_style = {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 1),
),
"color": rx.cond(
condition,
"white",
c_color("slate", 9),
),
"border": rx.cond(
condition,
f"1px solid {c_color('violet', 9)}",
f"1px solid {c_color('slate', 5)}",
),
"&[data-state='open']": {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 3),
),
},
"_hover": {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 3),
),
},
}
return rx.menu.root(
rx.menu.trigger(
| def sorting_filters() -> rx.Component:
return rx.vstack(
filter_item(
"history",
"Recent",
on_click=lambda: CustomComponentGalleryState.set_selected_filter("Recent"),
),
filter_item(
"arrow_down_big",
"Downloads",
border=True,
on_click=lambda: CustomComponentGalleryState.set_selected_filter(
"Downloads"
),
),
gap="0px",
width="100%",
) |
one",
},
**chips_box_style,
}
menu_item_style = {
"box-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
}
def sorting_filters() -> rx.Component:
return rx.vstack(
filter_item(
"history",
"Recent",
on_click=lambda: CustomComponentGalleryState.set_selected_filter("Recent"),
),
filter_item(
"arrow_down_big",
"Downloads",
border=True,
on_click=lambda: CustomComponentGalleryState.set_selected_filter(
"Downloads"
),
),
gap="0px",
width="100%",
)
def sorting_filters_dropdown_menu() -> rx.Component:
|
conditional_style = {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 1),
),
"color": rx.cond(
condition,
"white",
c_color("slate", 9),
),
"border": rx.cond(
condition,
f"1px solid {c_color('violet', 9)}",
f"1px solid {c_color('slate', 5)}",
),
"&[data-state='open']": {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 3),
),
},
"_hover": {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 3),
),
},
}
return rx.menu.root(
rx.menu.trigger(
rx.el.button(
rx.text(
"Sort",
rx.cond(
c | condition = CustomComponentGalleryState.selected_filter != "" |
x-sizing": "border-box",
"width": "191px",
"height": "auto",
"overflow": "hidden",
"padding": "0px",
"cursor": "default",
"background_color": c_color("slate", 2),
"border": f"1px solid {c_color('slate', 5)}",
"box-shadow": "0px 2px 4px rgba(0, 0, 0, 0.05)",
"border-radius": "12px",
"color": c_color("slate", 9),
**base,
}
def sorting_filters() -> rx.Component:
return rx.vstack(
filter_item(
"history",
"Recent",
on_click=lambda: CustomComponentGalleryState.set_selected_filter("Recent"),
),
filter_item(
"arrow_down_big",
"Downloads",
border=True,
on_click=lambda: CustomComponentGalleryState.set_selected_filter(
"Downloads"
),
),
gap="0px",
width="100%",
)
def sorting_filters_dropdown_menu() -> rx.Component:
condition = CustomComponentGalleryState.selected_filter != ""
|
return rx.menu.root(
rx.menu.trigger(
rx.el.button(
rx.text(
"Sort",
rx.cond(
condition,
rx.text(
f": {CustomComponentGalleryState.selected_filter}",
as_="span",
class_name="text-nowrap",
),
),
as_="span",
class_name="font-small",
),
get_icon(
icon="select",
),
justify_content="space-between",
),
style=sorting_box_style | conditional_style,
),
rx.menu.content(
rx.menu.item(sorting_filters(), style=menu_item_style),
bg="transparent",
box_shadow="None",
padding="0px",
overflow="visible",
border="none",
| conditional_style = {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 1),
),
"color": rx.cond(
condition,
"white",
c_color("slate", 9),
),
"border": rx.cond(
condition,
f"1px solid {c_color('violet', 9)}",
f"1px solid {c_color('slate', 5)}",
),
"&[data-state='open']": {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 3),
),
},
"_hover": {
"background": rx.cond(
condition,
c_color("violet", 9),
c_color("slate", 3),
),
},
} |
.button(
rx.text(
"Sort",
rx.cond(
condition,
rx.text(
f": {CustomComponentGalleryState.selected_filter}",
as_="span",
class_name="text-nowrap",
),
),
as_="span",
class_name="font-small",
),
get_icon(
icon="select",
),
justify_content="space-between",
),
style=sorting_box_style | conditional_style,
),
rx.menu.content(
rx.menu.item(sorting_filters(), style=menu_item_style),
bg="transparent",
box_shadow="None",
padding="0px",
overflow="visible",
border="none",
align="center",
),
width="100%",
)
|
def download(download_url: str) -> rx.Component:
return rx.link(
get_icon(icon="new_tab"),
underline="none",
href=download_url,
is_external=True,
class_name="text-slate-9 hover:!text-slate-9 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer rounded-[6px]",
title="Documentation",
)
def table_rows(category: dict):
name = rx.Var(
f"{category['package_name']!s}.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')",
)
updated_at = rx.Var(
f"({category['updated_at']}).split('T')[0].split('-').map((part, index) => index === 1 ? 'JanFebMarAprMayJunJulAugSepOctNovDec'.slice(part * 3, part * 3 + 3) : part.padStart(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
)
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.te | def package_url(package_name: str) -> str:
return f"https://pypi.org/pypi/{package_name}/" |
condition,
rx.text(
f": {CustomComponentGalleryState.selected_filter}",
as_="span",
class_name="text-nowrap",
),
),
as_="span",
class_name="font-small",
),
get_icon(
icon="select",
),
justify_content="space-between",
),
style=sorting_box_style | conditional_style,
),
rx.menu.content(
rx.menu.item(sorting_filters(), style=menu_item_style),
bg="transparent",
box_shadow="None",
padding="0px",
overflow="visible",
border="none",
align="center",
),
width="100%",
)
def package_url(package_name: str) -> str:
return f"https://pypi.org/pypi/{package_name}/"
|
def table_rows(category: dict):
name = rx.Var(
f"{category['package_name']!s}.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')",
)
updated_at = rx.Var(
f"({category['updated_at']}).split('T')[0].split('-').map((part, index) => index === 1 ? 'JanFebMarAprMayJunJulAugSepOctNovDec'.slice(part * 3, part * 3 + 3) : part.padStart(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
)
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.text(
"pip install " + category["package_name"],
as_="p",
class_name="font-small truncate flex-1 min-w-0",
),
get_icon(icon="copy", class_name="p-[5px]"),
on_click=rx.set_clipboard("pip install " + category["package_name"]),
| def download(download_url: str) -> rx.Component:
return rx.link(
get_icon(icon="new_tab"),
underline="none",
href=download_url,
is_external=True,
class_name="text-slate-9 hover:!text-slate-9 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer rounded-[6px]",
title="Documentation",
) |
e="font-small",
),
get_icon(
icon="select",
),
justify_content="space-between",
),
style=sorting_box_style | conditional_style,
),
rx.menu.content(
rx.menu.item(sorting_filters(), style=menu_item_style),
bg="transparent",
box_shadow="None",
padding="0px",
overflow="visible",
border="none",
align="center",
),
width="100%",
)
def package_url(package_name: str) -> str:
return f"https://pypi.org/pypi/{package_name}/"
def download(download_url: str) -> rx.Component:
return rx.link(
get_icon(icon="new_tab"),
underline="none",
href=download_url,
is_external=True,
class_name="text-slate-9 hover:!text-slate-9 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer rounded-[6px]",
title="Documentation",
)
|
def component_grid():
table = rx.table.root(
rx.table.header(
rx.table.row(
rx.foreach(
["Package Name", "Last Updated", "Install Command", "Docs"],
lambda column_name: rx.table.column_header_cell(
rx.text(column_name, size="1"),
),
),
white_space="nowrap",
),
),
rx.table.body(
rx.foreach(
CustomComponentGalleryState.paginated_data,
table_rows,
)
),
width="100%",
variant="ghost",
max_width="800px",
size="1",
)
return rx.box(
table,
class_name="w-full h-full min-h-[60vh] flex flex-col items-start justify-start",
)
def create_pagination():
return rx.hstack(
rx.hstack(
rx.text("Rows per page", weight="bold", font_size="12px"),
rx.select(
| def table_rows(category: dict):
name = rx.Var(
f"{category['package_name']!s}.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')",
)
updated_at = rx.Var(
f"({category['updated_at']}).split('T')[0].split('-').map((part, index) => index === 1 ? 'JanFebMarAprMayJunJulAugSepOctNovDec'.slice(part * 3, part * 3 + 3) : part.padStart(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
)
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.text(
"pip install " + category["package_name"],
as_="p",
class_name="font-small truncate flex-1 min-w-0",
),
get_icon(icon="copy", class_name="p-[5px]"),
on_click=rx.set_clipboard("pip install " + category["package_name"]),
class_name="flex flex-row gap-1.5 text-slate-9 w-full items-center overflow-hidden border border-slate-5 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer shadow-small rounded-[6px] px-1.5 max-w-[20rem]",
)
),
rx.table.cell(download(category["download_url"])),
white_space="nowrap",
align="center",
) |
get_icon(
icon="select",
),
justify_content="space-between",
),
style=sorting_box_style | conditional_style,
),
rx.menu.content(
rx.menu.item(sorting_filters(), style=menu_item_style),
bg="transparent",
box_shadow="None",
padding="0px",
overflow="visible",
border="none",
align="center",
),
width="100%",
)
def package_url(package_name: str) -> str:
return f"https://pypi.org/pypi/{package_name}/"
def download(download_url: str) -> rx.Component:
return rx.link(
get_icon(icon="new_tab"),
underline="none",
href=download_url,
is_external=True,
class_name="text-slate-9 hover:!text-slate-9 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer rounded-[6px]",
title="Documentation",
)
def table_rows(category: dict):
|
updated_at = rx.Var(
f"({category['updated_at']}).split('T')[0].split('-').map((part, index) => index === 1 ? 'JanFebMarAprMayJunJulAugSepOctNovDec'.slice(part * 3, part * 3 + 3) : part.padStart(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
)
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.text(
"pip install " + category["package_name"],
as_="p",
class_name="font-small truncate flex-1 min-w-0",
),
get_icon(icon="copy", class_name="p-[5px]"),
on_click=rx.set_clipboard("pip install " + category["package_name"]),
class_name="flex flex-row gap-1.5 text-slate-9 w-full items-center overflow-hidden border border-slate-5 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer shadow-small roun | name = rx.Var(
f"{category['package_name']!s}.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')",
) |
style=sorting_box_style | conditional_style,
),
rx.menu.content(
rx.menu.item(sorting_filters(), style=menu_item_style),
bg="transparent",
box_shadow="None",
padding="0px",
overflow="visible",
border="none",
align="center",
),
width="100%",
)
def package_url(package_name: str) -> str:
return f"https://pypi.org/pypi/{package_name}/"
def download(download_url: str) -> rx.Component:
return rx.link(
get_icon(icon="new_tab"),
underline="none",
href=download_url,
is_external=True,
class_name="text-slate-9 hover:!text-slate-9 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer rounded-[6px]",
title="Documentation",
)
def table_rows(category: dict):
name = rx.Var(
f"{category['package_name']!s}.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')",
)
|
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.text(
"pip install " + category["package_name"],
as_="p",
class_name="font-small truncate flex-1 min-w-0",
),
get_icon(icon="copy", class_name="p-[5px]"),
on_click=rx.set_clipboard("pip install " + category["package_name"]),
class_name="flex flex-row gap-1.5 text-slate-9 w-full items-center overflow-hidden border border-slate-5 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer shadow-small rounded-[6px] px-1.5 max-w-[20rem]",
)
),
rx.table.cell(download(category["download_url"])),
white_space="nowrap",
align="center",
)
def component_grid():
table = rx.table.root(
rx.table.header(
rx.table.row(
rx.foreach(
| updated_at = rx.Var(
f"({category['updated_at']}).split('T')[0].split('-').map((part, index) => index === 1 ? 'JanFebMarAprMayJunJulAugSepOctNovDec'.slice(part * 3, part * 3 + 3) : part.padStart(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
) |
part * 3 + 3) : part.padStart(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
)
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.text(
"pip install " + category["package_name"],
as_="p",
class_name="font-small truncate flex-1 min-w-0",
),
get_icon(icon="copy", class_name="p-[5px]"),
on_click=rx.set_clipboard("pip install " + category["package_name"]),
class_name="flex flex-row gap-1.5 text-slate-9 w-full items-center overflow-hidden border border-slate-5 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer shadow-small rounded-[6px] px-1.5 max-w-[20rem]",
)
),
rx.table.cell(download(category["download_url"])),
white_space="nowrap",
align="center",
)
|
def create_pagination():
return rx.hstack(
rx.hstack(
rx.text("Rows per page", weight="bold", font_size="12px"),
rx.select(
CustomComponentGalleryState.limits,
default_value="50",
on_change=CustomComponentGalleryState.delta_limit,
width="80px",
),
align_items="center",
),
rx.hstack(
rx.text(
f"Page {CustomComponentGalleryState.current_page} of {CustomComponentGalleryState.total_pages}",
width="100px",
weight="bold",
font_size="12px",
),
rx.button(
rx.icon(
tag="chevron-left",
on_click=CustomComponentGalleryState.previous,
size=25,
cursor="pointer",
),
color_scheme="gray",
variant="surface",
| def component_grid():
table = rx.table.root(
rx.table.header(
rx.table.row(
rx.foreach(
["Package Name", "Last Updated", "Install Command", "Docs"],
lambda column_name: rx.table.column_header_cell(
rx.text(column_name, size="1"),
),
),
white_space="nowrap",
),
),
rx.table.body(
rx.foreach(
CustomComponentGalleryState.paginated_data,
table_rows,
)
),
width="100%",
variant="ghost",
max_width="800px",
size="1",
)
return rx.box(
table,
class_name="w-full h-full min-h-[60vh] flex flex-col items-start justify-start",
) |
art(2, '0'))"
f".slice(1).join(' ') + ', ' + ({category['updated_at']}).split('T')[0].split('-')[0]"
)
return rx.table.row(
rx.table.cell(name),
rx.table.cell(updated_at),
rx.table.cell(
rx.box(
rx.text(
"pip install " + category["package_name"],
as_="p",
class_name="font-small truncate flex-1 min-w-0",
),
get_icon(icon="copy", class_name="p-[5px]"),
on_click=rx.set_clipboard("pip install " + category["package_name"]),
class_name="flex flex-row gap-1.5 text-slate-9 w-full items-center overflow-hidden border border-slate-5 bg-slate-1 hover:bg-slate-3 transition-bg cursor-pointer shadow-small rounded-[6px] px-1.5 max-w-[20rem]",
)
),
rx.table.cell(download(category["download_url"])),
white_space="nowrap",
align="center",
)
def component_grid():
|
return rx.box(
table,
class_name="w-full h-full min-h-[60vh] flex flex-col items-start justify-start",
)
def create_pagination():
return rx.hstack(
rx.hstack(
rx.text("Rows per page", weight="bold", font_size="12px"),
rx.select(
CustomComponentGalleryState.limits,
default_value="50",
on_change=CustomComponentGalleryState.delta_limit,
width="80px",
),
align_items="center",
),
rx.hstack(
rx.text(
f"Page {CustomComponentGalleryState.current_page} of {CustomComponentGalleryState.total_pages}",
width="100px",
weight="bold",
font_size="12px",
),
rx.button(
rx.icon(
tag="chevron-left",
on_click=CustomComponentGalleryState.previous,
size=25,
| table = rx.table.root(
rx.table.header(
rx.table.row(
rx.foreach(
["Package Name", "Last Updated", "Install Command", "Docs"],
lambda column_name: rx.table.column_header_cell(
rx.text(column_name, size="1"),
),
),
white_space="nowrap",
),
),
rx.table.body(
rx.foreach(
CustomComponentGalleryState.paginated_data,
table_rows,
)
),
width="100%",
variant="ghost",
max_width="800px",
size="1",
) |
rx.button(
rx.icon(
tag="chevron-left",
on_click=CustomComponentGalleryState.previous,
size=25,
cursor="pointer",
),
color_scheme="gray",
variant="surface",
size="1",
width="32px",
height="32px",
),
rx.button(
rx.icon(
tag="chevron-right",
on_click=CustomComponentGalleryState.next,
size=25,
cursor="pointer",
),
color_scheme="gray",
variant="surface",
size="1",
width="32px",
height="32px",
),
align_items="center",
spacing="1",
),
align_items="center",
spacing="4",
flex_wrap="wrap",
)
@docpage(right_sidebar=False)
| def custom_components() -> rx.Component:
return rx.box(
rx.box(
h1_comp(text="Custom Components"),
rx.box(
text_comp_2(
text="Reflex has a growing ecosystem of custom components that you can use to build your apps. Below is a list of some of the custom components available for Reflex.",
),
sorting_filters_dropdown_menu(),
class_name="flex flex-row w-full gap-12 justify-between items-center",
),
class_name="flex flex-col w-full",
),
component_grid(),
create_pagination(),
class_name="flex flex-col h-full w-full gap-6 mb-16",
on_mount=CustomComponentGalleryState.fetch_components_list,
) | |
"""Module for documenting Reflex environment variables."""
|
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The | from __future__ import annotations |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
|
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the envi | import inspect |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
|
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
| from typing import Any, List, Optional, Tuple |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
|
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for t | import reflex as rx |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
|
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
| from reflex.config import EnvironmentVariables |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
|
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = ins | from pcweb.flexdown import markdown |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
|
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_co | from pcweb.templates.docpage import docpage, h1_comp, h2_comp |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
|
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
| def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
|
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
| env_vars = [] |
"""Module for documenting Reflex environment variables."""
from __future__ import annotations
import inspect
from typing import Any, List, Optional, Tuple
import reflex as rx
from reflex.config import EnvironmentVariables
from pcweb.flexdown import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
|
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of enviro | for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr)) |
n import markdown
from pcweb.templates.docpage import docpage, h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
|
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "i | source_code = inspect.getsource(EnvironmentVariables) |
h1_comp, h2_comp
class EnvVarDocs:
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
|
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
e | lines = source_code.splitlines() |
"""Documentation for Reflex environment variables."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
|
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal w-[20%] justify-start pl-4 font-bold",
),
| for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments) |
bles."""
@classmethod
def get_all_env_vars(cls) -> List[Tuple[str, Any]]:
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
|
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal w-[20%] justify-start pl-4 font-bold",
),
| if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments) |
"""Get all environment variables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
|
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
| comments = [] |
riables from the environment class.
Returns:
A list of tuples containing the environment variable name and its EnvVar instance.
"""
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
|
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal | while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1 |
env_vars = []
for name, attr in inspect.getmembers(EnvironmentVariables):
if name.startswith("_") or not hasattr(attr, "name"):
continue
env_vars.append((name, attr))
return env_vars
@classmethod
def get_env_var_docstring(cls, name: str) -> Optional[str]:
"""Get the docstring for an environment variable.
Args:
name: The name of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
|
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal w-[20%] justify-start pl-4 font-bold",
),
| if comments:
return "\n".join(comments) |
me of the environment variable.
Returns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
|
if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
]
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal w-[20%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Type",
class_name="font-small text-slate-12 text-normal w-[15%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Default",
class_name="font-small text-slate-12 text-normal w-[15%] | env_vars = cls.get_all_env_vars() |
turns:
The docstring for the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
|
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal w-[20%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Type",
class_name="font-small text-slate-12 text-normal w-[15%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Default",
class_name="font-small text-slate-12 text-normal w-[15%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Description",
class_name="fon | if not include_internal:
env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
] |
the environment variable, or None if not found.
"""
source_code = inspect.getsource(EnvironmentVariables)
lines = source_code.splitlines()
for i, line in enumerate(lines):
if f"{name}:" in line and "EnvVar" in line:
j = i - 1
comments = []
while j >= 0 and lines[j].strip().startswith("#"):
comments.insert(0, lines[j].strip()[1:].strip())
j -= 1
if comments:
return "\n".join(comments)
return None
@classmethod
def generate_env_var_table(cls, include_internal: bool = False) -> rx.Component:
"""Generate a table of environment variables.
Args:
include_internal: Whether to include internal environment variables.
Returns:
A Reflex component containing the table.
"""
env_vars = cls.get_all_env_vars()
if not include_internal:
|
env_vars.sort(key=lambda x: x[0])
return rx.box(
rx.table.root(
rx.table.header(
rx.table.row(
rx.table.column_header_cell(
"Name",
class_name="font-small text-slate-12 text-normal w-[20%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Type",
class_name="font-small text-slate-12 text-normal w-[15%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Default",
class_name="font-small text-slate-12 text-normal w-[15%] justify-start pl-4 font-bold",
),
rx.table.column_header_cell(
"Description",
class_name="fon | env_vars = [
(name, var)
for name, var in env_vars
if not getattr(var, "internal", False)
] |
),
width="100%",
overflow_x="visible",
class_name="w-full",
),
)
def env_vars_page():
"""Generate the environment variables documentation page.
Returns:
A Reflex component containing the documentation.
"""
return rx.box(
h1_comp(text="Environment Variables"),
rx.code(
"reflex.config.EnvironmentVariables", class_name="code-style text-[18px]"
),
rx.divider(),
markdown(
"""
Reflex provides a number of environment variables that can be used to configure the behavior of your application.
These environment variables can be set in your shell environment or in a `.env` file.
This page documents all available environment variables in Reflex.
"""
),
h2_comp(text="Environment Variables"),
EnvVarDocs.generate_env_var_table(include_internal=False),
)
|
env_vars_doc.title = "Environment Variables"
| env_vars_doc = docpage(
"/docs/api-reference/environment-variables/",
"Environment Variables",
right_sidebar=False,
)(env_vars_page) |
)
def env_vars_page():
"""Generate the environment variables documentation page.
Returns:
A Reflex component containing the documentation.
"""
return rx.box(
h1_comp(text="Environment Variables"),
rx.code(
"reflex.config.EnvironmentVariables", class_name="code-style text-[18px]"
),
rx.divider(),
markdown(
"""
Reflex provides a number of environment variables that can be used to configure the behavior of your application.
These environment variables can be set in your shell environment or in a `.env` file.
This page documents all available environment variables in Reflex.
"""
),
h2_comp(text="Environment Variables"),
EnvVarDocs.generate_env_var_table(include_internal=False),
)
env_vars_doc = docpage(
"/docs/api-reference/environment-variables/",
"Environment Variables",
right_sidebar=False,
)(env_vars_page)
| env_vars_doc.title = "Environment Variables" | |
from reflex.utils.format import to_snake_case, to_title_case
from pcweb.components.icons import get_icon
from pcweb.templates.docpage import docpage, h1_comp, text_comp_2
def component_grid():
from pcweb.components.docpage.sidebar.sidebar_items import get_component_link
from pcweb.pages.docs import component_list, graphing_components
def generate_gallery(
components,
prefix: str = "",
):
sidebar = [
rx.box(
rx.link(
rx.el.h1(
to_title_case(to_snake_case(category), sep=" "),
class_name="font-large text-slate-12",
),
get_icon("new_tab", class_name="text-slate-11 [&>svg]:size-4"),
href=f"/docs/library/{prefix.strip('/') + '/' if prefix.strip('/') else ''}{category.lower()}",
underline="none",
class_name="px-4 py-2 bg-slate-1 hover:bg-slate-3 transition | import reflex as rx | |
import reflex as rx
|
from pcweb.components.icons import get_icon
from pcweb.templates.docpage import docpage, h1_comp, text_comp_2
def component_grid():
from pcweb.components.docpage.sidebar.sidebar_items import get_component_link
from pcweb.pages.docs import component_list, graphing_components
def generate_gallery(
components,
prefix: str = "",
):
sidebar = [
rx.box(
rx.link(
rx.el.h1(
to_title_case(to_snake_case(category), sep=" "),
class_name="font-large text-slate-12",
),
get_icon("new_tab", class_name="text-slate-11 [&>svg]:size-4"),
href=f"/docs/library/{prefix.strip('/') + '/' if prefix.strip('/') else ''}{category.lower()}",
underline="none",
class_name="px-4 py-2 bg-slate-1 hover:bg-slate-3 transition-bg flex flex-row justify-between items-center !text-slate-12 | from reflex.utils.format import to_snake_case, to_title_case |
import reflex as rx
from reflex.utils.format import to_snake_case, to_title_case
|
from pcweb.templates.docpage import docpage, h1_comp, text_comp_2
def component_grid():
from pcweb.components.docpage.sidebar.sidebar_items import get_component_link
from pcweb.pages.docs import component_list, graphing_components
def generate_gallery(
components,
prefix: str = "",
):
sidebar = [
rx.box(
rx.link(
rx.el.h1(
to_title_case(to_snake_case(category), sep=" "),
class_name="font-large text-slate-12",
),
get_icon("new_tab", class_name="text-slate-11 [&>svg]:size-4"),
href=f"/docs/library/{prefix.strip('/') + '/' if prefix.strip('/') else ''}{category.lower()}",
underline="none",
class_name="px-4 py-2 bg-slate-1 hover:bg-slate-3 transition-bg flex flex-row justify-between items-center !text-slate-12",
),
rx.box( | from pcweb.components.icons import get_icon |
import reflex as rx
from reflex.utils.format import to_snake_case, to_title_case
from pcweb.components.icons import get_icon
|
def component_grid():
from pcweb.components.docpage.sidebar.sidebar_items import get_component_link
from pcweb.pages.docs import component_list, graphing_components
def generate_gallery(
components,
prefix: str = "",
):
sidebar = [
rx.box(
rx.link(
rx.el.h1(
to_title_case(to_snake_case(category), sep=" "),
class_name="font-large text-slate-12",
),
get_icon("new_tab", class_name="text-slate-11 [&>svg]:size-4"),
href=f"/docs/library/{prefix.strip('/') + '/' if prefix.strip('/') else ''}{category.lower()}",
underline="none",
class_name="px-4 py-2 bg-slate-1 hover:bg-slate-3 transition-bg flex flex-row justify-between items-center !text-slate-12",
),
rx.box(
*[
rx.link(
| from pcweb.templates.docpage import docpage, h1_comp, text_comp_2 |
import reflex as rx
from reflex.utils.format import to_snake_case, to_title_case
from pcweb.components.icons import get_icon
from pcweb.templates.docpage import docpage, h1_comp, text_comp_2
def component_grid():
|
from pcweb.pages.docs import component_list, graphing_components
def generate_gallery(
components,
prefix: str = "",
):
sidebar = [
rx.box(
rx.link(
rx.el.h1(
to_title_case(to_snake_case(category), sep=" "),
class_name="font-large text-slate-12",
),
get_icon("new_tab", class_name="text-slate-11 [&>svg]:size-4"),
href=f"/docs/library/{prefix.strip('/') + '/' if prefix.strip('/') else ''}{category.lower()}",
underline="none",
class_name="px-4 py-2 bg-slate-1 hover:bg-slate-3 transition-bg flex flex-row justify-between items-center !text-slate-12",
),
rx.box(
*[
rx.link(
to_title_case(to_snake_case(c[0]), sep=" "),
href=get_compo | from pcweb.components.docpage.sidebar.sidebar_items import get_component_link |
import reflex as rx
from reflex.utils.format import to_snake_case, to_title_case
from pcweb.components.icons import get_icon
from pcweb.templates.docpage import docpage, h1_comp, text_comp_2
def component_grid():
from pcweb.components.docpage.sidebar.sidebar_items import get_component_link
|
def generate_gallery(
components,
prefix: str = "",
):
sidebar = [
rx.box(
rx.link(
rx.el.h1(
to_title_case(to_snake_case(category), sep=" "),
class_name="font-large text-slate-12",
),
get_icon("new_tab", class_name="text-slate-11 [&>svg]:size-4"),
href=f"/docs/library/{prefix.strip('/') + '/' if prefix.strip('/') else ''}{category.lower()}",
underline="none",
class_name="px-4 py-2 bg-slate-1 hover:bg-slate-3 transition-bg flex flex-row justify-between items-center !text-slate-12",
),
rx.box(
*[
rx.link(
to_title_case(to_snake_case(c[0]), sep=" "),
href=get_component_link(
category=category,
| from pcweb.pages.docs import component_list, graphing_components |
ransition-bg flex flex-row justify-between items-center !text-slate-12",
),
rx.box(
*[
rx.link(
to_title_case(to_snake_case(c[0]), sep=" "),
href=get_component_link(
category=category,
clist=c,
prefix=prefix,
),
class_name="font-small text-slate-11 hover:!text-violet-9 transition-color w-fit",
)
for c in components[category]
],
class_name="flex flex-col gap-2.5 px-4 py-2 border-t border-slate-5",
),
class_name="flex flex-col border border-slate-5 rounded-xl bg-slate-2 shadow-large overflow-hidden",
)
for category in components
]
return sidebar
|
# add `graphing/` prefix when generating graphing components to assume the url `/docs/library/graphing/<category>/<component>`.
graphs = generate_gallery(
components=graphing_components,
prefix="/graphing/",
)
return rx.box(
rx.box(
*core,
class_name="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",
),
rx.box(
h1_comp(
text="Graphing Components",
),
text_comp_2(
text="Discover our range of components for building interactive charts and data visualizations. Create clear, informative, and visually engaging representations of your data with ease.",
),
rx.box(
*graphs,
class_name="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",
),
class_name="flex flex-col",
),
class_name="w-full flex flex-col gap-16",
)
@docpage(
right_sideba | core = generate_gallery(
components=component_list,
) |
_title_case(to_snake_case(c[0]), sep=" "),
href=get_component_link(
category=category,
clist=c,
prefix=prefix,
),
class_name="font-small text-slate-11 hover:!text-violet-9 transition-color w-fit",
)
for c in components[category]
],
class_name="flex flex-col gap-2.5 px-4 py-2 border-t border-slate-5",
),
class_name="flex flex-col border border-slate-5 rounded-xl bg-slate-2 shadow-large overflow-hidden",
)
for category in components
]
return sidebar
core = generate_gallery(
components=component_list,
)
# add `graphing/` prefix when generating graphing components to assume the url `/docs/library/graphing/<category>/<component>`.
|
return rx.box(
rx.box(
*core,
class_name="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",
),
rx.box(
h1_comp(
text="Graphing Components",
),
text_comp_2(
text="Discover our range of components for building interactive charts and data visualizations. Create clear, informative, and visually engaging representations of your data with ease.",
),
rx.box(
*graphs,
class_name="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",
),
class_name="flex flex-col",
),
class_name="w-full flex flex-col gap-16",
)
@docpage(
right_sidebar=True,
pseudo_right_bar=True,
)
def library():
return rx.box(
h1_comp(
text="Component Library",
),
text_comp_2(
text="Components let you split the UI into independent, reusable pie | graphs = generate_gallery(
components=graphing_components,
prefix="/graphing/",
) |
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font | import reflex as rx | |
import reflex as rx
|
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
| from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2 |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
|
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 fl | def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}" |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
|
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9" | file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-") |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
|
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
rx.link(
format_titles(c),
| def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
|
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
| title_without_ext = path.split(".")[0] |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
|
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
| parts = title_without_ext.split("/") |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
|
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
| last_part = parts[-1] |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
|
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
rx.link(
format_tit | capitalized_last_part = last_part.replace("_", "-").title() |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
|
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
rx.link(
format_titles(c),
href=get_component_link(category, c),
c | from pcweb.pages.docs import recipes_list |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
|
sidebar = []
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
rx.link(
format_titles(c),
href=get_component_link(category, c),
class_name="font-small text-slate-11 hover:!text-violet-9 transition-color w-fit",
)
| icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
} |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
|
for item in recipes_list:
category = item.split("/")[-1]
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
rx.link(
format_titles(c),
href=get_component_link(category, c),
class_name="font-small text-slate-11 hover:!text-violet-9 transition-color w-fit",
)
for c in | sidebar = [] |
import reflex as rx
from pcweb.templates.docpage import docpage, h1_comp, h2_comp, text_comp_2
def get_component_link(category, clist) -> str:
file_name_without_extension = clist.split("/")[-1].split(".")[0].replace("_", "-")
return f"/docs/recipes/{category}/{file_name_without_extension}"
def format_titles(path):
title_without_ext = path.split(".")[0]
parts = title_without_ext.split("/")
last_part = parts[-1]
capitalized_last_part = last_part.replace("_", "-").title()
return capitalized_last_part
def component_grid():
from pcweb.pages.docs import recipes_list
icons = {
"layout": "panels-top-left",
"content": "layout-grid",
"auth": "lock-keyhole",
}
sidebar = []
for item in recipes_list:
|
sidebar.append(
rx.box(
rx.box(
rx.el.h1(
rx.utils.format.to_title_case(category),
class_name="font-large text-slate-12",
),
rx.icon(
icons.get(category, "shapes"),
size=18,
class_name="!text-slate-9",
),
class_name="px-4 py-2 flex flex-row !text-slate-12 gap-3 items-center justify-between",
),
rx.box(
*[
rx.link(
format_titles(c),
href=get_component_link(category, c),
class_name="font-small text-slate-11 hover:!text-violet-9 transition-color w-fit",
)
for c in recipes_list[category]
],
cla | category = item.split("/")[-1] |
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for com | import dataclasses | |
import dataclasses
|
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comment | import inspect |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
|
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, | from typing import Callable, Type |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
|
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualnam | import reflex as rx |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
|
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> | from pcweb.flexdown import markdown |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
|
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__do | from pcweb.templates.docpage import h1_comp, h2_comp |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
|
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubcla | def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
] |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
|
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubcla | self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
] |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
|
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name | def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__ |
import dataclasses
import inspect
import re
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
|
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
| def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments]) |
e
# Get the comment for a specific field.
from typing import Callable, Type
import reflex as rx
from pcweb.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
|
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
| def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__)) |
b.flexdown import markdown
from pcweb.templates.docpage import h1_comp, h2_comp
class Source(rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
|
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
| def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "") |
rx.Base):
"""Parse the source code of a component."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
|
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
.split("Args:")[0]
.split("Returns:")[0]
| def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out |
ent."""
# The component to parse.
module: Type
# The source code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
|
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
| if not issubclass(self.module, rx.Base):
return [] |
ce code.
code: list[str] = []
def __init__(self, *args, **kwargs):
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
|
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
.split("Args:")[0]
.split("Returns | out = self.get_annotations(self.module.__class_vars__) |
"""Initialize the source code parser."""
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
|
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
.split("Args:")[0]
.split("Returns:")[0]
.strip(),
"params": dict(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
).parameters
),
"ret": inspect.signature(
fn.__func__ if isinstance(fn, (classmeth | def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__)
return [] |
"
super().__init__(*args, **kwargs)
# Get the source code.
self.code = [
line
for line in inspect.getsource(self.module).splitlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
|
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
.split("Args:")[0]
.split("Returns:")[0]
.strip(),
"params": dict(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
).parameters
),
"ret": inspect.signature(
fn.__func__ if isinsta | if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__) |
tlines()
if len(line) > 0
]
def get_docs(self) -> str:
"""Get the docstring of the component.
Returns:
The docstring of the component.
"""
return self.module.__doc__
@staticmethod
def get_comment(comments: list[str]):
return "".join([comment.strip().strip("#") for comment in comments])
def get_name(self) -> str:
return ".".join((self.module.__module__, self.module.__qualname__))
def get_overview(self) -> str:
return inspect.cleandoc(self.module.__doc__ or "")
def get_class_fields(self) -> list[dict]:
if not issubclass(self.module, rx.Base):
return []
out = self.get_annotations(self.module.__class_vars__)
return out
def get_fields(self) -> list[dict]:
if dataclasses.is_dataclass(self.module):
return self.get_annotations(
{f.name: f for f in dataclasses.fields(self.module)}
)
|
return []
def get_methods(self):
return [
{
"name": name,
"signature": str(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
)
),
"description": (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
.split("Args:")[0]
.split("Returns:")[0]
.strip(),
"params": dict(
inspect.signature(
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
).parameters
),
"ret": inspect.signature(
fn.__func__ if isinsta | elif isinstance(self.module, type) and issubclass(self.module, rx.Base):
return self.get_annotations(self.module.__fields__) |
fn.__func__
if isinstance(fn, (classmethod, staticmethod))
else fn
).parameters
),
"ret": inspect.signature(
fn.__func__ if isinstance(fn, (classmethod, staticmethod)) else fn
).return_annotation,
}
for name, fn in self.module.__dict__.items()
if (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
and isinstance(fn, (Callable, classmethod, staticmethod))
and not name.startswith("_")
and name != "Config"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
|
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
reached_functions = re.search("def ", line)
if reached_functions:
# We've reached the functions, so stop.
break
# If we've reached a docstring, clear the comments.
if line.strip() == '"""':
comments.clear()
continue
# Get comments for prop
if line.strip().startswith("#"):
comments.append(line)
continue
# Check if this line has a prop.
match = re.search("\\w+:", line)
if match is None:
# This line doesn't have a var, so continue.
continue
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue. | comments = [] |
meters
),
"ret": inspect.signature(
fn.__func__ if isinstance(fn, (classmethod, staticmethod)) else fn
).return_annotation,
}
for name, fn in self.module.__dict__.items()
if (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
and isinstance(fn, (Callable, classmethod, staticmethod))
and not name.startswith("_")
and name != "Config"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
comments = []
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
|
if reached_functions:
# We've reached the functions, so stop.
break
# If we've reached a docstring, clear the comments.
if line.strip() == '"""':
comments.clear()
continue
# Get comments for prop
if line.strip().startswith("#"):
comments.append(line)
continue
# Check if this line has a prop.
match = re.search("\\w+:", line)
if match is None:
# This line doesn't have a var, so continue.
continue
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue.
comments.clear()
continue
prop = props[prop]
# redundant check just to double-check line above prop is a comment
assert sel | reached_functions = re.search("def ", line) |
.signature(
fn.__func__ if isinstance(fn, (classmethod, staticmethod)) else fn
).return_annotation,
}
for name, fn in self.module.__dict__.items()
if (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
and isinstance(fn, (Callable, classmethod, staticmethod))
and not name.startswith("_")
and name != "Config"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
comments = []
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
reached_functions = re.search("def ", line)
|
# If we've reached a docstring, clear the comments.
if line.strip() == '"""':
comments.clear()
continue
# Get comments for prop
if line.strip().startswith("#"):
comments.append(line)
continue
# Check if this line has a prop.
match = re.search("\\w+:", line)
if match is None:
# This line doesn't have a var, so continue.
continue
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue.
comments.clear()
continue
prop = props[prop]
# redundant check just to double-check line above prop is a comment
assert self.code[i - 1].strip().startswith("#"), (
f"Expected comment, got {self.code[i - 1]}"
| if reached_functions:
# We've reached the functions, so stop.
break |
self.module.__dict__.items()
if (
fn.__func__.__doc__
if isinstance(fn, (classmethod, staticmethod))
else fn.__doc__
)
and isinstance(fn, (Callable, classmethod, staticmethod))
and not name.startswith("_")
and name != "Config"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
comments = []
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
reached_functions = re.search("def ", line)
if reached_functions:
# We've reached the functions, so stop.
break
# If we've reached a docstring, clear the comments.
|
# Get comments for prop
if line.strip().startswith("#"):
comments.append(line)
continue
# Check if this line has a prop.
match = re.search("\\w+:", line)
if match is None:
# This line doesn't have a var, so continue.
continue
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue.
comments.clear()
continue
prop = props[prop]
# redundant check just to double-check line above prop is a comment
assert self.code[i - 1].strip().startswith("#"), (
f"Expected comment, got {self.code[i - 1]}"
)
# Get the comment for this prop.
comment = Source.get_comment(comments)
# reset comments
comments.clear()
| if line.strip() == '"""':
comments.clear()
continue |
aticmethod))
else fn.__doc__
)
and isinstance(fn, (Callable, classmethod, staticmethod))
and not name.startswith("_")
and name != "Config"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
comments = []
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
reached_functions = re.search("def ", line)
if reached_functions:
# We've reached the functions, so stop.
break
# If we've reached a docstring, clear the comments.
if line.strip() == '"""':
comments.clear()
continue
# Get comments for prop
|
# Check if this line has a prop.
match = re.search("\\w+:", line)
if match is None:
# This line doesn't have a var, so continue.
continue
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue.
comments.clear()
continue
prop = props[prop]
# redundant check just to double-check line above prop is a comment
assert self.code[i - 1].strip().startswith("#"), (
f"Expected comment, got {self.code[i - 1]}"
)
# Get the comment for this prop.
comment = Source.get_comment(comments)
# reset comments
comments.clear()
# Skip private props.
if "PRIVATE" in comment:
continue
# Add the prop to the output.
| if line.strip().startswith("#"):
comments.append(line)
continue |
startswith("_")
and name != "Config"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
comments = []
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
reached_functions = re.search("def ", line)
if reached_functions:
# We've reached the functions, so stop.
break
# If we've reached a docstring, clear the comments.
if line.strip() == '"""':
comments.clear()
continue
# Get comments for prop
if line.strip().startswith("#"):
comments.append(line)
continue
# Check if this line has a prop.
|
if match is None:
# This line doesn't have a var, so continue.
continue
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue.
comments.clear()
continue
prop = props[prop]
# redundant check just to double-check line above prop is a comment
assert self.code[i - 1].strip().startswith("#"), (
f"Expected comment, got {self.code[i - 1]}"
)
# Get the comment for this prop.
comment = Source.get_comment(comments)
# reset comments
comments.clear()
# Skip private props.
if "PRIVATE" in comment:
continue
# Add the prop to the output.
out.append(
{
"prop": prop,
"de | match = re.search("\\w+:", line) |
ig"
]
def get_annotations(self, props) -> list[dict]:
"""Get a dictionary of the props and their descriptions.
Returns:
A dictionary of the props and their descriptions.
"""
# The output.
out = []
comments = []
# Loop through the source code.
for i, line in enumerate(self.code):
# Check if we've reached the functions.
reached_functions = re.search("def ", line)
if reached_functions:
# We've reached the functions, so stop.
break
# If we've reached a docstring, clear the comments.
if line.strip() == '"""':
comments.clear()
continue
# Get comments for prop
if line.strip().startswith("#"):
comments.append(line)
continue
# Check if this line has a prop.
match = re.search("\\w+:", line)
|
# Get the prop.
prop = match.group(0).strip(":")
if prop not in props or prop.startswith("_"):
# This isn't a prop, so continue.
comments.clear()
continue
prop = props[prop]
# redundant check just to double-check line above prop is a comment
assert self.code[i - 1].strip().startswith("#"), (
f"Expected comment, got {self.code[i - 1]}"
)
# Get the comment for this prop.
comment = Source.get_comment(comments)
# reset comments
comments.clear()
# Skip private props.
if "PRIVATE" in comment:
continue
# Add the prop to the output.
out.append(
{
"prop": prop,
"description": comment,
}
)
# Return the output.
return out
def format_f | if match is None:
# This line doesn't have a var, so continue.
continue |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.