Skip to content

Commit

Permalink
feat(core): add tuiIcon pipe (#7244)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Apr 16, 2024
1 parent 0c9f073 commit f25b92a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions projects/core/components/icon/icon.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type {PipeTransform} from '@angular/core';
import {inject, Pipe} from '@angular/core';
import type {TuiStringHandler} from '@taiga-ui/cdk';
import {TUI_ICON_RESOLVER} from '@taiga-ui/core/tokens';

@Pipe({
standalone: true,
name: 'tuiIcon',
})
export class TuiIconPipe implements PipeTransform {
public readonly transform = inject<TuiStringHandler<string>>(TUI_ICON_RESOLVER);
}
1 change: 1 addition & 0 deletions projects/core/components/icon/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './icon.component';
export * from './icon.pipe';
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
icon="tuiIconHeartLarge"
[style.color]="'var(--tui-primary)'"
/>

<img
alt=""
[src]="'tuiIconHeartLarge' | tuiIcon"
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:host {
display: flex;
gap: 0.625rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {encapsulation} from '@demo/emulate/encapsulation';
@Component({
selector: 'tui-icon-example-1',
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
changeDetection,
})
Expand Down
8 changes: 7 additions & 1 deletion projects/demo/src/modules/components/icon/icon.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {tuiGetDocModules} from '@taiga-ui/addon-doc';
import {TuiIconComponent, TuiLinkDirective, TuiNotificationModule} from '@taiga-ui/core';
import {
TuiIconComponent,
TuiIconPipe,
TuiLinkDirective,
TuiNotificationModule,
} from '@taiga-ui/core';

import {TuiIconExample1} from './examples/1';
import {TuiIconExample2} from './examples/2';
Expand All @@ -15,6 +20,7 @@ import {ExampleTuiIconComponent} from './icon.component';
TuiLinkDirective,
TuiNotificationModule,
tuiGetDocModules(ExampleTuiIconComponent),
TuiIconPipe,
],
declarations: [
ExampleTuiIconComponent,
Expand Down

0 comments on commit f25b92a

Please sign in to comment.