Skip to content

feat: new navbar and breadcrumbs#2743

Merged
ogzhanolguncu merged 7 commits intomainfrom
new-navbar
Dec 13, 2024
Merged

feat: new navbar and breadcrumbs#2743
ogzhanolguncu merged 7 commits intomainfrom
new-navbar

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Dec 12, 2024

What does this PR do?

ENG-1585

Example Usage:

    <Navbar>
        <Navbar.Breadcrumbs icon={<Layers2 />}>
          <Navbar.Breadcrumbs.Link href="/apis">APIs</Navbar.Breadcrumbs.Link>
          <Navbar.Breadcrumbs.Link href="/apis/license-keys" isIdentifier>
            license-keys
          </Navbar.Breadcrumbs.Link>
          <Navbar.Breadcrumbs.Link href="/apis/keys">
            Keys
          </Navbar.Breadcrumbs.Link>
          <Navbar.Breadcrumbs.Ellipsis />
          <Navbar.Breadcrumbs.Link href="/apis/keys/key_2K" active isIdentifier>
            key_2K
          </Navbar.Breadcrumbs.Link>
        </Navbar.Breadcrumbs>
        <Navbar.Actions>
          <Button>button 1</Button>
          <Button>button 2</Button>
        </Navbar.Actions>
      </Navbar>

This PR also contains another small component that will be required for the Navbar. Currently, App relies heavily on Layout and adds padding through it. However, this approach creates issues since we can't add padding individually to each page. To fix this problem, we'll use:

export function PageContent({ children }: PropsWithChildren) {
  return <div className="p-4 lg:p-8">{children}</div>;
}

We'll wrap our pages with this component, which will handle padding for us. This will allow us to freely adjust padding for the navbar and other components.

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

This is how it will look.
image

Summary by CodeRabbit

  • New Features

    • Introduced a Navbar component with navigation functionality, including Actions, Breadcrumbs, and Link components.
    • Added a PageContent component for consistent layout management with responsive padding.
  • Documentation

    • Enhanced component display names for improved debugging and readability in React DevTools.

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2024

⚠️ No Changeset found

Latest commit: 5f560d0

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 Dec 12, 2024

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 Dec 13, 2024 9:06am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 9:06am
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 9:06am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 9:06am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

📝 Walkthrough

Walkthrough

This pull request introduces two new components to the dashboard: Navbar and PageContent. The Navbar component serves as a navigation bar with nested components for actions and breadcrumbs, while the PageContent component provides a layout wrapper for its children with specified padding. Both components are designed to enhance the user interface and improve navigation within the application.

Changes

File Change Summary
apps/dashboard/components/navbar.tsx Added Navbar component with nested Actions, Breadcrumbs, and Link components; defined types and interfaces; set display names for debugging.
apps/dashboard/components/page-content.tsx Introduced PageContent component to wrap children with specific padding classes.

Possibly related PRs

  • fix: add copy button to log details sections #2708: The changes in this PR involve adding a copy button to the log details sections, which may relate to the navigation functionality introduced in the main PR's Navbar component, as both enhance user interaction within the application.
  • feat: add beta tag to sidebar for logs #2716: This PR adds a beta tag to the sidebar for logs, which is relevant to the navigation context established in the main PR's Navbar component, as both involve navigation elements within the application.
  • chore: Update footer.tsx #2735: The addition of a link to the status page in the footer relates to the overall navigation structure of the application, similar to the navigation enhancements made in the main PR's Navbar component.

Suggested labels

Feature, 🕹️ oss.gg, :joystick: 300 points

Suggested reviewers

  • mcstepp
  • chronark
  • perkinsjr

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>, 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. (Experiment)
  • @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 Dec 12, 2024

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: 3

🧹 Outside diff range and nitpick comments (1)
apps/dashboard/components/navbar.tsx (1)

85-85: Use Block Statements in if Conditions for Consistency

For better readability and to follow standard coding practices, it's recommended to wrap the return statement inside a block {} after the if condition.

Apply this change:

- if (!React.isValidElement(child)) return null;
+ if (!React.isValidElement(child)) {
+   return null;
+ }
🧰 Tools
🪛 Biome (1.9.4)

[error] 85-85: Block statements are preferred in this position.

Unsafe fix: Wrap the statement with a JsBlockStatement

(lint/style/useBlockStatements)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a95fcd and 095cd1d.

