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

Feat 18 optimize animations for reduced motion #158

Conversation

Marvelousmicheal
Copy link
Collaborator

@Marvelousmicheal Marvelousmicheal commented Feb 14, 2025

Summary:
Adds accessibility-focused motion reductions and removes overly complex transition patterns in the sidebar to improve performance and WCAG compliance.

Key Changes:
✅ Added:

@media (prefers-reduced-motion: reduce) handling

Motion-safe/motion-reduce utility variants

Fallback transitions for critical UI elements

❌ Removed:

Nested transform animations

Complex calc()-based width transitions

Redundant transition property overrides

Summary by CodeRabbit

  • Documentation

    • Updated the presentation of contract details for improved clarity.
  • New Features

    • Improved alert dialog and dropdown animations to honor reduced motion preferences, enhancing accessibility.
    • Introduced a centralized animation system for smoother and more consistent UI transitions.
  • Style

    • Enhanced sidebar transition effects for a more refined and dynamically responsive experience.

Copy link

vercel bot commented Feb 14, 2025

@Marvelousmicheal is attempting to deploy a commit to the kindfi Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 14, 2025

Walkthrough

This PR updates both documentation and UI components. The README now presents policy information as plain text without bullet points. In the web components, conditional logic has been introduced to apply animations based on the user's reduced motion preference. The sidebar code now includes new constants and styles for smoother width and transform transitions. Additionally, a new module centralizes animation class definitions using Tailwind CSS, ensuring consistent and type-safe UI transitions across components.


Changes

File(s) Summary
apps/contract/README.md Removed bullet points from contract descriptions, now presenting details in plain text format.
apps/web/components/base/alert-dialog.tsx
apps/web/components/base/dropdown-menu.tsx
Modified to conditionally apply animation classes based on the reducedMotion state; animation handling is now centralized via helper logic.
apps/web/components/base/sidebar.tsx Introduced new constants (TRANSITION_DURATION, SIDEBAR_STYLES, SIDEBAR_STYLES_TWO) and updated class names to enhance sidebar transition effects.
apps/web/lib/animation.ts Added a new module exporting immutable combinations of Tailwind CSS animation classes for consistent UI transition effects.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant RM as ReducedMotion Checker
    participant AH as Animation Handler

    UI->>RM: Check reduced motion preference
    alt Reduced Motion Enabled
        RM-->>UI: Return TRUE
        UI->>AH: Request animation classes (omit animations)
    else Reduced Motion Disabled
        RM-->>UI: Return FALSE
        UI->>AH: Request animation classes (apply animations)
    end
    AH-->>UI: Provide appropriate animation parameters
    UI->>UI: Render with updated animations
Loading

Possibly related PRs


Suggested labels

documentation, enhancement, chore


Suggested reviewers

  • AndlerRL
  • Bran18

Poem

In code we weave a smoother dance,
Transitions blend with every chance.
Reduced motion finds its space,
Animations set a gentler pace.
Cheers to updates—onward we advance! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

@coderabbitai coderabbitai bot added chore A task that must be done. documentation Improvements or additions to documentation enhancement New feature improvement or request labels Feb 14, 2025
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

🧹 Nitpick comments (5)
apps/web/lib/animation.ts (1)

1-10: Consider enhancing documentation with examples for each animation type.

The current documentation provides a good overview, but we could make it more comprehensive by including examples for each animation category. This would help developers understand when to use specific animations.

Add examples in the documentation like this:

 /**
  * ANIMATION UTILITIES
  *
  * Predefined animation class combinations for common UI transitions.
  * Leverages Tailwind CSS animations and Radix UI state attributes.
  * All values are immutable for type safety (`as const`).
  *  @example
  * In a dialog.tsx component
  * className={cn(animations.fade.in)}
+ * 
+ * @examples
+ * // Fade animation
+ * className={cn(animations.fade.in)}
+ * 
+ * // Zoom animation
+ * className={cn(animations.zoom.in)}
+ * 
+ * // Slide animation
+ * className={cn(animations.slide.fromLeft)}
+ * 
+ * // Combined animation
+ * className={cn(animations.fadeAndZoomAndAnimate.inOut)}
  */
apps/web/components/base/sidebar.tsx (1)

41-50: Consider moving transition constants to a shared configuration file.

The transition duration and styles could be moved to a shared constants file to maintain consistency across components and improve maintainability.

Create a new file apps/web/lib/constants/transitions.ts:

export const TRANSITIONS = {
  duration: {
    default: '200ms',
    fast: '150ms',
    slow: '300ms'
  },
  styles: {
    sidebar: {
      width: {
        transition: 'width var(--transition-duration) linear',
        willChange: 'width'
      },
      transform: {
        transition: 'transform var(--transition-duration) linear',
        willChange: 'transform'
      }
    }
  }
} as const
apps/contract/README.md (3)

