Skip to content

Commit

Permalink
Forms: Add input-placeholder mixin
Browse files Browse the repository at this point in the history
Backported from Compass vNext (0.13), but modified for the 0.12
definition of legacy Firefox.

Fixes gh-2855
  • Loading branch information
nschonni committed Aug 24, 2013
1 parent 01a82cc commit 0d216bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/grids/sass/includes/_form.scss
Expand Up @@ -4,6 +4,7 @@
*/
@import "compass/css3/appearance";
@import "compass/css3/box-sizing";
@import "mixins";

@mixin forms {

Expand Down Expand Up @@ -134,8 +135,8 @@
&[type="search"] {
@include appearance(textfield);
}
@if $experimental-support-for-mozilla {
&:-moz-placeholder { color: $medium; }
@include input-placeholder {
color: $medium;
}
}

Expand Down Expand Up @@ -342,4 +343,4 @@
}

}
}
}
23 changes: 22 additions & 1 deletion src/grids/sass/includes/_mixins.scss
Expand Up @@ -172,7 +172,7 @@ $default-box-shadow-v-offset: 0;
&:focus, &:active {
@content;
}
}
}
} @else if $hover {
&:hover, &:focus {
@content;
Expand All @@ -183,3 +183,24 @@ $default-box-shadow-v-offset: 0;
}
}
}

// Style the html5 input placeholder in browsers that support it.
// Backported from the 0.13 release of Compass.
@mixin input-placeholder {
@if $experimental-support-for-webkit {
&::-webkit-input-placeholder {
@content;
}
}
@if $experimental-support-for-mozilla {
// Single colon for Firefox 19 and below, double for 20 and above.
&:-moz-placeholder, &::-moz-placeholder {
@content;
}
}
@if $experimental-support-for-microsoft {
&:-ms-input-placeholder {
@content;
}
}
}

0 comments on commit 0d216bd

Please sign in to comment.