Skip to content

Commit

Permalink
feat(md-collection): add headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanood committed Apr 18, 2016
1 parent 110c68b commit e180ce5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/collection/collection-header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
md-collection-header {
display: block;
}
4 changes: 4 additions & 0 deletions src/collection/collection-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template class="collection-header">
<require from="./collection-header.css"></require>
<content></content>
</template>
10 changes: 10 additions & 0 deletions src/collection/collection-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { customElement } from 'aurelia-templating';
import { inject } from 'aurelia-dependency-injection';

@customElement('md-collection-header')
@inject(Element)
export class MdCollectionHeader {
constructor(element) {
this.element = element;
}
}
3 changes: 2 additions & 1 deletion src/collection/collection.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="collection">
<div class="collection" ref="anchor">
<content select="md-collection-header"></content>
<content select="md-collection-item"></content>
</div>
</template>
7 changes: 7 additions & 0 deletions src/collection/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export class MdCollection {
this.element = element;
}

attached() {
let header = this.element.querySelector('md-collection-header');
if (header) {
this.anchor.classList.add('with-header');
}
}

getSelected() {
let items = [].slice.call(this.element.querySelectorAll('md-collection-selector'));
return items.filter(i => i.au['md-collection-selector'].viewModel.isSelected)
Expand Down
1 change: 1 addition & 0 deletions src/config-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class ConfigBuilder {
useCollection() : ConfigBuilder {
this.globalResources.push('./collection/collection');
this.globalResources.push('./collection/collection-item');
this.globalResources.push('./collection/collection-header');
this.globalResources.push('./collection/md-collection-selector');
return this;
}
Expand Down

0 comments on commit e180ce5

Please sign in to comment.