Skip to content

feat: sidebar first iteration#2992

Closed
ogzhanolguncu wants to merge 2 commits intomainfrom
feat-sidebar
Closed

feat: sidebar first iteration#2992
ogzhanolguncu wants to merge 2 commits intomainfrom
feat-sidebar

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Mar 19, 2025

What does this PR do?

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Redesigned the dashboard layout with an enhanced sidebar, offering more intuitive navigation and improved responsiveness.
    • Introduced new UI components for breadcrumb navigation and customizable buttons, enriching the overall user interface.
    • Added a mobile detection hook to ensure optimal behavior across devices.
  • Style

    • Updated background colors and border accents for a refreshed, modern look.
  • Chores

    • Upgraded dependencies and refined configuration settings for better performance and consistency.

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2025

⚠️ No Changeset found

Latest commit: d7ace92

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Mar 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 3:16pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 3:16pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 3:16pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 3:16pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2025

📝 Walkthrough

Walkthrough

This pull request restructures the dashboard layout and sidebar architecture. The previous sidebar components have been replaced with new ones—AppSidebar, SidebarInset, and SidebarProvider—with updated styling and layout structure. Workspace navigations now import icons from a different library and adjust the corresponding type definitions. Several new UI components have been added, including breadcrumb navigation and a customizable button, along with comprehensive sidebar subcomponents and a new mobile detection hook. Additional configuration updates include changes to the Tailwind setup and an upgraded dependency in the package manifest.

Changes

File(s) Change Summary
apps/dashboard/app/(app)/layout.tsx
apps/dashboard/app/(app)/workspace-navigations.tsx
Layout & Navigation: Restructured layout by replacing DesktopSidebar and MobileSideBar with AppSidebar, SidebarInset, and SidebarProvider. Updated workspace navigations to use @unkey/icons and refined the NavItem type.
apps/dashboard/components/app-sidebar.tsx
apps/dashboard/components/ui/sidebar.tsx
Sidebar Components: Introduced new sidebar components. Added AppSidebar for sidebar rendering and a comprehensive sidebar implementation with multiple subcomponents (e.g., SidebarProvider, SidebarTrigger, SidebarMenu, etc.) managing state and responsive behaviors.
apps/dashboard/components/ui/breadcrumb.tsx
apps/dashboard/components/ui/button.tsx
apps/dashboard/components/ui/collapsible.tsx
UI Components: Added new components for breadcrumb navigation and a customizable button. Made formatting adjustments in the collapsible component (removal of semicolons).
apps/dashboard/components.json Configuration: Added a "tsx": true flag for TypeScript JSX support, a new Tailwind CSS "prefix": "" option, and new alias mappings for "ui", "lib", and "hooks".
apps/dashboard/hooks/use-mobile.tsx Hook: Introduced the useIsMobile hook to detect mobile viewport sizes using a media query.
apps/dashboard/package.json Dependency Update: Upgraded the tailwind-merge dependency from ^2.2.2 to ^2.5.4.
internal/ui/tailwind.config.js Tailwind Config: Added a new color name "base" in the generateRadixColors function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Layout
    participant SidebarProvider
    participant AppSidebar
    participant SidebarInset

    User->>Layout: Load application
    Layout->>SidebarProvider: Initialize sidebar state
    SidebarProvider->>AppSidebar: Render sidebar UI components
    AppSidebar->>SidebarInset: Display navigation & main content
    User->>AppSidebar: Interact (toggle/sidebar action)
Loading

Possibly related PRs

Suggested labels

🕹️ oss.gg, :joystick: 300 points, Good first issue

Suggested reviewers

  • mcstepp
  • chronark
  • perkinsjr

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code 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 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 generate unit testing code.
    • @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.

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 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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2025

Thank you for following the naming conventions for pull request titles! 🙏

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.

Actionable comments posted: 2

🧹 Nitpick comments (6)
apps/dashboard/hooks/use-mobile.tsx (1)

5-7: Consider handling SSR more gracefully.

Because window is only available in the browser, this logic won’t run on the server. That’s fine, but when the component first mounts, isMobile remains undefined briefly. Consider initializing it to false or clarifying this behavior in documentation to avoid confusion in a server-side render scenario.

apps/dashboard/components/ui/button.tsx (1)

43-56: Set a default type="button" if not otherwise specified.

When <button> is used inside forms, browsers default to type="submit", which can produce unintended behavior. Consider using a default type of button unless the user specifies otherwise.

 const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
   ({ className, variant, size, asChild = false, ...props }, ref) => {
     const Comp = asChild ? Slot : "button"
     return (
       <Comp
-        className={cn(buttonVariants({ variant, size, className }))}
+        className={cn(buttonVariants({ variant, size, className }))}
+        type={props.type || "button"}
         ref={ref}
         {...props}
       />
     )
   }
 )
apps/dashboard/app/(app)/layout.tsx (2)

31-33: Enhance cross-browser compatibility of viewport units.

The h-[100dvh] unit is supported on most modern browsers. Some older or mobile browsers might mishandle it due to browser UI chrome. This is likely fine for a dashboard, but consider known cross-browser caveats if usage on mobile is critical.


40-65: Evaluate user experience for a disabled workspace.

The fallback for when workspace.enabled is false is consistent, but it leaves the user in a partially rendered layout with a static message. Consider offering a more explicit call to action (e.g., a button linking to support resources) or additional instructions so users clearly know what to do next.

apps/dashboard/app/(app)/workspace-navigations.tsx (1)

45-48: Add test coverage for the Tag component.
This new Tag component is a useful addition. Consider adding a light test suite to verify that it correctly renders the provided label and applies custom class names.

apps/dashboard/components/app-sidebar.tsx (1)

48-57: Ensure future expansions of nested navigation are handled.
Although createNestedNavigation simply returns baseNav for now, its structure indicates future sub-item logic. Verify that deeper sub-navigation needs are addressed in subsequent iterations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4e5f6d and d7ace92.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • apps/dashboard/app/(app)/layout.tsx (2 hunks)
  • apps/dashboard/app/(app)/workspace-navigations.tsx (6 hunks)
  • apps/dashboard/components.json (1 hunks)
  • apps/dashboard/components/app-sidebar.tsx (1 hunks)
  • apps/dashboard/components/ui/breadcrumb.tsx (1 hunks)
  • apps/dashboard/components/ui/button.tsx (1 hunks)
  • apps/dashboard/components/ui/collapsible.tsx (1 hunks)
  • apps/dashboard/components/ui/sidebar.tsx (1 hunks)
  • apps/dashboard/hooks/use-mobile.tsx (1 hunks)
  • apps/dashboard/package.json (1 hunks)
  • internal/ui/tailwind.config.js (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
apps/dashboard/app/(app)/workspace-navigations.tsx (1)
apps/dashboard/lib/utils.ts (1) (1)
  • cn (5-7)
apps/dashboard/app/(app)/layout.tsx (3)
apps/dashboard/components/ui/sidebar.tsx (2) (2)
  • SidebarProvider (768-768)
  • SidebarInset (758-758)
apps/dashboard/components/app-sidebar.tsx (1) (1)
  • AppSidebar (171-206)
internal/ui/src/components/empty.tsx (1) (1)
  • Empty (6-18)
🪛 Biome (1.9.4)
apps/dashboard/components/ui/breadcrumb.tsx

[error] 64-71: The HTML element with the interactive role "link" is not focusable.

A non-interactive HTML element that is not focusable may not be reachable for users that rely on keyboard navigation, even with an added role like "link".
Add a tabIndex attribute to make this element focusable.

(lint/a11y/useFocusableInteractive)

⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Docs
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (17)
apps/dashboard/components.json (1)

5-5: Configuration updates look good for supporting the new sidebar components

The addition of TSX support and the empty prefix for Tailwind classes will provide a cleaner development experience. The new aliases for UI components, libraries, and hooks create a well-organized import structure that will help maintain consistency across the codebase.

Also applies to: 10-11, 15-18

internal/ui/tailwind.config.js (1)

79-79: New "base" color palette is a good addition

The inclusion of a "base" color set provides more design flexibility for the sidebar implementation. This follows the established pattern for color definition in the application.

Consider documenting this color's purpose and usage in a design system document if not already done.

apps/dashboard/package.json (1)

100-100: Package update to tailwind-merge looks good

Updating to the newer version (2.5.4) is appropriate when introducing new UI components like the sidebar. This update likely includes performance improvements and bug fixes that will benefit the new implementation.

apps/dashboard/components/ui/collapsible.tsx (1)

1-11: Style formatting changes for consistency

The removal of semicolons appears to be for code style consistency. While this doesn't affect functionality, maintaining a consistent code style across the project is important.

Ensure these changes align with the project's ESLint configuration or style guide.

apps/dashboard/hooks/use-mobile.tsx (1)

18-19: Enforce consistency on the returned value.

Returning !!isMobile forces a boolean output, which is good. Just ensure all consumers interpret false correctly for loading states or SSR scenarios.

apps/dashboard/components/ui/button.tsx (1)

7-35: Button variants look consistent with the design system.

The class-variance-authority setup is neat and covers common variant cases. No issues here.

apps/dashboard/app/(app)/layout.tsx (1)

34-39: Check for potential global state overlaps.

Wrapping the layout in <SidebarProvider> might affect anything that uses this global context. Ensure that the new context is only influencing components that need it, particularly if other parts of the dashboard layout expect a different context or layout structure.

apps/dashboard/app/(app)/workspace-navigations.tsx (2)

6-14: Switch to the new icon library and broader icon type looks good.
The import changes from lucide-react to @unkey/icons and adjusting the icon property from a narrower type to React.ElementType provide flexibility. This aligns with the PR's objective of refining the dashboard UX.

Also applies to: 16-19


62-129: Updated navigation icons align with the new design system.
All icon references have been successfully updated to the @unkey/icons library. This fully supports the PR’s directive for a more unified style.

apps/dashboard/components/app-sidebar.tsx (4)

38-46: Utility function for button styles is concise.
The getButtonStyles function cleanly merges conditional classNames, which simplifies style management in various states.


59-168: Good use of concurrent UI state transitions.
Employing useTransition for navigation feedback is a neat pattern. It keeps the UI responsive by showing a spinner while transitioning.


170-206: AppSidebar integrates neatly into the layout.
The structure, including SidebarHeader, SidebarContent, and SidebarFooter, helps maintain a clear separation of layout elements.


208-281: Animated spinner handles reduced motion gracefully.
The logic respects user motion preferences with prefers-reduced-motion. This attention to accessibility is commendable.

apps/dashboard/components/ui/sidebar.tsx (4)

56-163: SidebarProvider properly manages sidebar state with cookies.
Storing and restoring the sidebar state via cookies and providing a controlled vs. uncontrolled API is a solid design.


165-270: Core Sidebar component logic is clear and flexible.
The variant-based approach (sidebar, floating, inset) keeps styling concerns organized. Collapsible patterns are well handled.


546-603: Tooltip logic for collapsed sidebars is well-structured.
Conditionally displaying the tooltip when the sidebar is collapsed is a nice touch, improving discoverability of icons.


712-717: Sub-item structure is straightforward.
SidebarMenuSubItem is a simple container that cleanly separates sub-menu item logic.

Comment on lines +8 to +16
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
mql.addEventListener("change", onChange)
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
return () => mql.removeEventListener("change", onChange)
}, [])
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Provide a fallback for older browsers.

