-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(material/timepicker): add timepicker documentation and live exam…
…ples Populates the timepicker's guide and add live examples.
- Loading branch information
Showing
18 changed files
with
565 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
export {TimepickerOverviewExample} from './timepicker-overview/timepicker-overview-example'; | ||
export {TimepickerFormsExample} from './timepicker-forms/timepicker-forms-example'; | ||
export {TimepickerDatepickerIntegrationExample} from './timepicker-datepicker-integration/timepicker-datepicker-integration-example'; | ||
export {TimepickerValidationExample} from './timepicker-validation/timepicker-validation-example'; | ||
export {TimepickerOptionsExample} from './timepicker-options/timepicker-options-example'; | ||
export {TimepickerCustomIconExample} from './timepicker-custom-icon/timepicker-custom-icon-example'; | ||
export {TimepickerLocaleExample} from './timepicker-locale/timepicker-locale-example'; | ||
export {TimepickerHarnessExample} from './timepicker-harness/timepicker-harness-example'; |
8 changes: 8 additions & 0 deletions
8
...s-examples/material/timepicker/timepicker-custom-icon/timepicker-custom-icon-example.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 @@ | ||
<mat-form-field> | ||
<mat-label>Pick a time</mat-label> | ||
<input matInput [matTimepicker]="picker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="picker"> | ||
<mat-icon matTimepickerToggleIcon>globe</mat-icon> | ||
</mat-timepicker-toggle> | ||
<mat-timepicker #picker/> | ||
</mat-form-field> |
16 changes: 16 additions & 0 deletions
16
...nts-examples/material/timepicker/timepicker-custom-icon/timepicker-custom-icon-example.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,16 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {MatTimepickerModule} from '@angular/material/timepicker'; | ||
import {MatIcon} from '@angular/material/icon'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {provideNativeDateAdapter} from '@angular/material/core'; | ||
|
||
/** @title Timepicker with custom toggle icon */ | ||
@Component({ | ||
selector: 'timepicker-custom-icon-example', | ||
templateUrl: 'timepicker-custom-icon-example.html', | ||
providers: [provideNativeDateAdapter()], | ||
imports: [MatFormFieldModule, MatInputModule, MatTimepickerModule, MatIcon], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TimepickerCustomIconExample {} |
3 changes: 3 additions & 0 deletions
3
...imepicker/timepicker-datepicker-integration/timepicker-datepicker-integration-example.css
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,3 @@ | ||
mat-form-field { | ||
margin-right: 16px; | ||
} |
18 changes: 18 additions & 0 deletions
18
...mepicker/timepicker-datepicker-integration/timepicker-datepicker-integration-example.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,18 @@ | ||
<mat-form-field> | ||
<mat-label>Meeting date</mat-label> | ||
<input matInput [matDatepicker]="datepicker" [(ngModel)]="value"> | ||
<mat-datepicker #datepicker/> | ||
<mat-datepicker-toggle [for]="datepicker" matSuffix/> | ||
</mat-form-field> | ||
|
||
<mat-form-field> | ||
<mat-label>Meeting time</mat-label> | ||
<input matInput | ||
[matTimepicker]="timepicker" | ||
[(ngModel)]="value" | ||
[ngModelOptions]="{updateOn: 'blur'}"> | ||
<mat-timepicker #timepicker/> | ||
<mat-timepicker-toggle [for]="timepicker" matSuffix/> | ||
</mat-form-field> | ||
|
||
<p>Value: {{value}}</p> |
26 changes: 26 additions & 0 deletions
26
...timepicker/timepicker-datepicker-integration/timepicker-datepicker-integration-example.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,26 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {MatTimepickerModule} from '@angular/material/timepicker'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {provideNativeDateAdapter} from '@angular/material/core'; | ||
import {MatDatepickerModule} from '@angular/material/datepicker'; | ||
|
||
/** @title Timepicker integration with datepicker */ | ||
@Component({ | ||
selector: 'timepicker-datepicker-integration-example', | ||
templateUrl: 'timepicker-datepicker-integration-example.html', | ||
styleUrl: './timepicker-datepicker-integration-example.css', | ||
providers: [provideNativeDateAdapter()], | ||
imports: [ | ||
MatFormFieldModule, | ||
MatInputModule, | ||
MatTimepickerModule, | ||
MatDatepickerModule, | ||
FormsModule, | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TimepickerDatepickerIntegrationExample { | ||
value: Date; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/components-examples/material/timepicker/timepicker-forms/timepicker-forms-example.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,10 @@ | ||
<mat-form-field> | ||
<mat-label>Pick a time</mat-label> | ||
<input matInput [formControl]="formControl" [matTimepicker]="picker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="picker"/> | ||
<mat-timepicker #picker/> | ||
</mat-form-field> | ||
|
||
<p>Value: {{formControl.value}}</p> | ||
<p>Touched: {{formControl.touched}}</p> | ||
<p>Dirty: {{formControl.dirty}}</p> |
24 changes: 24 additions & 0 deletions
24
src/components-examples/material/timepicker/timepicker-forms/timepicker-forms-example.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,24 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {FormControl, ReactiveFormsModule} from '@angular/forms'; | ||
import {MatTimepickerModule} from '@angular/material/timepicker'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {provideNativeDateAdapter} from '@angular/material/core'; | ||
|
||
/** @title Timepicker forms integration */ | ||
@Component({ | ||
selector: 'timepicker-forms-example', | ||
templateUrl: 'timepicker-forms-example.html', | ||
providers: [provideNativeDateAdapter()], | ||
imports: [MatFormFieldModule, MatInputModule, MatTimepickerModule, ReactiveFormsModule], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TimepickerFormsExample { | ||
formControl: FormControl<Date | null>; | ||
|
||
constructor() { | ||
const initialValue = new Date(); | ||
initialValue.setHours(12, 30, 0); | ||
this.formControl = new FormControl(initialValue); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/components-examples/material/timepicker/timepicker-locale/timepicker-locale-example.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 @@ | ||
<mat-form-field> | ||
<mat-label>Pick a time</mat-label> | ||
<input matInput [(ngModel)]="value" [matTimepicker]="picker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="picker"/> | ||
<mat-timepicker #picker/> | ||
</mat-form-field> | ||
|
||
<button mat-button (click)="switchLocale()">Dynamically switch to Bulgarian</button> |
24 changes: 24 additions & 0 deletions
24
src/components-examples/material/timepicker/timepicker-locale/timepicker-locale-example.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,24 @@ | ||
import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {MatTimepickerModule} from '@angular/material/timepicker'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {DateAdapter, provideNativeDateAdapter} from '@angular/material/core'; | ||
import {MatButtonModule} from '@angular/material/button'; | ||
|
||
/** @title Timepicker with different locale */ | ||
@Component({ | ||
selector: 'timepicker-locale-example', | ||
templateUrl: 'timepicker-locale-example.html', | ||
providers: [provideNativeDateAdapter()], | ||
imports: [MatFormFieldModule, MatInputModule, MatTimepickerModule, FormsModule, MatButtonModule], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TimepickerLocaleExample { | ||
private readonly _adapter = inject<DateAdapter<unknown, unknown>>(DateAdapter); | ||
value = new Date(2024, 0, 1, 13, 45, 0); | ||
|
||
protected switchLocale() { | ||
this._adapter.setLocale('bg-BG'); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...omponents-examples/material/timepicker/timepicker-options/timepicker-options-example.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,30 @@ | ||
<h3>Interval examples</h3> | ||
|
||
<div> | ||
<mat-form-field> | ||
<mat-label>Every 45 minutes</mat-label> | ||
<input matInput [matTimepicker]="minutesPicker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="minutesPicker"/> | ||
<mat-timepicker interval="45min" #minutesPicker/> | ||
</mat-form-field> | ||
</div> | ||
|
||
<div> | ||
<mat-form-field> | ||
<mat-label>Every 3.5 hours</mat-label> | ||
<input matInput [matTimepicker]="hoursPicker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="hoursPicker"/> | ||
<mat-timepicker interval="3.5h" #hoursPicker/> | ||
</mat-form-field> | ||
</div> | ||
|
||
<h3>Custom list of options</h3> | ||
|
||
<div> | ||
<mat-form-field> | ||
<mat-label>Pick a time of day</mat-label> | ||
<input matInput [matTimepicker]="customPicker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="customPicker"/> | ||
<mat-timepicker [options]="customOptions" #customPicker/> | ||
</mat-form-field> | ||
</div> |
21 changes: 21 additions & 0 deletions
21
src/components-examples/material/timepicker/timepicker-options/timepicker-options-example.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,21 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {MatTimepickerModule, MatTimepickerOption} from '@angular/material/timepicker'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {provideNativeDateAdapter} from '@angular/material/core'; | ||
|
||
/** @title Timepicker options customization */ | ||
@Component({ | ||
selector: 'timepicker-options-example', | ||
templateUrl: 'timepicker-options-example.html', | ||
providers: [provideNativeDateAdapter()], | ||
imports: [MatFormFieldModule, MatInputModule, MatTimepickerModule], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TimepickerOptionsExample { | ||
customOptions: MatTimepickerOption<Date>[] = [ | ||
{label: 'Morning', value: new Date(2024, 0, 1, 9, 0, 0)}, | ||
{label: 'Noon', value: new Date(2024, 0, 1, 12, 0, 0)}, | ||
{label: 'Evening', value: new Date(2024, 0, 1, 22, 0, 0)}, | ||
]; | ||
} |
2 changes: 2 additions & 0 deletions
2
...ponents-examples/material/timepicker/timepicker-overview/timepicker-overview-example.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<mat-form-field> | ||
<mat-label>Pick a time</mat-label> | ||
<!-- #docregion minimum-setup --> | ||
<input matInput [matTimepicker]="picker"> | ||
<mat-timepicker-toggle matIconSuffix [for]="picker"/> | ||
<mat-timepicker #picker/> | ||
<!-- #enddocregion minimum-setup --> | ||
</mat-form-field> |
3 changes: 3 additions & 0 deletions
3
...ents-examples/material/timepicker/timepicker-validation/timepicker-validation-example.css
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,3 @@ | ||
mat-form-field { | ||
margin-bottom: 30px; | ||
} |
26 changes: 26 additions & 0 deletions
26
...nts-examples/material/timepicker/timepicker-validation/timepicker-validation-example.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,26 @@ | ||
<mat-form-field> | ||
<mat-label>Pick a time</mat-label> | ||
<input | ||
matInput | ||
[formControl]="formControl" | ||
[matTimepicker]="picker" | ||
matTimepickerMin="12:30" | ||
matTimepickerMax="17:30"> | ||
<mat-timepicker-toggle matIconSuffix [for]="picker"/> | ||
<mat-timepicker #picker/> | ||
|
||
@if (formControl.errors?.['matTimepickerParse']) { | ||
<mat-error>Value isn't a valid time</mat-error> | ||
} | ||
|
||
@if (formControl.errors?.['matTimepickerMin']) { | ||
<mat-error>Value is too early</mat-error> | ||
} | ||
|
||
@if (formControl.errors?.['matTimepickerMax']) { | ||
<mat-error>Value is too late</mat-error> | ||
} | ||
</mat-form-field> | ||
|
||
<p>Enter a value before 12:30 PM or after 5:30 PM to see the errors</p> | ||
<p>Errors: {{formControl.errors | json}}</p> |
20 changes: 20 additions & 0 deletions
20
...nents-examples/material/timepicker/timepicker-validation/timepicker-validation-example.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,20 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {JsonPipe} from '@angular/common'; | ||
import {FormControl, ReactiveFormsModule} from '@angular/forms'; | ||
import {MatTimepickerModule} from '@angular/material/timepicker'; | ||
import {MatInputModule} from '@angular/material/input'; | ||
import {MatFormFieldModule} from '@angular/material/form-field'; | ||
import {provideNativeDateAdapter} from '@angular/material/core'; | ||
|
||
/** @title Timepicker validation */ | ||
@Component({ | ||
selector: 'timepicker-validation-example', | ||
templateUrl: 'timepicker-validation-example.html', | ||
styleUrl: './timepicker-validation-example.css', | ||
providers: [provideNativeDateAdapter()], | ||
imports: [MatFormFieldModule, MatInputModule, MatTimepickerModule, ReactiveFormsModule, JsonPipe], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TimepickerValidationExample { | ||
formControl = new FormControl<Date | null>(null); | ||
} |
Oops, something went wrong.