Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 1fcd017

Browse files
Michael Chenjelbourn
authored andcommitted
feat(datepicker): Add theme color and border width on focused datepicker
1 parent 1ec607c commit 1fcd017

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/components/datepicker/datePicker-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ md-datepicker.md-THEME_NAME-theme {
99
.md-datepicker-input-container {
1010
border-bottom-color: '{{background-300}}';
1111

12+
&.md-datepicker-focused {
13+
border-bottom-color: '{{primary-500}}'
14+
}
15+
1216
&.md-datepicker-invalid {
1317
border-bottom-color: '{{warn-500}}';
1418
}

src/components/datepicker/datePicker.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
'ng-click="ctrl.openCalendarPane($event)">' +
4949
'<md-icon class="md-datepicker-calendar-icon" md-svg-icon="md-calendar"></md-icon>' +
5050
'</md-button>' +
51-
'<div class="md-datepicker-input-container">' +
52-
'<input class="md-datepicker-input" aria-haspopup="true">' +
53-
51+
'<div class="md-datepicker-input-container" ' +
52+
'ng-class="{\'md-datepicker-focused\': ctrl.isFocused}">' +
53+
'<input class="md-datepicker-input" aria-haspopup="true" ' +
54+
'ng-focus="ctrl.setFocused(true)" ng-blur="ctrl.setFocused(false)">' +
5455
'<md-button md-no-ink class="md-datepicker-triangle-button md-icon-button" ' +
5556
'ng-click="ctrl.openCalendarPane($event)" ' +
5657
'aria-label="{{::ctrl.dateLocale.msgOpenCalendar}}">' +
@@ -143,6 +144,9 @@
143144
/** @type {Date} */
144145
this.date = null;
145146

147+
/** @type {boolean} */
148+
this.isFocused = false;
149+
146150
/** @type {boolean} */
147151
this.isDisabled;
148152
this.setDisabled($element[0].disabled || angular.isString($attrs['disabled']));
@@ -371,6 +375,14 @@
371375
}, false);
372376
};
373377

378+
/**
379+
* Sets whether the input is currently focused.
380+
* @param {boolean} isFocused
381+
*/
382+
DatePickerCtrl.prototype.setFocused = function(isFocused) {
383+
this.isFocused = isFocused;
384+
};
385+
374386
/**
375387
* Handles a click on the document body when the floating calendar pane is open.
376388
* Closes the floating calendar pane if the click is not inside of it.

src/components/datepicker/datePicker.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ $md-datepicker-open-animation-duration: 0.2s;
3131
display: inline-block;
3232
width: auto;
3333
margin-left: $md-datepicker-button-gap;
34+
35+
&.md-datepicker-focused {
36+
border-bottom-width: 2px;
37+
}
3438
}
3539

3640

0 commit comments

Comments
 (0)