mql.addEventListener("change", onChange) is not supported in some older browsers, which still rely on mql.addListener. You may want a small compatibility fallback if older browsers must be supported.

 React.useEffect(() => {
   const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
-  mql.addEventListener("change", onChange)
+  if (mql.addEventListener) {
+    mql.addEventListener("change", onChange)
+  } else {
+    mql.addListener(onChange)
+  }

   return () => {
-    mql.removeEventListener("change", onChange)
+    if (mql.removeEventListener) {
+      mql.removeEventListener("change", onChange)
+    } else {
+      mql.removeListener(onChange)
+    }
   }
 }, [])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
mql.addEventListener("change", onChange)
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
return () => mql.removeEventListener("change", onChange)
}, [])
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
if (mql.addEventListener) {
mql.addEventListener("change", onChange)
} else {
mql.addListener(onChange)
}
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
return () => {
if (mql.removeEventListener) {
mql.removeEventListener("change", onChange)
} else {
mql.removeListener(onChange)
}
}
}, [])

Comment on lines +64 to +71
<span
ref={ref}
role="link"
aria-disabled="true"
aria-current="page"
className={cn("font-normal text-foreground", className)}
{...props}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve accessibility issue with non-focusable link role.
Using role="link" on a <span> that lacks focusability conflicts with accessibility guidelines. Either remove the link role or add a tabIndex={0} and an appropriate click handler if you want keyboard users to navigate.

-  <span
-    role="link"
-    aria-disabled="true"
-    aria-current="page"
-    ...
-  />
+  <span
+    aria-disabled="true"
+    aria-current="page"
+    ...
+  />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<span
ref={ref}
role="link"
aria-disabled="true"
aria-current="page"
className={cn("font-normal text-foreground", className)}
{...props}
/>
<span
ref={ref}
aria-disabled="true"
aria-current="page"
className={cn("font-normal text-foreground", className)}
{...props}
/>
🧰 Tools
🪛 Biome (1.9.4)

[error] 64-71: The HTML element with the interactive role "link" is not focusable.

A non-interactive HTML element that is not focusable may not be reachable for users that rely on keyboard navigation, even with an added role like "link".
Add a tabIndex attribute to make this element focusable.

(lint/a11y/useFocusableInteractive)

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