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

Adding Sidebar #145

wants to merge 1 commit into from

Conversation

Raj4646
Copy link
Contributor

@Raj4646 Raj4646 commented Feb 26, 2024

Components ->
xt.sidebar() - Parent element for the sidebar. Takes a prop "top", which can be the height of navbar or whatever needs to be rendered above it.
xt.sidebar_item - It takes title and href and class_name for styling.

Summary by CodeRabbit

  • New Features
    • Introduced Sidebar and SidebarItem components for creating a sticky sidebar layout in web interfaces, with customizable properties such as width, top position, and styling options.

Copy link
Contributor

coderabbitai bot commented Feb 26, 2024

Walkthrough

The update introduces Sidebar and SidebarItem components to the nextpy library, enhancing its web interface capabilities. These components are now accessible and can be utilized to create customizable, sticky sidebars with multiple items for web applications, providing a structured and stylish navigation pane.

Changes

File Path Change Summary
nextpy/__init__.py and nextpy/__init__.pyi Export Sidebar and SidebarItem entities; add imports for these from ...web.components.
nextpy/.../components/chakra/__init__.py and .../chakra/layout/__init__.py Declare and export sidebar and sidebar_item for Chakra UI.
nextpy/.../chakra/layout/sidebar.py Introduce functions for sidebar component creation, including styling and layout options.

🐰✨
A sidebar here, a sidebar there,
CodeRabbit hopped without a care.
Crafting menus so sleek and neat,
With items lined up, oh what a feat!
🌟📚🌈
Now your web's charm, with no compare,
Thanks to updates pulled from thin air.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@Raj4646 Raj4646 changed the title Add Sidebar in nextpy Adding Sidebar Feb 26, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f9ab6ef and 4aa7b9c.
Files selected for processing (5)
  • nextpy/init.py (1 hunks)
  • nextpy/init.pyi (1 hunks)
  • nextpy/interfaces/web/components/chakra/init.py (1 hunks)
  • nextpy/interfaces/web/components/chakra/layout/init.py (1 hunks)
  • nextpy/interfaces/web/components/chakra/layout/sidebar.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • nextpy/init.py
Additional comments: 3
nextpy/interfaces/web/components/chakra/layout/__init__.py (1)
  • 16-16: The addition of Sidebar and SidebarItem to the exports is correctly implemented and aligns with the PR's objectives to enhance the framework's sidebar functionality. The dynamic approach to populating __all__ ensures that these components are automatically exported, which is both efficient and maintainable.
nextpy/interfaces/web/components/chakra/__init__.py (1)
  • 164-165: The declarations for sidebar and sidebar_item are correctly added, aligning with the PR's objectives. However, unlike other components that use the .create method, these are directly assigned. If this inconsistency is intentional due to the nature of Sidebar and SidebarItem, it's acceptable. Otherwise, consider aligning with the existing component creation pattern for consistency.
nextpy/__init__.pyi (1)
  • 401-402: The addition of sidebar and sidebar_item imports from nextpy.interfaces.web.components is correctly implemented and follows the existing pattern of importing components in this file. This change effectively exposes the new sidebar functionality to users of the next.py framework, aligning with the PR's objectives.

Comment on lines +5 to +17
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,
)
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.

Comment on lines +20 to +42
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,
)
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant