From 0a9c169f0c4586ac04153d9e14be812e706ecce4 Mon Sep 17 00:00:00 2001 From: Kara Erickson Date: Mon, 4 Apr 2016 14:40:21 -0700 Subject: [PATCH] feat(list): support subheaders in lists --- src/components/list/list.scss | 41 ++++++++++++++++++++++++++++++-- src/demo-app/list/list-demo.html | 12 ++++++---- src/demo-app/list/list-demo.scss | 4 ++-- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/components/list/list.scss b/src/components/list/list.scss index 7f6a9ca8f0d9..d6b61286ebbd 100644 --- a/src/components/list/list.scss +++ b/src/components/list/list.scss @@ -1,4 +1,5 @@ @import "variables"; +@import "default-theme"; $md-list-side-padding: 16px; $md-list-avatar-size: 40px; @@ -25,7 +26,7 @@ $md-dense-three-line-height: 76px; /* This mixin provides all list-item styles, changing font size and height -based on whether the list is in "dense" mode. +based on whether the list is in dense mode. */ @mixin md-list-item-base($font-size, $base-height, $avatar-height, $two-line-height, $three-line-height) { @@ -86,7 +87,7 @@ based on whether the list is in "dense" mode. /* This mixin provides all md-line styles, changing secondary font size -based on whether the list is in "dense" mode. +based on whether the list is in dense mode. */ @mixin md-line-base($secondary-font-size) { @@ -104,10 +105,39 @@ based on whether the list is in "dense" mode. } } +/* +This mixin provides all subheader styles, adjusting heights and padding +based on whether the list is in dense mode. +*/ +@mixin md-subheader-base($top-padding, $secondary-size, $base-height) { + display: block; + box-sizing: border-box; + height: $base-height; + padding: $md-list-side-padding; + margin: 0; + + font-size: $secondary-size; + font-weight: 500; + color: md-color($md-foreground, secondary-text); + + &:first-child { + margin-top: -$top-padding; + } +} + md-list { padding-top: $md-list-top-padding; display: block; + [md-subheader] { + @include md-subheader-base( + $md-list-top-padding, + $md-list-secondary-font, + $md-list-base-height + ); + } + + md-list-item { @include md-list-item-base( $md-list-font-size, @@ -126,6 +156,13 @@ md-list[dense] { padding-top: $md-dense-top-padding; display: block; + [md-subheader] { + @include md-subheader-base( + $md-dense-top-padding, + $md-dense-font-size, + $md-dense-base-height + ); + } md-list-item { @include md-list-item-base( diff --git a/src/demo-app/list/list-demo.html b/src/demo-app/list/list-demo.html index 3f5204db22e4..01f300b7a5e1 100644 --- a/src/demo-app/list/list-demo.html +++ b/src/demo-app/list/list-demo.html @@ -8,6 +8,7 @@

md-list demo

Normal lists

+

Items

{{item}} @@ -22,19 +23,20 @@

{{contact.name}}

+

Today

Image of {{message.from}} -

{{message.from}}

+

{{message.from}}

{{message.subject}} -- {{message.message}}

- + -

{{message.from}}

+

{{message.from}}

{{message.subject}}

{{message.message}}

@@ -44,6 +46,7 @@

{{message.from}}

Dense lists

+

Items

{{item}} @@ -57,9 +60,10 @@

{{contact.name}}

+

Today

Image of {{message.from}} -

{{message.from}}

+

{{message.from}}

{{message.subject}}

{{message.message}}

diff --git a/src/demo-app/list/list-demo.scss b/src/demo-app/list/list-demo.scss index 4cfc8d09903a..442b8a480a2e 100644 --- a/src/demo-app/list/list-demo.scss +++ b/src/demo-app/list/list-demo.scss @@ -4,9 +4,9 @@ display: flex; md-list { - border: 1px dotted gray; + border: 1px solid rgba(0,0,0,0.12); width: 350px; - margin: 0 20px; + margin: 20px; } h2 {