Skip to content

Commit

Permalink
docs(timepicker): create documentation for timepicker (#1481)
Browse files Browse the repository at this point in the history
  • Loading branch information
natali-abyss authored and valorkin committed Jan 12, 2017
1 parent 8072960 commit 8e18733
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 78 deletions.
2 changes: 2 additions & 0 deletions demo/src/app/components/timepicker/demos/basic/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<timepicker [(ngModel)]="mytime"></timepicker>
<pre class="alert alert-info">Time is: {{mytime}}</pre>
9 changes: 9 additions & 0 deletions demo/src/app/components/timepicker/demos/basic/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-basic',
templateUrl: './basic.html'
})
export class DemoTimepickerBasicComponent {
public mytime: Date = new Date();
}
2 changes: 2 additions & 0 deletions demo/src/app/components/timepicker/demos/config/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<timepicker [(ngModel)]="mytime"></timepicker>
<pre class="alert alert-info">Time is: {{mytime}}</pre>
22 changes: 22 additions & 0 deletions demo/src/app/components/timepicker/demos/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component } from '@angular/core';
import { TimepickerConfig } from 'ng2-bootstrap';

// such override allows to keep some initial values

export function getTimepickerConfig(): TimepickerConfig {
return Object.assign(new TimepickerConfig(), {
hourStep: 2,
minuteStep: 10,
showMeridian: false,
readonlyInput: false,
mousewheel: true
});
}

@Component({
selector: 'demo-timepicker-config',
templateUrl: './config.html',
providers: [{provide: TimepickerConfig, useFactory: getTimepickerConfig}]
})
export class DemoTimepickerConfigComponent {
}
18 changes: 18 additions & 0 deletions demo/src/app/components/timepicker/demos/custom/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<timepicker [(ngModel)]="mytime" [hourStep]="hstep" [minuteStep]="mstep"></timepicker>

<pre class="alert alert-info">Time is: {{mytime}}</pre>

<div class="row">
<div class="col-xs-6">
Hours step is:
<select class="form-control" [(ngModel)]="hstep">
<option *ngFor="let opt of options.hstep" [value]="opt">{{opt}}</option>
</select>
</div>
<div class="col-xs-6">
Minutes step is:
<select class="form-control" [(ngModel)]="mstep">
<option *ngFor="let opt of options.mstep" [value]="opt">{{opt}}</option>
</select>
</div>
</div>
16 changes: 16 additions & 0 deletions demo/src/app/components/timepicker/demos/custom/custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-custom',
templateUrl: './custom.html'
})
export class DemoTimepickerCustomComponent {
public hstep: number = 1;
public mstep: number = 15;

public mytime: Date = new Date();
public options: any = {
hstep: [1, 2, 3],
mstep: [1, 5, 10, 15, 25, 30]
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<timepicker [(ngModel)]="mytime" [showMeridian]="ismeridian" [readonlyInput]="!isEnabled"></timepicker>
<hr>

<button type="button" class="btn btn-info" (click)="isEnabled=!isEnabled">Enable / Disable input</button>

12 changes: 12 additions & 0 deletions demo/src/app/components/timepicker/demos/disabled/disabled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-disabled',
templateUrl: './disabled.html'
})
export class DemoTimepickerDisabledComponent {
public ismeridian: boolean = false;
public isEnabled: boolean = true;
public mytime: Date = new Date();

}
6 changes: 6 additions & 0 deletions demo/src/app/components/timepicker/demos/dynamic/dynamic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<timepicker [(ngModel)]="mytime" (change)="changed()"></timepicker>

<pre class="alert alert-info">Time is: {{mytime}}</pre>

<button type="button" class="btn btn-primary" (click)="update()">Set to 14:00</button>
<button type="button" class="btn btn-danger" (click)="clear()">Clear</button>
25 changes: 25 additions & 0 deletions demo/src/app/components/timepicker/demos/dynamic/dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-dynamic',
templateUrl: './dynamic.html'
})
export class DemoTimepickerDynamicComponent {

public mytime: Date = new Date();

public update(): void {
let d = new Date();
d.setHours(14);
d.setMinutes(0);
this.mytime = d;
}

public changed(): void {
console.log('Time changed to: ' + this.mytime);
}

public clear(): void {
this.mytime = void 0;
}
}
36 changes: 31 additions & 5 deletions demo/src/app/components/timepicker/demos/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
import { TimepickerDemoComponent } from './timepicker-demo.component';
import { DemoTimepickerBasicComponent } from './basic/basic';
import { DemoTimepickerConfigComponent } from './config/config';
import { DemoTimepickerMeridianComponent } from './meridian/meridian';
import { DemoTimepickerDisabledComponent } from './disabled/disabled';
import { DemoTimepickerCustomComponent } from './custom/custom';
import { DemoTimepickerDynamicComponent } from './dynamic/dynamic';

export const DEMO_COMPONENTS = [
TimepickerDemoComponent
DemoTimepickerBasicComponent, DemoTimepickerConfigComponent, DemoTimepickerMeridianComponent,
DemoTimepickerDisabledComponent, DemoTimepickerCustomComponent, DemoTimepickerDynamicComponent
];

