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

feat(card): improved to behave as spec #5607

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ $button-fab-mini-line-height: rem(4.00) !default;

$button-fab-toast-offset: $button-fab-height * 0.75 !default;

$icon-button-height: rem(4.800) !default;
$icon-button-width: rem(4.800) !default;
$icon-button-height: rem(4.000) !default;
$icon-button-width: rem(4.000) !default;
$icon-button-margin: rem(0.600) !default;

// Fix issue causing buttons in Firefox to be 2px bigger than they should
Expand Down Expand Up @@ -93,9 +93,8 @@ button.md-button::-moz-focus-inner {
margin: 0 $icon-button-margin;
height: $icon-button-height;
min-width: 0;
line-height: $icon-button-height;
padding-left: 0;
padding-right: 0;
line-height: $icon-size;
padding: $baseline-grid;
width: $icon-button-width;
border-radius: $button-icon-border-radius;
.md-ripple-container {
Expand Down
25 changes: 25 additions & 0 deletions src/components/card/card-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,29 @@ md-card.md-THEME_NAME-theme {
.md-card-image {
border-radius: $card-border-radius $card-border-radius 0 0;
}

md-card-header {
md-card-avatar {
md-icon {
color: '{{background-color}}';
background-color: '{{foreground-3}}';
}
}

md-card-header-text {
.md-subhead {
color: '{{foreground-2}}'
}
}
}

md-card-title {
md-card-title-text {
&:not(:only-child) {
.md-subhead {
color: '{{foreground-2}}';
}
}
}
}
}
64 changes: 60 additions & 4 deletions src/components/card/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* Card components.
*/
angular.module('material.components.card', [
'material.core'
])
'material.core'
])
.directive('mdCard', mdCardDirective);



