73bcce88
luigser
COMPONENTS
|
1
2
3
4
5
6
7
8
9
10
11
|
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
|
a1a3bc73
Luigi Serra
graphs updates
|
12
|
<link rel="import" href="../paper-material/paper-material.html">
|
c5169e0e
Renato De Donato
a new hope
|
13
|
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
|
73bcce88
luigser
COMPONENTS
|
14
15
|
<!--
|
f748e9cf
Luigi Serra
new controllet an...
|
16
|
Material design: [Cards](https://www.google.com/design/spec/components/cards.html)
|
73bcce88
luigser
COMPONENTS
|
17
18
19
20
21
22
23
24
25
26
27
28
|
`paper-card` is a container with a drop shadow.
Example:
<paper-card heading="Card Title">
<div class="card-content">Some content</div>
<div class="card-actions">
<paper-button>Some action</paper-button>
</div>
</paper-card>
|
dbc787cf
Luigi Serra
Controllet cross ...
|
29
30
31
32
33
|
Example - top card image:
<paper-card heading="Card Title" image="/path/to/image.png">
...
</paper-card>
|
f748e9cf
Luigi Serra
new controllet an...
|
34
|
|
73bcce88
luigser
COMPONENTS
|
35
36
37
38
39
40
41
42
43
44
|
### Accessibility
By default, the `aria-label` will be set to the value of the `heading` attribute.
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
|
73bcce88
luigser
COMPONENTS
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
`--paper-card-header-color` | The color of the header text | `#000`
`--paper-card-header` | Mixin applied to the card header section | `{}`
`--paper-card-header-text` | Mixin applied to the title in the card header section | `{}`
`--paper-card-header-image` | Mixin applied to the image in the card header section | `{}`
`--paper-card-header-image-text` | Mixin applied to the text overlapping the image in the card header section | `{}`
`--paper-card-content` | Mixin applied to the card content section| `{}`
`--paper-card-actions` | Mixin applied to the card action section | `{}`
`--paper-card` | Mixin applied to the card | `{}`
@group Paper Elements
@element paper-card
@demo demo/index.html
-->
<dom-module id="paper-card">
<template>
|
f748e9cf
Luigi Serra
new controllet an...
|
61
|
<style include="paper-material">
|
73bcce88
luigser
COMPONENTS
|
62
63
64
65
|
:host {
display: inline-block;
position: relative;
box-sizing: border-box;
|
a1a3bc73
Luigi Serra
graphs updates
|
66
|
|
c5169e0e
Renato De Donato
a new hope
|
67
68
|
background: #fff;
border-radius: 2px;
|
73bcce88
luigser
COMPONENTS
|
69
70
71
|
@apply(--paper-card);
}
|
73bcce88
luigser
COMPONENTS
|
72
73
74
75
76
77
78
|
/* IE 10 support for HTML5 hidden attr */
[hidden] {
display: none !important;
}
.header {
position: relative;
|
f748e9cf
Luigi Serra
new controllet an...
|
79
80
81
|
border-top-left-radius: inherit;
border-top-right-radius: inherit;
overflow: hidden;
|
73bcce88
luigser
COMPONENTS
|
82
83
84
|
@apply(--paper-card-header);
}
|
c5169e0e
Renato De Donato
a new hope
|
85
|
.header img {
|
73bcce88
luigser
COMPONENTS
|
86
|
width: 100%;
|
73bcce88
luigser
COMPONENTS
|
87
|
pointer-events: none;
|
73bcce88
luigser
COMPONENTS
|
88
89
90
91
92
93
|
@apply(--paper-card-header-image);
}
.header .title-text {
padding: 16px;
font-size: 24px;
|
c5169e0e
Renato De Donato
a new hope
|
94
|
font-weight: bold;
|
73bcce88
luigser
COMPONENTS
|
95
|
color: var(--paper-card-header-color, #000);
|
73bcce88
luigser
COMPONENTS
|
96
97
98
99
100
101
|
@apply(--paper-card-header-text);
}
.header .title-text.over-image {
position: absolute;
bottom: 0px;
|
73bcce88
luigser
COMPONENTS
|
102
103
104
105
106
107
|
@apply(--paper-card-header-image-text);
}
:host ::content .card-content {
padding: 16px;
position:relative;
|
73bcce88
luigser
COMPONENTS
|
108
109
110
111
112
113
114
|
@apply(--paper-card-content);
}
:host ::content .card-actions {
border-top: 1px solid #e8e8e8;
padding: 5px 16px;
position:relative;
|
73bcce88
luigser
COMPONENTS
|
115
116
117
118
|
@apply(--paper-card-actions);
}
</style>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
119
|
<div class="header">
|
c5169e0e
Renato De Donato
a new hope
|
120
|
<img hidden$="[[!image]]" src="[[image]]">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
121
122
|
<div hidden$="[[!heading]]" class$="[[_computeHeadingClass(image)]]">[[heading]]</div>
</div>
|
73bcce88
luigser
COMPONENTS
|
123
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
124
|
<content></content>
|
73bcce88
luigser
COMPONENTS
|
125
126
|
</template>
|
c5169e0e
Renato De Donato
a new hope
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
</dom-module>
<script>
Polymer({
is: 'paper-card',
properties: {
/**
* The title of the card.
*/
heading: {
type: String,
value: '',
observer: '_headingChanged'
},
/**
* The url of the title image of the card.
*/
image: {
type: String,
value: ''
|
73bcce88
luigser
COMPONENTS
|
152
153
|
},
|
c5169e0e
Renato De Donato
a new hope
|
154
155
156
157
158
159
160
|
/**
* The z-depth of the card, from 0-5.
*/
elevation: {
type: Number,
value: 1,
reflectToAttribute: true
|
73bcce88
luigser
COMPONENTS
|
161
162
|
},
|
c5169e0e
Renato De Donato
a new hope
|
163
164
165
166
167
168
169
|
/**
* Set this to true to animate the card shadow when setting a new
* `z` value.
*/
animatedShadow: {
type: Boolean,
value: false
|
f748e9cf
Luigi Serra
new controllet an...
|
170
171
|
},
|
c5169e0e
Renato De Donato
a new hope
|
172
173
174
175
176
177
178
179
180
|
/**
* Read-only property used to pass down the `animatedShadow` value to
* the underlying paper-material style (since they have different names).
*/
animated: {
type: Boolean,
reflectToAttribute: true,
readOnly: true,
computed: '_computeAnimated(animatedShadow)'
|
73bcce88
luigser
COMPONENTS
|
181
|
}
|
c5169e0e
Renato De Donato
a new hope
|
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
},
_headingChanged: function(heading) {
var label = this.getAttribute('aria-label');
this.setAttribute('aria-label', heading);
},
_computeHeadingClass: function(image) {
var cls = 'title-text';
if (image)
cls += ' over-image';
return cls;
},
_computeAnimated: function(animatedShadow) {
return animatedShadow;
}
});
</script>
|