diff --git a/Gruntfile.js b/Gruntfile.js index a164625fb..e2a380e4b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -453,6 +453,11 @@ module.exports = function (grunt) { cwd: 'src/', src: ['pagination/**/*.html'], dest: 'templates/pagination.js' + }, + 'patternfly.datepicker' : { + cwd: 'src/', + src: ['datepicker/**/*.html'], + dest: 'templates/datepicker.js' } }, // ng-annotate tries to make the code safe for minification automatically diff --git a/misc/ng-docs.css b/misc/ng-docs.css index 1053d7457..fd4378dcd 100644 --- a/misc/ng-docs.css +++ b/misc/ng-docs.css @@ -375,4 +375,7 @@ ul.events > li > h3 { background-color: #cc0000; } +.type-hint-date { + background:#582fc0; +} diff --git a/src/datepicker/bootstrap-datepicker.component.js b/src/datepicker/bootstrap-datepicker.component.js new file mode 100644 index 000000000..9134d5805 --- /dev/null +++ b/src/datepicker/bootstrap-datepicker.component.js @@ -0,0 +1,38 @@ +angular.module('patternfly.datepicker').component('pfBootstrapDatepicker', { + bindings: { + date: '<', + format: '@?', + dateOptions: '', + isOpen: '', + popupPlacement: '@?' + }, + templateUrl: 'datepicker/datepicker.html', + controller: function () { + 'use strict'; + + var ctrl = this; + + ctrl.defaultDateOptions = { + showWeeks : false, + formatDay : "d" + }; + ctrl.defaultIsOpen = false; + + ctrl.$onInit = function () { + ctrl.format = "MM/dd/yyyy"; + ctrl.showButtonBar = true; + ctrl.popupPlacement = "auto bottom-left"; + + if (angular.isUndefined(ctrl.dateOptions)) { + ctrl.dateOptions = {}; + } + _.defaults(ctrl.dateOptions, ctrl.defaultDateOptions); + _.defaults(ctrl.isOpen, ctrl.defaultIsOpen); + }; + + ctrl.$onChanges = function (changes) { + _.defaults(ctrl.isOpen, ctrl.defaultIsOpen); + }; + + } +}); diff --git a/src/datepicker/datepicker.html b/src/datepicker/datepicker.html new file mode 100644 index 000000000..d973817eb --- /dev/null +++ b/src/datepicker/datepicker.html @@ -0,0 +1,14 @@ +
+ + + + +
diff --git a/src/datepicker/datepicker.less b/src/datepicker/datepicker.less new file mode 100644 index 000000000..41cf7c64f --- /dev/null +++ b/src/datepicker/datepicker.less @@ -0,0 +1,120 @@ +.uib-datepicker-popup { + padding: 4px; + + *:focus { + outline: none; + } + + button { + background: @color-pf-white; + border: none; + box-shadow: none; + } + + th { + height: 30px; + } + + .uib-title { + font-size: 14px; + font-weight: 500; + padding: 5px; + + strong { + font-weight: normal; + } + } + + .uib-left { + height: 30px; + + .glyphicon { + display: none; + } + + &::before { + content: "\00AB"; + } + } + + .uib-right { + height: 30px; + + .glyphicon { + display: none; + } + + &::before { + content: "\00BB"; + } + } + + .uib-day { + + button.btn.btn-default { + height: 30px; + width: 30px; + + &:hover { + background: @color-pf-blue-50; + } + + &.active { + background: @color-pf-blue-400; + border-color: @color-pf-blue-600; + color: @color-pf-white; + box-shadow: none; + padding: 0; + + .text-info { // this is today's date + color: @color-pf-white; + } + } + + &:not(.active){ + .text-info { // this is today's date + color: @color-pf-black-800; + background: @color-pf-gold-200; + height: 30px; + width: 30px; + padding: 7px; + display: inline-block; + margin: -1px -7px -2px -7px; + + &:hover { + background: @color-pf-blue-50; + } + } + } + } + + } + + .uib-button-bar { + padding: 0; + + .btn-group { + width: 100%; + + .uib-clear { + display: none; + } + + .uib-datepicker-current { + color: @color-pf-black; + width: 100%; + font-size: 14px; + font-weight: 500; + height: 30px; + + &:hover { + background: @color-pf-blue-50; + } + } + } + + .uib-close { + display: none; + } + } +} diff --git a/src/datepicker/datepicker.module.js b/src/datepicker/datepicker.module.js new file mode 100644 index 000000000..5acf23322 --- /dev/null +++ b/src/datepicker/datepicker.module.js @@ -0,0 +1,9 @@ +/** + * @name patternfly datepicker + * + * @description + * Datepicker module for patternfly. + * + */ +angular.module('patternfly.datepicker', ['ui.bootstrap']); + diff --git a/src/datepicker/examples/bootstrap.datepicker.js b/src/datepicker/examples/bootstrap.datepicker.js new file mode 100644 index 000000000..c5501167a --- /dev/null +++ b/src/datepicker/examples/bootstrap.datepicker.js @@ -0,0 +1,50 @@ +/** + * @ngdoc directive + * @name patternfly.datepicker.componenet:pfBootstrapDatepicker + * @element pf-bootstrap-datepicker + * + * @param {date} date Must be a Javascript Date - to be displayed in the input. Can be left empty. + * @param {string} format Optional date format for displayed dates ('MM/dd/yyyy' by default). + * @param {boolean} isOpen Optional boolean for determining whether or not to have the datepicker default to open (false by default). + * @param {string} popupPlacement Optional configuration string used to position the popup datepicker relative to the input element. See {@link https://angular-ui.github.io/bootstrap/#datepickerPopup Angular UI Datepicker Popup}. + * @param {object} dateOptions Optional uib-datepicker configuration object. See {@link https://angular-ui.github.io/bootstrap/#datepicker Angular UI Datepicker}. + * + * @description + * A wrapper for the Angular UI {@link http://angular-ui.github.io/bootstrap/#!#datepickerPopup datepicker}. + * + * @example +