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-05-05 21:38:15 +03:00
background : $bmd-form-control-bg-repeat-y $bmd-form-control-bg-position ;
2016-03-28 23:18:19 +03:00
background-size : $bmd-form-control-bg-size ;
2016-01-26 23:37:28 +03:00
border : 0 ;
transition : background 0 s ease-out ;
2017-08-31 16:36:40 +03:00
padding-left : 0 ;
padding-right : 0 ;
2016-01-26 21:12:48 +03:00
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 {
2018-01-23 14:29:26 +03:00
@include bmd-form-color ( theme-color ( success ) , theme-color ( success ) , theme-color ( success )) ;
2016-01-26 21:12:48 +03:00
}
. has-info {
2018-01-23 14:29:26 +03:00
@include bmd-form-color ( theme-color ( info ) , theme-color ( info ) , theme-color ( info )) ;
2016-01-26 21:12:48 +03:00
}
. has-warning {
2018-01-23 14:29:26 +03:00
@include bmd-form-color ( theme-color ( warning ) , theme-color ( warning ) , theme-color ( warning )) ;
2016-01-26 21:12:48 +03:00
}
. has-danger {
2018-01-23 14:29:26 +03:00
@include bmd-form-color ( theme-color ( danger ) , theme-color ( danger ) , theme-color ( 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 {
2017-09-05 15:26:39 +03:00
display : flex ;
align-items : center ;
2016-01-26 21:12:48 +03:00
padding : 0 ; // get rid of any padding as this is a width transition
2017-09-05 15:26:39 +03:00
min-height : 2 .1 em ;
2016-01-26 21:12:48 +03:00
// Expandable Holder.
. collapse {
2017-09-05 15:26:39 +03:00
flex : 1 ;
display : none ;
& . show {
2016-01-26 21:12:48 +03:00
// 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.
2017-09-05 15:26:39 +03:00
max-width : 1200 px ;
2016-01-26 21:12:48 +03:00
}
}
. collapsing ,
2017-08-11 17:59:31 +03:00
. width : not ( . collapse ) ,
// collapsing is removed and momentarily only width is present
2017-09-05 15:26:39 +03:00
. collapse . show {
display : block ;
2016-01-26 21:12:48 +03:00
}
. 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;
// }
//}
2016-08-02 22:13:43 +03:00
. form-inline {
@include media-breakpoint-up ( sm ) {
. input-group {
display : inline-flex ;
align-items : center ;
}
}
}