Skip to content

Commit

Permalink
feat(datetime): add placeholder attribute
Browse files Browse the repository at this point in the history
fixes #7966
  • Loading branch information
Olivier Goguel authored and brandyscarney committed Feb 13, 2017
1 parent 6a0c92c commit 52a6d41
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/components/datetime/datetime.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ $datetime-ios-padding-bottom: $item-ios-padding-bottom !default;
/// @prop - Padding left of the DateTime component
$datetime-ios-padding-left: $item-ios-padding-left !default;

/// @prop - Color of the DateTime placeholder
$datetime-ios-placeholder-color: #999 !default;


.datetime-ios {
padding: $datetime-ios-padding-top $datetime-ios-padding-right $datetime-ios-padding-bottom $datetime-ios-padding-left;
}

.datetime-ios .datetime-placeholder {
color: $datetime-ios-placeholder-color;
}
7 changes: 7 additions & 0 deletions src/components/datetime/datetime.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ $datetime-md-padding-bottom: $item-md-padding-bottom !default;
/// @prop - Padding left of the DateTime component
$datetime-md-padding-left: $item-md-padding-left !default;

/// @prop - Color of the DateTime placeholder
$datetime-md-placeholder-color: #999 !default;


.datetime-md {
padding: $datetime-md-padding-top $datetime-md-padding-right $datetime-md-padding-bottom $datetime-md-padding-left;
}

.datetime-md .datetime-placeholder {
color: $datetime-md-placeholder-color;
}
9 changes: 8 additions & 1 deletion src/components/datetime/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ export const DATETIME_VALUE_ACCESSOR: any = {
@Component({
selector: 'ion-datetime',
template:
'<div class="datetime-text">{{_text}}</div>' +
'<div *ngIf="!_text" class="datetime-text datetime-placeholder">{{placeholder}}</div>' +
'<div *ngIf="_text" class="datetime-text">{{_text}}</div>' +
'<button aria-haspopup="true" ' +
'type="button" ' +
'[id]="id" ' +
Expand Down Expand Up @@ -407,6 +408,12 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
*/
@Input() pickerOptions: any = {};

/**
* @input {string} The text to display when there's no date selected yet.
* Using lowercase to match the input attribute
*/
@Input() placeholder: string = '';

/**
* @input {string} The mode determines which platform styles to use.
* Possible values are: `"ios"`, `"md"`, or `"wp"`.
Expand Down
9 changes: 9 additions & 0 deletions src/components/datetime/datetime.wp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ $datetime-wp-border-width: 2px !default;
/// @prop - Border color of the DateTime component
$datetime-wp-border-color: $input-wp-border-color !default;

/// @prop - Color of the DateTime placeholder
$datetime-wp-placeholder-color: $input-wp-border-color !default;


.datetime-wp {
padding: $datetime-wp-padding-top $datetime-wp-padding-right $datetime-wp-padding-bottom $datetime-wp-padding-left;

Expand All @@ -42,3 +46,8 @@ $datetime-wp-border-color: $input-wp-border-color !default;
.item-datetime .datetime-wp ion-label[floating] {
transform: translate3d(8px, 41px, 0);
}

.datetime-wp .datetime-placeholder {
color: $datetime-wp-placeholder-color;
}

5 changes: 5 additions & 0 deletions src/components/datetime/test/basic/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<ion-datetime displayFormat="MMMM" [(ngModel)]="monthOnly"></ion-datetime>
</ion-item>

<ion-item>
<ion-label>MM DD YY</ion-label>
<ion-datetime displayFormat="MM DD YY" [(ngModel)]="placeholderDate" placeholder="Select Date"></ion-datetime>
</ion-item>

<ion-item>
<ion-label>YYYY</ion-label>
<ion-datetime displayFormat="YYYY" min="1981" max="2002" [(ngModel)]="wwwInvented"></ion-datetime>
Expand Down

0 comments on commit 52a6d41

Please sign in to comment.