This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinfo-card.html
141 lines (130 loc) · 3.74 KB
/
info-card.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
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
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/paper-item/paper-icon-item.html">
<link rel="import" href="bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="bower_components/neon-animation/animations/transform-animation.html">
<link rel="import" href="bower_components/paper-fab/paper-fab.html">
<link rel="import" href="star-rating.html">
<dom-module id="info-card">
<template>
<style>
:host {
display: block:
}
paper-dialog {
position: absolute;
bottom: 0;
left: 0;
right: 0;
max-width: 100%;
width: 600px;
margin: 0 auto;
overflow: initial !important; /* override paper-dialog */
}
paper-dialog paper-fab {
margin: 0;
position: absolute;
right: 16px;
top: calc(-56px / 2);
--paper-fab-background: var(--paper-green-500);
--paper-fab-keyboard-focus-background: var(--paper-green-700);
}
#card-title {
margin-left: calc(56px); /* icon width*/
}
#card-title h2 {
@apply(--paper-font-headline);
margin-bottom: 8px;
}
iron-icon[item-icon] {
opacity: var(--dark-secondary-opacity);
}
.away {
padding: 8px 0;
color: var(--paper-light-blue-700);
border-top: 1px solid var(--paper-grey-300);
border-bottom: 1px solid var(--paper-grey-300);
margin-top: 20px;
}
</style>
<paper-dialog id="dialog"
entry-animation="slide-up-and-fade-animation"
exit-animation="slide-down-and-fade-animation" on-click="_eatClick">
<header id="card-title">
<h2>{{marker.name}}</h2>
<template is="dom-if" if="[[marker.rating]]">
<star-rating rating="{{marker.rating}}"
total="{{marker.user_ratings_total}}"></star-rating>
</template>
<div class="away">{{_computeDurationStr(marker.duration)}}</div>
</header>
<paper-fab icon="maps:directions-car" on-tap="_showDirections"></paper-fab>
<paper-icon-item>
<iron-icon icon="maps:place" item-icon></iron-icon>
<span>{{marker.formatted_address}}</span>
</paper-icon-item>
<paper-icon-item>
<iron-icon icon="communication:phone" item-icon></iron-icon>
<span>{{marker.formatted_phone_number}}</span>
</paper-icon-item>
<paper-icon-item class="layout horizontal start"
hidden$="{{!marker.opening_hours.weekday_text.length}}">
<iron-icon icon="device:access-time" item-icon></iron-icon>
<div class="layout vertical">
<template is="dom-repeat"
items="{{marker.opening_hours.weekday_text}}" as="day">
<div>{{day}}</div>
</template>
</div>
</paper-icon-item>
</paper-dialog>
</template>
<script>
Polymer({
is: 'info-card',
properties: {
marker: {
type: Object,
value: function() { return {}; }
//notify: true
},
dismissOnOutsideClick: {
type: Boolean,
value: true,
observer: '_onDismissOnClickOutsideChanged'
}
},
open: function() {
this.$.dialog.animationConfig = {
entry: {
name: 'transform-animation',
node: this.$.dialog,
transformFrom: 'translateY(calc(100% + 56px/2))',
transformTo: 'translateY(0)'
},
exit: {
name: 'transform-animation',
node: this.$.dialog,
transformFrom: 'translateY(0)',
transformTo: 'translateY(calc(100% + 56px/2))'
}
};
this.$.dialog.open();
},
close: function() {
this.$.dialog.close();
},
_showDirections: function() {
this.fire('show-directions');
},
_computeDurationStr: function(duration) {
return duration ? duration + ' away' : 'Unknown distance from you';
},
_onDismissOnClickOutsideChanged: function() {
this.$.dialog.noCancelOnOutsideClick = this.dismissOnOutsideClick;
},
_eatClick: function(e, detail) {
e.stopPropagation();
}
});
</script>
</dom-module>