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

[WEB-4100] TabMenu animation delay and root/contents class modifiers #581

Merged
merged 5 commits into from
Dec 17, 2024

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Dec 17, 2024

Jira Ticket Link / Motivation

https://ably.atlassian.net/browse/WEB-4100

Summary of changes

Fixes an issue with TabMenu where the animated highlight under the active tab extends outwards from 0px to the full width of the tab, meaning that every re-render, you get the horizontal panning in the video below. Not ideal, so this PR only "turns on" the animated width CSS transition after the target width of the highlight has been calculated, meaning no extra transition at the start, but transitions are maintained when navigating from tab to tab.

Screen.Recording.2024-12-17.at.16.31.50.mov

Also adds extra props to modify the class names of the root and contents elements in TabMenu, and adds an extra icon needed for LeftSidebar.

Version bump:

  • Updated the version in package.json from 15.1.8 to 15.1.9.

How do you manually test this?

Book

Reviewer Tasks (optional)

Merge/Deploy Checklist

  • Written automated tests for implemented features/fixed bugs
  • Rebased and squashed commits
  • Commits have clear descriptions of their changes
  • Checked for any performance regressions

Frontend Checklist

  • No frontend changes in this PR
  • Added before/after screenshots for changes
  • Tested on different platforms/browsers with Browserstack
  • Compared with the initial design / our brand guidelines
  • Checked the code for accessibility issues (VoiceOver User Guide)?

Summary by CodeRabbit

  • New Features

    • Enhanced TabMenu component with customizable class names for root and content elements.
    • Improved animation handling for the TabMenu component.
  • Version Update

    • Updated application version to 15.1.9.

Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces two main changes: an update to the package version in package.json and enhancements to the TabMenu component in src/core/TabMenu.tsx. The version has been bumped to a development version (15.1.9-dev.7f0b586a). In the TabMenu component, two new optional properties (rootClassName and contentsClassName) have been added to provide more styling flexibility, and the animation handling logic has been refined.

Changes

File Change Summary
package.json Version updated from 15.1.8 to 15.1.9-dev.7f0b586a
src/core/TabMenu.tsx - Added optional rootClassName prop
- Added optional contentsClassName prop
- Improved animation state management

Assessment against linked issues

Objective Addressed Explanation
WEB-4100: Implement new header and footer for docs No direct changes related to header or footer implementation

Poem

🐰 A version hop, a class name's dance,
TabMenu twirls with stylish stance,
Flexibility springs like a rabbit's leap,
Animations smooth, no detail too deep,
Code evolves with playful grace! 🎨


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. (Beta)
  • @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
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: 0

🧹 Nitpick comments (2)
src/core/TabMenu.tsx (2)

83-83: Consider extracting the animation delay constant.

The animation logic is sound, but the hardcoded delay of 150ms should be extracted into a named constant for better maintainability and documentation.

+ const ANIMATION_DELAY_MS = 150;
  
  useEffect(() => {
    if (animatedOption && highlight.width > 0) {
      setTimeout(() => {
        setAnimated(true);
-     }, 150);
+     }, ANIMATION_DELAY_MS);
    }
  }, [animatedOption, highlight.width]);

Also applies to: 89-89, 92-98


142-142: Consider adding type safety for className props.

While the className application is correct, consider using a more type-safe approach for className props to prevent runtime errors.

import { ClassValue } from 'clsx';

export type TabMenuProps = {
  // ... other props
  rootClassName?: ClassValue;
  contentsClassName?: ClassValue;
};

This would ensure that only valid class values can be passed to the component.

Also applies to: 183-187

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9cdcbf7 and c6f9c4d.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/core/TabMenu.tsx (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (3)
src/core/TabMenu.tsx (3)

30-39: LGTM! Well-documented prop additions.

The new rootClassName and contentsClassName props are well-documented and follow the existing TypeScript patterns.


76-77: LGTM! Clean props destructuring.

The new props are correctly destructured alongside existing props.


Line range hint 1-194: Verify animation behavior across different scenarios.

Please ensure the animation behavior is tested in the following scenarios:

  1. Initial render
  2. Tab switching
  3. Window resize
  4. Dark/light theme switches
  5. Different viewport sizes

@jamiehenson jamiehenson force-pushed the tab-menu-default-animated-fix branch 2 times, most recently from f20004c to c1d7f60 Compare December 17, 2024 16:27
src/core/TabMenu.tsx Outdated Show resolved Hide resolved
Copy link
Member

@kennethkalmer kennethkalmer left a comment

Choose a reason for hiding this comment

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

@jamiehenson jamiehenson force-pushed the tab-menu-default-animated-fix branch from c1d7f60 to 3b7e19d Compare December 17, 2024 16:49
@jamiehenson jamiehenson force-pushed the tab-menu-default-animated-fix branch from 3b7e19d to f2af5c4 Compare December 17, 2024 16:53
@jamiehenson jamiehenson force-pushed the tab-menu-default-animated-fix branch from b456c7a to d96b56b Compare December 17, 2024 17:10
Copy link
Contributor

@aralovelace aralovelace left a comment

Choose a reason for hiding this comment

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

just had a look as well and its looks nice!

@jamiehenson jamiehenson merged commit ec3d114 into main Dec 17, 2024
4 checks passed
@jamiehenson jamiehenson deleted the tab-menu-default-animated-fix branch December 17, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants