-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Inline error state styling #132
Changes from 1 commit
eb58ef2
ca5c067
5b519f6
e5c8d0e
ca3ffd0
68c5f9b
175f09a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ textarea { | |
vertical-align: middle; | ||
background-color: #fff; | ||
background-repeat: no-repeat; // Repeat and position set for form states (success, error, etc) | ||
background-position: right center; | ||
background-position: right 8px center; | ||
border: 1px solid #ccc; | ||
border-radius: 3px; | ||
outline: none; | ||
|
@@ -131,7 +131,6 @@ dl.form { | |
width: 440px; | ||
max-width: 100%; | ||
margin-right: 5px; | ||
background-position-x: 98%; | ||
} | ||
|
||
input { | ||
|
@@ -211,64 +210,105 @@ dl.form { | |
} | ||
} | ||
|
||
.form-note { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You know, I have no idea. This isn't actually an addition, it just moved as a result of pasting stuff in. This diff isn't entirely accurate in that regard... Unless I'm mistaken, it's in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe nuke it? 🤷 |
||
display: inline-block; | ||
padding: 5px; | ||
margin-top: -1px; | ||
font-size: 11px; | ||
color: #494620; | ||
background: #f7ea57; | ||
border: 1px solid #c0b536; | ||
border-top-color: #fff; | ||
border-bottom-right-radius: 3px; | ||
border-bottom-left-radius: 3px; | ||
} | ||
|
||
// Form validation | ||
// | ||
// Our inline errors | ||
|
||
&.warn, | ||
&.errored { | ||
> dt label { | ||
color: #900; | ||
dd.warning, | ||
dd.error { | ||
display: inline-block; | ||
position: absolute; | ||
max-width: 450px; // Keep our long errors readable | ||
z-index: 10; | ||
margin: 2px 0 0; | ||
padding: 5px 8px; | ||
font-size: 13px; | ||
font-weight: normal; | ||
border-radius: 3px; | ||
} | ||
|
||
// General text next to the field | ||
.error { | ||
display: inline; | ||
color: #900; | ||
dd.warning:after, | ||
dd.warning:before, | ||
dd.error:after, | ||
dd.error:before { | ||
bottom: 100%; | ||
z-index: 15; | ||
left: 15px; | ||
border: solid transparent; | ||
content: " "; | ||
height: 0; | ||
width: 0; | ||
position: absolute; | ||
pointer-events: none; | ||
} | ||
|
||
// Specific error explanations from the server | ||
dd.error, | ||
dd.warning { | ||
display: inline-block; | ||
padding: 5px; | ||
font-size: 11px; | ||
color: #494620; | ||
background: #f7ea57; | ||
border: 1px solid #c0b536; | ||
border-top-color: #fff; | ||
border-bottom-right-radius: 3px; | ||
border-bottom-left-radius: 3px; | ||
dd.warning:after, | ||
dd.error:after { | ||
border-width: 5px; | ||
margin-left: -5px; | ||
} | ||
} | ||
|
||
&.warn { | ||
// General text next to the field | ||
.warning { | ||
display: inline; | ||
color: #900; | ||
dd.warning:before, | ||
dd.error:before { | ||
border-width: 6px; | ||
margin-left: -6px; | ||
} | ||
} | ||
|
||
// Specific warning explanations from the server | ||
&.warn { | ||
dd.warning { | ||
display: inline-block; | ||
padding: 5px; | ||
font-size: 11px; | ||
color: #494620; | ||
background: #f7ea57; | ||
border: 1px solid #c0b536; | ||
border-top-color: #fff; | ||
border-bottom-right-radius: 3px; | ||
border-bottom-left-radius: 3px; | ||
color: #4e401e; | ||
background-color: #ffe5a7; | ||
border: 1px solid #e7ce94; | ||
|
||
&:after { | ||
border-color: rgba(255, 229, 167, 0); | ||
border-bottom-color: #ffe5a7; | ||
} | ||
|
||
&:before { | ||
border-color: rgba(205, 186, 131, 0); | ||
border-bottom-color: #cdb683; | ||
} | ||
} | ||
} | ||
|
||
.form-note { | ||
display: inline-block; | ||
padding: 5px; | ||
margin-top: -1px; | ||
font-size: 11px; | ||
color: #494620; | ||
background: #f7ea57; | ||
border: 1px solid #c0b536; | ||
border-top-color: #fff; | ||
border-bottom-right-radius: 3px; | ||
border-bottom-left-radius: 3px; | ||
&.errored { | ||
> dt label { | ||
color: $brand-red; | ||
} | ||
|
||
dd.error { | ||
color: #fff; | ||
background-color: #bf1515; | ||
border-color: #911; | ||
font-size: 13px; | ||
|
||
&:after { | ||
border-color: rgba(191, 21, 21, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
border-bottom-color: #bf1515; | ||
} | ||
|
||
&:before { | ||
border-color: rgba(153, 17, 17, 0); | ||
border-bottom-color: #911; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there's a comma here, I think
background-position
only accepts two values, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was a little too clever, but up to four values are totally valid. Old declarations throughout .com are 98% from the left, but this is more consistent and renders more accurately regardless of the size of the input. This way it'll always be 8px from the right and centered vertically.
https://css-tricks.com/almanac/properties/b/background-position/#browser-support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh yeah, wasn't thinking about that. Nice dude. Maybe add something there as a quick comment so folks don't think it's an error?