13-17: Consistency in List Formatting for Account Factory
The description for the Account Factory still uses leading hyphens. Since the PR objective specifies removal of bullet points in favor of plain text formatting, consider removing the hyphens here to maintain consistency and clarity.


20-26: Revisit Bullet Formatting for Auth Controller
Similar to the Account Factory section, the Auth Controller details still begin with hyphenated list items. To fully align with the PR objective of eliminating bullet points, it might be worthwhile to remove these hyphens for a uniform plain text style.


30-36: Typographical Refinement in Account Contract Descriptions
In the Account Contract description, note the double period after "WebAuthn specifications.." on line 31. Removing the extra period will improve the professionalism and readability of the documentation. In addition, as with previous sections, consider removing the leading hyphen if plain text is the desired style.

🧰 Tools
🪛 LanguageTool

[typographical] ~31-~31: Two consecutive dots
Context: ...es, in line with WebAuthn specifications.. - Provides methods for account recovery...

(DOUBLE_PUNCTUATION)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 04e263e and 9526008.

📒 Files selected for processing (5)
  • apps/contract/README.md (1 hunks)
  • apps/web/components/base/alert-dialog.tsx (1 hunks)
  • apps/web/components/base/dropdown-menu.tsx (1 hunks)
  • apps/web/components/base/sidebar.tsx (4 hunks)
  • apps/web/lib/animation.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.ts`: Review TypeScript files ensuring type safety with...

**/*.ts: Review TypeScript files ensuring type safety with no 'any' usage unless justified. Verify named exports, proper error handling with typed errors, and pure functions. Check module encapsulation and consistent naming using camelCase for functions and PascalCase for types. Validate unit test coverage for utilities if required.

  • apps/web/lib/animation.ts
`**/*.md`: Review documentation for technical accuracy and c...

**/*.md: Review documentation for technical accuracy and completeness. Verify code examples are correct and up-to-date. Ensure clear installation instructions and proper API documentation.

  • apps/contract/README.md
🧠 Learnings (1)
apps/web/components/base/dropdown-menu.tsx (1)
Learnt from: Marvelousmicheal
PR: kindfi-org/kindfi#70
File: apps/web/components/base/dropdown-menu.tsx:48-65
Timestamp: 2025-01-27T08:48:57.046Z
Learning: In the dropdown menu component, when implementing animation class utilities, using an if statement for the reducedMotion check is preferred over a ternary operator for better readability.
🪛 LanguageTool
apps/contract/README.md

[typographical] ~31-~31: Two consecutive dots
Context: ...es, in line with WebAuthn specifications.. - Provides methods for account recovery...

(DOUBLE_PUNCTUATION)

🔇 Additional comments (4)
apps/web/components/base/alert-dialog.tsx (1)

54-58: Great implementation of accessibility features!

The component effectively handles reduced motion preferences while maintaining proper ARIA attributes. The conditional application of animations based on user preferences aligns well with WCAG guidelines.

apps/web/components/base/dropdown-menu.tsx (1)

26-33: Well-structured animation utility function with clear separation of concerns!

The implementation follows best practices by:

  1. Using an if statement for better readability (as per past learning)
  2. Centralizing animation logic
  3. Maintaining consistent behavior with other components
apps/web/components/base/sidebar.tsx (1)

454-457: Great use of will-change property for performance optimization!

The implementation properly uses will-change for width and transform properties, which helps browsers optimize animations. The motion-reduce utility class is also correctly applied for accessibility.

apps/contract/README.md (1)

8-9: Clear and Informative Overview Heading
The "Overview" section is introduced clearly, providing a good context for the subsequent contract details.

@Bran18 Bran18 requested review from Bran18 and AndlerRL February 15, 2025 19:20
@Bran18 Bran18 self-assigned this Feb 15, 2025
Copy link

vercel bot commented Feb 15, 2025

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

Name Status Preview Comments Updated (UTC)
kindfi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 15, 2025 7:33pm

Copy link
Contributor

@Bran18 Bran18 left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉 Thanks for the quick changes—great work! Just a small heads-up for next time: please use a branch-based approach instead of a fork. It'll make collaboration even smoother! Keep it up

@Bran18 Bran18 merged commit 1bdc0c2 into kindfi-org:develop Feb 15, 2025
3 of 4 checks passed
@Bran18 Bran18 linked an issue Feb 15, 2025 that may be closed by this pull request
Jagadeeshftw pushed a commit that referenced this pull request Feb 18, 2025
…mponents (#158)

Co-authored-by: Brandon Fernández <[email protected]>
Signed-off-by: Jagadeeshftw <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A task that must be done. documentation Improvements or additions to documentation enhancement New feature improvement or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize animations for reduced motion
2 participants