Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mixins to style with different invalid colors #435

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,16 @@ The following custom properties and mixins are available for styling:
| `--paper-input-container-disabled` | Mixin applied to the container when it's disabled | `{}` |
| `--paper-input-container-label` | Mixin applied to the label | `{}` |
| `--paper-input-container-label-focus` | Mixin applied to the label when the input is focused | `{}` |
| `--paper-input-container-label-invalid` | Mixin applied to the label when the input is invalid | `{}` |
| `--paper-input-container-label-floating` | Mixin applied to the label when floating | `{}` |
| `--paper-input-container-input` | Mixin applied to the input | `{}` |
| `--paper-input-container-underline` | Mixin applied to the underline | `{}` |
| `--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focused | `{}` |
| `--paper-input-container-underline-invalid` | Mixin applied to the underline when the input is invalid | `{}` |
| `--paper-input-container-underline-disabled` | Mixin applied to the underline when the input is disabled | `{}` |
| `--paper-input-prefix` | Mixin applied to the input prefix | `{}` |
| `--paper-input-suffix` | Mixin applied to the input suffix | `{}` |
|`--paper-input-container-add-on-invalid` | Mixin applied to the add-on when the input is invalid | `{}` |

This element is `display:block` by default, but you can set the `inline` attribute to make it
`display:inline-block`.
Expand Down
21 changes: 21 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ <h3>Inputs can have custom logic</h3>
</paper-input-container>
</template>
</demo-snippet>

<h3>Inputs can have custom error styling</h3>
<demo-snippet>
<template>
<style is="custom-style">
.styled-error-input {
--paper-input-container-label-invalid: {
color: var(--paper-indigo-500);
};
--paper-input-container-underline-invalid: {
background: var(--paper-orange-500);
};
--paper-input-container-add-on-invalid: {
color: var(--paper-blue-grey-600);
};
}
</style>
<paper-input class="styled-error-input" label="this input requires some text" required auto-validate error-message="needs some text!"></paper-input>
<paper-input class="styled-error-input" label="this input requires letters only" auto-validate pattern="[a-zA-Z]*" error-message="letters only!"></paper-input>
</template>
</demo-snippet>
</div>

<script>
Expand Down
8 changes: 8 additions & 0 deletions paper-input-container.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@
`--paper-input-container-disabled` | Mixin applied to the container when it's disabled | `{}`
`--paper-input-container-label` | Mixin applied to the label | `{}`
`--paper-input-container-label-focus` | Mixin applied to the label when the input is focused | `{}`
`--paper-input-container-label-invalid` | Mixin applied to the label when the input is invalid | `{}`
`--paper-input-container-label-floating` | Mixin applied to the label when floating | `{}`
`--paper-input-container-input` | Mixin applied to the input | `{}`
`--paper-input-container-underline` | Mixin applied to the underline | `{}`
`--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focused | `{}`
`--paper-input-container-underline-invalid` | Mixin applied to the underline when the input is invalid | `{}`
`--paper-input-container-underline-disabled` | Mixin applied to the underline when the input is disabled | `{}`
`--paper-input-prefix` | Mixin applied to the input prefix | `{}`
`--paper-input-suffix` | Mixin applied to the input suffix | `{}`
`--paper-input-container-add-on-invalid` | Mixin applied to the add-on when the input is invalid | `{}`

This element is `display:block` by default, but you can set the `inline` attribute to make it
`display:inline-block`.
Expand Down Expand Up @@ -164,6 +167,7 @@
transition: transform 0.25s;

@apply(--paper-transition-easing);
@apply(--paper-input-container-underline-invalid);
}

.unfocused-line {
Expand Down Expand Up @@ -250,6 +254,8 @@
.input-content.is-invalid ::content label,
.input-content.is-invalid ::content .paper-input-label {
color: var(--paper-input-container-invalid-color, --error-color);

@apply(--paper-input-container-label-invalid);
}

.input-content.label-is-hidden ::content label,
Expand Down Expand Up @@ -306,6 +312,8 @@

.add-on-content.is-invalid ::content * {
color: var(--paper-input-container-invalid-color, --error-color);

@apply(--paper-input-container-add-on-invalid);
}

.add-on-content.is-highlighted ::content * {
Expand Down