-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experimental): add new component
Badge
- Loading branch information
1 parent
b649c2a
commit 65a164f
Showing
33 changed files
with
1,285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
projects/demo/src/modules/experimental/badge/badge.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
50
projects/demo/src/modules/experimental/badge/badge.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
164
projects/demo/src/modules/experimental/badge/badge.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 «99+» | ||
</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> |
Oops, something went wrong.