Skip to content

Conversation

Arpan-206
Copy link
Member

@Arpan-206 Arpan-206 commented Jul 28, 2025

Checklist:

  • I've thoroughly self-reviewed my changes
  • I've added tests for my changes, unless they affect admin-only areas (or are otherwise not worth testing)
  • I've verified any visual changes using Percy (add a commit with [percy] in the message to trigger)

Summary by CodeRabbit

  • New Features

    • Introduced a floating teal bar in the desktop header that smoothly highlights the active navigation link.
    • Navigation links dynamically update their style to clearly indicate the active route.
  • Style

    • Enhanced header navigation link styling with distinct colors for active and inactive states.
  • Bug Fixes

    • Improved accuracy and responsiveness of active route highlighting in the header navigation.

Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Warning

Rate limit exceeded

@Arpan-206 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bf893e5 and ba2406c.

📒 Files selected for processing (1)
  • app/components/header/index.ts (5 hunks)

Walkthrough

A floating green bar has been added to the desktop header navigation to visually highlight the active route. This involves new logic and properties in the header component for positioning and animating the bar, dynamic class assignment to navigation links based on route activity, and route awareness in link components. No changes were made to exported or public entity declarations beyond new tracked properties and actions.

Changes

Cohort / File(s) Change Summary
Header Component Template & Floating Bar
app/components/header/index.hbs
Wrapped navigation links in a container with lifecycle modifiers to handle floating bar setup and updates. Added a new absolutely positioned floating green bar element whose style is dynamically bound to component state, visually highlighting the active navigation link.
Header Component Logic & Bar Positioning
app/components/header/index.ts
Introduced tracked properties for floating bar style and container reference, new actions for floating bar setup and updates, and logic to compute and animate the floating bar's position relative to the active navigation link. Extended route change handling to update the bar.
Navigation Link Template
app/components/header/link.hbs
Updated the LinkTo element to use dynamic classes based on its active state, added a relative class, and included a data-route attribute for identification. The active state now visually alters text color.
Navigation Link Logic
app/components/header/link.ts
Added an injected router service and a computed isActive getter to determine if the link represents the current route or its parent route, enabling dynamic styling and route awareness in the link component.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RouterService
    participant HeaderComponent
    participant LinkComponent

    User->>RouterService: Navigates to a new route
    RouterService-->>HeaderComponent: Notify route change
    HeaderComponent->>HeaderComponent: handleRouteChange()
    HeaderComponent->>HeaderComponent: findAndPositionActiveLink()
    HeaderComponent->>LinkComponent: Query active link element (via data-route)
    LinkComponent->>RouterService: Check if link is active
    RouterService-->>LinkComponent: Return route match
    LinkComponent-->>HeaderComponent: Return active link element
    HeaderComponent->>HeaderComponent: calculateFloatingBarPosition()
    HeaderComponent-->>User: Animate floating bar to active link position
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

A floating bar, a teal delight,
Glides beneath the links so bright.
When routes do change, it moves anew,
Highlighting paths for all to view.
Rabbits cheer with every hop—
Our header’s style just leveled up!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch floating-green-bars

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 generate unit tests to generate unit tests 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.

cursor[bot]

This comment was marked as outdated.

Copy link

github-actions bot commented Jul 28, 2025

Test Results

  1 files  ±0    1 suites  ±0   8m 44s ⏱️ +18s
642 tests +2  594 ✅ +3  48 💤 ±0  0 ❌ ±0 
642 runs  +2  594 ✅ +4  48 💤 ±0  0 ❌  - 1 

Results for commit 9969be2. ± Comparison against base commit e8e990a.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 5 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/header/link.ts 42.85% 2 Missing and 2 partials ⚠️
app/components/header/index.ts 94.44% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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

♻️ Duplicate comments (2)
app/components/header/index.ts (2)

123-137: Critical: Fix null pointer error and formatting issues

This method has the exact null pointer issue identified in the previous review, plus multiple formatting problems.

The method attempts to call getBoundingClientRect() on activeLink without null checking, and has several formatting issues:

   private positionFloatingBar(activeLink: HTMLElement, container: HTMLElement) {
+    if (!activeLink) {
+      this.floatingBarStyle = 'opacity: 0;';
+      return;
+    }
+
     const containerRect = container.getBoundingClientRect();
     const linkRect = activeLink.getBoundingClientRect();
-    
+
     const left = linkRect.left - containerRect.left;
     const width = linkRect.width;
     const bottom = -18;
-    
+
     this.floatingBarStyle = `
       left: ${left}px;
       width: ${width}px;
       bottom: ${bottom}px;
       opacity: 1;
     `;
   }