export const DEMOS = {
old: {
component: require('!!raw?lang=typescript!./timepicker-demo.component'),
html: require('!!raw?lang=markup!./timepicker-demo.component.html')
basic: {
component: require('!!raw?lang=typescript!./basic/basic'),
html: require('!!raw?lang=markup!./basic/basic.html')
},
meridian: {
component: require('!!raw?lang=typescript!./meridian/meridian'),
html: require('!!raw?lang=markup!./meridian/meridian.html')
},
disabled: {
component: require('!!raw?lang=typescript!./disabled/disabled'),
html: require('!!raw?lang=markup!./disabled/disabled.html')
},
custom: {
component: require('!!raw?lang=typescript!./custom/custom'),
html: require('!!raw?lang=markup!./custom/custom.html')
},
dynamic: {
component: require('!!raw?lang=typescript!./dynamic/dynamic'),
html: require('!!raw?lang=markup!./dynamic/dynamic.html')
},
config: {
component: require('!!raw?lang=typescript!./config/config'),
html: require('!!raw?lang=markup!./config/config.html')
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<timepicker [(ngModel)]="mytime" (change)="changed()" [showMeridian]="ismeridian"></timepicker>

<pre class="alert alert-info">Time is: {{mytime}}</pre>

<hr>

<button type="button" class="btn btn-info" (click)="toggleMode()">12H / 24H</button>

16 changes: 16 additions & 0 deletions demo/src/app/components/timepicker/demos/meridian/meridian.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-timepicker-meridian',
templateUrl: './meridian.html'
})
export class DemoTimepickerMeridianComponent {
public ismeridian:boolean = true;

public mytime:Date = new Date();

public toggleMode():void {
this.ismeridian = !this.ismeridian;
}

}

This file was deleted.

This file was deleted.

48 changes: 39 additions & 9 deletions demo/src/app/components/timepicker/timepicker-section.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ let titleDoc = require('html!markdown!./docs/title.md');
<li><a routerLink="." fragment="usage">Usage</a></li>
<li><a routerLink="." fragment="examples">Examples</a>
<ul>
<!--<li><a routerLink="." fragment="link-color">Link color</a></li>-->
<li><a routerLink="." fragment="basic">Timepicker</a></li>
<li><a routerLink="." fragment="meridian">Meridian</a></li>
<li><a routerLink="." fragment="disabled">Disabled</a></li>
<li><a routerLink="." fragment="custom">Custom steps</a></li>
<li><a routerLink="." fragment="dynamic">Dynamic</a></li>
<li><a routerLink="." fragment="config">Configuring defaults</a></li>
</ul>
</li>
<li><a routerLink="." fragment="api-reference">API Reference</a>
Expand All @@ -31,20 +36,45 @@ let titleDoc = require('html!markdown!./docs/title.md');
<h2 routerLink="." fragment="examples" id="examples">Examples</h2>
<!-- basic -->
<ng-sample-box [ts]="demos.old.component" [html]="demos.old.html">
<timepicker-demo></timepicker-demo>
<h2 routerLink="." fragment="basic" id="basic">Timepicker</h2>
<ng-sample-box [ts]="demos.basic.component" [html]="demos.basic.html">
<demo-timepicker-basic></demo-timepicker-basic>
</ng-sample-box>
<h2 routerLink="." fragment="meridian" id="meridian">Meridian</h2>
<ng-sample-box [ts]="demos.meridian.component" [html]="demos.meridian.html">
<demo-timepicker-meridian></demo-timepicker-meridian>
</ng-sample-box>
<h2 routerLink="." fragment="disabled" id="disabled">Disabled</h2>
<ng-sample-box [ts]="demos.disabled.component" [html]="demos.disabled.html">
<demo-timepicker-disabled></demo-timepicker-disabled>
</ng-sample-box>
<h2 routerLink="." fragment="custom" id="custom">Custom steps</h2>
<ng-sample-box [ts]="demos.custom.component" [html]="demos.custom.html">
<demo-timepicker-custom></demo-timepicker-custom>
</ng-sample-box>
<h2 routerLink="." fragment="dynamic" id="dynamic">Dynamic</h2>
<ng-sample-box [ts]="demos.dynamic.component" [html]="demos.dynamic.html">
<demo-timepicker-dynamic></demo-timepicker-dynamic>
</ng-sample-box>
<h2 routerLink="." fragment="config" id="config">Configuring defaults</h2>
<ng-sample-box [ts]="demos.config.component" [html]="demos.config.html">
<demo-timepicker-config></demo-timepicker-config>
</ng-sample-box>
<h2 routerLink="." fragment="api-reference" id="api-reference">API Reference</h2>
<ng-api-doc id="timepicker-component" directive="TimepickerComponent"></ng-api-doc>
<ng-api-doc-config id="timepicker-config" type="TimepickerConfig"></ng-api-doc-config>
<ng-api-doc routerLink="." fragment="timepicker-component" id="timepicker-component" directive="TimepickerComponent"></ng-api-doc>
<ng-api-doc-config routerLink="." fragment="timepicker-config" id="timepicker-config" type="TimepickerConfig"></ng-api-doc-config>
</demo-section>`
})
export class TimepickerSectionComponent {
public name:string = 'Timepicker';
public src:string = 'https://github.com/valor-software/ng2-bootstrap/tree/development/src/timepicker';
public name: string = 'Timepicker';
public src: string = 'https://github.com/valor-software/ng2-bootstrap/tree/development/src/timepicker';
public demos: any = DEMOS;
public titleDoc:string = titleDoc;
public titleDoc: string = titleDoc;
}
4 changes: 4 additions & 0 deletions demo/src/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ a:hover {
text-decoration: none;
}

.hidden {
display: none !important;
}

/************* START TOP MENU **************/

#top-menu {
Expand Down

0 comments on commit 8e18733

Please sign in to comment.