Skip to content

feat(core, kit): implement icon mode resolution system (#10938) #11311

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FeironoX5
Copy link

@FeironoX5 FeironoX5 commented Jul 13, 2025

Refs #10938

  • Icon resolution is now handled by TUI_ICON_MODE_RESOLVER for icon mode resolution (@font/@image(.data/.mask)/@icon) and icon resource resolvers: TUI_ICON_SVG_RESOURCE_RESOLVER, TUI_ICON_IMAGE_RESOURCE_RESOLVER, TUI_ICON_FONT_RESOURCE_RESOLVER
  • Updated affected components, styles, and some examples accordingly

Next steps:

  • Set default --t-font-icon CSS variable
  • Implement resource resolvers override mechanism
  • Update demo (so it would pass unit tests), provide more examples, write tests
  • Replace all TUI_ICON_RESOLVER usages

@Copilot Copilot AI review requested due to automatic review settings July 13, 2025 12:13
@FeironoX5 FeironoX5 requested a review from a team as a code owner July 13, 2025 12:13
@FeironoX5 FeironoX5 requested review from MarsiBarsi, waterplea, nsbarsukov, vladimirpotekhin and mdlufy and removed request for a team July 13, 2025 12:13
Copy link

Tests are running 🚀

Wait for workflow run with tests to finish ☕

Copy link

nx-cloud bot commented Jul 13, 2025

View your CI Pipeline Execution ↗ for commit d0670a9

Command Status Duration Result
nx run-many --target test --all --output-style=... ❌ Failed 3m 25s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-13 12:36:06 UTC

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a new, unified icon mode resolution system by introducing dedicated DI tokens for mode and resource resolution, updating core components and directives to consume resolved icon metadata, and extending LESS styles and demo examples to support multiple icon modes.

  • Introduce TUI_ICON_MODE_RESOLVER and individual resource resolvers for SVG, image, image-data, and font icons
  • Refactor TuiIcon, TuiIcons, and TuiIconBadge to use TuiResolvedIcon (class name + resource path)
  • Update LESS styles and demo code to handle .tui-svg-icon, .tui-image-icon, and .tui-font-icon modes

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
projects/kit/directives/icon-badge/icon-badge.style.less Add mode-specific badge selectors and styles for SVG, image, and font badges
projects/kit/directives/icon-badge/icon-badge.directive.ts Change badgeSrc to TuiResolvedIcon and bind resource path and badge class
projects/demo/src/modules/components/icon/examples/5/index.ts Switch provider to TUI_ICON_MODE_RESOLVER and adjust imports
projects/demo/src/modules/components/icon/examples/2/index.ts Remove deprecated tuiIconResolverProvider, clear providers
projects/demo/src/modules/components/icon/examples/2/index.html Update icon attributes to use new @image.mask. syntax
projects/demo/src/modules/components/icon/examples/10/index.ts Prefix data URI example with @image.mask.
projects/demo/src/modules/components/icon/examples/1/index.less Add @font-face and --t-font-icon variable for font icon example
projects/demo/src/modules/components/icon/examples/1/index.html Add font/image icon examples; update pipe usage to access .resource.src
projects/demo/src/modules/components/button-group/examples/1/index.less Add @font-face and --t-font-icon for button-group example
projects/demo/src/modules/components/button-group/examples/1/index.html Add badge demo in button-group example
projects/core/tokens/index.ts Export new icon-mode and resource-resolver tokens
projects/core/tokens/icon-resource-resolver.ts Define TUI_ICON_{SVG,IMAGE,DATA,FONT}_RESOURCE_RESOLVER tokens
projects/core/tokens/icon-resolver.ts Update deprecated TUI_ICON_RESOLVER to wrap in url() and adjust prefix logic
projects/core/tokens/icon-mode-resolver.ts Implement TUI_ICON_MODE_RESOLVER mapping modes to className and resource resolver
projects/core/styles/components/icons.less Extend icons directive styles for start/end modes across SVG, image, and font
projects/core/styles/components/icon.less Adjust tui-icon styles to support SVG, image, and font modes
projects/core/directives/icons/icons.directive.ts Refactor to use tuiInjectIconModeResolver, bind new CSS variables and classes
projects/core/components/icon/icon.pipe.ts Change TuiIconPipe to return TuiResolvedIcon via tuiInjectIconModeResolver
projects/core/components/icon/icon.component.ts Refactor TuiIcon to use computed props for path and class based on resolved icon

Copy link

bundlemon bot commented Jul 13, 2025

BundleMon

Files updated (1)
Status Path Size Limits
demo/browser/main.(hash).js
345.39KB (+754B +0.21%) +10%
Unchanged files (4)
Status Path Size Limits
demo/browser/vendor.(hash).js
260.83KB +10%
demo/browser/runtime.(hash).js
51.95KB +10%
demo/browser/styles.(hash).css
21.3KB +10%
demo/browser/polyfills.(hash).js
11.16KB +10%

Total files change +750B +0.11%

Groups updated (1)
Status Path Size Limits
demo/browser/*..js
9.34MB (+1.83KB +0.02%) -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link
Member

@waterplea waterplea left a comment

Choose a reason for hiding this comment

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

  1. This is a lot more complicated than it should be.
  2. Let'd do [data-icon-start/end="icon/img/font"] instead of classes.
  3. I don't think we need the icon mode resolver, I think it's ok to hardcode @font./@img./@icon. prefixes. We will just use last one as a default to maintain backwards compatibility with @tui. or any custom icons people might have.
  4. I don't want to complicate the resolver, I think in case of @font. we can just put whatever's after it to --t-icon-xxx CSS variable as is, no need to resolve it, and in all other cases just proceed to pass the string to the resolver as we do now.
  5. --t-font-icon should be --tui-font-icon, our public CSS vars start with --tui- and private start with --t-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants