-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmostly-error.html
More file actions
114 lines (97 loc) · 2.54 KB
/
mostly-error.html
File metadata and controls
114 lines (97 loc) · 2.54 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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="behaviors/mostly-i18n-behavior.html">
<!--
An element to display errors.
Example:
<mostly-error code="404"></mostly-error>
@group Mostly UI
@element mostly-error
-->
<dom-module id="mostly-error">
<template>
<style>
:host {
display: block;
padding: 24px;
background: rgba(0, 0, 0, 0.025);
border-radius: 4px;
border: 1px dashed rgba(0, 0, 0, 0.1);
}
:host([hidden]) {
display: none !important;
}
.code {
@apply --layout-flex;
text-transform: uppercase;
color: var(--mostly-text-default, rgba(0,0,0,0.3));
text-align: center;
font-size: 1.4rem;
font-weight: 700;
}
.description {
@apply --layout-flex;
text-transform: uppercase;
color: var(--mostly-text-default, rgba(0,0,0,0.3));
text-align: center;
font-size: 1.2rem;
font-weight: 500;
padding: 8px;
}
.url {
@apply --layout-flex;
color: var(--mostly-text-default, rgba(0,0,0,0.3));
text-align: center;
padding: 16px 0;
font-size: .8rem;
}
.message {
@apply --layout-flex;
color: var(--mostly-text-default, rgba(0,0,0,0.3));
text-align: center;
padding: 8px 0;
font-size: 1rem;
font-weight: 500;
}
</style>
<div class="code" hidden$="[[!code]]">[[code]]</div>
<div class="description" hidden$="[[!code]]">[[_label(code)]]</div>
<div class="url" hidden$="[[!url]]">[[url]]</div>
<div class="message" hidden$="[[!message]]">[[message]]</div>
</template>
<script>
Polymer({
is: 'mostly-error',
behaviors: [Mostly.I18nBehavior],
properties: {
/**
* The error code. Description will rely on a label with key 'error.<code>'.
**/
code: String,
/**
* Error message to display.
**/
message: String,
url: String,
hidden: {
type: Boolean,
value: false,
reflectToAttribute: true
}
},
show: function(code, url, message) {
if (arguments.length) {
this.code = code;
this.url = url;
this.message = message;
}
this.hidden = false;
},
hide: function() {
this.hidden = true;
},
_label: function() {
return this.i18n('error.' + this.code);
}
});
</script>
</dom-module>