Skip to content

refactor(icon): Enhanced multi-theme support and improved performance#2087

Open
rkaraivanov wants to merge 1 commit intomasterfrom
rkaraivanov/icon-refactoring
Open

refactor(icon): Enhanced multi-theme support and improved performance#2087
rkaraivanov wants to merge 1 commit intomasterfrom
rkaraivanov/icon-refactoring

Conversation

@rkaraivanov
Copy link
Member

Description

Features:

  • Add support for multiple themes coexisting on the same page
  • Icon references now resolve based on per-component theme context
  • Icons within different igc-theme-provider elements render correctly
  • Implement batched notifications using microtask queue for performance
  • Add automatic deduplication of icon change notifications

Performance Improvements:

  • Refactor _iconLoaded to class method instead of arrow function property
    • Reduces memory footprint by sharing method across all icon instances
    • Still maintains proper lifecycle management with bound references
  • Implement notification batching to prevent excessive listener calls
    • Uses queueMicrotask for zero-delay batching
    • Automatically deduplicates icon:collection pairs
    • Significantly improves performance when registering multiple icons

Architecture Changes:

  • Remove global theme state from IconsRegistry singleton
  • Pass theme as parameter to getIconRef() for stateless resolution
  • Icon components now pass their local theme context to registry
  • Each icon resolves references based on its own theme-provider context
  • Preserve backward compatibility with optional theme parameter

Icon Resolution Priority (updated):

  1. User-set references (external or internal)
  2. Theme-specific aliases from ICON_REFERENCES
  3. Default theme fallback
  4. Return icon as-is if no reference found

Added API docuementation for all new and updated methods, properties, and behaviors. Added comprehensive unit and integration tests covering multi-theme scenarios, BFCache handling, and theme-provider interactions.

Fixes:

  • Icons now work correctly in multi-theme applications
  • No more theme conflicts when using multiple theme-providers
  • Prevents unnecessary re-renders during bulk icon registration
  • Eliminates potential race conditions in theme state

This refactor enables proper multi-theme support while maintaining backward compatibility and improving overall performance through batched notifications.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Refactoring (code improvements without functional changes)

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally
  • I have updated documentation if needed

Features:
- Add support for multiple themes coexisting on the same page
- Icon references now resolve based on per-component theme context
- Icons within different igc-theme-provider elements render correctly
- Implement batched notifications using microtask queue for performance
- Add automatic deduplication of icon change notifications

Performance Improvements:
- Refactor _iconLoaded to class method instead of arrow function property
  * Reduces memory footprint by sharing method across all icon instances
  * Still maintains proper lifecycle management with bound references
- Implement notification batching to prevent excessive listener calls
  * Uses queueMicrotask for zero-delay batching
  * Automatically deduplicates icon:collection pairs
  * Significantly improves performance when registering multiple icons

Architecture Changes:
- Remove global theme state from IconsRegistry singleton
- Pass theme as parameter to getIconRef() for stateless resolution
- Icon components now pass their local theme context to registry
- Each icon resolves references based on its own theme-provider context
- Preserve backward compatibility with optional theme parameter

Icon Resolution Priority (updated):
1. User-set references (external or internal)
2. Theme-specific aliases from ICON_REFERENCES
3. Default theme fallback
4. Return icon as-is if no reference found

Added API docuementation for all new and updated methods, properties, and behaviors.
Added comprehensive unit and integration tests covering multi-theme scenarios, BFCache handling, and theme-provider interactions.

Fixes:
- Icons now work correctly in multi-theme applications
- No more theme conflicts when using multiple theme-providers
- Prevents unnecessary re-renders during bulk icon registration
- Eliminates potential race conditions in theme state

This refactor enables proper multi-theme support while maintaining backward
compatibility and improving overall performance through batched notifications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant