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

Commit

Permalink
feat(subheader): add subheader component
Browse files Browse the repository at this point in the history
references: #216
  • Loading branch information
rschmukler committed Sep 14, 2014
1 parent d5d7e8d commit c377a36
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/base/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var Constant = {
BUTTON : 'button',
CHECKBOX : 'checkbox',
DIALOG : 'dialog',
HEADING : 'heading',
LIST : 'list',
LIST_ITEM : 'listitem',
RADIO : 'radio',
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions src/components/subheader/_subheader.scss
Original file line number Diff line number Diff line change
@@ -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
}
}
39 changes: 39 additions & 0 deletions src/components/subheader/demos/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

<div ng-app="app" ng-controller="AppCtrl">
<material-content layout="vertical">
<section>
<material-subheader class="material-subheader-colored">Unread Messages</material-subheader>
<material-list layout="vertical">
<material-item ng-repeat="message in messages">
<div class="material-tile-left">
<img ng-src="{{message.face}}" class="face" alt="{{message.who}}">
</div>
<div class="material-tile-content">
<h2>{{message.what}}</h2>
<h3>{{message.who}}</h3>
<p>
{{message.notes}}
</p>
</div>
</material-item>
</material-list>
</section>
<section>
<material-subheader>Read Messages</material-subheader>
<material-list layout="vertical">
<material-item ng-repeat="message in messages">
<div class="material-tile-left">
<img ng-src="{{message.face}}" class="face" alt="{{message.who}}">
</div>
<div class="material-tile-content">
<h2>{{message.what}}</h2>
<h3>{{message.who}}</h3>
<p>
{{message.notes}}
</p>
</div>
</material-item>
</material-list>
</section>
</material-content>
</div>
21 changes: 21 additions & 0 deletions src/components/subheader/demos/basic/script.js
Original file line number Diff line number Diff line change
@@ -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"
},
];
});
12 changes: 12 additions & 0 deletions src/components/subheader/demos/basic/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

material-content {
margin-right: 7px;
}

.face {
border-radius: 30px;
border: 1px solid #ddd;
width: 48px;
margin: 16px;
}

10 changes: 10 additions & 0 deletions src/components/subheader/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"module": "material.components.subheader",
"name": "SubHeader",
"demos": {
"basic": {
"name": "Basic Usage",
"files": ["demos/basic/*"]
}
}
}
38 changes: 38 additions & 0 deletions src/components/subheader/subheader.js
Original file line number Diff line number Diff line change
@@ -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 `<material-subheader>` directive is a subheader for a section
*
* @usage
* <hljs lang="html">
* <material-subheader>Online Friends</material-subheader>
* </hljs>
*/

function materialSubheaderDirective() {
return {
restrict: 'E',
compile: function($el, $attr) {
$el.attr({
'role' : Constant.ARIA.ROLE.HEADING
});
}
};
}
17 changes: 17 additions & 0 deletions src/components/subheader/subheader.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe('materialSubheader', function() {
beforeEach(module('material.components.subheader'));

it('should set aria role', inject(function($compile, $rootScope) {
var $el = $compile('<material-subheader>Hello world!</material-header>')($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('<material-subheader>Hello {{ to }}!</material-subheader>')($scope);
$scope.$digest();
expect($el.html()).toEqual('Hello world!');
}));

});
1 change: 1 addition & 0 deletions src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/theme/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $font-color-base: #444;

// Font colors
$text-light: #f1f1f1;
$text-medium: #999;
$text-dark: #111111;

// Theme colors
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c377a36

Please sign in to comment.