forked from Jigsaw-Code/outline-apps
-
Notifications
You must be signed in to change notification settings - Fork 5
/
user-comms-dialog.js
151 lines (127 loc) · 4.25 KB
/
user-comms-dialog.js
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
/*
Copyright 2020 The Outline Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
Polymer({
_template: html`
<style>
#wrapper {
background: var(--dark-green);
color: rgba(255, 255, 255, 0.54);
text-align: center;
}
#content {
padding: 8px 0 16px 0;
}
a {
text-decoration: none;
color: rgba(255, 255, 255, 0.54);
}
.highlight {
color: rgba(255, 255, 255, 0.87);
}
#tips {
padding: 8px 0;
font-size: 12px;
opacity: 0.87;
color: rgba(255, 255, 255, 0.54);
}
#tips iron-icon {
height: 18px;
}
#title,
#detail {
margin: 8px 0;
}
#detail {
width: 75%;
margin-left: auto;
margin-right: auto;
}
/*
Animated entry/exit using a max-height-based transition, as suggested at:
https://stackoverflow.com/questions/3508605/how-can-i-transition-height-0-to-height-auto-using-css
The advantage of a max-height-based transition is that the flow of the surrounding of the
elements is taken into account. Very important for any server cards beneath!
Note: The "active" max-height isn't as hard-coded as it may look: just pick something much
larger than is ever expected in practice - only the actual height will be used.
*/
#wrapper {
max-height: 0;
transition: max-height 0.5s ease-out;
overflow: hidden;
}
#wrapper.active {
max-height: 1000px;
transition: max-height 0.5s ease-in;
}
</style>
<div id="wrapper">
<div id="content">
<div id="tips"><iron-icon icon="icons:lightbulb-outline"></iron-icon>[[localize(iconTextLocalizationKey)]]</div>
<div id="title" class="highlight">[[localize(titleLocalizationKey)]]</div>
<div id="detail">[[localize(detailLocalizationKey)]]</div>
<div id="buttons">
<a hidden\$="[[_shouldHideLink()]]" href\$="[[linkUrl]]">
<paper-button>[[localize(linkTextLocalizationKey)]]</paper-button>
</a>
<paper-button class="highlight" on-tap="_dismiss">[[localize(dismissButtonTextLocalizationKey)]]</paper-button>
</div>
</div>
</div>
`,
is: 'user-comms-dialog',
properties: {
// Need to declare localize function passed in from parent, or else
// localize() calls within the template won't be updated.
localize: Function,
// Localization key for the dialog title. Required.
titleLocalizationKey: String,
// Localization key for the text detail. Required.
detailLocalizationKey: String,
// Optional localization key for the text displayed next to the icon.
iconTextLocalizationKey: {
type: String,
value: 'tips',
},
// Optional URL for the left side link button. If empty, the link will not be displayed.
linkUrl: String,
// Optional text localization key for the left side button.
linkTextLocalizationKey: {
type: String,
value: 'get-help',
},
// Optional text localization key for the right side dismiss button.
dismissButtonTextLocalizationKey: {
type: String,
value: 'got-it',
},
// Optional event to fire when the dialog is dismissed.
fireEventOnHide: String,
},
show: function() {
this.$.wrapper.classList.add('active');
},
hide: function() {
this.$.wrapper.classList.remove('active');
},
_dismiss: function() {
this.hide();
if (!!this.fireEventOnHide) {
this.fire(this.fireEventOnHide);
}
},
_shouldHideLink: function() {
return !this.linkUrl;
}
});