Additionally, move this method before updateFloatingBarPosition to fix member ordering.


116-121: Fix formatting and improve error handling

The method has formatting issues and needs better error handling for when no active link is found.

   private updateFloatingBarPosition(containerElement: HTMLElement) {
     const currentRoute = this.router.currentRouteName;
     const activeLink = containerElement.querySelector(`[data-route="${currentRoute}"]`) as HTMLElement;
-    
+
+    if (!activeLink) {
+      this.floatingBarStyle = 'opacity: 0;';
+      return;
+    }
+
     this.positionFloatingBar(activeLink, containerElement);
   }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d6cc1d and c379280.

📒 Files selected for processing (4)
  • app/components/header/index.hbs (1 hunks)
  • app/components/header/index.ts (3 hunks)
  • app/components/header/link.hbs (1 hunks)
  • app/components/header/link.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/components/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/formatting-component-files.mdc)

app/components/**/*.ts: Use TypeScript (.ts) files for components in app/components
Import from @glimmer/component when creating components
Use interface Signature { ... } to define the component's signature
class doesn't have to be in Args, Ember automatically forwards native args like class, id etc. to the component
Ensure the component is registered with Glint using declare module ...

Files:

  • app/components/header/link.ts
  • app/components/header/index.ts
**/*.{js,ts,hbs,gts,gjs}

📄 CodeRabbit Inference Engine (.rules/no-bugs.md)

**/*.{js,ts,hbs,gts,gjs}: Avoid typos
Don't have really obvious bugs
Follow reasonable conventions of the language we're programming in

Files:

  • app/components/header/link.ts
  • app/components/header/link.hbs
  • app/components/header/index.hbs
  • app/components/header/index.ts
🧠 Learnings (2)
app/components/header/link.ts (4)

Learnt from: CR
PR: codecrafters-io/frontend#0
File: .cursor/rules/formatting-component-files.mdc:0-0
Timestamp: 2025-07-25T04:24:47.305Z
Learning: Applies to app/components/**/*.ts : Use interface Signature { ... } to define the component's signature

Learnt from: CR
PR: codecrafters-io/frontend#0
File: .cursor/rules/formatting-component-files.mdc:0-0
Timestamp: 2025-07-25T04:24:47.305Z
Learning: Applies to app/components/**/*.ts : Import from @glimmer/component when creating components

Learnt from: CR
PR: codecrafters-io/frontend#0
File: .cursor/rules/formatting-component-files.mdc:0-0
Timestamp: 2025-07-25T04:24:47.305Z
Learning: Applies to app/components/**/*.ts : class doesn't have to be in Args, Ember automatically forwards native args like class, id etc. to the component

Learnt from: CR
PR: codecrafters-io/frontend#0
File: .cursor/rules/formatting-component-files.mdc:0-0
Timestamp: 2025-07-25T04:24:47.305Z
Learning: Applies to app/components/**/*.ts : Ensure the component is registered with Glint using declare module ...

app/components/header/index.ts (1)

