-
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):
Rating
add new component (#5633)
Co-authored-by: taiga-family-bot <[email protected]>
- Loading branch information
1 parent
9de981e
commit 254e68b
Showing
30 changed files
with
582 additions
and
8 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
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
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
6 changes: 6 additions & 0 deletions
6
projects/demo/src/modules/experimental/rating/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,6 @@ | ||
<label tuiLabel="Rate Taiga UI"> | ||
<tui-rating | ||
class="rating" | ||
[(ngModel)]="value" | ||
></tui-rating> | ||
</label> |
5 changes: 5 additions & 0 deletions
5
projects/demo/src/modules/experimental/rating/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,5 @@ | ||
.rating { | ||
fill: currentColor; | ||
font-size: 0.625rem; | ||
width: 10rem; | ||
} |
14 changes: 14 additions & 0 deletions
14
projects/demo/src/modules/experimental/rating/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,14 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-rating-example-1', | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiRatingExample1 { | ||
value = 0; | ||
} |
20 changes: 20 additions & 0 deletions
20
projects/demo/src/modules/experimental/rating/examples/2/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,20 @@ | ||
<label tuiLabel="Are you satisfied with Taiga UI?"> | ||
<tui-rating | ||
class="rating" | ||
[attr.data-value]="value" | ||
[icon]="icon" | ||
[max]="3" | ||
[(ngModel)]="value" | ||
></tui-rating> | ||
<button | ||
*ngIf="value" | ||
appearance="icon" | ||
iconLeft="tuiIconCloseLarge" | ||
size="s" | ||
tuiIconButton | ||
class="button" | ||
(click)="value = 0" | ||
> | ||
Clear | ||
</button> | ||
</label> |
23 changes: 23 additions & 0 deletions
23
projects/demo/src/modules/experimental/rating/examples/2/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,23 @@ | ||
.rating, | ||
.button { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
|
||
.rating { | ||
&[data-value='1'] { | ||
color: var(--tui-negative); | ||
} | ||
|
||
&[data-value='2'] { | ||
color: var(--tui-warning-fill); | ||
} | ||
|
||
&[data-value='3'] { | ||
color: var(--tui-positive); | ||
} | ||
|
||
&:hover { | ||
color: var(--tui-info-fill); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
projects/demo/src/modules/experimental/rating/examples/2/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,29 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiContextWithImplicit} from '@taiga-ui/cdk'; | ||
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; | ||
|
||
@Component({ | ||
selector: 'tui-rating-example-2', | ||
templateUrl: 'index.html', | ||
styleUrls: ['index.less'], | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiRatingExample2 { | ||
value = 0; | ||
|
||
readonly icon: PolymorpheusContent<TuiContextWithImplicit<number>> = ({ | ||
$implicit, | ||
}) => { | ||
switch ($implicit) { | ||
case 1: | ||
return 'tuiIconFrownLarge'; | ||
case 2: | ||
return 'tuiIconMehLarge'; | ||
default: | ||
return 'tuiIconSmileLarge'; | ||
} | ||
}; | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/demo/src/modules/experimental/rating/examples/3/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,7 @@ | ||
<label tuiLabel="Back to the Future"> | ||
<tui-rating | ||
[max]="10" | ||
[ngModel]="8.5" | ||
[readOnly]="true" | ||
></tui-rating> | ||
</label> |
11 changes: 11 additions & 0 deletions
11
projects/demo/src/modules/experimental/rating/examples/3/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,11 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-rating-example-3', | ||
templateUrl: 'index.html', | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiRatingExample3 {} |
13 changes: 13 additions & 0 deletions
13
projects/demo/src/modules/experimental/rating/examples/import/import-module.md
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 @@ | ||
```ts | ||
import {NgModule} from '@angular/core'; | ||
import {TuiRatingModule} from '@taiga-ui/experimental'; | ||
// ... | ||
|
||
@NgModule({ | ||
imports: [ | ||
// ... | ||
TuiRatingModule, | ||
], | ||
}) | ||
export class MyModule {} | ||
``` |
3 changes: 3 additions & 0 deletions
3
projects/demo/src/modules/experimental/rating/examples/import/insert-template.md
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,3 @@ | ||
```html | ||
<tui-rating [(ngModel)]="value"></tui-rating> | ||
``` |
33 changes: 33 additions & 0 deletions
33
projects/demo/src/modules/experimental/rating/rating.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,33 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {TuiDocExample, TuiRawLoaderContent} from '@taiga-ui/addon-doc'; | ||
|
||
@Component({ | ||
selector: 'example-rating', | ||
templateUrl: './rating.template.html', | ||
changeDetection, | ||
}) | ||
export class ExampleTuiRatingComponent { | ||
readonly exampleModule: TuiRawLoaderContent = import( | ||
'./examples/import/import-module.md?raw' | ||
); | ||
|
||
readonly exampleHtml: TuiRawLoaderContent = import( | ||
'./examples/import/insert-template.md?raw' | ||
); | ||
|
||
readonly example1: TuiDocExample = { | ||
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'), | ||
LESS: import('./examples/2/index.less?raw'), | ||
}; | ||
|
||
readonly example3: TuiDocExample = { | ||
HTML: import('./examples/3/index.html?raw'), | ||
}; | ||
} |
31 changes: 31 additions & 0 deletions
31
projects/demo/src/modules/experimental/rating/rating.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,31 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {tuiGetDocModules} from '@taiga-ui/addon-doc'; | ||
import {TuiLabelModule, TuiNotificationModule} from '@taiga-ui/core'; | ||
import {TuiButtonModule, TuiRatingModule} from '@taiga-ui/experimental'; | ||
|
||
import {TuiRatingExample1} from './examples/1'; | ||
import {TuiRatingExample2} from './examples/2'; | ||
import {TuiRatingExample3} from './examples/3'; | ||
import {ExampleTuiRatingComponent} from './rating.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
TuiRatingModule, | ||
TuiNotificationModule, | ||
TuiLabelModule, | ||
tuiGetDocModules(ExampleTuiRatingComponent), | ||
TuiButtonModule, | ||
], | ||
declarations: [ | ||
ExampleTuiRatingComponent, | ||
TuiRatingExample1, | ||
TuiRatingExample2, | ||
TuiRatingExample3, | ||
], | ||
exports: [ExampleTuiRatingComponent], | ||
}) | ||
export class ExampleTuiRatingModule {} |
59 changes: 59 additions & 0 deletions
59
projects/demo/src/modules/experimental/rating/rating.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,59 @@ | ||
<tui-doc-page | ||
header="Rating" | ||
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> | ||
|
||
<tui-doc-example | ||
id="basic" | ||
heading="Basic" | ||
[content]="example1" | ||
> | ||
<tui-rating-example-1></tui-rating-example-1> | ||
</tui-doc-example> | ||
|
||
<tui-doc-example | ||
id="icons" | ||
heading="Custom icons" | ||
[content]="example2" | ||
> | ||
<tui-rating-example-2></tui-rating-example-2> | ||
</tui-doc-example> | ||
|
||
<tui-doc-example | ||
id="readonly" | ||
heading="Readonly" | ||
[content]="example3" | ||
> | ||
<tui-rating-example-3></tui-rating-example-3> | ||
</tui-doc-example> | ||
</ng-template> | ||
|
||
<ng-template pageTab="Setup"> | ||
<ol class="b-demo-steps"> | ||
<li> | ||
<p>Import module:</p> | ||
|
||
<tui-doc-code | ||
filename="my.module.ts" | ||
[code]="exampleModule" | ||
></tui-doc-code> | ||
</li> | ||
|
||
<li> | ||
<p>Add to the template:</p> | ||
|
||
<tui-doc-code | ||
filename="my.component.html" | ||
[code]="exampleHtml" | ||
></tui-doc-code> | ||
</li> | ||
</ol> | ||
</ng-template> | ||
</tui-doc-page> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './rating.component'; | ||
export * from './rating.module'; | ||
export * from './rating.options'; |
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,8 @@ | ||
{ | ||
"lib": { | ||
"entryFile": "index.ts", | ||
"styleIncludePaths": [ | ||
"../../../core/styles" | ||
] | ||
} | ||
} |
Oops, something went wrong.