Skip to content

Commit

Permalink
feat(datepicker): Add theme color and border width on focused datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Chen authored and kennethcachia committed Sep 23, 2015
1 parent 7e3b591 commit ac582c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/datepicker/datePicker-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ md-datepicker.md-THEME_NAME-theme {
.md-datepicker-input-container {
border-bottom-color: '{{background-300}}';

&.md-datepicker-focused {
border-bottom-color: '{{primary-500}}'
}

&.md-datepicker-invalid {
border-bottom-color: '{{warn-500}}';
}
Expand Down
18 changes: 15 additions & 3 deletions src/components/datepicker/datePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@
'ng-click="ctrl.openCalendarPane($event)">' +
'<md-icon class="md-datepicker-calendar-icon" md-svg-icon="md-calendar"></md-icon>' +
'</md-button>' +
'<div class="md-datepicker-input-container">' +
'<input class="md-datepicker-input" aria-haspopup="true">' +

'<div class="md-datepicker-input-container" ' +
'ng-class="{\'md-datepicker-focused\': ctrl.isFocused}">' +
'<input class="md-datepicker-input" aria-haspopup="true" ' +
'ng-focus="ctrl.setFocused(true)" ng-blur="ctrl.setFocused(false)">' +
'<md-button md-no-ink class="md-datepicker-triangle-button md-icon-button" ' +
'ng-click="ctrl.openCalendarPane($event)" ' +
'aria-label="{{::ctrl.dateLocale.msgOpenCalendar}}">' +
Expand Down Expand Up @@ -143,6 +144,9 @@
/** @type {Date} */
this.date = null;

/** @type {boolean} */
this.isFocused = false;

/** @type {boolean} */
this.isDisabled;
this.setDisabled($element[0].disabled || angular.isString($attrs['disabled']));
Expand Down Expand Up @@ -371,6 +375,14 @@
}, false);
};

/**
* Sets whether the input is currently focused.
* @param {boolean} isFocused
*/
DatePickerCtrl.prototype.setFocused = function(isFocused) {
this.isFocused = isFocused;
};

/**
* Handles a click on the document body when the floating calendar pane is open.
* Closes the floating calendar pane if the click is not inside of it.
Expand Down
4 changes: 4 additions & 0 deletions src/components/datepicker/datePicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ $md-datepicker-open-animation-duration: 0.2s;
display: inline-block;
width: auto;
margin-left: $md-datepicker-button-gap;

&.md-datepicker-focused {
border-bottom-width: 2px;
}
}


Expand Down

0 comments on commit ac582c8

Please sign in to comment.