-
Notifications
You must be signed in to change notification settings - Fork 10
/
gold-password-input-warning.html
83 lines (69 loc) · 2.06 KB
/
gold-password-input-warning.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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="../paper-input/paper-input-addon-behavior.html">
<!--
`<gold-password-input-warning>` is a warning add-on to use with `<paper-input-container>`. The warning is
displayed when a warning message needs to be displayed.
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--gold-password-input-warning-color` | The foreground color of the error | `--paper-amber-a700`
`--gold-password-input-warning` | Mixin applied to the error | `{}`
-->
<dom-module id="gold-password-input-warning">
<template>
<style>
:host {
display: inline-block;
visibility: hidden;
color: var(--gold-password-input-warning-color, var(--paper-amber-a700));
@apply --paper-font-caption;
@apply --gold-password-input-warning;
position: absolute;
left:0;
right:0;
}
:host([warning]) {
visibility: visible;
};
</style>
<slot></slot>
</template>
</dom-module>
<script>
Polymer({
is: 'gold-password-input-warning',
behaviors: [
Polymer.PaperInputAddonBehavior
],
properties: {
/**
* True if the error is showing.
*/
warning: {
reflectToAttribute: true,
notify: true,
type: Boolean
}
},
/**
* This overrides the update function in PaperInputAddonBehavior.
* @param {{
* inputElement: (Element|undefined),
* value: (string|undefined),
* invalid: boolean
* }} state -
* inputElement: The input element.
* value: The input value.
* invalid: True if the input value is invalid.
*/
update: function(state) {
state.value = state.value || '';
if (state.value === '') {
this.warning = false;
}
}
});
</script>