Skip to content

Commit

Permalink
Release 1.6.0
Browse files Browse the repository at this point in the history
Add new `customSize` option to allow specifying a custom star size
  • Loading branch information
hughjdavey committed Jun 7, 2022
1 parent ea3be5a commit 8231cfa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.6.0 (07/06/2022)

* Add new `customSize` option to allow specifying a custom star size

## 1.5.1 (28/04/2021)

* Fix table of contents links in `README.md`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-stars",
"version": "1.5.1",
"version": "1.6.0",
"description": "Simple stars rating component for Angular >= 2",
"repository": {
"type": "git",
Expand Down
9 changes: 6 additions & 3 deletions src/lib/ngx-stars.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class NgxStarsComponent implements OnInit, OnDestroy {
@Input()
size: number;

@Input()
customSize: string;

@Input()
color: string;

Expand Down Expand Up @@ -91,7 +94,7 @@ export class NgxStarsComponent implements OnInit, OnDestroy {
}

starPadding(): { [p: string]: string } {
return { 'margin-right': this.customPadding || `0.${this.safeSize()}rem` };
return { 'margin-right': this.customPadding || `calc(${this.starSize().width} / 10)` };
}

starColorAndSize(): { [p: string]: string } {
Expand All @@ -104,8 +107,8 @@ export class NgxStarsComponent implements OnInit, OnDestroy {

starSize(): { [p: string]: string } {
return {
height: `${15 * this.safeSize()}px`,
width: `${16 * this.safeSize()}px`,
height: this.customSize || `${15 * this.safeSize()}px`,
width: this.customSize || `${16 * this.safeSize()}px`,
};
}

Expand Down

0 comments on commit 8231cfa

Please sign in to comment.