/**
* @ngdoc directive
* @name mdCard
Expand All @@ -29,6 +28,28 @@ angular.module('material.components.card', [
* Action buttons can be included in an `<md-card-actions>` element, similar to `<md-dialog-actions>`.
* You can then position buttons using layout attributes.
*
* Card is built with:
* * `<md-card-header>` - Header for the card, holds avatar, text and squared image
* - `<md-card-avatar>` - Card avatar
* - `md-user-avatar` - Class for user image
* - `<md-icon>`
* - `<md-card-header-text>` - Contains elements for the card description
* - `md-title` - Class for the card title
* - `md-subhead` - Class for the card sub header
* * `<img>` - Image for the card
* * `<md-card-title>` - Card content title
* - `<md-card-title-text>`
* - `md-headline` - Class for the card content title
* - `md-subhead` - Class for the card content sub header
* - `<md-card-title-media>` - Squared image within the title
* - `md-media-sm` - Class for small image
* - `md-media-md` - Class for medium image
* - `md-media-lg` - Class for large image
* * `<md-card-content>` - Card content
* - `md-media-xl` - Class for extra large image
* * `<md-card-actions>` - Card actions
* - `<md-card-icon-actions>` - Icon actions
*
* Cards have constant width and variable heights; where the maximum height is limited to what can
* fit within a single view on a platform, but it can temporarily expand as needed.
*
Expand Down Expand Up @@ -62,11 +83,46 @@ angular.module('material.components.card', [
* </md-card>
* </hljs>
*
* ### Card with header, image, title actions and content
* <hljs lang="html">
* <md-card>
* <md-card-header>
* <md-card-avatar>
* <img class="md-user-avatar" src="avatar.png"/>
* </md-card-avatar>
* <md-card-header-text>
* <span class="md-title">Title</span>
* <span class="md-subhead">Sub header</span>
* </md-card-header-text>
* </md-card-header>
* <img ng-src="card-image.png" class="md-card-image" alt="image caption">
* <md-card-title>
* <md-card-title-text>
* <span class="md-headline">Card headline</span>
* <span class="md-subhead">Card subheader</span>
* </md-card-title-text>
* </md-card-title>
* <md-card-actions layout="row" layout-align="start center">
* <md-button>Action 1</md-button>
* <md-button>Action 2</md-button>
* <md-card-icon-actions>
* <md-button class="md-icon-button" aria-label="icon">
* <md-icon md-svg-icon="icon"></md-icon>
* </md-button>
* </md-card-icon-actions>
* </md-card-actions>
* <md-card-content>
* <p>
* Card content
* </p>
* </md-card-content>
* </md-card>
* </hljs>
*/
function mdCardDirective($mdTheming) {
return {
restrict: 'E',
link: function($scope, $element, $attr) {
link: function ($scope, $element) {
$mdTheming($element);
}
};
Expand Down
172 changes: 166 additions & 6 deletions src/components/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,56 @@ md-card {

box-shadow: $card-box-shadow;

md-card-header {
padding: $card-padding;
display: flex;
flex-direction: row;

&:first-child {
md-card-avatar {
margin-right: 12px;
}
}

&:last-child {
md-card-avatar {
margin-left: 12px;
}
}

md-card-avatar {
width: 40px;
height: 40px;

.md-user-avatar,
md-icon{
border-radius: 50%;
}

md-icon {
padding: 8px;
}

& + md-card-header-text {
max-height: 40px;

.md-title {
font-size: 14px;
}
}
}

md-card-header-text {
display: flex;
flex: 1;
flex-direction: column;

.md-subhead {
font-size: 14px;
}
}
}

> img,
> :not(md-card-content) img {
display: flex;
Expand All @@ -17,21 +67,131 @@ md-card {
height: auto;
}

md-card-title {
padding: 3 * $card-padding / 2 $card-padding $card-padding;
display: flex;
flex: 1;
flex-direction: row;

& + md-card-content {
padding-top: 0;
}

md-card-title-text {
flex: 1;
flex-direction: column;
display: flex;

.md-subhead {
padding-top: 0;
font-size: 14px;
}

&:only-child {
.md-subhead {
padding-top: 3 * $card-padding / 4;
}
}
}

md-card-title-media {
margin-top: - $card-padding / 2;

.md-media-sm {
height: 80px;
width: 80px;
}
.md-media-md {
height: 112px;
width: 112px;
}
.md-media-lg {
height: 152px;
width: 152px;
}
}
}

md-card-content {
display: block;
padding: $card-padding;

& > p {
margin: 0;
}

.md-media-xl {
height: 240px;
width: 240px;
}
}

.md-actions, md-card-actions {
margin: 0;
margin: $baseline-grid;

&.layout-column {
.md-button {
&:not(.md-icon-button) {
margin: $baseline-grid / 4 0;

&:first-of-type {
margin-top: 0;
}

&:last-of-type {
margin-bottom: 0;
}
}

.md-button {
margin-bottom: $baseline-grid;
margin-top: $baseline-grid;
margin-right: $baseline-grid * .5;
margin-left: $baseline-grid * .5;
&.md-icon-button {
margin-top: 3 * $baseline-grid / 4;
margin-bottom: 3 * $baseline-grid / 4;
}
}
}

md-card-icon-actions {
flex: 1;
justify-content: flex-start;
display: flex;
flex-direction: row;
}

&:not(.layout-column) .md-button {
&:not(.md-icon-button) {
margin: 0 $baseline-grid * .5;

&:first-of-type {
margin-left: 0;
}

&:last-of-type {
margin-right: 0;
}
}

&.md-icon-button {
margin-left: 3 * $baseline-grid / 4;
margin-right: 3 * $baseline-grid / 4;

&:first-of-type {
margin-left: 3 * $baseline-grid / 2;
}

&:last-of-type {
margin-right: 3 * $baseline-grid / 2;
}
}

& + md-card-icon-actions {
flex: 1;
justify-content: flex-end;
display: flex;
flex-direction: row;
}
}
}

md-card-footer {
margin-top: auto;
padding: $card-padding;
Expand Down
Loading