8000 feat(styling): improve sidebar by baktun14 · Pull Request #1344 · akash-network/console · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(styling): improve sidebar #1344

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

Merged
merged 8 commits into from
May 21, 2025
Merged

feat(styling): improve sidebar #1344

merged 8 commits into from
May 21, 2025

Conversation

baktun14
Copy link
Contributor
@baktun14 baktun14 commented May 19, 2025

#553
#1326
#1325

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced popover menus and nested group menus in the sidebar for improved navigation and access to social links, resources, and help sections.
    • Added tooltips to sidebar route buttons when the sidebar is collapsed.
  • Enhancements

    • Redesigned the theme toggle to use three distinct buttons for light, dark, and system modes.
    • Updated sidebar structure for better modularity and conditional rendering based on wallet connection.
    • Improved node status bar layout and added a separator for clearer visual organization.
    • Refined pagination display for large page sets, providing a more intuitive and consistent navigation experience.
    • Sidebar toggle button updated to include labels and dynamic styling.
    • Sidebar hover-based expansion removed for simplified navigation.
    • Layout now initializes sidebar open state from stored user preference.
  • Bug Fixes

    • Ensured enabling GPU in forms automatically sets the GPU count to at least one.
  • Removals

    • Removed the footer from the home page.
  • Chores

    • Increased default service pricing values for deployments.

@baktun14 baktun14 requested a review from a team as a code owner May 19, 2025 17:11
Copy link
coderabbitai bot commented May 19, 2025

Walkthrough

This set of changes primarily restructures the sidebar navigation system and related UI components in the deploy-web app. It introduces new sidebar menu popover and hovered group menu components, updates sidebar item types, simplifies the theme toggle, and refactors the paginator logic. Additional minor UI and logic adjustments are applied across several components, including removal of the footer from the home page, GPU form control enhancements, and state initialization improvements in the layout.

Changes

File(s) Change Summary
apps/deploy-web/src/components/home/HomeContainer.tsx Removed the Footer component import and its rendering from HomeContainer.
apps/deploy-web/src/components/layout/ModeToggle.tsx Changed theme toggle from a dropdown to three distinct icon buttons for light, dark, and system themes.
apps/deploy-web/src/components/layout/NodeStatusBar.tsx Updated layout and styling; removed bottom margin; added a separator below node status; adjusted button and container classes.
apps/deploy-web/src/components/layout/Sidebar.tsx Refactored sidebar to remove hover expansion logic; reorganized routes and navigation groups; updated toggle button and conditional rendering; integrated version and social links into nested menus.
apps/deploy-web/src/components/layout/SidebarGroupMenu.tsx Now conditionally renders SidebarRouteButton or SidebarGroupMenuPopover based on presence of hoveredRoutes.
apps/deploy-web/src/components/layout/SidebarGroupMenuPopover.tsx New: Introduced SidebarGroupMenuPopover component for popover menus in the sidebar.
apps/deploy-web/src/components/layout/SidebarHoveredGroupMenu.tsx New: Added SidebarHoveredGroupMenu component for rendering hovered sidebar group menus.
apps/deploy-web/src/components/layout/SidebarRouteButton.tsx Added isHovered prop; improved selected logic; wrapped button in Tooltip when sidebar is closed and not hovered; added support for dividers.
apps/deploy-web/src/components/sdl/GpuFormControl.tsx Ensured enabling GPU checkbox sets GPU count to 1 if previously zero.
apps/deploy-web/src/types/index.ts Modified ISidebarRoute: made title, url, and activeRoutes optional; added hoveredRoutes, hasDivider, and customComponent properties.
apps/deploy-web/src/utils/sdl/data.ts Increased default pricing amounts in defaultService and defaultRentGpuService.
packages/ui/components/pagninator.tsx Rewrote pagination link logic for >6 pages; now always shows first/last page, sliding window around current page, and ellipses as needed.
apps/deploy-web/src/components/layout/Layout.tsx Changed isNavOpen state initialization to use lazy initializer reading from localStorage and media query; removed redundant effect hook.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Sidebar
    participant SidebarGroupMenu
    participant SidebarGroupMenuPopover
    participant SidebarHoveredGroupMenu

    User->>Sidebar: Clicks or hovers on sidebar menu
    Sidebar->>SidebarGroupMenu: Render group menu
    SidebarGroupMenu->>SidebarGroupMenuPopover: If route has hoveredRoutes, render popover
    SidebarGroupMenuPopover->>SidebarHoveredGroupMenu: Show hovered group menu in popover
    SidebarHoveredGroupMenu-->>User: Display submenu items
