forked from ebidel/polymer-gmail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterial-search.html
87 lines (82 loc) · 2.38 KB
/
material-search.html
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
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/core-toolbar/core-toolbar.html">
<link rel="import" href="bower_components/core-menu/core-menu.html">
<link rel="import" href="bower_components/paper-item/paper-item.html">
<link rel="import" href="bower_components/core-header-panel/core-header-panel.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="bower_components/core-icons/av-icons.html">
<polymer-element name="material-search" attributes="active previousSearches narrow" fit>
<template>
<style>
:host {
display: none;
margin: 0;
background: rgba(255, 255, 255, 0.9);
color: #757575;
z-index: 20;
}
:host([active]) {
display: block;
}
core-menu {
margin-left: 0;
margin-right: 0;
}
core-toolbar {
background-color: white;
}
input {
border: none;
background: transparent;
font: inherit;
font-size: 16px;
outline: none;
}
@media (min-width: 600px) {
core-menu {
max-width: 50%;
margin: 0 auto;
}
}
paper-item core-icon {
margin-right: 24px !important;
}
</style>
<core-header-panel mode="standard" fit>
<core-toolbar class="{{ {'core-narrow' : narrow} | tokenList}}">
<paper-icon-button icon="arrow-back" on-tap="{{toggle}}"></paper-icon-button>
<input id="searchbox" placeholder="Search mail" flex>
<paper-icon-button icon="av:mic"></paper-icon-button>
</core-toolbar>
<core-menu on-core-select="{{onSelect}}">
<template repeat="{{p in previousSearches}}">
<paper-item><core-icon icon="history"></core-icon>{{p}}</paper-item>
</template>
</core-menu>
</core-header-panel>
</template>
<script>
Polymer({
publish: {
narrow: {value: false, reflect: true},
active: {value: false, reflect: true}
},
created: function() {
this.previousSearches = [];
},
onSelect: function(e, detail, sender) {
if (detail.isSelected) {
this.async(function() {
this.toggle();
}, null, 250); // Introduce small delay so user sees ripple.
}
},
toggle: function() {
this.active = !this.active;
if (this.active) {
this.$.searchbox.focus();
}
}
});
</script>
</polymer-element>