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

fix: restore classname for active tab in categories tab #208

Merged

Conversation

TopETH
Copy link
Member

@TopETH TopETH commented May 3, 2024

Close #170

Summary by CodeRabbit

  • New Features
    • Enhanced navigation in category tabs by introducing dynamic scrolling to the selected category upon initialization.
    • Improved user interface by highlighting the active category tab, making it easier to identify the current selection.

@TopETH TopETH self-assigned this May 3, 2024
Copy link

vercel bot commented May 3, 2024

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

Name Status Preview Comments Updated (UTC)
masterbots ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 4:02am

Copy link
Contributor

coderabbitai bot commented May 3, 2024

Walkthrough

The updates involve enhancing the CategoryLink and CategoryTabs components to improve user interaction with category tabs. The CategoryLink now accepts an activeTab parameter to dynamically adjust its class based on activity. Additionally, a useEffect hook in CategoryTabs ensures the UI scrolls to the active category upon initialization, enhancing user experience by maintaining context.

Changes

Files Change Summary
.../category-tabs/category-link.tsx Added activeTab prop to control active class assignment.
.../category-tabs/category-tabs.tsx Introduced useEffect for auto-scrolling and updated CategoryLink rendering with activeTab.

Assessment against linked issues

Objective Addressed Explanation
Restore classname for active tab in categories tab (#170)

🐇💬
Oh hark! The tabs do dance anew,
With clicks that mark, as changes brew.
A scroll, a glance, a tab in bloom,
Now active states in styles resume.
Code hops along, with joy it springs,
For every tab its own song sings. 🎶🌼


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3af3a2d and d982bfd.
Files selected for processing (2)
  • apps/masterbots.ai/components/shared/category-tabs/category-link.tsx (2 hunks)
  • apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx (2 hunks)
Additional comments not posted (6)
apps/masterbots.ai/components/shared/category-tabs/category-link.tsx (3)

8-13: Added activeTab prop to CategoryLink function signature.

This change aligns with the PR objectives to dynamically update the classname based on the active tab.


18-19: Ensure correct conditional logic for dynamic className assignment.

This verification is crucial to ensure that all category names are correctly transformed and compared against activeTab.

Verification successful

The verification process did not find any instances of toSlug(category.name) being used incorrectly or in a way that would conflict with the conditional logic for className assignment in the provided code snippet. This suggests that the conditional logic as implemented should correctly handle the transformation and comparison of category names against activeTab.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the conditional logic for className assignment correctly handles all possible category names and the 'all' category.

# Test: Search for any category names that might not be correctly handled by the toSlug function or the conditional logic.
rg --type typescript --files-with-matches $'category.name' | xargs rg 'toSlug\($_\)'

Length of output: 118



Script:

#!/bin/bash
# Description: Verify that the conditional logic for className assignment correctly handles all possible category names and the 'all' category.

# Corrected Test: Search for any category names that might not be correctly handled by the toSlug function or the conditional logic.
rg --type ts --files-with-matches $'category.name' | xargs rg 'toSlug\($_\)'

Length of output: 75


30-37: Conditional rendering of motion.span based on active tab.

This implementation ensures that the visual indicator for the active tab is only rendered when necessary, which is efficient and aligns with the intended functionality.

apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx (3)

5-6: Added necessary imports for useEffect and toSlug.

These imports are essential for the new features implemented in this component, such as automatic scrolling and URL-friendly category name transformation.


15-35: Implemented useEffect for automatic scrolling to the initial category.

This feature enhances user experience by navigating directly to the specified category upon component mount. Ensure that the initialCategory prop is always provided or handled gracefully if missing.


39-46: Updated rendering logic to pass activeTab prop to CategoryLink.

This change is crucial for maintaining the visual consistency of the active tab across different components and aligns with the PR objectives.


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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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

github-actions bot commented May 3, 2024

⚡️ Lighthouse report

Page: https://masterbots-d32t22t9e-bitcash.vercel.app/
Report https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1714709383878-75320.report.html

Category Score
🔴 Performance 43
🟢 Accessibility 96
🟠 Best practices 78
🟠 SEO 85
🔴 PWA 38

Page: https://masterbots-d32t22t9e-bitcash.vercel.app/b/moneybot
Report https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1714709384263-72318.report.html

Category Score
🟠 Performance 55
🟢 Accessibility 95
🟠 Best practices 78
🟠 SEO 85
🔴 PWA 38

Page: https://masterbots-d32t22t9e-bitcash.vercel.app/u/slug-1
Report https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1714709384750-86810.report.html

Category Score
🟠 Performance 59
🟢 Accessibility 94
🟠 Best practices 78
🟠 SEO 83
🔴 PWA 38

Page: https://masterbots-d32t22t9e-bitcash.vercel.app/p
Report https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1714709385088-12934.report.html

Category Score
🟠 Performance 60
🟢 Accessibility 92
🟠 Best practices 78
🟠 SEO 76
🔴 PWA 38

Page: https://masterbots-d32t22t9e-bitcash.vercel.app/health
Report https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1714709385410-89173.report.html

Category Score
🟠 Performance 56
🟠 Accessibility 59
🟠 Best practices 74
🔴 SEO 42
🔴 PWA 13

Page: https://masterbots-d32t22t9e-bitcash.vercel.app/health/a8103808-14a3-48ed-aa5a-9e490cfdcf0e
Report https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1714709385617-97439.report.html

Category Score
🟠 Performance 57
🟠 Accessibility 59
🟠 Best practices 74
🔴 SEO 42
🔴 PWA 13

Copy link
Contributor

@AndlerRL AndlerRL left a comment

Choose a reason for hiding this comment

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

LGTM! Merging 👍

@AndlerRL AndlerRL merged commit 0d622f6 into alpha May 3, 2024
4 checks passed
@AndlerRL AndlerRL deleted the topeth/restore-classname-for-active-tab-in-categories-tab branch May 3, 2024 20:13
@AndlerRL
Copy link
Contributor

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.

Restore classname for active tab in categories tab
2 participants