Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adding Sidebar #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nextpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
"ScaleFade",
"Script",
"Select",
"Sidebar",
"SidebarItem",
"Skeleton",
"SkeletonCircle",
"SkeletonText",
Expand Down
2 changes: 2 additions & 0 deletions nextpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ from nextpy.interfaces.web.components import (
)
from nextpy.interfaces.web.components import select_slider_thumb as select_slider_thumb
from nextpy.interfaces.web.components import select_slider_track as select_slider_track
from nextpy.interfaces.web.components import sidebar as sidebar
from nextpy.interfaces.web.components import sidebar_item as sidebar_item
from nextpy.interfaces.web.components import skeleton as skeleton
from nextpy.interfaces.web.components import skeleton_circle as skeleton_circle
from nextpy.interfaces.web.components import skeleton_text as skeleton_text
Expand Down
2 changes: 2 additions & 0 deletions nextpy/interfaces/web/components/chakra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
select_slider_filled_track = RangeSliderFilledTrack.create
select_slider_thumb = RangeSliderThumb.create
select_slider_track = RangeSliderTrack.create
sidebar = Sidebar
sidebar_item = SidebarItem
skeleton = Skeleton.create
skeleton_circle = SkeletonCircle.create
skeleton_text = SkeletonText.create
Expand Down
1 change: 1 addition & 0 deletions nextpy/interfaces/web/components/chakra/layout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .html import Html
from .spacer import Spacer
from .stack import Hstack, Stack, Vstack
from .sidebar import Sidebar, SidebarItem
from .wrap import Wrap, WrapItem

__all__ = [f for f in dir() if f[0].isupper()] # type: ignore
42 changes: 42 additions & 0 deletions nextpy/interfaces/web/components/chakra/layout/sidebar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import nextpy as xt



def SidebarItem(text, href, class_name="", **kwargs):
return xt.link(
xt.text(text),
class_name=f"text-md text-left {class_name}",
href=href,
bg="transparent",
_hover={"bg": "#0A4075"},
border_radius="999px",
width="100%",
pl="14px",
py="6px",
**kwargs,
)
Comment on lines +5 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SidebarItem function correctly implements the creation of a sidebar item using the xt.link component. The use of class_name to allow for additional styling is a good practice. However, consider documenting the expected **kwargs to improve maintainability and usability for other developers.

Consider adding documentation for the **kwargs parameter to clarify what additional arguments are supported and how they are used. This will enhance the function's usability and maintainability.



def Sidebar(
*children,
top="0px",
**kwargs,
):
return xt.box(
xt.vstack(
*children,
spacing="4px",
width="100%",
align_items="start",
pl="4px",
pt="1rem",
height="100%",
),
display=["none", "block", "block"],
width="15em",
top=top,
height=f"calc(100dvh - {top})",
position="sticky",
class_name="pt-4 pl-4 overflow-y-auto ",
**kwargs,
)
Comment on lines +20 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Sidebar function effectively creates a sidebar container with customizable top positioning and additional styling options. The use of xt.vstack for vertical alignment of children and the sticky positioning are well-suited for a sidebar component. However, the hardcoded display values may limit responsiveness across different screen sizes.

Consider making the display property customizable through parameters or responsive design techniques to enhance the sidebar's adaptability across various devices.

Loading