-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(ngx-material-timepicker-toggle): add a button to open the timepicker * ref(timepicker directive): set default time only after first value check * ref(timepicker directive): make function more readable
- Loading branch information
Showing
8 changed files
with
121 additions
and
30 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
8 changes: 8 additions & 0 deletions
8
...epicker/components/timepicker-toggle-button/ngx-material-timepicker-toggle.component.html
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,8 @@ | ||
<button class="ngx-material-timepicker-toggle" (click)="open($event)" [disabled]="disabled" type="button"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px" *ngIf="!customIcon"> | ||
<path | ||
d="M 12 2 C 6.4889971 2 2 6.4889971 2 12 C 2 17.511003 6.4889971 22 12 22 C 17.511003 22 22 17.511003 22 12 C 22 6.4889971 17.511003 2 12 2 z M 12 4 C 16.430123 4 20 7.5698774 20 12 C 20 16.430123 16.430123 20 12 20 C 7.5698774 20 4 16.430123 4 12 C 4 7.5698774 7.5698774 4 12 4 z M 11 6 L 11 12.414062 L 15.292969 16.707031 L 16.707031 15.292969 L 13 11.585938 L 13 6 L 11 6 z"/> | ||
</svg> | ||
|
||
<ng-content select="[ngxMaterialTimepickerToggleIcon]"></ng-content> | ||
</button> |
17 changes: 17 additions & 0 deletions
17
...epicker/components/timepicker-toggle-button/ngx-material-timepicker-toggle.component.scss
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,17 @@ | ||
.ngx-material-timepicker-toggle { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 4px; | ||
background-color: transparent; | ||
border-radius: 50%; | ||
text-align: center; | ||
border: none; | ||
outline: none; | ||
user-select: none; | ||
transition: background-color .3s; | ||
cursor: pointer; | ||
&:focus { | ||
background-color: rgba(0, 0, 0, .07); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...imepicker/components/timepicker-toggle-button/ngx-material-timepicker-toggle.component.ts
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,34 @@ | ||
import {Component, ContentChild, Input} from '@angular/core'; | ||
import {NgxMaterialTimepickerToggleIconDirective} from '../../directives/ngx-material-timepicker-toggle-icon.directive'; | ||
import {NgxMaterialTimepickerComponent} from '../../ngx-material-timepicker.component'; | ||
|
||
@Component({ | ||
selector: 'ngx-material-timepicker-toggle', | ||
templateUrl: 'ngx-material-timepicker-toggle.component.html', | ||
styleUrls: ['ngx-material-timepicker-toggle.component.scss'] | ||
}) | ||
|
||
export class NgxMaterialTimepickerToggleComponent { | ||
|
||
@Input('for') timepicker: NgxMaterialTimepickerComponent; | ||
|
||
@Input() | ||
get disabled(): boolean { | ||
return this._disabled === undefined ? this.timepicker.disabled : this._disabled; | ||
} | ||
|
||
set disabled(value: boolean) { | ||
this._disabled = value; | ||
} | ||
|
||
private _disabled: boolean; | ||
|
||
@ContentChild(NgxMaterialTimepickerToggleIconDirective) customIcon: NgxMaterialTimepickerToggleIconDirective; | ||
|
||
open(event): void { | ||
if (this.timepicker) { | ||
this.timepicker.open(); | ||
event.stopPropagation(); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/app/material-timepicker/directives/ngx-material-timepicker-toggle-icon.directive.ts
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,7 @@ | ||
import {Directive} from '@angular/core'; | ||
|
||
//To override a default toggle icon | ||
@Directive({selector: '[ngxMaterialTimepickerToggleIcon]'}) | ||
|
||
export class NgxMaterialTimepickerToggleIconDirective { | ||
} |
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
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