-
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
(#5247)
- Loading branch information
1 parent
1aca22d
commit 9f16da7
Showing
29 changed files
with
1,136 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
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
73 changes: 73 additions & 0 deletions
73
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,73 @@ | ||
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 {TuiStatus} from '@taiga-ui/kit'; | ||
|
||
@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'), | ||
LESS: import('./examples/3/index.less?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: ReadonlyArray<TuiStatus | 'accent' | 'light'> = [ | ||
'accent', | ||
'default', | ||
'primary', | ||
'custom', | ||
'success', | ||
'error', | ||
'warning', | ||
'info', | ||
'neutral', | ||
'light', | ||
]; | ||
|
||
appearance = this.appearanceVariants[0]; | ||
|
||
readonly sizeVariants: ReadonlyArray<TuiSizeS | TuiSizeXL> = ['s', 'm', 'l', 'xl']; | ||
|
||
size: TuiSizeS | TuiSizeXL = this.sizeVariants[1]; | ||
|
||
hoverable = false; | ||
|
||
contentTypeVariants = ['text', 'with icon', 'image']; | ||
contentType = this.contentTypeVariants[0]; | ||
} |
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
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, TuiFadeModule} 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, | ||
TuiFadeModule, | ||
TuiNotificationModule, | ||
TuiAddonDocModule, | ||
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiBadgeComponent)), | ||
TuiBadgeModule, | ||
TuiTextfieldControllerModule, | ||
TuiLabelModule, | ||
], | ||
declarations: [ | ||
ExampleTuiBadgeComponent, | ||
TuiBadgeExample1, | ||
TuiBadgeExample2, | ||
TuiBadgeExample3, | ||
TuiBadgeExample4, | ||
TuiBadgeExample5, | ||
], | ||
exports: [ExampleTuiBadgeComponent], | ||
}) | ||
export class ExampleTuiBadgeModule {} |
152 changes: 152 additions & 0 deletions
152
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,152 @@ | ||
<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="content-type" | ||
heading="Content type (mobile platform)" | ||
[content]="example3" | ||
> | ||
<tui-badge-example-3></tui-badge-example-3> | ||
</tui-doc-example> | ||
|
||
<tui-doc-example | ||
id="fade" | ||
heading="Long value" | ||
[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 === 'with icon'" | ||
[appearance]="appearance" | ||
[hoverable]="hoverable" | ||
[size]="size" | ||
> | ||
<tui-svg src="tuiIconCheck"></tui-svg> | ||
<div tuiFade>Taiga UI</div> | ||
</tui-badge> | ||
|
||
<tui-badge | ||
*ngIf="contentType === 'text'" | ||
[appearance]="appearance" | ||
[hoverable]="hoverable" | ||
[size]="size" | ||
> | ||
Taiga UI | ||
</tui-badge> | ||
|
||
<tui-badge | ||
*ngIf="contentType === 'image'" | ||
[appearance]="appearance" | ||
[hoverable]="hoverable" | ||
[size]="size" | ||
> | ||
<img | ||
alt="market" | ||
src="assets/images/avatar.jpg" | ||
/> | ||
</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="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 into a module</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> |
29 changes: 29 additions & 0 deletions
29
projects/demo/src/modules/experimental/badge/examples/1/index.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,29 @@ | ||
<tui-badge appearance="primary">Primary</tui-badge> | ||
|
||
<tui-badge appearance="accent">Accent</tui-badge> | ||
|
||
<tui-badge appearance="light">Light</tui-badge> | ||
|
||
<tui-badge>Default</tui-badge> | ||
|
||
<tui-badge appearance="success">Success</tui-badge> | ||
|
||
<tui-badge appearance="error">Error</tui-badge> | ||
<tui-badge appearance="warning">Warning</tui-badge> | ||
|
||
<tui-badge appearance="neutral">Neutral</tui-badge> | ||
<tui-badge appearance="info">Info</tui-badge> | ||
|
||
<p> | ||
Use CSS and | ||
<code>appearance="custom"</code> | ||
for support colors | ||
</p> | ||
<tui-badge | ||
*tuiRepeatTimes="let index of 20" | ||
appearance="custom" | ||
class="support-{{ index + 1 }}" | ||
[hoverable]="true" | ||
> | ||
Taiga | ||
</tui-badge> |
13 changes: 13 additions & 0 deletions
13
projects/demo/src/modules/experimental/badge/examples/1/index.less
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,13 @@ | ||
tui-badge { | ||
margin: 0.5rem; | ||
} | ||
|
||
@iterations: 20; | ||
|
||
.loop (@i) when (@i > 0) { | ||
.support-@{i} { | ||
background-color: ~'var(--tui-support-@{i}, var(--tui-support-0@{i}))'; | ||
} | ||
.loop(@i - 1); | ||
} | ||
.loop (@iterations); |
12 changes: 12 additions & 0 deletions
12
projects/demo/src/modules/experimental/badge/examples/1/index.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,12 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-badge-example-1', | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiBadgeExample1 {} |
Oops, something went wrong.