2016-01-26 21:12:48 +03:00
form {
2016-03-21 17:56:51 +03:00
// ensure enough room at the bottom of any form to display a one-line bmd-help
2016-03-28 23:18:19 +03:00
margin-bottom : ( $bmd-help-size-ratio * $font-size-base ) * $line-height-base ;
2016-01-26 21:12:48 +03:00
// reverse the above for navbars (no help expected in a navbar form)
. navbar & {
margin-bottom : 0 ; // only adjust bottom so that pull-xs-right flexed margin-left: auto works
2016-03-21 17:56:51 +03:00
. bmd-form-group {
2016-01-26 21:12:48 +03:00
display : inline-block ;
padding-top : 0 ;
}
. btn {
margin-bottom : 0 ;
}
}
}
// -----
// Inputs
//
// Reference http://www.google.com/design/spec/components/text-fields.html
// MDL implementation: http://www.getmdl.io/components/index.html#textfields-section
. form-control {
2016-03-28 23:18:19 +03:00
background-repeat : $bmd-form-control-bg-repeat-y ;
background-position : $bmd-form-control-bg-position ;
background-size : $bmd-form-control-bg-size ;
2016-01-26 23:37:28 +03:00
border : 0 ;
transition : background 0 s ease-out ;
2016-01-26 21:12:48 +03:00
2016-01-26 23:37:28 +03:00
// on disabled, kill the bg animation image and fall back to a simple dotted bottom border
2016-03-21 17:56:51 +03:00
@include bmd-disabled () {
2016-01-26 23:37:28 +03:00
background-image : none ;
2016-01-26 21:12:48 +03:00
border-bottom : $input-btn-border-width dotted $input-border-color ;
}
2016-01-26 23:37:28 +03:00
// The border bottom should be static in all states, the decorator will be animated over this.
& : focus ,
2016-03-21 17:56:51 +03:00
. bmd-form-group . is-focused & {
2016-03-28 23:18:19 +03:00
background-size : $bmd-form-control-bg-size-active ;
2016-01-26 23:37:28 +03:00
//border-bottom: $input-btn-border-width solid $input-border-color;
transition-duration : 0 .3 s ;
2016-01-26 21:12:48 +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?
//
2016-03-21 17:56:51 +03:00
. bmd-help {
2016-01-26 21:12:48 +03:00
position : absolute ;
display : none ;
2016-03-22 23:49:50 +03:00
font-size : .8 rem ;
2016-01-26 21:12:48 +03:00
font-weight : normal ;
@extend . text-muted ;
2016-03-21 17:56:51 +03:00
. bmd-form-group . is-focused & {
2016-01-26 21:12:48 +03:00
display : block ;
}
2016-03-22 23:49:50 +03:00
//--------------------------------------
// Multiple help blocks
// - absolute positioning is used above to prevent bouncing
// - when there is more than one, this will bounce but will at least show
& : nth-of-type ( 2 ) {
padding-top : 1 rem ; // the first one requires top padding to push it below the first one which is absolute positioned
}
+ . bmd-help {
position : relative ;
margin-bottom : 0 ;
}
2016-01-26 21:12:48 +03:00
}
// -----
// State coloring: default, success, info, warning, danger
//
2016-03-21 17:56:51 +03:00
@include bmd-selection-color () ;
2016-03-28 23:18:19 +03:00
@include bmd-form-color ( $bmd-label-color , $bmd-label-color-focus , $input-border-color ) ;
2016-01-26 21:12:48 +03:00
. has-success {
2016-03-21 17:56:51 +03:00
@include bmd-form-color ( $brand-success , $brand-success , $brand-success ) ;
2016-01-26 21:12:48 +03:00
}
. has-info {
2016-03-21 17:56:51 +03:00
@include bmd-form-color ( $brand-info , $brand-info , $brand-info ) ;
2016-01-26 21:12:48 +03:00
}
. has-warning {
2016-03-21 17:56:51 +03:00
@include bmd-form-color ( $brand-warning , $brand-warning , $brand-warning ) ;
2016-01-26 21:12:48 +03:00
}
. has-danger {
2016-03-21 17:56:51 +03:00
@include bmd-form-color ( $brand-danger , $brand-danger , $brand-danger ) ;
2016-01-26 21:12:48 +03:00
}
// Reference http://www.google.com/design/spec/components/text-fields.html
// MDL implementation: http://www.getmdl.io/components/index.html#textfields-section
2016-03-28 23:18:19 +03:00
//.variations(unquote(" label"), color, $bmd-input-placeholder-color); // default label color variations
2016-01-26 21:12:48 +03:00
2016-03-21 17:56:51 +03:00
// Whereas .form-group adds structure, bmd-form-group just needs to make sure we have enough padding for our labels to work. That's the only purpose.
. bmd-form-group {
2016-01-26 21:12:48 +03:00
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
2016-03-21 17:56:51 +03:00
[ class ^ = ' bmd-label ' ] ,
[ class * = ' bmd-label ' ] {
2016-01-26 21:12:48 +03:00
position : absolute ;
pointer-events : none ;
transition : 0 .3 s ease all ;
// hint to browser for optimization
2016-03-21 17:56:51 +03:00
& . bmd-label-floating {
2016-01-26 21:12:48 +03:00
will-change : left , top , contents ; // TODO: evaluate effectiveness - looking for community feedback
}
}
// hide label-placeholders when the field is filled
2016-03-21 17:56:51 +03:00
& . is-filled . bmd-label-placeholder {
2016-01-26 21:12:48 +03:00
display : none ;
}
// Optional class to make the text field inline collapsible/expandable (collapsed by default)
// This uses the BS collapse js to make the width expand.
2016-03-21 17:56:51 +03:00
// `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 bmd-collapse-inline
2016-01-26 21:12:48 +03:00
// FIXME: js needs to do the focus on shown.bs.collapse event http://v4-alpha.getbootstrap.com/components/collapse/#events
2016-03-21 17:56:51 +03:00
& . bmd-collapse-inline {
2016-01-26 21:12:48 +03:00
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 () ;
}
}
2016-03-21 17:56:51 +03:00
// default floating size/location with an bmd-form-group
2016-03-28 23:18:19 +03:00
@include bmd-form-size-variant ( $font-size-base , $bmd-label-top-margin-base , $input-padding-y , $bmd-form-line-height , " bmd-form-group default " ) ;
2016-01-26 21:12:48 +03:00
// sm floating size/location
2016-03-21 17:56:51 +03:00
& . bmd-form-group-sm {
2016-03-28 23:18:19 +03:00
@include bmd-form-size-variant ( $font-size-sm , $bmd-label-top-margin-sm , $input-padding-y-sm , $bmd-form-line-height-sm , " bmd-form-group sm " ) ;
2016-01-26 21:12:48 +03:00
}
// lg floating size/location
2016-03-21 17:56:51 +03:00
& . bmd-form-group-lg {
2016-03-28 23:18:19 +03:00
@include bmd-form-size-variant ( $font-size-lg , $bmd-label-top-margin-lg , $input-padding-y-lg , $bmd-form-line-height-sm , " bmd-form-group lg " ) ;
2016-01-26 21:12:48 +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
2016-03-28 23:18:19 +03:00
@include bmd-form-size-variant ( $font-size-base , $bmd-label-top-margin-base , $input-padding-y , $bmd-form-line-height ) ;
2016-01-26 21:12:48 +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 ;
}
}
// Input files - hide actual input - requires specific markup in the sample.
2016-03-21 17:56:51 +03:00
//.bmd-form-group input[type=file] {
2016-01-26 21:12:48 +03:00
// 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;
// }
//
// label {
// margin: 0;
// }
//}