Learnt from: CR
PR: codecrafters-io/frontend#0
File: .rules/no-bugs.md:0-0
Timestamp: 2025-07-25T04:24:57.955Z
Learning: Applies to **/*.{js,ts,hbs,gts,gjs} : Don't have really obvious bugs

🪛 GitHub Actions: Test
app/components/header/link.ts

[error] 22-22: Prettier formatting error: Delete extra spaces (prettier/prettier).


[warning] Prettier formatting warning: Code style issues found. Run Prettier with --write to fix.

app/components/header/index.hbs

[error] 49-49: ember-template-lint: elements cannot have inline styles (no-inline-styles) and Concatenated styles must be marked as htmlSafe (style-concatenation).


[error] 49-49: ember-template-lint: Concatenated styles must be marked as htmlSafe (style-concatenation).


[warning] Prettier formatting warning: Code style issues found. Run Prettier with --write to fix.

app/components/header/index.ts

[error] 90-90: ESLint: Expected blank line before this statement (padding-line-between-statements).


[error] 106-106: ESLint: Member setupFloatingBar should be declared before member toggleMobileMenu (@typescript-eslint/member-ordering).


[error] 119-119: Prettier formatting error: Delete extra spaces (prettier/prettier).


[error] 123-123: ESLint: Member positionFloatingBar should be declared before member updateFloatingBarPosition (@typescript-eslint/member-ordering).


[error] 126-126: Prettier formatting error: Delete extra spaces (prettier/prettier).


[error] 130-130: Prettier formatting error: Delete extra spaces (prettier/prettier).


[warning] Prettier formatting warning: Code style issues found. Run Prettier with --write to fix.

🔇 Additional comments (9)
app/components/header/link.ts (2)

2-3: LGTM: Proper service imports

The service injection import and RouterService type import follow the expected patterns for Ember components.


16-16: LGTM: Correct service declaration

The router service is properly injected using the documented pattern with proper typing.

app/components/header/link.hbs (2)

4-6: LGTM: Dynamic class assignment based on active state

The conditional class assignment correctly applies darker text colors for active links and lighter colors for inactive ones, while preserving hover states. The relative positioning class is appropriate for the floating bar feature.


8-8: LGTM: Added data-route attribute for DOM querying

The data-route attribute enables the floating bar positioning logic to identify the active link element, which is essential for the feature implementation.

app/components/header/index.hbs (2)

41-41: LGTM: Proper lifecycle modifier usage

The container wrapper with did-insert and did-update modifiers correctly triggers floating bar setup and updates on route changes.


42-44: LGTM: Navigation links structure preserved

The existing navigation link iteration remains unchanged, maintaining the component's functionality while adding the necessary container for floating bar positioning.

app/components/header/index.ts (3)

28-28: LGTM: Proper tracked property initialization

The floatingBarStyle tracked property is correctly initialized with hidden state (opacity: 0).


111-114: LGTM: Floating bar update action

The update action correctly delegates to the position update method.


88-94: Fix formatting and add error handling

The route change handling logic is sound but has formatting issues and needs error handling.

   @action
   handleRouteChange() {
     this.mobileMenuIsExpanded = false;
+
     setTimeout(() => {
       const container = document.querySelector('[data-test-header] .relative') as HTMLElement;
       if (container) {
         this.updateFloatingBarPosition(container);
       }
     }, 10);
   }
⛔ Skipped due to learnings
Learnt from: CR
PR: codecrafters-io/frontend#0
File: .rules/no-bugs.md:0-0
Timestamp: 2025-07-25T04:24:57.955Z
Learning: Applies to **/*.{js,ts,hbs,gts,gjs} : Don't have really obvious bugs

@Arpan-206 Arpan-206 force-pushed the floating-green-bars branch from c379280 to 47a67e2 Compare July 28, 2025 16:54
cursor[bot]

This comment was marked as outdated.

Copy link

codecov bot commented Jul 28, 2025

Bundle Report

Changes will increase total bundle size by 2.38kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
client-array-push 38.42MB 2.38kB (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/chunk.*.js 2.32kB 3.08MB 0.08%
assets/chunk.*.css 55 bytes 231.3kB 0.02%

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

<div
class="absolute -bottom-[18px] h-0.5 bg-teal-500 transition-all duration-200 ease-out"
style={{this.floatingBarStyle}}
data-test-floating-bar
Copy link
Member

Choose a reason for hiding this comment

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

If we aren't using data-... selectors, remove them

}
});
}

@action
handleRouteChange() {
Copy link
Member

Choose a reason for hiding this comment

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

It could be confusing as to why we have two methods for detecting route changes. Let's make this more clear:

  • Rename handleRouteChange -> handleRouteWillChange (this makes it clear that it fires before a transition(
  • Don't do the floating bar update here, it isn't needed and will be triggered in DidUpdateCurrentRouteName anyway.

Closing the mobile menu is something we want to do early (before a page starts loading). Moving the highlight bar though is something that can only be done after a loading state so doesn't need to be done here.

data-test-header-link
data-route={{@route}}
Copy link
Member

Choose a reason for hiding this comment

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

@Arpan-206 arpan let's pay more attention to detail + re-review properly when refactoring - this data-route=... is not needed anymore

cursor[bot]

This comment was marked as outdated.


if (!currentRoute || currentRoute.includes('loading')) {
return;
}
Copy link

Choose a reason for hiding this comment

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

Bug: Floating Bar Visibility Issue During Navigation

The updateFloatingBarPosition method's early return condition currentRoute.includes('loading') is too broad. This prevents the floating bar from appearing on initial page load and causes it to remain visible under a previously active header link instead of hiding when navigating to routes that should not have an active header link (e.g., course pages) if an intermediate loading state is encountered.

Locations (1)
Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

Feels too janky w/o this.

Copy link
Member

Choose a reason for hiding this comment

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

Yep good call

@Arpan-206 Arpan-206 requested a review from rohitpaulk July 31, 2025 13:55
@Arpan-206 Arpan-206 merged commit e3c38a5 into main Aug 1, 2025
9 checks passed
@Arpan-206 Arpan-206 deleted the floating-green-bars branch August 1, 2025 03:24
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.

2 participants