3
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
Code distributed by Google as part of the polymer project is also
8
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11
<link rel="import" href="../polymer/polymer.html">
12
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
13
<link rel="import" href="../iron-image/iron-image.html">
14
<link rel="import" href="../paper-material/paper-material.html">
15
<link rel="import" href="../paper-styles/default-theme.html">
18
Material design: [Cards](https://www.google.com/design/spec/components/cards.html)
20
`paper-card` is a container with a drop shadow.
24
<paper-card heading="Card Title">
25
<div class="card-content">Some content</div>
26
<div class="card-actions">
27
<paper-button>Some action</paper-button>
31
Example - top card image:
33
<paper-card heading="Card Title" image="/path/to/image.png">
39
By default, the `aria-label` will be set to the value of the `heading` attribute.
43
The following custom properties and mixins are available for styling:
45
Custom property | Description | Default
46
----------------|-------------|----------
47
`--paper-card-background-color` | The background color of the card | `--primary-background-color`
48
`--paper-card-header-color` | The color of the header text | `#000`
49
`--paper-card-header` | Mixin applied to the card header section | `{}`
50
`--paper-card-header-text` | Mixin applied to the title in the card header section | `{}`
51
`--paper-card-header-image` | Mixin applied to the image in the card header section | `{}`
52
`--paper-card-header-image-text` | Mixin applied to the text overlapping the image in the card header section | `{}`
53
`--paper-card-content` | Mixin applied to the card content section| `{}`
54
`--paper-card-actions` | Mixin applied to the card action section | `{}`
55
`--paper-card` | Mixin applied to the card | `{}`
62
<dom-module id="paper-card">
64
<style include="paper-material">
66
display: inline-block;
68
box-sizing: border-box;
69
background-color: var(--paper-card-background-color, --primary-background-color);
72
@apply(--paper-font-common-base);
76
/* IE 10 support for HTML5 hidden attr */
78
display: none !important;
83
border-top-left-radius: inherit;
84
border-top-right-radius: inherit;
87
@apply(--paper-card-header);
92
--iron-image-width: 100%;
95
@apply(--paper-card-header-image);
102
color: var(--paper-card-header-color, #000);
104
@apply(--paper-card-header-text);
107
.header .title-text.over-image {
111
@apply(--paper-card-header-image-text);
114
:host ::content .card-content {
118
@apply(--paper-card-content);
121
:host ::content .card-actions {
122
border-top: 1px solid #e8e8e8;
126
@apply(--paper-card-actions);
131
<iron-image hidden$="[[!image]]" src="[[image]]" preload$="[[preloadImage]]" fade$="[[fadeImage]]"></iron-image>
132
<div hidden$="[[!heading]]" class$="[[_computeHeadingClass(image)]]">[[heading]]</div>
144
* The title of the card.
149
observer: '_headingChanged'
153
* The url of the title image of the card.
161
* When `true`, any change to the image url property will cause the
162
* `placeholder` image to be shown until the image is fully rendered.
170
* When `preloadImage` is true, setting `fadeImage` to true will cause the
171
* image to fade into place.
179
* The z-depth of the card, from 0-5.
184
reflectToAttribute: true
188
* Set this to true to animate the card shadow when setting a new
197
* Read-only property used to pass down the `animatedShadow` value to
198
* the underlying paper-material style (since they have different names).
202
reflectToAttribute: true,
204
computed: '_computeAnimated(animatedShadow)'
208
_headingChanged: function(heading) {
209
var label = this.getAttribute('aria-label');
210
this.setAttribute('aria-label', heading);
213
_computeHeadingClass: function(image) {
214
var cls = 'title-text';
216
cls += ' over-image';
220
_computeAnimated: function(animatedShadow) {
221
return animatedShadow;