Skip to content

Commit

Permalink
feat(experimental): add new component Badge
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin committed Aug 30, 2023
1 parent b649c2a commit 65a164f
Show file tree
Hide file tree
Showing 33 changed files with 1,285 additions and 0 deletions.
21 changes: 21 additions & 0 deletions projects/core/animations/animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,27 @@ export const tuiScaleIn = trigger(`tuiScaleIn`, [
),
]);

export const tuiExpressiveEntrance = trigger(`tuiExpressiveEntrance`, [
transition(
`:enter`,
[
style({transform: `scale(0)`}),
animate(TRANSITION, style({transform: `scale(1.1)`})),
animate(TRANSITION, style({transform: `scale(1)`})),
],
DURATION,
),
transition(
`:leave`,
[
style({transform: `scale(1)`}),
animate(TRANSITION, style({transform: `scale(1.1)`})),
animate(TRANSITION, style({transform: `scale(0)`})),
],
DURATION,
),
]);

export const tuiScaleInList = trigger(`tuiScaleInList`, [
transition(
`* => *`,
Expand Down
Binary file added projects/demo/src/assets/images/market.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions projects/demo/src/modules/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ export const ROUTES: Routes = [
title: `Avatar`,
},
},
{
path: `experimental/badge`,
loadChildren: async () =>
(await import(`../experimental/badge/badge.module`)).ExampleTuiBadgeModule,
data: {
title: `Badge`,
},
},
{
path: `experimental/fade`,
loadChildren: async () =>
Expand Down
6 changes: 6 additions & 0 deletions projects/demo/src/modules/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,12 @@ export const pages = [
keywords: `аватар, image, pic, icon, картинка, изображение, avatar, stack`,
route: `/experimental/avatar`,
},
{
section: `Experimental`,
title: `Badge`,
keywords: `бэдж, бейдж, овал, badge, нотификация`,
route: `/experimental/badge`,
},
{
section: `Experimental`,
title: `Fade`,
Expand Down
86 changes: 86 additions & 0 deletions projects/demo/src/modules/experimental/badge/badge.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {RawLoaderContent, TuiDocExample} from '@taiga-ui/addon-doc';
import {TuiSizeS, TuiSizeXL} from '@taiga-ui/core';
import {TuiBadgeAppearance} from '@taiga-ui/experimental';

@Component({
selector: 'example-badge',
templateUrl: './badge.template.html',
changeDetection,
})
export class ExampleTuiBadgeComponent {
readonly exampleModule: RawLoaderContent = import(
'./examples/import/import-module.md?raw'
);

readonly exampleHtml: RawLoaderContent = import(
'./examples/import/insert-template.md?raw'
);

readonly example1: TuiDocExample = {
TypeScript: import('./examples/1/index.ts?raw'),
HTML: import('./examples/1/index.html?raw'),
LESS: import('./examples/1/index.less?raw'),
};

readonly example2: TuiDocExample = {
TypeScript: import('./examples/2/index.ts?raw'),
HTML: import('./examples/2/index.html?raw'),
};

readonly example3: TuiDocExample = {
TypeScript: import('./examples/3/index.ts?raw'),
HTML: import('./examples/3/index.html?raw'),
};

readonly example4: TuiDocExample = {
TypeScript: import('./examples/4/index.ts?raw'),
HTML: import('./examples/4/index.html?raw'),
LESS: import('./examples/4/index.less?raw'),
};

readonly example5: TuiDocExample = {
TypeScript: import('./examples/5/index.ts?raw'),
HTML: import('./examples/5/index.html?raw'),
LESS: import('./examples/5/index.less?raw'),
};

readonly appearanceVariants: TuiBadgeAppearance[] = [
'accent',
'default',
'primary',
'custom',
'success',
'error',
'warning',
'info',
'neutral',
'dark-text',
];

appearance = this.appearanceVariants[0];

values: {[key: string]: number | string} = {
Taiga: 'Taiga',
'Very long text': 'Very long text',
'5': 5,
'99': 99,
'100': 100,
'"100"': '100',
'""': '',
};

readonly sizeVariants: ReadonlyArray<TuiSizeS | TuiSizeXL> = ['s', 'm', 'l', 'xl'];

size: TuiSizeS | TuiSizeXL = this.sizeVariants[1];

valueVariants: ReadonlyArray<number | string> = Object.keys(this.values);

value: number | string = 'Taiga';

hoverable = false;

contentTypeVariants = ['empty', 'icon', 'image'];
contentType = this.contentTypeVariants[0];
}
50 changes: 50 additions & 0 deletions projects/demo/src/modules/experimental/badge/badge.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc';
import {TuiRepeatTimesModule} from '@taiga-ui/cdk';
import {
TuiLabelModule,
TuiModeModule,
TuiNotificationModule,
TuiSvgModule,
TuiTextfieldControllerModule,
} from '@taiga-ui/core';
import {TuiBadgeModule} from '@taiga-ui/experimental';
import {TuiRadioListModule} from '@taiga-ui/kit';

import {ExampleTuiBadgeComponent} from './badge.component';
import {TuiBadgeExample1} from './examples/1';
import {TuiBadgeExample2} from './examples/2';
import {TuiBadgeExample3} from './examples/3';
import {TuiBadgeExample4} from './examples/4';
import {TuiBadgeExample5} from './examples/5';

@NgModule({
imports: [
TuiBadgeModule,
TuiModeModule,
TuiRepeatTimesModule,
TuiSvgModule,
TuiRadioListModule,
FormsModule,
CommonModule,
TuiNotificationModule,
TuiAddonDocModule,
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiBadgeComponent)),
TuiBadgeModule,
TuiTextfieldControllerModule,
TuiLabelModule,
],
declarations: [
ExampleTuiBadgeComponent,
TuiBadgeExample1,
TuiBadgeExample2,
TuiBadgeExample3,
TuiBadgeExample4,
TuiBadgeExample5,
],
exports: [ExampleTuiBadgeComponent],
})
export class ExampleTuiBadgeModule {}
164 changes: 164 additions & 0 deletions projects/demo/src/modules/experimental/badge/badge.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<tui-doc-page
header="Badge"
package="EXPERIMENTAL"
type="components"
>
<ng-template pageTab>
<tui-notification status="warning">
This code is
<strong>experimental</strong>
and is a subject to change. Expect final solution to be shipped in the next major version
</tui-notification>

<p>New version for Badge component following updated design specs for displaying text, pictures and icons.</p>

<tui-doc-example
id="base"
heading="Basic"
[content]="example1"
>
<tui-badge-example-1></tui-badge-example-1>
</tui-doc-example>

<tui-doc-example
id="sizes"
heading="Sizes"
[content]="example2"
>
<tui-badge-example-2></tui-badge-example-2>
</tui-doc-example>

<tui-doc-example
id="variants"
heading="Variants (mobile platform)"
[content]="example3"
>
<tui-badge-example-3></tui-badge-example-3>
</tui-doc-example>

<tui-doc-example
id="fade"
heading="Fade"
[content]="example4"
>
<tui-badge-example-4></tui-badge-example-4>
</tui-doc-example>

<tui-doc-example
id="custom"
heading="Customization"
[content]="example5"
>
<tui-badge-example-5></tui-badge-example-5>
</tui-doc-example>
</ng-template>

<ng-template pageTab>
<tui-doc-demo>
<p>
<tui-badge
*ngIf="contentType === 'icon'"
[appearance]="appearance"
[hoverable]="hoverable"
[size]="size"
[value]="values[value]"
>
<tui-svg src="tuiIconCheck"></tui-svg>
</tui-badge>

<tui-badge
*ngIf="contentType === 'empty'"
[appearance]="appearance"
[hoverable]="hoverable"
[size]="size"
[value]="values[value]"
></tui-badge>

<tui-badge
*ngIf="contentType === 'image'"
[appearance]="appearance"
[hoverable]="hoverable"
[size]="size"
>
<img
alt="market"
src="assets/images/market.png"
/>
</tui-badge>
</p>
</tui-doc-demo>
<label
tuiLabel="Content type"
class="tui-space_vertical-3"
>
<tui-radio-list
orientation="horizontal"
[items]="contentTypeVariants"
[(ngModel)]="contentType"
></tui-radio-list>
</label>
<tui-doc-documentation>
<ng-template
documentationPropertyMode="input"
documentationPropertyName="size"
documentationPropertyType="TuiSizeL"
[documentationPropertyValues]="sizeVariants"
[(documentationPropertyValue)]="size"
>
Size
</ng-template>
<ng-template
documentationPropertyMode="input"
documentationPropertyName="appearance"
documentationPropertyType="TuiStatus"
[documentationPropertyValues]="appearanceVariants"
[(documentationPropertyValue)]="appearance"
>
Appearance
</ng-template>
<ng-template
documentationPropertyMode="input"
documentationPropertyName="value"
documentationPropertyType="string | number"
[documentationPropertyValues]="valueVariants"
[(documentationPropertyValue)]="value"
>
Value. If value is a number and is more than 99, it will be replaced with &laquo;99+&raquo;
</ng-template>
<ng-template
documentationPropertyMode="input"
documentationPropertyName="hoverable"
documentationPropertyType="boolean"
[(documentationPropertyValue)]="hoverable"
>
Enable hovered state
</ng-template>
</tui-doc-documentation>
</ng-template>

<ng-template pageTab>
<ol class="b-demo-steps">
<li>
<p>
Import
<code>TuiBadgeModule</code>
into a module where you want to use our component
</p>

<tui-doc-code
filename="myComponent.module.ts"
[code]="exampleModule"
></tui-doc-code>
</li>

<li>
<p>Add to the template:</p>

<tui-doc-code
filename="myComponent.template.html"
[code]="exampleHtml"
></tui-doc-code>
</li>
</ol>
</ng-template>
</tui-doc-page>
Loading

0 comments on commit 65a164f

Please sign in to comment.