2015-12-14 20:55:59 +03:00
form {
// ensure enough room at the bottom of any form to display a one-line mdb-help
margin-bottom : ( $mdb-help-size-ratio * $font-size-base ) * $line-height ;
2015-12-21 22:27:44 +03:00
// reverse the above for navbars (no help expected in a navbar form)
. navbar & {
2016-01-21 02:10:34 +03:00
margin-bottom : 0 ; // only adjust bottom so that pull-xs-right flexed margin-left: auto works
2015-12-23 19:46:20 +03:00
. mdb-form-group {
display : inline-block ;
padding-top : 0 ;
}
2015-12-23 20:58:25 +03:00
. btn {
margin-bottom : 0 ;
}
2015-12-21 22:27:44 +03:00
}
2015-12-14 20:55:59 +03:00
}
2015-11-22 00:36:03 +03:00
// -----
// Inputs
//
// Reference http://www.google.com/design/spec/components/text-fields.html
// MDL implementation: http://www.getmdl.io/components/index.html#textfields-section
2015-12-07 22:34:46 +03:00
. form-control {
2015-12-09 02:59:07 +03:00
// The border bottom should be static in all states, the decorator will be animated over this.
& ,
& : focus ,
. mdb-form-group . is-focused & {
border : 0 ;
2015-12-10 18:02:44 +03:00
border-bottom : $input-btn-border-width solid $input-border-color ;
2015-12-09 02:59:07 +03:00
}
2015-12-17 02:19:02 +03:00
@include mdb-disabled () {
2015-12-10 18:02:44 +03:00
border-bottom : $input-btn-border-width dotted $input-border-color ;
2015-12-09 02:59:07 +03:00
}
}
2015-12-07 20:40:42 +03:00
2015-12-09 03:11:42 +03:00
// Focus underline animation =================================
2015-12-09 02:59:07 +03:00
. mdb-form-control-decorator {
position : relative ;
2015-12-10 18:02:44 +03:00
top : ( - 1 * $input-btn-border-width ) ; // move the top up enough to overlay the border from the input
2015-12-09 02:59:07 +03:00
display : block ;
2015-12-09 03:11:42 +03:00
& : : before ,
& : : after {
position : absolute ;
width : 0 ;
2015-12-14 17:59:54 +03:00
height : $input-btn-border-width + 1 ;
2015-12-09 03:11:42 +03:00
content : " " ;
transition : 0 .3 s ease all ;
// focused state - it transitions the width of each (before and after) to 50% creating the center out effect
. form-control : focus ~ & ,
. mdb-form-group . is-focused . form-control ~ & {
width : 50 % ;
}
}
& : : before {
left : 50 % ;
}
& : : after {
right : 50 % ;
2015-11-18 23:20:12 +03:00
}
2015-11-22 00:36:03 +03:00
}
2015-12-11 00:49:02 +03:00
2015-12-09 04:09:56 +03:00
// End: Focus underline animation =================================
2015-11-18 23:20:12 +03:00
2015-12-10 22:23:01 +03:00
// Help blocks (not in v4)
// position: absolute approach - uses no vertical space and there is no form jumping, but text wrapping - not so good.
// FIXME: width/wrapping isn't automatic and overflows occur. What are some solutions?
//
. mdb-help {
position : absolute ;
display : none ;
font-size : 80 % ;
font-weight : normal ;
@extend . text-muted ;
. mdb-form-group . is-focused & {
display : block ;
}
}
2015-11-22 00:36:03 +03:00
// -----
2015-12-12 00:13:33 +03:00
// State coloring: default, success, info, warning, danger
2015-11-22 00:36:03 +03:00
//
2015-12-15 01:42:22 +03:00
@include mdb-selection-color () ;
2015-12-11 20:32:00 +03:00
@include mdb-form-color ( $mdb-label-color , $mdb-label-color-focus , $input-border-color ) ;
. has-success {
@include mdb-form-color ( $brand-success , $brand-success , $brand-success ) ;
}
. has-info {
@include mdb-form-color ( $brand-info , $brand-info , $brand-info ) ;
}
. has-warning {
@include mdb-form-color ( $brand-warning , $brand-warning , $brand-warning ) ;
}
. has-danger {
@include mdb-form-color ( $brand-danger , $brand-danger , $brand-danger ) ;
}
2015-11-22 00:36:03 +03:00
// Reference http://www.google.com/design/spec/components/text-fields.html
// MDL implementation: http://www.getmdl.io/components/index.html#textfields-section
2015-12-11 00:49:02 +03:00
//.variations(unquote(" label"), color, $mdb-input-placeholder-color); // default label color variations
2015-12-12 00:13:33 +03:00
// Whereas .form-group adds structure, mdb-form-group just needs to make sure we have enough padding for our labels to work. That's the only purpose.
2015-12-07 20:40:42 +03:00
. mdb-form-group {
2015-12-09 02:59:07 +03:00
position : relative ;
2015-11-11 01:35:08 +03:00
// -----
2015-12-14 19:30:59 +03:00
// Labels
2015-11-11 01:35:08 +03:00
//
// Reference http://www.google.com/design/spec/components/text-fields.html
// MDL implementation: http://www.getmdl.io/components/index.html#textfields-section
2015-12-14 20:04:02 +03:00
[ class ^ = ' mdb-label ' ] ,
[ class * = ' mdb-label ' ] {
2015-12-12 00:13:33 +03:00
position : absolute ;
pointer-events : none ;
transition : 0 .3 s ease all ;
2015-12-11 20:32:00 +03:00
2015-12-12 00:13:33 +03:00
// hint to browser for optimization
& . mdb-label-floating {
will-change : left , top , contents ; // TODO: evaluate effectiveness - looking for community feedback
}
2015-12-14 20:04:02 +03:00
}
// hide label-placeholders when the field is filled
& . is-filled . mdb-label-placeholder {
display : none ;
2015-11-18 23:20:12 +03:00
}
2015-12-12 00:13:33 +03:00
2016-01-08 05:12:56 +03:00
// Optional class to make the text field inline collapsible/expandable (collapsed by default)
// This uses the BS collapse js to make the width expand.
// `width` class must also be on the element FIXME: do this with JS, it is a marker class and should be implicit because after all, we are an mdb-collapse-inline
// FIXME: js needs to do the focus on shown.bs.collapse event http://v4-alpha.getbootstrap.com/components/collapse/#events
& . mdb-collapse-inline {
padding : 0 ; // get rid of any padding as this is a width transition
// Expandable Holder.
. collapse {
& . in {
// This is an unfortunate hack. Animating between widths in percent (%)
// in many browsers (Chrome, Firefox) only animates the inner visual style
// of the input - the outer bounding box still 'jumps'.
// Thus assume a sensible maximum, and animate to/from that value.
max-width : 600 px ;
}
}
. collapsing ,
. width : not ( . collapse ) , / / collapsing is removed and momentarily only width is present
. collapse . in {
display : inline-block ;
}
. collapsing {
@include material-animation-default () ;
}
}
2015-12-11 00:49:02 +03:00
// default floating size/location with an mdb-form-group
2015-12-14 20:55:59 +03:00
@include mdb-form-size-variant ( $font-size-base , $mdb-label-top-margin-base , $input-padding-y , $mdb-form-line-height , " mdb-form-group default " ) ;
2015-12-11 00:49:02 +03:00
// sm floating size/location
2015-12-14 20:55:59 +03:00
& . mdb-form-group-sm {
@include mdb-form-size-variant ( $font-size-sm , $mdb-label-top-margin-sm , $input-padding-y-sm , $mdb-form-line-height-sm , " mdb-form-group sm " ) ;
}
// lg floating size/location
& . mdb-form-group-lg {
@include mdb-form-size-variant ( $font-size-lg , $mdb-label-top-margin-lg , $input-padding-y-lg , $mdb-form-line-height-sm , " mdb-form-group lg " ) ;
}
2015-12-09 05:25:35 +03:00
}
2015-11-18 23:20:12 +03:00
2016-01-06 02:16:37 +03:00
// default floating size/location without a form-group (will skip form-group styles, and just render default sizing variation) - IMPORTANT for non-form-group spacing such as radio/checkbox/switch
@include mdb-form-size-variant ( $font-size-base , $mdb-label-top-margin-base , $input-padding-y , $mdb-form-line-height ) ;
2015-12-11 00:49:02 +03:00
2015-12-09 05:25:35 +03:00
select {
& ,
& . form-control {
// Use vendor prefixes as `appearance` isn't part of the CSS spec. OSX doesn't obey the border-radius: 0 without this.
-moz-appearance : none ;
-webkit-appearance : none ;
2015-11-02 23:39:13 +03:00
}
2015-11-10 22:36:15 +03:00
}
2014-10-03 15:58:24 +04:00
2015-11-18 23:20:12 +03:00
// Input files - hide actual input - requires specific markup in the sample.
2015-12-07 20:40:42 +03:00
//.mdb-form-group input[type=file] {
// opacity: 0;
// position: absolute;
// top: 0;
// right: 0;
// bottom: 0;
// left: 0;
// width: 100%;
// height: 100%;
// z-index: 100;
//}
//
//
//.form-horizontal {
//
// // Consistent vertical alignment of radios and checkboxes
// .radio,
// .checkbox,
// .radio-inline,
// .checkbox-inline {
// padding-top: 0;
// }
//
// .radio {
// margin-bottom: 10px;
// }
//
// label {
// text-align: right;
// }
//
2015-12-11 00:49:02 +03:00
// label {
2015-12-07 20:40:42 +03:00
// margin: 0;
// }
//}