Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:cron-expression): adjust the layout
- Loading branch information
1 parent
1060115
commit 613f09c
Showing
15 changed files
with
434 additions
and
527 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
components/cron-expression/cron-expression-input.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,48 @@ | ||
/** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core'; | ||
|
||
import { CronChangeType, TimeType } from './typings'; | ||
|
||
@Component({ | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
selector: 'nz-cron-expression-input', | ||
exportAs: 'nzCronExpression', | ||
template: ` | ||
<div class="ant-cron-expression-input"> | ||
<input | ||
nz-input | ||
[(ngModel)]="value" | ||
[name]="label" | ||
(focus)="focusInputEffect()" | ||
(blur)="blurInputEffect()" | ||
(ngModelChange)="setValue()" | ||
/> | ||
</div> | ||
` | ||
}) | ||
export class NzCronExpressionInputComponent { | ||
@Input() value: string = '0'; | ||
@Input() label: TimeType = 'second'; | ||
@Output() readonly focusEffect = new EventEmitter<TimeType>(); | ||
@Output() readonly blurEffect = new EventEmitter<void>(); | ||
@Output() readonly getValue = new EventEmitter<CronChangeType>(); | ||
|
||
constructor() {} | ||
|
||
focusInputEffect(): void { | ||
this.focusEffect.emit(this.label); | ||
} | ||
|
||
blurInputEffect(): void { | ||
this.blurEffect.emit(); | ||
} | ||
|
||
setValue(): void { | ||
this.getValue.emit({ label: this.label, value: this.value }); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
components/cron-expression/cron-expression-label.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,46 @@ | ||
/** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE | ||
*/ | ||
|
||
import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input, OnInit } from '@angular/core'; | ||
|
||
import { NzCronExpressionLabelI18n } from 'ng-zorro-antd/i18n'; | ||
|
||
import { TimeType, TimeTypeError } from './typings'; | ||
|
||
@Component({ | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
selector: 'nz-cron-expression-label', | ||
exportAs: 'nzCronExpression', | ||
template: ` | ||
<div | ||
class="ant-cron-expression-label" | ||
[class.ant-cron-expression-label-foucs]="labelFocus === type" | ||
[class.ant-cron-expression-error]="!valid" | ||
nz-tooltip | ||
[nzTooltipTitle]="error" | ||
[nzTooltipVisible]="!valid" | ||
nzTooltipPlacement="bottom" | ||
> | ||
<label>{{ locale[type] }}</label> | ||
</div> | ||
<ng-template #error> | ||
<div class="ant-cron-expression-hint" [innerHTML]="locale[labelError]"></div> | ||
</ng-template> | ||
` | ||
}) | ||
export class NzCronExpressionLabelComponent implements OnInit { | ||
@Input() type: TimeType = 'second'; | ||
@Input() valid: boolean = true; | ||
@Input() locale!: NzCronExpressionLabelI18n; | ||
@Input() labelFocus: string | null = null; | ||
labelError: TimeTypeError = 'secondError'; | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void { | ||
this.labelError = `${this.type}Error`; | ||
} | ||
} |
Oops, something went wrong.