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 14a8a8b commit 5f3d094
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 deletions.
10 changes: 9 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@
"replicants",
"tuiiconbutton",
"hitbox",
"viewports"
"viewports",
"Grigori",
"Constantinopolsky",
"Rimsky",
"Korsakov",
"Wolfflegelstainhausenbergedorf",
"Arkhangelsky",
"Zoya",
"Kosmodemyanskaya"
],
"ignoreRegExpList": ["\\(https?://.*?\\)", "\\/{1}.+\\/{1}", "\\%2F.+", "\\%2C.+", "\\ɵ.+", "\\ыва.+"],
"overrides": [
Expand Down
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,36 @@
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
import {
ChangeDetectionStrategy,
Component,
HostBinding,
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()
@HostBinding('attr.title')
label = '';

@tuiPure
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,7 @@ tui-avatar-labeled {
line-height: 0.895rem;
font-size: 0.75rem;
padding: 0 0.5rem;
white-space: nowrap;

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

0 comments on commit 5f3d094

Please sign in to comment.