Loading

Poem

A sidebar now with menus that pop,
Hover and routes—no need to stop!
Theme toggles shine, three buttons in line,
Pagination’s clear, the numbers align.
With tooltips and dividers, the UI feels new—
Oh, what a spring for the code to hop through!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-21T00_08_42_900Z-debug-0.log

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed6000 and 3dd357d.

📒 Files selected for processing (1)
  • apps/deploy-web/src/components/layout/Layout.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test-stats-web-build
  • GitHub Check: test-deploy-web-build
  • GitHub Check: test-provider-console-build
🔇 Additional comments (2)
apps/deploy-web/src/components/layout/Layout.tsx (2)

60-69: Great improvement to sidebar state initialization!

The refactored code now uses a lazy initializer pattern for isNavOpen state that:

  1. Properly reads saved preferences from localStorage
  2. Respects the current screen size
  3. Eliminates the need for a separate effect hook that would cause unnecessary renders

This is a solid improvement that consolidates state initialization logic and ensures consistent sidebar behavior across page reloads.


86-86: Minor whitespace change

This is just a whitespace change that maintains consistent code formatting.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
codecov bot commented May 19, 2025

Codecov Report

Attention: Patch coverage is 23.28767% with 56 lines in your changes missing coverage. Please review.

Project coverage is 33.43%. Comparing base (6ad02ce) to head (3dd357d).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
apps/deploy-web/src/components/layout/Sidebar.tsx 10.00% 18 Missing ⚠️
.../src/components/layout/SidebarGroupMenuPopover.tsx 40.00% 9 Missing ⚠️
...y-web/src/components/layout/SidebarRouteButton.tsx 20.00% 7 Missing and 1 partial ⚠️
apps/deploy-web/src/components/layout/Layout.tsx 0.00% 5 Missing and 1 partial ⚠️
.../src/components/layout/SidebarHoveredGroupMenu.tsx 40.00% 6 Missing ⚠️
...ps/deploy-web/src/components/layout/ModeToggle.tsx 25.00% 3 Missing ⚠️
...loy-web/src/components/layout/SidebarGroupMenu.tsx 25.00% 2 Missing and 1 partial ⚠️
...s/deploy-web/src/components/sdl/GpuFormControl.tsx 0.00% 2 Missing ⚠️
...deploy-web/src/components/layout/NodeStatusBar.tsx 50.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (23.28%) is below the target coverage (30.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1344    +/-   ##
========================================
  Coverage   33.42%   33.43%            
========================================
  Files         789      791     +2     
  Lines       19267    19297    +30     
  Branches     3569     3589    +20     
========================================
+ Hits         6440     6451    +11     
+ Misses      12616    12237   -379     
- Partials      211      609   +398     
Flag Coverage Δ *Carryforward flag
api 64.05% <ø> (ø) Carriedforward from 2ed6000
deploy-web 13.57% <23.28%> (+0.05%) ⬆️
notifications 81.86% <ø> (ø) Carriedforward from 2ed6000
provider-proxy 80.09% <ø> (ø) Carriedforward from 2ed6000

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...s/deploy-web/src/components/home/HomeContainer.tsx 0.00% <ø> (ø)
apps/deploy-web/src/types/index.ts 100.00% <ø> (ø)
apps/deploy-web/src/utils/sdl/data.ts 100.00% <ø> (ø)
...deploy-web/src/components/layout/NodeStatusBar.tsx 47.36% <50.00%> (ø)
...s/deploy-web/src/components/sdl/GpuFormControl.tsx 0.00% <0.00%> (ø)
...ps/deploy-web/src/components/layout/ModeToggle.tsx 27.77% <25.00%> (ø)
...loy-web/src/components/layout/SidebarGroupMenu.tsx 45.45% <25.00%> (-4.55%) ⬇️
apps/deploy-web/src/components/layout/Layout.tsx 38.33% <0.00%> (-0.65%) ⬇️
.../src/components/layout/SidebarHoveredGroupMenu.tsx 40.00% <40.00%> (ø)
...y-web/src/components/layout/SidebarRouteButton.tsx 31.81% <20.00%> (-9.36%) ⬇️
... and 2 more

... and 136 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
@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.

Actionable comments posted: 6

🧹 Nitpick comments (3)
apps/deploy-web/src/components/layout/SidebarHoveredGroupMenu.tsx (1)

21-37: Consider adding more aria attributes for better accessibility

While the component uses semantic HTML and role attributes, you could enhance accessibility by adding aria-labelledby to connect the nav element with the group title.

-      <nav className={cn("flex flex-1 flex-col", { ["items-center"]: !isNavOpen })} aria-label="Sidebar">
+      <nav 
+        className={cn("flex flex-1 flex-col", { ["items-center"]: !isNavOpen })} 
+        aria-label={`Sidebar ${group.title || 'Menu'}`}
+        aria-labelledby={group.title ? `sidebar-group-${group.title}` : undefined}
+      >
        <ul role="list" className="w-full space-y-1">
          {!!group.title && isNavOpen && (
            <li>
-              <span className="text-sm font-light">{group.title}</span>
+              <span id={`sidebar-group-${group.title}`} className="text-sm font-light">{group.title}</span>
            </li>
          )}
apps/deploy-web/src/components/layout/SidebarGroupMenuPopover.tsx (1)

50-57: Shadowed variable & unstable React key

Using the same identifier route in the map callback shadows the outer prop and makes the JSX harder to read.
More importantly, the key relies on route.title, which is optional in ISidebarRoute; if two routes omit title you’ll get duplicate keys and React warnings.

{route.hoveredRoutes?.map((grp, idx) => (
-  <SidebarHoveredGroupMenu key={route.title} group={route} … />
+  <SidebarHoveredGroupMenu key={grp.title ?? idx} group={grp} … />
))}
apps/deploy-web/src/components/layout/SidebarRouteButton.tsx (1)

55-56: Anchor rendered even for “non-link” routes

route.url && useNextLinkTag ? <Link …> is fine, but the fallback always renders an <a> even when route.url is falsy. If the item is supposed to be a plain button (e.g. triggers state changes), prefer button to avoid confusing semantics and screen-reader behaviour.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between ed61a3a and bd152e3.

📒 Files selected for processing (12)
  • apps/deploy-web/src/components/home/HomeContainer.tsx (0 hunks)
  • apps/deploy-web/src/components/layout/ModeToggle.tsx (2 hunks)
  • apps/deploy-web/src/components/layout/NodeStatusBar.tsx (3 hunks)
  • apps/deploy-web/src/components/layout/Sidebar.tsx (6 hunks)
  • apps/deploy-web/src/components/layout/SidebarGroupMenu.tsx (2 hunks)
  • apps/deploy-web/src/components/layout/SidebarGroupMenuPopover.tsx (1 hunks)
  • apps/deploy-web/src/components/layout/SidebarHoveredGroupMenu.tsx (1 hunks)
  • apps/deploy-web/src/components/layout/SidebarRouteButton.tsx (3 hunks)
  • apps/deploy-web/src/components/sdl/GpuFormControl.tsx (1 hunks)
  • apps/deploy-web/src/types/index.ts (1 hunks)
  • apps/deploy-web/src/utils/sdl/data.ts (2 hunks)
  • packages/ui/components/pagninator.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/deploy-web/src/components/home/HomeContainer.tsx
🧰 Additional context used
🧬 Code Graph Analysis (4)
apps/deploy-web/src/components/layout/SidebarGroupMenu.tsx (2)
apps/deploy-web/src/components/layout/SidebarRouteButton.tsx (1)
  • SidebarRouteButton (21-72)
apps/deploy-web/src/components/layout/SidebarGroupMenuPopover.tsx (1)
  • SidebarGroupMenuPopover (17-62)
apps/deploy-web/src/components/layout/SidebarRouteButton.tsx (2)
apps/provider-console/src/utils/styleUtils.ts (1)
  • cn (4-6)
packages/ui/components/tooltip.tsx (3)
  • Tooltip (76-76)
  • TooltipTrigger (76-76)
  • TooltipContent (76-76)
apps/deploy-web/src/components/layout/SidebarHoveredGroupMenu.tsx (3)
apps/deploy-web/src/types/index.ts (1)
  • ISidebarGroupMenu (17-21)
apps/provider-console/src/utils/styleUtils.ts (1)
  • cn (4-6)
apps/deploy-web/src/components/layout/SidebarRouteButton.tsx (1)
  • SidebarRouteButton (21-72)
apps/deploy-web/src/components/layout/NodeStatusBar.tsx (2)
packages/network-store/src/network.store.ts (1)
  • selectedNetwork (66-68)
apps/provider-console/src/components/shared/LinearLoadingSkeleton.tsx (1)
  • LinearLoadingSkeleton (8-10)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test-stats-web-build
  • GitHub Check: test-deploy-web-build
  • GitHub Check: test-provider-console-build
🔇 Additional comments (18)
apps/deploy-web/src/components/layout/ModeToggle.tsx (3)

4-4: Appropriate dependency management.

The import of the Button component from the organization's UI library ensures consistent styling and behavior across the application.


27-41: UI improvement with better accessibility and user experience.

The change from a dropdown to discrete buttons provides several benefits:

  • Immediate visibility of all theme options
  • Direct interaction without extra clicks
  • Clear visual indication of the active theme via the "text-primary" class
  • Proper accessibility with screen reader text for each button

This implementation aligns with modern UI practices for theme toggles.


36-40: Creative solution for system theme representation.

The system theme button cleverly uses absolute positioning to overlay both light and dark theme icons, visually communicating that this option adapts to system preferences.

packages/ui/components/pagninator.tsx (5)

46-82: Great refactoring of the pagination logic!

The new implementation is much more straightforward and maintainable. By using a consistent pattern of showing:

  1. Always the first page
  2. A conditional starting ellipsis
  3. A sliding window of pages around the current page
  4. A conditional ending ellipsis
  5. Always the last page

This approach creates a more intuitive pagination experience while simplifying the code. The sliding window calculation with Math.max and Math.min is elegant and handles edge cases well.


44-44: Good early return pattern.

The early return for simpler cases improves code readability and performance by exiting the function early when pagination is straightforward.


59-61: Well-implemented sliding window logic.

The calculation of startPage and endPage using Math.max and Math.min is an elegant way to handle boundary conditions while maintaining a consistent window size around the current page.


55-57: Proper ellipsis condition for start range.

The condition currentPage > 4 correctly determines when to show the starting ellipsis, which ensures we don't show an ellipsis when it's not necessary (when the current page is close to the beginning).


71-73: Proper ellipsis condition for end range.

The condition currentPage < totalPages - 3 correctly determines when to show the ending ellipsis, which ensures we don't show an ellipsis when it's not necessary (when the current page is close to the end).

apps/deploy-web/src/utils/sdl/data.ts (1)

163-163: Consistent pricing change applied to defaultRentGpuService

The same pricing amount increase (from 10,000 to 100,000 uakt) has been applied consistently to the GPU service configuration, maintaining parity between service types.

apps/deploy-web/src/components/sdl/GpuFormControl.tsx (1)

117-119: Improved UX with automatic GPU count initialization

This enhancement ensures a valid initial state by automatically setting the GPU count to 1 when a user enables GPU support with a zero count. This prevents inconsistent configurations and improves the user experience.

apps/deploy-web/src/types/index.ts (1)

24-24: Clean type updates to support new sidebar functionality

The changes to ISidebarRoute type properly support the new sidebar navigation system by making previously required properties optional and adding new properties for hover menus, dividers, and custom components.

These type changes align well with the component implementations in SidebarGroupMenu, SidebarHoveredGroupMenu, and others.

Also applies to: 26-27, 32-34

apps/deploy-web/src/components/layout/SidebarGroupMenu.tsx (2)

7-7: LGTM: New import for SidebarGroupMenuPopover

The import is correctly added to support the conditional rendering pattern implemented below.


31-35: Good implementation of conditional menu rendering

The conditional rendering logic is clean and effectively determines whether to show a standard route button or a popover menu based on the presence of hoveredRoutes.

apps/deploy-web/src/components/layout/SidebarHoveredGroupMenu.tsx (1)

1-40: Well-structured new component for hovered sidebar menus

This component is well-organized and follows good React practices:

  • Clear prop types with appropriate optional flags
  • Good use of conditional rendering for the divider and group title
  • Proper handling of custom components vs. standard route buttons
  • Semantic HTML structure with nav and list roles for accessibility

The component correctly passes isHovered to the SidebarRouteButton to ensure proper display within hover menus.

apps/deploy-web/src/components/layout/NodeStatusBar.tsx (4)

2-2: Updated import to include Separator component

Added Separator to support the new layout with a divider at the bottom of the component.


20-22: Improved layout for network title display

The updated flex layout provides better alignment and spacing for the network title.


26-28: Enhanced button styling for better visual hierarchy

Good styling updates to the node status button:

  • Changed to "secondary" variant for visual consistency with the sidebar
  • Added flex layout with justify-between for better alignment of the node ID and status

44-44: Good addition of visual separator

The Separator component with margin creates a clear visual distinction between the node status and following content.

@baktun14 baktun14 force-pushed the features/improve-sidebar branch from 6ca90a9 to 2ed6000 Compare May 21, 2025 00:01
@baktun14 baktun14 merged commit 77e88dd into main May 21, 2025
26 of 27 checks passed
@baktun14 baktun14 deleted the features/improve-sidebar branch May 21, 2025 14:13
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.

1 participant
0