-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(grid-list): add header and footer support #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
// TODO(kara): Review this to see if MD spec updates are needed | ||
@import "list-shared"; | ||
|
||
/* height of tile header or footer if it has one line */ | ||
$md-grid-list-one-line-height: 48px; | ||
/* height of tile header or footer if it has two lines */ | ||
$md-grid-list-two-line-height: 68px; | ||
/* side padding for text in tile headers and footers */ | ||
$md-grid-list-text-padding: 16px; | ||
|
||
/* font styles for text in tile headers and footers */ | ||
$md-grid-list-font-size: 16px; | ||
$md-grid-list-secondary-font: 12px; | ||
|
||
md-grid-list { | ||
display: block; | ||
|
@@ -29,32 +40,30 @@ md-grid-tile { | |
// Headers & footers | ||
md-grid-tile-header, | ||
md-grid-tile-footer { | ||
@include md-line-base($md-grid-list-secondary-font); | ||
@include md-normalize-text(); | ||
|
||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
height: 48px; | ||
height: $md-grid-list-one-line-height; | ||
color: #fff; | ||
background: rgba(0, 0, 0, 0.18); | ||
overflow: hidden; | ||
padding: 0 $md-grid-list-text-padding; | ||
font-size: $md-grid-list-font-size; | ||
|
||
// Positioning | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
|
||
h3, | ||
h4 { | ||
font-weight: 400; | ||
margin: 0 0 0 16px; | ||
} | ||
|
||
h3 { | ||
font-size: 14px; | ||
&.md-2-line { | ||
height: $md-grid-list-two-line-height; | ||
} | ||
} | ||
|
||
h4 { | ||
font-size: 12px; | ||
} | ||
.md-grid-list-text { | ||
@include md-line-wrapper-base(); | ||
} | ||
|
||
md-grid-tile-header { | ||
|
@@ -64,4 +73,17 @@ md-grid-tile { | |
md-grid-tile-footer { | ||
bottom: 0; | ||
} | ||
|
||
[md-grid-avatar] { | ||
padding-right: $md-grid-list-text-padding; | ||
|
||
[dir='rtl'] & { | ||
padding-right: 0; | ||
padding-left: $md-grid-list-text-padding; | ||
} | ||
|
||
&:empty { | ||
display:none; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space after colon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<ng-content select="[md-grid-avatar]"></ng-content> | ||
<div class="md-grid-list-text"><ng-content select="[md-line]"></ng-content></div> | ||
<ng-content></ng-content> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,12 @@ import { | |
Renderer, | ||
ElementRef, | ||
Input, | ||
ContentChildren, | ||
QueryList, | ||
AfterContentInit | ||
} from '@angular/core'; | ||
|
||
import {coerceToNumber} from './grid-list'; | ||
import { coerceToNumber } from './grid-list'; | ||
import { MdLine, MdLineSetter } from '@angular2-material/core/line/line'; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
|
@@ -19,11 +22,8 @@ import {coerceToNumber} from './grid-list'; | |
export class MdGridTile { | ||
_rowspan: number = 1; | ||
_colspan: number = 1; | ||
_element: HTMLElement; | ||
|
||
constructor(private _renderer: Renderer, element: ElementRef) { | ||
this._element = element.nativeElement; | ||
} | ||
constructor(private _renderer: Renderer, private _element: ElementRef) {} | ||
|
||
@Input() | ||
get rowspan() { | ||
|
@@ -48,7 +48,28 @@ export class MdGridTile { | |
* @internal | ||
*/ | ||
setStyle(property: string, value: string): void { | ||
this._renderer.setElementStyle(this._element, property, value); | ||
this._renderer.setElementStyle(this._element.nativeElement, property, value); | ||
} | ||
|
||
} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'md-grid-tile-header, md-grid-tile-footer', | ||
templateUrl: 'grid-tile-text.html' | ||
}) | ||
export class MdGridTileText implements AfterContentInit { | ||
/** | ||
* Helper that watches the number of lines in a text area and sets | ||
* a class on the host element that matches the line count. | ||
*/ | ||
_lineSetter: MdLineSetter; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add description for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
@ContentChildren(MdLine) _lines: QueryList<MdLine>; | ||
|
||
constructor(private _renderer: Renderer, private _element: ElementRef) {} | ||
|
||
ngAfterContentInit() { | ||
this._lineSetter = new MdLineSetter(this._lines, this._renderer, this._element); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment explaining why we don't want to show empty tiles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done