-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rating): allow decimal numbers as rating values
Closes #817
- Loading branch information
1 parent
8b0fb3b
commit 964d8cf
Showing
7 changed files
with
121 additions
and
11 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
demo/src/app/components/rating/demos/decimal/decimal.component.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,12 @@ | ||
<template #t let-fill="fill"> | ||
<span *ngIf="fill === 100" class="star full">♥</span> | ||
<span *ngIf="fill === 0" class="star">♥</span> | ||
<span *ngIf="fill < 100 && fill > 0" class="star"> | ||
<span class="half" [style.width.%]="fill">♥</span>♥ | ||
</span> | ||
</template> | ||
<ngb-rating [(rate)]="currentRate" [starTemplate]="t" [readonly]="true" max="5"></ngb-rating> | ||
<hr> | ||
<pre>Rate: <b>{{currentRate}}</b></pre> | ||
<button class="btn btn-sm btn-outline-primary" (click)="currentRate = 1.35">1.35</button> | ||
<button class="btn btn-sm btn-outline-primary" (click)="currentRate = 4.72">4.72</button> |
26 changes: 26 additions & 0 deletions
26
demo/src/app/components/rating/demos/decimal/decimal.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,26 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ngbd-rating-decimal', | ||
templateUrl: './decimal.component.html', | ||
styles: [` | ||
.star { | ||
position: relative; | ||
display: inline-block; | ||
font-size: 3rem; | ||
color: #d3d3d3; | ||
} | ||
.full { | ||
color: red; | ||
} | ||
.half { | ||
position: absolute; | ||
display: inline-block; | ||
overflow: hidden; | ||
color: red; | ||
} | ||
`] | ||
}) | ||
export class RatingDecimalComponent { | ||
currentRate = 3.14; | ||
} |
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 './decimal.component'; | ||
export const decimalTsContent = require('!!prismjs?lang=typescript!./decimal.component.ts'); | ||
export const decimalHtmlContent = require('!!prismjs?lang=markup!./decimal.component.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
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