-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpaper-chip.html
More file actions
214 lines (186 loc) · 6.41 KB
/
paper-chip.html
File metadata and controls
214 lines (186 loc) · 6.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-keys/iron-a11y-keys.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-icon/iron-icon.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../paper-styles/color.html">
<link rel="import" href="paper-chip-behavior.html">
<link rel="import" href="paper-chip-icons.html">
<!--
Material Design: [Chips](http://www.google.com/design/spec/components/chips.html)
`paper-chip` Chips represent complex entities in small blocks, such as a contact.
They can contain a photo, short title string, and brief information.
## Examples:
deletable chip with iron-icon
<paper-chip label="John Doe" deletable>
<iron-icon class="icon" icon="android"></iron-icon>
</paper-chip>
Basic chip with single letter instead of an icon
<paper-chip label="Jane Doe">
<div class="icon">J</div>
</paper-chip>
Setting the height of a chip:
<style>
paper-chip.small {
--paper-chip-height: 24px;
}
</style>
...
<paper-chip label="Jane Doe" class="small">
<div class="icon">J</div>
</paper-chip>
-->
<dom-module id="paper-chip">
<template>
<style>
:root {
}
:host {
display: inline-block;
vertical-align: top;
position: relative;
outline: none;
font-size: calc(var(--paper-chip-height, 32px) / 2);
cursor: default;
margin: 8px 0;
height: calc(calc(var(--paper-chip-height, 32px) / 2) - 4);
overflow: visible;
border-radius: calc(var(--paper-chip-height, 32px) / 2);
font-family: 'Roboto', 'Noto', sans-serif;
@apply(--paper-chip);
}
paper-material#paperContainer {
calc(var(--paper-chip-height, 32px) / 2);
background-color: var(--paper-chip-background-color, #fff);
@apply(--paper-chip-paper-container);
}
.main-container {
background-color: var(--paper-chip-background-color, --paper-grey-300);
position: relative;
color: var(--paper-chip-secondary-text-color, --paper-grey-600);
@apply(--layout-vertical);
}
/* pressed state */
:host([pressed]) .main-container {
background-color: var(--paper-chip-pressed-background-color, --paper-grey-400);
}
.chip-container {
box-sizing: border-box;
height: var(--paper-chip-height, 32px);
@apply(--layout-horizontal);
@apply(--layout-center);
}
.main-container
,.icon-container {
border-radius: calc(var(--paper-chip-height, 32px) / 2);
}
.icon-container {
font-size: calc(var(--paper-chip-height, 32px) / 2);
width: var(--paper-chip-height, 32px);
height: var(--paper-chip-height, 32px);
@apply(--layout-horizontal);
@apply(--layout-center);
@apply(--layout-center-justified);
}
.icon-container ::content .icon {
width: var(--paper-chip-height, 32px);
height: var(--paper-chip-height, 32px);
line-height: var(--paper-chip-height, 32px);
border-radius: 100%;
overflow: hidden;
text-align: center;
vertical-align: middle;
font-weight: bold;
background-color: var(--paper-chip-icon-background-color, --paper-grey-600);
color: var(--paper-chip-icon-text-color, #fff);
@apply(--layout-flex);
}
.icon-container ::content .icon svg {
margin: 4px;
}
/* initially hidden elements */
:host([no-image]) .icon-container {
display: none;
}
.label-container {
font-family: 'Roboto', 'Noto', sans-serif;
padding-top: 8px;
padding-right: 12px;
padding-bottom: 8px;
padding-left: 8px;
@apply(--layout-flex-auto);
@apply(--layout-self-center);
@apply(--paper-chip-label-container);
}
:host([no-image]) .label-container {
padding-left: 12px;
}
:host([removable]) .label-container {
padding-right: 4px;
}
.label-container .chip-label {
margin: 0;
font-weight: normal;
color: var(--paper-chip-label-text-color, --paper-grey-900);
}
.remove-btn-container {
width: calc(var(--paper-chip-height, 32px) / 3 * 2);
height: calc(var(--paper-chip-height, 32px) / 3 * 2);
margin-left: 0px;
margin-right: 4px;
@apply(--layout-horizontal);
@apply(--layout-center-center);
}
:host(:not([removable])) .remove-btn-container {
display: none;
}
.remove-btn {
width: calc(var(--paper-chip-height, 32px) / 2);
height: calc(var(--paper-chip-height, 32px) / 2);
border-radius: 50%;
cursor: pointer;
background-color: var(--paper-chip-removebtn-background-color, --paper-grey-500);
color: var(--paper-chip-removebtn-icon-color, --paper-grey-300);
@apply(--layout-horizontal);
@apply(--layout-center-center);
}
.remove-btn iron-icon {
padding: 2px;
height: calc(var(--paper-chip-height, 32px) / 2);
width: calc(var(--paper-chip-height, 32px) / 2);
}
</style>
<iron-a11y-keys keys="del" on-keys-pressed="remove"></iron-a11y-keys>
<paper-material id="paperContainer" elevation="[[elevation]]">
<div class="main-container">
<div class="chip-container">
<div class="icon-container">
<content select=".icon"></content>
</div>
<div class="label-container">
<span class="chip-label">[[label]]</span>
</div>
<div class="remove-btn-container">
<div class="remove-btn" on-tap="remove" aria-label="remove button">
<iron-icon icon="paper-chip:close"></iron-icon>
</div>
</div>
</div>
</div>
</paper-material>
</template>
<script>
Polymer({
is: 'paper-chip',
behaviors: [
WebPaperElem.PaperChipBehavior
],
ready: function() {
if (this.$.removeBtn) {
// disable tabindex on remove button so that tabindex can be used for chips
this.$.removeBtn.removeAttribute('tabindex');
}
},
});
</script>
</dom-module>