Skip to content

Commit

Permalink
Merge pull request #8 from MurhafSousli/dev
Browse files Browse the repository at this point in the history
fix fraction rating value
  • Loading branch information
MurhafSousli authored Jun 5, 2017
2 parents 37ef88d + 9f6aeb0 commit b7240db
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 17 deletions.
25 changes: 13 additions & 12 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.3",
"@angular/compiler-cli": "^4.1.2",
"@types/jasmine": "2.5.38",
"@angular/cli": "1.1.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "2.5.45",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
"karma-coverage-istanbul-reporter": "^1.2.1",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
}
3 changes: 1 addition & 2 deletions demo/src/app/rating/component/bar-rating.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ export class BarRatingComponent implements OnInit, OnChanges, ControlValueAccess
private updateState(nextValue) {
/** Set rate value as text */
this.nextRate = nextValue - 1;

/** Set the rating */
this.contexts = Array.from({ length: this.max }, (context, index) => ({
selected: index < nextValue,
selected: index + 1 <= nextValue,
fraction: (index + 1 === Math.round(nextValue) && nextValue % 1) >= 0.5,
click: (e) => this.handleClick(e, index),
enter: () => this.handleEnter(index)
Expand Down
1 change: 1 addition & 0 deletions demo/src/app/rating/themes/br-fontawesome-o-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

.br-fraction:after {
content: '\f123';
color: $green-color;
}

}
Expand Down
31 changes: 31 additions & 0 deletions demo/src/app/rating/themes/br-stars-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.br-stars {
.br-units {

align-items: center;
}
.br-unit {
background-position: center center;
background-size: contain;
background-repeat: no-repeat;
background-image: url("data:image/svg+xml;charset=utf8,%3C?xml version='1.0' encoding='iso-8859-1'?%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512.002 512.002' style='enable-background:new 0 0 512.002 512.002;' xml:space='preserve'%3E%3Cpath style='fill:%23F0D355;' d='M400.07,502.64c-3.551,0-7.116-0.825-10.398-2.5L256.001,431.95L122.33,500.14 c-3.283,1.675-6.848,2.5-10.399,2.5c-4.728,0-9.431-1.464-13.408-4.336c-6.961-5.031-10.52-13.537-9.215-22.026l22.995-149.648 L6.579,219.236c-6.002-6.096-8.103-15.031-5.446-23.163c2.656-8.131,9.626-14.103,18.069-15.481l147.912-24.138l68.49-134.585 c3.904-7.675,11.786-12.507,20.397-12.507c8.611,0,16.493,4.833,20.396,12.507l68.49,134.585L492.8,180.592 c8.444,1.378,15.413,7.35,18.07,15.481c2.656,8.132,0.555,17.067-5.447,23.163L399.7,326.628l22.993,149.648 c1.305,8.49-2.254,16.995-9.215,22.026C409.502,501.175,404.798,502.64,400.07,502.64z'/%3E%3Cg style='opacity:0.1;'%3E%3Cpath style='fill:%23414042;' d='M146.585,486.578c-6.96-5.03-10.52-13.537-9.215-22.026l22.995-149.647L54.643,207.512 c-6.003-6.096-8.103-15.031-5.447-23.163c1.232-3.769,3.397-7.065,6.199-9.663l-36.193,5.906 c-8.444,1.378-15.413,7.35-18.069,15.481c-2.657,8.132-0.556,17.067,5.446,23.163l105.724,107.391L89.307,476.276 c-1.305,8.49,2.254,16.995,9.215,22.026c3.977,2.872,8.68,4.336,13.408,4.336c3.551,0,7.117-0.826,10.399-2.5l25.267-12.89 C147.257,487.03,146.914,486.817,146.585,486.578z'/%3E%3C/g%3E%3C/svg%3E");

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

margin-left: 5px;
width: 28px;
height: 28px;
filter: grayscale(1);

&:first-child {
margin-left: 0;
}
}

.br-selected, .br-active {
filter: grayscale(0);
}
}

7 changes: 6 additions & 1 deletion demo/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
// import 'classlist.js'; // Run `npm install --save classlist.js`.

/** IE10 and IE11 requires the following to support `@angular/animation`. */
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
Expand Down Expand Up @@ -66,3 +67,7 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.
/**
* Need to import at least one locale-data with intl.
*/
// import 'intl/locale-data/jsonp/en';
5 changes: 5 additions & 0 deletions demo/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"node_modules/codelyzer"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
Expand Down Expand Up @@ -45,18 +46,22 @@
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
Expand Down
3 changes: 1 addition & 2 deletions src/component/bar-rating.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ export class BarRatingComponent implements OnInit, OnChanges, ControlValueAccess
private updateState(nextValue) {
/** Set rate value as text */
this.nextRate = nextValue - 1;

/** Set the rating */
this.contexts = Array.from({ length: this.max }, (context, index) => ({
selected: index < nextValue,
selected: index + 1 <= nextValue,
fraction: (index + 1 === Math.round(nextValue) && nextValue % 1) >= 0.5,
click: (e) => this.handleClick(e, index),
enter: () => this.handleEnter(index)
Expand Down
1 change: 1 addition & 0 deletions src/themes/br-fontawesome-o-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

.br-fraction:after {
content: '\f123';
color: $green-color;
}

}
Expand Down

0 comments on commit b7240db

Please sign in to comment.