Skip to content

Commit

Permalink
feat(module:time-picker): support borderless (#7547)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeard30 committed Jul 11, 2022
1 parent 5095218 commit a8c3f95
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
14 changes: 14 additions & 0 deletions components/time-picker/demo/bordered.md
@@ -0,0 +1,14 @@
---
order: 12
title:
zh-CN: 无边框
en-US: Bordered-less
---

## zh-CN

无边框样式。

## en-US

Bordered-less style component.
8 changes: 8 additions & 0 deletions components/time-picker/demo/bordered.ts
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-time-picker-bordered',
template: ` <nz-time-picker nzBorderless></nz-time-picker> `,
styles: []
})
export class NzDemoTimePickerBorderedComponent {}
1 change: 1 addition & 0 deletions components/time-picker/doc/index.en-US.md
Expand Up @@ -46,6 +46,7 @@ import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';
| `[nzSecondStep]` | interval between seconds in picker | `number` | `1` ||
| `[nzSize]` | width of time picker box | `'large' \| 'small' \| 'default'` | `'default'` |
| `[nzStatus]` | Set validation status | `'error' \| 'warning'` | - |
| `[nzBorderless]` | remove the border | `boolean` | `false` | - |
| `[nzOpen]` | whether to popup panel, double binding | `boolean` | `false` |
| `[nzPlaceHolder]` | display when there's no value | `string` | `"Select a time"` |
| `[nzPopupClassName]` | className of panel | `string` | `''` ||
Expand Down
1 change: 1 addition & 0 deletions components/time-picker/doc/index.zh-CN.md
Expand Up @@ -47,6 +47,7 @@ import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';
| `[nzSecondStep]` | 秒选项间隔 | `number` | `1` ||
| `[nzSize]` | 时间选择框大小 | `'large'\|'small'\|'default'` | `'default'` |
| `[nzStatus]` | 设置校验状态 | `'error' \| 'warning'` | - |
| `[nzBorderless]` | 移除边框 | `boolean` | `false` | - |
| `[nzOpen]` | 面板是否打开,可双向绑定 | `boolean` | `false` |
| `[nzPlaceHolder]` | 没有值的时候显示的内容 | `string` | `"请选择时间"` |
| `[nzPopupClassName]` | 弹出层类名 | `string` | `''` ||
Expand Down
8 changes: 7 additions & 1 deletion components/time-picker/time-picker.component.spec.ts
Expand Up @@ -276,7 +276,11 @@ describe('time-picker', () => {
expect(result.getMinutes()).toEqual(10);
expect(result.getSeconds()).toEqual(30);
}));

it('should support nzBorderless', fakeAsync(() => {
fixture.componentInstance.nzBorderless = true;
fixture.detectChanges();
expect(fixture.debugElement.query(By.css(`.ant-picker-borderless`))).toBeDefined();
}));
describe('setup I18n service', () => {
let srv: NzI18nService;

Expand Down Expand Up @@ -397,6 +401,7 @@ describe('time-picker', () => {
[nzSuffixIcon]="nzSuffixIcon"
[nzBackdrop]="nzBackdrop"
[nzDefaultOpenValue]="defaultOpenValue"
[nzBorderless]="nzBorderless"
></nz-time-picker>
`
})
Expand All @@ -409,6 +414,7 @@ export class NzTestTimePickerComponent {
use12Hours = false;
nzSuffixIcon?: string;
nzBackdrop = false;
nzBorderless = true;
defaultOpenValue: Date | null = new Date('2020-03-27T00:00:00');
onChange(_: Date | null): void {}
@ViewChild(NzTimePickerComponent, { static: false }) nzTimePickerComponent!: NzTimePickerComponent;
Expand Down
3 changes: 3 additions & 0 deletions components/time-picker/time-picker.component.ts
Expand Up @@ -122,6 +122,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'timePicker';
'[class.ant-picker-disabled]': `nzDisabled`,
'[class.ant-picker-focused]': `focused`,
'[class.ant-picker-rtl]': `dir === 'rtl'`,
'[class.ant-picker-borderless]': `nzBorderless`,
'(click)': 'open()'
},
animations: [slideMotion],
Expand All @@ -135,6 +136,7 @@ export class NzTimePickerComponent implements ControlValueAccessor, OnInit, Afte
static ngAcceptInputType_nzAllowEmpty: BooleanInput;
static ngAcceptInputType_nzDisabled: BooleanInput;
static ngAcceptInputType_nzAutoFocus: BooleanInput;
static ngAcceptInputType_nzBorderless: BooleanInput;

private _onChange?: (value: Date | null) => void;
private _onTouched?: () => void;
Expand Down Expand Up @@ -213,6 +215,7 @@ export class NzTimePickerComponent implements ControlValueAccessor, OnInit, Afte
@Input() @InputBoolean() nzDisabled = false;
@Input() @InputBoolean() nzAutoFocus = false;
@Input() @WithConfig() nzBackdrop = false;
@Input() @InputBoolean() nzBorderless: boolean = false;

emitValue(value: Date | null): void {
this.setValue(value, true);
Expand Down

0 comments on commit a8c3f95

Please sign in to comment.