Skip to content

Commit

Permalink
feat(formComponent): started form component
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Jan 13, 2017
1 parent facbeab commit 4516f89
Show file tree
Hide file tree
Showing 12 changed files with 431 additions and 28 deletions.
2 changes: 1 addition & 1 deletion chore/gulp/tasks/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gulp.task('project:clean', function (done) {

//helper for development
gulp.task('project:update-example', function (done) {
var destination = path.join('examples','angular1', 'node_modules', 'angular-star-rating', 'dist' );
var destination = path.join('examples','angular2', 'node_modules', 'angular-star-rating', 'dist' );
helper.log('update lib in example. copy ' + config.dist + ' to ' + destination);
return gulp.src('./'+config.dist+'/*')
.pipe(gulp.dest(destination), done);
Expand Down
4 changes: 2 additions & 2 deletions examples/angular2/angular-cli.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"project": {
"version": "1.0.0-beta.24",
"name": "angular2"
"version": "2.0.0-beta.24",
"name": "angular-star-rating"
},
"apps": [
{
Expand Down
3 changes: 2 additions & 1 deletion examples/angular2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",
"bootstrap": "^4.0.0-alpha.6",
"core-js": "^2.4.1",
"css-star-rating": "^1.1.1",
"rxjs": "^5.0.1",
Expand All @@ -31,7 +32,7 @@
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.24",
"angular-cli": "^1.0.0-beta.25.5",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
Expand Down
222 changes: 216 additions & 6 deletions examples/angular2/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,216 @@
<h1>
{{title}}
</h1>
<star-rating-comp>
COMPONENT IS NOT WORKING
</star-rating-comp>

<div id="init-view" class="container">

<div class="jumbotron">
<h1 class="">Angular Star Rating</h1>
<p class="lead">
Angular1 Star Rating is a >2 Angular component based on css only techniques written in scss<br/>
It is based on <a href="https://github.com/BioPhoton/css-star-rating">Css Star Rating</a>,
a fully featured and customizable css only star rating component written in scss.
</p>

<h1>
{{title}}
</h1>

<star-rating-comp
[rating]="4"
[id]="id"
[showHalfStars]="showHalfStars"
[disabled]="disabled"
[readOnly]="readOnly"
[space]="space"
[size]="size"
[numOfStars]="numOfStars"
[staticColor]="color"
[speed]="speed"
[labelText]="rating"
[labelPosition]="position"
[starType]="starType"


>
COMPONENT IS NOT WORKING
</star-rating-comp>


</div>

<div class="container">

<star-rating-bindings-form>

</star-rating-bindings-form>

<div class="row">
<div class="col-xs-4">
<fieldset class="form-group row">
<legend>Layout</legend>

<div class="form-check">
<label class="col-xs-4 col-form-label">Lable Position</label>
<div class="col-xs-8">
<select class="form-control" [ngModel]="position">
<option value="">position</option>
<option value="{{value}}" *ngFor="let value of labelPositionOptions">{{value}}
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-xs-6 col-form-label">starOptions: {{starType}}</label>
<div class="col-xs-6">
<select class="form-control" [ngModel]="starType">
<option value="">starType</option>
<option value="{{value}}" *ngFor="let value of starOptions">{{value}}
</option>
</select>
</div>

</div>

<div class="form-group row">
<label class="col-xs-4 col-form-label">Space</label>
<div class="col-xs-8">
<select class="form-control" [ngModel]="space">
<option value="">space</option>
<option value="{{value}}" *ngFor="let value of spaceOptions">{{value}}
</option>
</select>
</div>

</div>

</fieldset>

</div>
<div class="col-xs-4">
<fieldset class="form-group row">
<legend>Dimensions
</legend>
<div class="form-group">
<label class="col-xs-6 col-form-label">NumOfStars</label>
<div class="col-xs-6">
<input type="number" class="form-control" placeholder="NumOfStars"
[ngModel]="numOfStars" (ngModelChange)="numOfStars = $event"> {{numOfStars}}
</div>
</div>
<div class="form-group row">
<label class="col-xs-6 col-form-label">Size: {{size}}</label>
<div class="col-xs-6">
<select class="form-control" [ngModel]="size" (ngModelChange)="size = $event">
<option value="">size</option>
<option value="{{value}}" *ngFor="let value of sizeOptions">{{value}}
</option>
</select>
</div>

</div>

</fieldset>

</div>
<div class="col-xs-4">
<fieldset class="form-group">

<legend>Styling
</legend>

<div class="form-group row">
<label class="col-xs-4 col-form-label">Color</label>
<div class="col-xs-8">
<select class="form-control" [ngModel]="color" (ngModelChange)="color = $event">
<option value="">color</option>
<option value="{{value}}" *ngFor="let value of colorOptions">{{value}}
</option>
</select>
</div>

</div>

<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" ng-change="updateGetColorBinding()" [ngModel]="useCustomCetColor" (ngModelChange)="size = $event">
use custom getColor function
</label>
</div>

<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" [ngModel]="disabled" (ngModelChange)="disabled = $event">
Disabled
</label>
</div>

<div class="form-group row">
<label class="col-xs-4 col-form-label">Speed: {{speed}}</label>
<div class="col-xs-8">
<select class="form-control" [ngModel]="speed" (ngModelChange)="speed = $event">
<option value="">speed</option>
<option value="{{value}}" *ngFor="let value of speedOptions">{{value}}
</option>
</select>
</div>
</div>

</fieldset>

</div>

</div>

<div class="row">
<div class="col-xs-4">
<fieldset class="form-group">
<legend>Other
</legend>

<div class="form-group row">
<label class="col-xs-6 col-form-label">Id</label>
<div class="col-xs-6">
<input type="text" class="form-control" placeholder="Id" [ngModel]="id" (ngModelChange)="id = $event"">
</div>
</div>

<div class="form-group row">
<label class="col-xs-6 col-form-label">Rating</label>
<div class="col-xs-6">
<input type="number" class="form-control" placeholder="rating" step="0.5" [ngModel]="rating" (ngModelChange)="rating = $event">
</div>
</div>

<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" [ngModel]="showHalfStars" (ngModelChange)="showHalfStars = $event">
showHalfStars
</label>
</div>

<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" ng-change="updateGetHalfStarVisibleBinding()" [ngModel]="useCustomGetHalfStarVisible">
use custom getHalfStarVisible function
</label>
</div>

<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" [ngModel]="readOnly" (ngModelChange)="readOnly = $event">
ReadOnly
</label>
</div>

<div class="form-group row">
<label class="col-xs-6 col-form-label">Text</label>
<div class="col-xs-6">
<input type="text" class="form-control" placeholder=":Label text" [ngModel]="labelText" (ngModelChange)="labelText = $event">
</div>
</div>

</fieldset>
</div>
</div>
<!---->
</div>

</div>
79 changes: 79 additions & 0 deletions examples/angular2/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Component } from '@angular/core';
/*
import {
starRatingColors, starRatingPosition, starRatingStarTypes,
starRatingSpeed, starRatingSizes, starRatingStarSpace, IStarRatingOnClickEvent, IStarRatingOnUpdateEvent
} from "../../../../src/star-rating-struct";
*/

@Component({
selector: 'app-root',
Expand All @@ -7,5 +13,78 @@ import { Component } from '@angular/core';
//directives: [StarRatingComponent]
})
export class AppComponent {

title = 'app works!';
/*
//option sets
colorOptions:Array<starRatingColors|string> = ['default','negative', 'ok', 'positive'];
labelPositionOptions:Array<starRatingPosition|string> = ['top','right', 'left', 'bottom'];
starOptions:Array<starRatingStarTypes> = ['svg', 'icon', 'image'];
speedOptions:Array<starRatingSpeed> = ['immediately', 'noticeable', 'slow'];
sizeOptions:Array<starRatingSizes> = ['small', 'medium', 'large'];
spaceOptions:Array<starRatingStarSpace|string> = ['around', 'between', 'no'];
//component input properties (> bindings)
id: string;
//pathEmpty: string;
//pathFilled:string;
numOfStars:number = 5;
rating: number = 3.5;
labelText: number = this.rating;
color:starRatingColors;
speed:starRatingSpeed|string;
size: starRatingSizes|string;
space: boolean = false;
readOnly: boolean = false;
disabled: boolean = false;
showHalfStars:boolean = false;
//component input functions (> bindings)
getColor;
useCustomCetColor:boolean = false;
getHalfStarVisible;
useCustomGetHalfStarVisible:boolean = false;
constructor() {
}
//component output (& bindings)
onClick($event:IStarRatingOnClickEvent): void {
console.log('single onClick rating: ',$event.rating);
}
onUpdate($event:IStarRatingOnUpdateEvent): void {
console.log('single onUpdate rating: ',$event.rating);
this.rating = $event.rating;
}
updateGetColorBinding() {
if(this.useCustomCetColor) {
this.getColor = this._getColor;
}
else {
this.getColor = undefined;
}
}
updateGetHalfStarVisibleBinding() {
if(this.useCustomGetHalfStarVisible) {
this.getHalfStarVisible = this._getHalfStarVisible;
}
else {
this.getHalfStarVisible = undefined;
}
}
_getColor(rating :number|string, numOfStars:number, staticColor:string):string {
console.log('single getColor rating: ',rating, 'numOfStars: ', numOfStars, 'fixColor: ', staticColor);
let colors = ['default', 'negative', 'ok', 'positive'];
return colors[Math.floor(Math.random() * colors.length)];
};
_getHalfStarVisible(rating:number):boolean {
console.log('getHalfStarVisible rating: ',rating, rating%1);
return (rating<3);
};
*/

}
8 changes: 5 additions & 3 deletions examples/angular2/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import {StarRatingModule} from "angular-star-rating/src/star-rating.module";
//import {StarRatingModule} from "angular-star-rating/src/star-rating.module";
//import { StarRatingBindingsFormComponent } from './common/star-rating-bindings-form/star-rating-bindings-form.component';

@NgModule({
declarations: [
AppComponent
AppComponent,
//StarRatingBindingsFormComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
StarRatingModule
//StarRatingModule
],
providers: [],
bootstrap: [AppComponent]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="container">
<h1>Hero Form</h1>
<form>

<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" required>
</div>

<div class="form-group">
<label for="alterEgo">Alter Ego</label>
<input type="text" class="form-control" id="alterEgo">
</div>

<div class="form-group">
<label for="staticColor">Static Color:</label>
<select class="form-control" id="staticColor" required>
<option *ngFor="let staticColor of colorOptions" [value]="staticColor">{{staticColor}}</option>
</select>
</div>

<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>

0 comments on commit 4516f89

Please sign in to comment.