-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli-migration): migrate to webpack and sass
- Loading branch information
Showing
17 changed files
with
488 additions
and
1,160 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
Empty file.
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
Empty file.
3 changes: 0 additions & 3 deletions
3
examples/angular2/src/app/common/star-rating/star-rating.component.html
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
examples/angular2/src/app/common/star-rating/star-rating.module.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,79 @@ | ||
import {Injectable} from '@angular/core'; | ||
import { | ||
IStarRatingCompBindings, | ||
starRatingSizes, | ||
starRatingSpeed, | ||
starRatingPosition, | ||
starRatingStarTypes, | ||
starRatingColors | ||
} from "./star-rating-struct"; | ||
|
||
/** | ||
* Configuration service for the StarRating component. | ||
* You can inject this service, typically in your root component, and customize the values of its properties in | ||
* order to provide default values for all the star ratings used in the application. | ||
*/ | ||
@Injectable() | ||
export class StarRatingConfig implements IStarRatingCompBindings { | ||
|
||
classEmpty: string = "default-star-empty-icon"; | ||
|
||
classHalf: string = "default-star-half-icon"; | ||
|
||
classFilled: string = "default-star-filled-icon"; | ||
|
||
numOfStars: number = 5; | ||
|
||
size: starRatingSizes = "medium"; | ||
|
||
speed: starRatingSpeed = "noticeable"; | ||
|
||
labelPosition: starRatingPosition = "left"; | ||
|
||
starType: starRatingStarTypes = "svg"; | ||
|
||
assetsPath: string = "assets/images/"; | ||
|
||
svgPath: string = this.assetsPath + "star-rating.icons.svg"; | ||
svgEmptySymbolId: string = "star-empty"; | ||
svgHalfSymbolId: string = "star-half"; | ||
svgFilledSymbolId: string = "star-filled"; | ||
|
||
svgPathEmpty: string = this.svgPath + "#" + this.svgEmptySymbolId; | ||
|
||
svgPathHalf: string = this.svgPath + "#" + this.svgHalfSymbolId; | ||
|
||
svgPathFilled: string = this.svgPath + "#" + this.svgFilledSymbolId; | ||
|
||
getColor(rating: number, numOfStars: number, staticColor?: starRatingColors): starRatingColors { | ||
rating = rating || 0; | ||
|
||
//if a fix color is set use this one | ||
if (staticColor) { | ||
return staticColor; | ||
} | ||
|
||
//calculate size of smallest fraction | ||
let fractionSize = numOfStars / 3; | ||
|
||
//apply color by fraction | ||
let color: starRatingColors = 'default'; | ||
if (rating > 0) { | ||
color = 'negative'; | ||
} | ||
if (rating > fractionSize) { | ||
color = 'ok'; | ||
} | ||
if (rating > fractionSize * 2) { | ||
color = 'positive'; | ||
} | ||
|
||
return color; | ||
} | ||
|
||
getHalfStarVisible(rating: number): boolean { | ||
return Math.abs(rating % 1) > 0; | ||
} | ||
|
||
|
||
} |
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,36 @@ | ||
export type starRatingSizes = "small" | "medium" | "large"; | ||
export type starRatingColors = "default" | "negative" | "ok" | "positive"; | ||
export type starRatingSpeed = "immediately" | "noticeable" | "slow"; | ||
export type starRatingPosition = "left" | "right" | "top" | "bottom"; | ||
export type starRatingStarTypes = "svg" | "icon" | "image"; | ||
export type starRatingStarSpace= "no" | "between" | "around"; | ||
|
||
export interface IStarRatingCompBindings { | ||
//Inputs (< bindings) | ||
id?: string; | ||
labelText?: string; | ||
staticColor?: starRatingColors; | ||
labelPosition?: starRatingPosition; | ||
speed?: starRatingSpeed; | ||
size?: starRatingSizes; | ||
starType?: starRatingStarTypes; | ||
space?: starRatingStarSpace; | ||
readOnly?: boolean; | ||
disabled?: boolean; | ||
showHalfStars?: boolean; | ||
rating?: number; | ||
numOfStars?: number; | ||
getHalfStarVisible?(rating: number): boolean; | ||
getColor?(rating: number, numOfStars: number, staticColor?: starRatingColors): starRatingColors; | ||
//Outputs (& bindings) | ||
onClick?: ($event: any) => IStarRatingOnClickEvent; | ||
onUpdate?: ($event: any) => IStarRatingOnUpdateEvent; | ||
} | ||
|
||
export interface IStarRatingOnClickEvent { | ||
rating: number; | ||
} | ||
|
||
export interface IStarRatingOnUpdateEvent { | ||
rating: number; | ||
} |
Oops, something went wrong.