Skip to content

Commit

Permalink
feat(kit): support [label] in tui-avatar-labeled
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Feb 29, 2024
1 parent b049aa3 commit 29e458a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
<tui-avatar-labeled>
<tui-avatar-labeled label="Grigori Constantinopolsky">
<tui-avatar
[src]="'https://avatars.githubusercontent.com/u/10106368' | tuiFallbackSrc: 'tuiIconUserLarge' | async"
></tui-avatar>

<div tuiFade>MarsiBarsi</div>
</tui-avatar-labeled>

<tui-avatar-labeled>
<tui-avatar-labeled label="Nikolai Rimsky-Korsakov">
<tui-avatar
[src]="'https://avatars.githubusercontent.com/u/11832552' | tuiFallbackSrc: 'tuiIconUserLarge' | async"
></tui-avatar>

<div tuiFade>Inkin</div>
<div tuiFade>Alexander</div>
</tui-avatar-labeled>

<tui-avatar-labeled>
<tui-avatar-labeled label="Hubert Wolfflegelstainhausenbergedorf">
<tui-avatar
[src]="'https://avatars.githubusercontent.com/u/46284632' | tuiFallbackSrc: 'tuiIconUserLarge' | async"
></tui-avatar>

<div tuiFade>Potekhin</div>
<div tuiFade>Vladimir</div>
</tui-avatar-labeled>

<tui-avatar-labeled>
<tui-avatar-labeled label="Arkhangelsky Constantine">
<tui-avatar
[src]="'https://avatars.githubusercontent.com/u/35179038' | tuiFallbackSrc: 'tuiIconUserLarge' | async"
></tui-avatar>
</tui-avatar-labeled>

<div tuiFade>Barsukov</div>
<div tuiFade>Nikita</div>
<tui-avatar-labeled label="Zoya Kosmodemyanskaya">
<tui-avatar
[src]="'https://avatars.githubusercontent.com/u/8158578' | tuiFallbackSrc: 'tuiIconUserLarge' | async"
></tui-avatar>
</tui-avatar-labeled>
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
Input,
ViewEncapsulation,
} from '@angular/core';
import {tuiPure} from '@taiga-ui/cdk';

@Component({
selector: 'tui-avatar-labeled',
template: '<ng-content></ng-content>',
template: `
<ng-content></ng-content>
<ng-container *ngIf="label.length">
<span
*ngFor="let item of split(label)"
tuiFade
>
{{ item }}
</span>
</ng-container>
`,
styleUrls: ['./avatar-labeled.styles.less'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TuiAvatarLabeledComponent {}
export class TuiAvatarLabeledComponent {
@Input()
public label = '';

@tuiPure
public split(label: string): readonly string[] {
return label.split(' ');
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
// eslint-disable-next-line @taiga-ui/experience/no-deep-imports
import {TuiFadeModule} from '@taiga-ui/experimental/directives/fade';

import {TuiAvatarLabeledComponent} from './avatar-labeled.component';

@NgModule({
imports: [CommonModule, TuiFadeModule],
declarations: [TuiAvatarLabeledComponent],
exports: [TuiAvatarLabeledComponent],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ tui-avatar-labeled {
line-height: 0.895rem;
font-size: 0.75rem;
padding: 0 0.5rem;
//noinspection CssInvalidPropertyValue
text-wrap: nowrap;

tui-avatar {
margin-bottom: 0.375rem;
Expand Down

0 comments on commit 29e458a

Please sign in to comment.