mdGridList: Implement new md-gridlist component
Overview
A grid list is best suited to presenting a homogenous data type, typically images, and is optimized for visual comprehension and differentiating between like data types.

See the Material Design Specification for Details: Gridlist Specs
The developer will need to implement an Angular Material version that conforms to the functionality and UX defined in the Design specification [above].
Developers should use existing Angular Material components and coding patterns as guides for their own implementation. Shell component assets are available for quick starts [see Below].
Important Considerations
- Consider a
md-gridlist-itemto support needs of tile header and footers, plan to support the primary and secondary actions specified in the Design docs. - Use css to define the dimensions of each md-gridlist-item.
- Consider need for
md-imagefor image tiles - Consider image background loading, promise-based load indicator, image-loaded caching, and transforms for scaling; may be part of functionality associated within an
md-imagecomponent.
<md-gridlist>
<md-gridlist-item>
<!--
This is a tile that supports ideas of headers and footers;
where images have precedence over text.
-->
<md-image />
</md-gridlist-item>
</md-gridlist>
- Static and dynamic (using ng-repeat) usages should be considered.
- Questions of ripple inks and activity indicators should be considered.
The component implementation may be dependent upon the
md-iconrewrite and availability.
Development Instructions
- Checkout and use the wip-gridlist branch
- Open the
/src/components/gridlistfolder - Modify the shell files for your implementation needs.
- Implement unit tests to confirm your functionality; use
gulp karmaconfirm passing. - Create a Pull Request when your component is ready for review and merging to master
Following the Coding Standards Guidelines Follow the [Submitting a Pull Request] Guidelines
Note: Never commit to #master. Only commit your changes to the WIP branch (above).
I don't like the idea of <md-image>, because we can just do this with CSS and a class. Also, people will want to define images not just with image tags, but also background-images/SVGs.
Questions
1) Appears a tile can span multiple column with no partial-column files.
Perhaps a <md-gridlist-item md-gridlist-span=“1” > would be useful; where the span defines how many columns are spanned for a particular tile.
2) How doe the tile items reflow and/or resize; if the device changes orientation and the viewport changes?
The question is which has priority: number of columns or size of tiles. We probably need to let the developer decided that. <md-gridlist md-gridlist-priority=“size”>
Here's a good start in pure CSS: http://codepen.io/anon/pen/VYjGOm.
Tools:
- Flexbox for item wrapping
- Responsive media queries to set the width of grid items depending on the screen size: width 33% on mobile, width 25% on rotated mobile, etc.
- A CSS pseudo-selector to force the items' height to match their percent width.
- Using SASS mixins, we can have our responsive queries also support
item[num-cols="2"]etc: just have a selector which doubles the width of those items.
Thanks Andrew. That is a good start.
@ajoslin I like the implementation. It would be nice to set a min/max number of items and just let the %s work themselves out like with flex.
Can you set a number of items per row with a flex property that I don't know of?
Or perhaps there's a different approach I haven't thought of yet.. On Fri, Jan 2, 2015 at 20:18 Ilan Biala [email protected] wrote:
@ajoslin https://github.com/ajoslin I like the implementation. It would be nice to set a min/max number of items and just let the %s work themselves out like with flex.
— Reply to this email directly or view it on GitHub https://github.com/angular/material/issues/933#issuecomment-68581308.
@ajoslin It would probably require some javascript. If mdGridList will require JS for styles anyway, I'll see if I can come up with something.
The bad thing about using js for layout is that it's almost impossible to know when you need to recalculate the layout, in every situation. The container could resize without the window resizing, or get a margin added to it, or anything.
@ajoslin right, I'll look around any try to come up with a css-based solution.
Will doing anything with min-width/max-width in the media queries work? Setting that through JS would be fine, but I'm not finding a way to get the items to scale to fit the row because they are all equal height and width. Does mdGridList need to be square items?
I was thinking about taking a similar approach to how the project approaches responsive layout. Something along the lines of <md-grid-list cols-{sm,md,lg}="n"> and a fallback "cols" attribute.
@ilanbiala Rectangular items are fine.
@shyndman if rectangular items are fine, then we can remove the :before rules, and probably get something to work with min-width + max-width? I'm trying to with this pen, but some alignment issues and such. I'll test out changing the min max through javascript media queries. Do you guys use some sort of helper for setting media queries through javascript?
@shyndman just by switching from flex-grow to flex, I fixed the alignment issues. Only thing to fix now is when they are not fully expanded and not dynamically changing within the same media query..
Not sure if this article helps us at all since we are trying to use flexbox, but still.
@shyndman per our accessibility discussion and having primary/secondary actions as sibling elements rather than a parent/child relationship, I did a little markup demo. This also applies to md-card. http://codepen.io/marcysutton/pen/VYpjQz
Looks great. Thanks Marcy.
I have another question. Is it appropriate to use header and footer inside the md-grid-tile element? I thought the tiles might be considered sectioning roots, but I'm not sure.
And if they are sectioning roots, can I annotate them to that effect?
From what I just read, for them to be contained in valid sectioning roots md-grid-tile might need to be replaced by a <section> or <figure> element. No one uses the HTML5 heading algorithm, so h1-h6 headings shouldn't start over. But header and footer look ok to use! http://html5doctor.com/outlines/
Is there a way that I can indicate to a screenreader that an md-grid-tile is equivalent to a section?
I don't think so, it's an abstract role that isn't meant to be used: http://www.w3.org/TR/wai-aria/roles#section. Putting the actual <section> or <figure> tags currently seems to be the only way to provide those semantics, although it's unclear if sectioning contexts even happen with those elements. https://twitter.com/kevinsuttle/status/555169693514731520