📒 Files selected for processing (3)
  • apps/dashboard/components/navbar.tsx (1 hunks)
  • apps/dashboard/components/page-content.tsx (1 hunks)
  • apps/dashboard/tailwind.config.js (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/dashboard/components/page-content.tsx

[error] 1-1: All these imports are only used as types.

Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Use import type.

(lint/style/useImportType)

apps/dashboard/components/navbar.tsx

[error] 85-85: Block statements are preferred in this position.

Unsafe fix: Wrap the statement with a JsBlockStatement

(lint/style/useBlockStatements)


[error] 90-90: Avoid using the index of an array as key property in an element.

This is the source of the key value.

The order of the items may change, and this also affects performances and component state.
Check the React documentation.

(lint/suspicious/noArrayIndexKey)


[error] 93-93: Avoid using the index of an array as key property in an element.

This is the source of the key value.

The order of the items may change, and this also affects performances and component state.
Check the React documentation.

(lint/suspicious/noArrayIndexKey)

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: 1

🧹 Outside diff range and nitpick comments (4)
apps/dashboard/components/navbar.tsx (4)

35-36: Address background color inconsistency

The TODO comment indicates a design system inconsistency with the background color. This should be resolved to maintain consistency across the application.

Consider:

  1. Updating the design system to use the correct background color
  2. Creating a new design token for this specific use case
  3. Documenting the decision in the design system documentation

46-52: Add ARIA role for better accessibility

The Actions component should have an appropriate ARIA role to improve accessibility.

 <div 
   ref={ref} 
+  role="toolbar"
+  aria-label="Page actions"
   className={cn("flex items-center gap-3", className)} 
   {...props}
 >

86-110: Enhance keyboard navigation support

Consider adding keyboard navigation support for better accessibility.

 <a
   ref={ref}
   href={href}
+  tabIndex={0}
+  role="link"
   className={cn(
     "text-sm transition-colors",
     active ? "text-accent-12" : "text-accent-10 hover:text-accent-11",
     dynamic && "font-mono",
     className,
   )}
   {...(active || isLast ? { "aria-current": "page" } : {})}
   {...props}
 >

112-123: Consider making ellipsis interactive

The ellipsis could be enhanced to show hidden breadcrumbs when clicked, improving navigation for users.

Consider implementing a dropdown or popover to display the hidden navigation items when the ellipsis is clicked.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between befd54b and 949833b.

📒 Files selected for processing (1)
  • apps/dashboard/components/navbar.tsx (1 hunks)
🔇 Additional comments (2)
apps/dashboard/components/navbar.tsx (2)

77-78: Consider alternative to index as key

While the current usage of index as key is marked as acceptable, consider if there's a way to derive a more stable key from the child props or content.

#!/bin/bash
# Check if child elements typically have stable props that could be used as keys
ast-grep --pattern 'React.cloneElement($child, { key: $_ })'

127-131: LGTM! Well-structured component naming

The display names are properly set and follow a consistent naming convention, which will help with debugging and component identification in React DevTools.

Copy link
Collaborator

@MichaelUnkey MichaelUnkey left a comment

Choose a reason for hiding this comment

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

Might be a good idea to add this component to our internal UI and Engineering docs

internal/ui/src/components
apps/engineering/content/design/components
Markdown with examples of usage.

Not sure if this or another PR would be better.
This would also give us a place to view the component as @chronark suggested in slack Here.

@chronark
Copy link
Collaborator

@MichaelUnkey how would you have approached this differently?

@ogzhanolguncu
Copy link
Contributor Author

@MichaelUnkey how would you have approached this differently?

I'm merging this since this is a blocker for breadcrumb clean-up, but let's keep the discussion going.

@pullflow-com
Copy link

pullflow-com bot commented Dec 13, 2024

From Oz@chronark could you leave an approve so we move on with cleanup

@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue Dec 13, 2024
Merged via the queue into main with commit bc34781 Dec 13, 2024
@ogzhanolguncu ogzhanolguncu deleted the new-navbar branch December 13, 2024 11:06
@pullflow-com
Copy link

pullflow-com bot commented Dec 13, 2024

From Oz ‣ yeah on it

@pullflow-com
Copy link

pullflow-com bot commented Dec 13, 2024

From Oz ‣ finding icons on nucleo is hard as f

@pullflow-com
Copy link

pullflow-com bot commented Dec 13, 2024

From Oz ‣ 😄

Copy link
Collaborator

did you log in?
most of them are only visible when you’re logged in

@pullflow-com
Copy link

pullflow-com bot commented Dec 13, 2024

From Oz ‣ yeah problem is finding the matching on from figma

@pullflow-com
Copy link

pullflow-com bot commented Dec 13, 2024

From Oz ‣ I think i'll tell Vitor to update names on Figma like This svg is search-input

Copy link
Collaborator

Copy link
Collaborator

no need to ask vitor, he already helped

@chronark
Copy link
Collaborator

Might be a good idea to add this component to our internal UI and Engineering docs

internal/ui/src/components apps/engineering/content/design/components Markdown with examples of usage.

Not sure if this or another PR would be better. This would also give us a place to view the component as @chronark suggested in slack Here.

@MichaelUnkey
I don't think this has a place in the shared ui package. The reason is that it's not really shared between anything. It's only used in the dashboard, so it's easier to just keep it there.

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.

3 participants