diff --git a/index.html b/index.html index 34781e58..483ab8e8 100644 --- a/index.html +++ b/index.html @@ -385,36 +385,69 @@

Input - floating labels form-group sizing

-
- - - Please enter a valid email address span.help-block.hint +
+ + + Please enter a valid email address +
+ +
+ + + Please enter a valid email address
- + - Please enter a valid email address span.help-block.hint + Please enter a valid email address

Input - static labels form-group sizing

-
- - +
+ + + Please enter a valid email address +
-

This is a hint as a p.help-block.hint

+
+ + + Please enter a valid email address
- - - -

This is a hint as a p.help-block.hint

+ + + Please enter a valid email address
+ +

Input - + floating label feedback variants +

+
+ + + Please enter a valid email address +
+ +
+ + + Please enter a valid email address +
+ +
+ + + Please enter a valid email address +
+ +

Input - Legacy

diff --git a/less/_inputs.less b/less/_inputs.less index cd6e846e..5024e63b 100644 --- a/less/_inputs.less +++ b/less/_inputs.less @@ -75,31 +75,82 @@ .form-group { position: relative; + // ----- // Labels + // + // Reference http://www.google.com/design/spec/components/text-fields.html + // MDL implementation: http://www.getmdl.io/components/index.html#textfields-section + + @label-as-placeholder-top: -1 * @md-input-padding-base-vertical; label.control-label { // static label // same label properties as form-group placeholder. could be shared with a ruleset but makes sass conversion painful color: @input-placeholder-color; font-size: @floating-label-size-ratio * @md-input-font-size-base; // same as focused size of floating font-weight: normal; - margin: 16px 0 0 0; // std and lg + + &.floating-label { + font-size: @md-input-font-size-base; // as placeholder + position: absolute; + pointer-events: none; + left: 0px; + top: @label-as-placeholder-top; // place the floating label to look like a placeholder with input padding + transition: 0.3s ease all; + } } .variations(~" label.control-label", color, @input-placeholder-color); // default label color variations .variations(~".is-focused label.control-label", color, @input-default); // focused label color variations + &.is-focused { + label.control-label{ + &.floating-label{ + font-size: @md-input-label-font-size-base; // 12px + } + } + } + + // sizing of focused/open/labels + &.is-focused, + &:not(.is-empty) { + label.control-label{ + &.floating-label { + top: @label-as-placeholder-top - (@md-input-label-font-size-base + @md-input-padding-base-vertical); // FIXME this needs to be calculated and moved up to .is-focused !!! + font-size: @md-input-label-font-size-base; + } + } + } + // sm &.form-group-sm { + .form-control { + .material-placeholder({ + font-size: @md-input-font-size-small; + }); + } + label.control-label { // static label - font-size: @floating-label-size-ratio * @md-input-font-size-small; // same as focused size of floating - margin: 12px 0 0 0; // sm only + font-size: @floating-label-size-ratio * @md-input-font-size-small; // static + //margin: 12px 0 0 0; // sm only + &.floating-label { + font-size: @md-input-font-size-small; // as placeholder + } } } // lg &.form-group-lg { + .form-control { + .material-placeholder({ + font-size: @md-input-font-size-large; + }); + } + label.control-label { // static label font-size: @floating-label-size-ratio * @md-input-font-size-large; // same as focused size of floating + &.floating-label { + font-size: @md-input-font-size-large; // as placeholder (never larger than size-base) + } } } @@ -162,33 +213,6 @@ select.form-control { } } -// Reference http://www.google.com/design/spec/components/text-fields.html -// MDL implementation: http://www.getmdl.io/components/index.html#textfields-section - -label.control-label.floating-label { - @label-as-placeholder-top: -1 * @md-input-padding-base-vertical; - - font-size: @md-input-font-size-base; // Input sizes - position: absolute; - pointer-events: none; - left: 0px; - top: @label-as-placeholder-top; // place the floating label to look like a placeholder with input padding - transition: 0.3s ease all; - - .form-group.is-focused & { - label.control-label { - font-size: @md-input-label-font-size-base; // 12px - } - } - - // sizing - .form-group.is-focused &, - .form-group:not(.is-empty) & { - top: @label-as-placeholder-top - (@md-input-label-font-size-base + @md-input-padding-base-vertical); // FIXME this needs to be calculated and moved up to .is-focused !!! - font-size: @md-input-label-font-size-base; - } -} - .input-group { .form-group { .form-control { diff --git a/test.html b/test.html index be44c4e5..742fcaa2 100644 --- a/test.html +++ b/test.html @@ -31,10 +31,32 @@
-

Input - Legacy

- - +

Input - static labels + form-group sizing +

+
+ + + +

This is a hint

+
+ +
+ + + +

This is a hint

+
+ +
+ + + +

This is a hint

+
+ +