Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* issue185: + append timepicker to input

* issue185: + tests

* + test to cover appendToBody fn

* fix(ngx-timepicker-field): bug with changing minutes via input field

* issue218: ! fix theming

* fix(ngx-material-timepicker): formatting minutes

* issue208: + hoursOnly input to prevent switching to minutes automatically

* issue114: ! clicking area for 00 and 12 in 24 format

* issue227: + timepickerClass input for setting custom css class

* issue227: ! tests

* issue185: + example
  • Loading branch information
Agranom authored Oct 5, 2019
1 parent 664f89c commit 55964ab
Show file tree
Hide file tree
Showing 31 changed files with 937 additions and 548 deletions.
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ https://agranom.github.io/ngx-material-timepicker/
* [NgxTimepickerFieldComponent](#ngxtimepickerfieldcomponent)
* [NgxMaterialTimepickerToggleComponent](#ngxmaterialtimepickertogglecomponent)
* [NgxMaterialTimepickerToggleIconDirective](#ngxmaterialtimepickertoggleicondirective)
* [NgxMaterialTimepickerThemeDirective](#ngxmaterialtimepickerthemedirective)
* [Development](#development)
* [Tests](#tests)
* [License](#license)
Expand Down Expand Up @@ -122,6 +121,12 @@ Selector: `ngx-material-timepicker`
preventOverlayClick: boolean | Set `true` to prevent closing the timepicker by overlay click. Uses `false` by default |
| @Input()
disableAnimation: boolean | Set `true` to prevent opening and closing timepicker animation. Uses `false` by default |
| @Input()
hoursOnly: boolean | Set `true` to prevent switching to minutes automatically once hour is selected. Uses `false` by default |
| @Input()
theme: NgxMaterialTimepickerTheme | Custom css properties which will override the defaults |
| @Input()
timepickerClass: string | To provide a custom css class for the timepicker |
| @Output()
timeSet: EventEmitter\<string\> | Emits time when that was set. |
| @Output()
Expand Down Expand Up @@ -182,19 +187,6 @@ Can be used to override the icon of a `NgxMaterialTimepickerToggleComponent`.

Selector: `[ngxMaterialTimepickerToggleIcon]`

#### NgxMaterialTimepickerThemeDirective

Can be used to override styles of a `NgxMaterialTimepicker`.

Selector: `ngx-material-timepicker[ngxMaterialTimepickerTheme]`

**Properties**

| Name | Description |
|------|-------------|
| @Input()
ngxMaterialTimepickerTheme: NgxMaterialTimepickerTheme | Custom css properties which will override the defaults |

## Development

### Prepare your environment
Expand Down
18 changes: 16 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ <h3 class="ngx-material-timepicker-examples__title">Examples</h3>
<input placeholder="Custom theme" aria-label="Custom theme"
[ngxTimepicker]="darkPicker" readonly>
<ngx-material-timepicker #darkPicker
[ngxMaterialTimepickerTheme]="darkTheme"></ngx-material-timepicker>
[theme]="darkTheme"></ngx-material-timepicker>
</div>
<div class="ngx-material-timepicker-example__form-group">
<input placeholder="Custom hint" aria-label="Custom hint"
Expand All @@ -195,6 +195,20 @@ <h3 class="ngx-material-timepicker-examples__title">Examples</h3>
</div>
</div>
</section>
<section class="ngx-material-timepicker-examples__container ngx-material-timepicker-example">
<app-example-source-code [sourceCode]="appendToInput">Append to input</app-example-source-code>
<div class="ngx-material-timepicker-example__body">
<p class="ngx-material-timepicker-example__description">
Timepicker appends to input.
</p>
<div class="ngx-material-timepicker-example__form-group">
<input placeholder="Append to input" aria-label="Append to input"
[ngxTimepicker]="appendedToInput" readonly>
<ngx-material-timepicker #appendedToInput
[appendToInput]="true"></ngx-material-timepicker>
</div>
</div>
</section>
</div>
<div class="ngx-material-timepicker-heading">
<h2 class="ngx-material-timepicker-heading__title">ngx-timepicker-field</h2>
Expand All @@ -211,7 +225,7 @@ <h3 class="ngx-material-timepicker-examples__title">Examples</h3>
<ngx-timepicker-field [defaultTime]="'11:11 am'"></ngx-timepicker-field>
</div>
<div class="ngx-material-timepicker-example__form-group">
<ngx-timepicker-field [format]="24" [defaultTime]="'23:11'"></ngx-timepicker-field>
<ngx-timepicker-field [format]="24" [defaultTime]="'07:00'"></ngx-timepicker-field>
</div>
<div class="ngx-material-timepicker-example__form-group">
<ngx-timepicker-field [format]="24" [defaultTime]="'23:11'"></ngx-timepicker-field>
Expand Down
11 changes: 0 additions & 11 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@

$border-color: rgba(0, 0, 0, .09);

:host {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
display: flex;
flex-direction: column;
}

* {
box-sizing: border-box;
Expand Down Expand Up @@ -64,7 +54,6 @@ $border-color: rgba(0, 0, 0, .09);
.ngx-material-timepicker {
padding-top: 50px;
height: 100vh;
overflow-y: auto;
display: flex;
flex-direction: column;
}
Expand Down
11 changes: 10 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class AppComponent {
<div class="custom-theme-example">
<input placeholder="Custom theme" aria-label="Custom theme"
[ngxTimepicker]="darkPicker" readonly>
<ngx-material-timepicker #darkPicker [ngxMaterialTimepickerTheme]="darkTheme"></ngx-material-timepicker>
<ngx-material-timepicker #darkPicker [theme]="darkTheme"></ngx-material-timepicker>
</div>
//...
Expand Down Expand Up @@ -194,4 +194,13 @@ export class AppComponent {
<ngx-timepicker-field [controlOnly]="true"></ngx-timepicker-field>
</div>
`;

appendToInput = `
<div class="ngx-timepicker-field-example">
<input placeholder="Append to input" aria-label="Append to input"
[ngxTimepicker]="appendedToInput" readonly>
<ngx-material-timepicker #appendedToInput
[appendToInput]="true"></ngx-material-timepicker>
</div>
`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<div class="timepicker-backdrop-overlay" [overlay]="preventOverlayClick"
[ngClass]="{'timepicker-backdrop-overlay--transparent': appendToInput}"></div>
<div class="timepicker-overlay">
<ngx-material-timepicker-content [appendToInput]="appendToInput"
[inputElement]="inputElement"
[ngxMaterialTimepickerTheme]="theme">
<div class="timepicker"
[@timepicker]="animationState"
(@timepicker.done)="animationDone($event)"
[ngClass]="timepickerClass">
<header class="timepicker__header">
<ngx-material-timepicker-dial [format]="format" [hour]="(selectedHour | async)?.time"
[minute]="(selectedMinute | async)?.time"
[period]="selectedPeriod | async"
[activeTimeUnit]="activeTimeUnit"
[minTime]="minTime"
[maxTime]="maxTime"
[isEditable]="enableKeyboardInput"
[editableHintTmpl]="editableHintTmpl"
[minutesGap]="minutesGap"
(periodChanged)="changePeriod($event)"
(timeUnitChanged)="changeTimeUnit($event)"
(hourChanged)="onHourChange($event)"
(minuteChanged)="onMinuteChange($event)"
></ngx-material-timepicker-dial>
</header>
<div class="timepicker__main-content">
<div class="timepicker__body" [ngSwitch]="activeTimeUnit">
<div *ngSwitchCase="timeUnit.HOUR">
<ngx-material-timepicker-24-hours-face *ngIf="format === 24;else ampmHours"
(hourChange)="onHourChange($event)"
[selectedHour]="selectedHour | async"
[minTime]="minTime"
[maxTime]="maxTime"
[format]="format"
(hourSelected)="onHourSelected($event)"></ngx-material-timepicker-24-hours-face>
<ng-template #ampmHours>
<ngx-material-timepicker-12-hours-face
(hourChange)="onHourChange($event)"
[selectedHour]="selectedHour | async"
[period]="selectedPeriod | async"
[minTime]="minTime"
[maxTime]="maxTime"
(hourSelected)="onHourSelected($event)"></ngx-material-timepicker-12-hours-face>
</ng-template>
</div>
<ngx-material-timepicker-minutes-face *ngSwitchCase="timeUnit.MINUTE"
[selectedMinute]="selectedMinute | async"
[selectedHour]="(selectedHour | async)?.time"
[minTime]="minTime"
[maxTime]="maxTime"
[format]="format"
[period]="selectedPeriod | async"
[minutesGap]="minutesGap"
(minuteChange)="onMinuteChange($event)"></ngx-material-timepicker-minutes-face>
</div>
<div class="timepicker__actions">
<div (click)="close()">
<!--suppress HtmlUnknownAttribute -->
<ng-container
*ngTemplateOutlet="cancelBtnTmpl ? cancelBtnTmpl : cancelBtnDefault"></ng-container>
</div>
<div (click)="setTime()">
<!--suppress HtmlUnknownAttribute -->
<ng-container
*ngTemplateOutlet="confirmBtnTmpl ? confirmBtnTmpl : confirmBtnDefault"></ng-container>
</div>
</div>
</div>
</div>
</ngx-material-timepicker-content>
</div>
<ng-template #cancelBtnDefault>
<ngx-material-timepicker-button>Cancel</ngx-material-timepicker-button>
</ng-template>
<ng-template #confirmBtnDefault>
<ngx-material-timepicker-button>Ok</ngx-material-timepicker-button>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
background-color: rgba(0, 0, 0, 0.3);
z-index: 999;
pointer-events: auto;

&--transparent {
background-color: transparent;
}
}

.timepicker-overlay {
Expand Down
Loading

0 comments on commit 55964ab

Please sign in to comment.