Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p-rating component with custom icons #3795

Closed
mselerin opened this issue Aug 31, 2017 · 1 comment
Closed

p-rating component with custom icons #3795

mselerin opened this issue Aug 31, 2017 · 1 comment
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@mselerin
Copy link
Contributor

I'm submitting a ...

[x] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap

Current behavior
The rating component shows only stars icons.

Expected behavior
It would be usefull if we could specify the icons to render this component.

What is the motivation / use case for changing the behavior?
A concrete use case is when we want to show a "price rating" component. Instead of stars, we could show dollars / euros signs.

A simple implementation for this is to have 3 more inputs :

@Input() iconActive: string = 'fa-star';
@Input() iconInactive: string = 'fa-star-o';
@Input() iconBan: string = 'fa-ban';

and use it in the component template :

@Component({
    selector: 'p-rating',
    template: `
        <div class="ui-rating" [ngClass]="{'ui-state-disabled': disabled}">
            <a href="#" *ngIf="cancel" (click)="clear($event)">
                <span class="fa" [ngClass]="[iconBan]"></span>
            </a>
            <a href="#" *ngFor="let star of starsArray;let i=index" (click)="rate($event,i)">
                <span class="fa" [ngClass]="{iconInactive: (!value || i >= value), iconActive:(i < value)}"></span>
            </a>
        </div>
    `,
    providers: [RATING_VALUE_ACCESSOR]
})

I'll provide a PR with this solution ASAP.

@MrBlaise
Copy link

I would love to see this feature as well. However I would love to have even more options. I really like how the guys at ng-boostrap (https://ng-bootstrap.github.io/#/components/rating/examples) doing the rating component.

It would be really nice if we could pass a template to customize the ratings, and be able to use fractions.

@cagataycivici cagataycivici self-assigned this Oct 3, 2017
@cagataycivici cagataycivici added the Type: New Feature Issue contains a new feature or new component request label Oct 3, 2017
@cagataycivici cagataycivici added this to the 4.2.2 milestone Oct 3, 2017
cagataycivici added a commit that referenced this issue Oct 3, 2017
#3795 p-rating component with custom icons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

3 participants