diff --git a/config/build.config.js b/config/build.config.js index ff7b7dd54e4..82f8b53bd55 100644 --- a/config/build.config.js +++ b/config/build.config.js @@ -89,6 +89,7 @@ module.exports = { 'src/components/sidenav/sidenav.js', 'src/components/slider/slider.js', 'src/components/switch/switch.js', + 'src/components/subheader/subheader.js', 'src/components/tabs/tabs.js', 'src/components/tabs/js/*.js', 'src/components/toast/toast.js', diff --git a/src/base/constants.js b/src/base/constants.js index 0367a16b438..7acd5adfbed 100644 --- a/src/base/constants.js +++ b/src/base/constants.js @@ -4,6 +4,7 @@ var Constant = { BUTTON : 'button', CHECKBOX : 'checkbox', DIALOG : 'dialog', + HEADING : 'heading', LIST : 'list', LIST_ITEM : 'listitem', RADIO : 'radio', diff --git a/src/components/subheader/README.md b/src/components/subheader/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/components/subheader/_subheader.scss b/src/components/subheader/_subheader.scss new file mode 100644 index 00000000000..9aeb5ba8d03 --- /dev/null +++ b/src/components/subheader/_subheader.scss @@ -0,0 +1,13 @@ +material-subheader { + color: $text-medium; + display: block; + font-size: $subheader-font-size; + font-weight: $subheader-font-weight; + line-height: $subheader-line-height; + padding: $subheader-padding; + margin: $subheader-margin; + + &.material-subheader-colored { + color: $theme-light-blue + } +} diff --git a/src/components/subheader/demos/basic/index.html b/src/components/subheader/demos/basic/index.html new file mode 100644 index 00000000000..9b1153d70e7 --- /dev/null +++ b/src/components/subheader/demos/basic/index.html @@ -0,0 +1,39 @@ + +
+ +
+ Unread Messages + + +
+ {{message.who}} +
+
+

{{message.what}}

+

{{message.who}}

+

+ {{message.notes}} +

+
+
+
+
+
+ Read Messages + + +
+ {{message.who}} +
+
+

{{message.what}}

+

{{message.who}}

+

+ {{message.notes}} +

+
+
+
+
+
+
diff --git a/src/components/subheader/demos/basic/script.js b/src/components/subheader/demos/basic/script.js new file mode 100644 index 00000000000..33a2df9917a --- /dev/null +++ b/src/components/subheader/demos/basic/script.js @@ -0,0 +1,21 @@ + +angular.module('app', ['ngMaterial']) + +.controller('AppCtrl', function($scope) { + $scope.messages = [ + { + face : '/img/list/60.jpeg', + what: 'Brunch this weekend?', + who: 'Min Li Chan', + when: '3:08PM', + notes: " I'll be in your neighborhood doing errands" + }, + { + face : '/img/list/60.jpeg', + what: 'Brunch this weekend?', + who: 'Min Li Chan', + when: '3:08PM', + notes: " I'll be in your neighborhood doing errands" + }, + ]; +}); diff --git a/src/components/subheader/demos/basic/style.css b/src/components/subheader/demos/basic/style.css new file mode 100644 index 00000000000..342508b49c4 --- /dev/null +++ b/src/components/subheader/demos/basic/style.css @@ -0,0 +1,12 @@ + +material-content { + margin-right: 7px; +} + +.face { + border-radius: 30px; + border: 1px solid #ddd; + width: 48px; + margin: 16px; +} + diff --git a/src/components/subheader/module.json b/src/components/subheader/module.json new file mode 100644 index 00000000000..4523f77dc7a --- /dev/null +++ b/src/components/subheader/module.json @@ -0,0 +1,10 @@ +{ + "module": "material.components.subheader", + "name": "SubHeader", + "demos": { + "basic": { + "name": "Basic Usage", + "files": ["demos/basic/*"] + } + } +} diff --git a/src/components/subheader/subheader.js b/src/components/subheader/subheader.js new file mode 100644 index 00000000000..1fd4a21e5c0 --- /dev/null +++ b/src/components/subheader/subheader.js @@ -0,0 +1,38 @@ +/** + * @ngdoc module + * @name material.components.subheader + * @description + * SubHeader module + */ +angular.module('material.components.subheader', []) + +.directive('materialSubheader', [ + materialSubheaderDirective +]); + +/** + * @ngdoc directive + * @name materialSubheader + * @module material.components.subheader + * + * @restrict E + * + * @description + * The `` directive is a subheader for a section + * + * @usage + * + * Online Friends + * + */ + +function materialSubheaderDirective() { + return { + restrict: 'E', + compile: function($el, $attr) { + $el.attr({ + 'role' : Constant.ARIA.ROLE.HEADING + }); + } + }; +} diff --git a/src/components/subheader/subheader.spec.js b/src/components/subheader/subheader.spec.js new file mode 100644 index 00000000000..1e4f9e610f0 --- /dev/null +++ b/src/components/subheader/subheader.spec.js @@ -0,0 +1,17 @@ +describe('materialSubheader', function() { + beforeEach(module('material.components.subheader')); + + it('should set aria role', inject(function($compile, $rootScope) { + var $el = $compile('Hello world!')($rootScope); + expect($el.attr('role')).toEqual('heading'); + })); + + it('should preserve content', inject(function($compile, $rootScope) { + var $scope = $rootScope.$new(); + $scope.to = 'world'; + var $el = $compile('Hello {{ to }}!')($scope); + $scope.$digest(); + expect($el.html()).toEqual('Hello world!'); + })); + +}); diff --git a/src/main.scss b/src/main.scss index 9abf7f17e86..60c0b0305a6 100644 --- a/src/main.scss +++ b/src/main.scss @@ -26,6 +26,7 @@ "components/sidenav/sidenav", "components/form/form", "components/slider/slider", +"components/subheader/subheader", "components/switch/switch", "components/toast/toast", "components/toolbar/toolbar", diff --git a/src/theme/_variables.scss b/src/theme/_variables.scss index 238b8c7b708..6cbfc700d26 100644 --- a/src/theme/_variables.scss +++ b/src/theme/_variables.scss @@ -9,6 +9,7 @@ $font-color-base: #444; // Font colors $text-light: #f1f1f1; +$text-medium: #999; $text-dark: #111111; // Theme colors @@ -89,6 +90,14 @@ $whiteframe-zindex-z4: 4; $whiteframe-shadow-z5: 0px 27px 24px 0 rgba(0,0,0,0.2); $whiteframe-zindex-z5: 5; +// SubHeader + +$subheader-line-height: 1em; +$subheader-font-size: 0.9em; +$subheader-padding: ($baseline-grid * 2) 0px ($baseline-grid * 2) ($baseline-grid * 2); +$subheader-font-weight: 400; +$subheader-margin: 0 0 0 0; + // Lists and tiles $list-h2-font-size: 1.1em;