Skip to content

Commit

Permalink
Add required field mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Sep 7, 2018
1 parent 268bed4 commit 9ebd76c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"mixins/field-button.html",
"mixins/menu-overlay.html",
"mixins/overlay.html",
"mixins/required-field.html",
"color.html",
"font-icons.html",
"shadow.html",
Expand Down
55 changes: 55 additions & 0 deletions mixins/required-field.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<link rel="import" href="../color.html">

<dom-module id="material-required-field">
<template>
<style>
[part="label"] {
display: block;
position: absolute;
top: 8px;
font-size: 1em;
line-height: 1;
height: 20px;
margin-bottom: -4px;
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
color: var(--material-secondary-text-color);
transform-origin: 0 75%;
transform: scale(0.75);
}

:host([required]) [part="label"]::after {
content: " *";
color: inherit;
}

:host([invalid]) [part="label"] {
color: var(--material-error-text-color);
}

[part="error-message"] {
font-size: .75em;
line-height: 1;
color: var(--material-error-text-color);
margin-top: 6px;
}

:host(:not([invalid])) [part="error-message"] {
margin-top: 0;
max-height: 0;
overflow: hidden;
}

:host([invalid]) [part="error-message"] {
animation: reveal 0.2s;
}

@keyframes reveal {
0% {
opacity: 0;
}
}
</style>
</template>
</dom-module>

0 comments on commit 9ebd76c

Please sign in to comment.