Commit 4c82dd36 authored by Mark Otto's avatar Mark Otto

Refactor input groups

* Deprecate .input-append and .input-prepend
* Use new, single base class for component, .input-group
* Deprecate .addon for .input-group-addon
* For compatibility with all buttons, require .input-group-btn to wrap buttons and button dropdowns
* Still need to reimplement with segmented button dropdowns, but that's dependent on a refactor of those first
parent 6649918c
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
cursor: pointer; cursor: pointer;
white-space: nowrap;
.buttonBackground(@btn-background, @btn-background-highlight, @grayDark, 0 1px 1px rgba(255,255,255,.75)); .buttonBackground(@btn-background, @btn-background-highlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
border: 1px solid @btn-border; border: 1px solid @btn-border;
border-bottom-color: darken(@btn-border, 10%); border-bottom-color: darken(@btn-border, 10%);
......
...@@ -421,49 +421,50 @@ select:focus:invalid { ...@@ -421,49 +421,50 @@ select:focus:invalid {
// INPUT GROUPS
// ------------
// Allow us to put symbols and text within the input field for a cleaner look // Input groups
.input-append, // --------------------------------------------------
.input-prepend {
margin-bottom: 5px;
font-size: 0; // white space collapse hack
white-space: nowrap; // Prevent span and input from separating
// Reset the white space collapse hack // Base styles
input, // -------------------------
select, .input-group {
.uneditable-input, display: table;
.dropdown-menu {
font-size: @font-size-base; // Undo padding and float of grid classes
&[class*="span"] {
float: none;
padding: 0;
} }
input, input,
select, select,
.uneditable-input { .uneditable-input {
position: relative; // placed here by default so that on :focus we can place the input above the .add-on for full border and box-shadow goodness width: 100%;
float: none; // Undo the float from grid sizing
margin: 0; // Prevent bottom margin from screwing up alignment in stacked forms
font-size: @font-size-base;
vertical-align: top;
border-radius: 0 @input-border-radius @input-border-radius 0;
// Make input on top when focused so blue border and shadow always show
&:focus {
z-index: 2;
}
} }
input[class*="span"], }
select[class*="span"],
.uneditable-input[class*="span"] { // Display as table-cell
// -------------------------
.input-group-addon,
.input-group-btn,
.input-group input,
.input-group .uneditable-input {
display: table-cell;
margin: 0; margin: 0;
} border-radius: 0;
.add-on { }
display: inline-block; // Addon and addon wrapper for buttons
width: auto; .input-group-addon,
height: @line-height-base; .input-group-btn {
min-width: 16px; width: 1%;
padding: 6px; vertical-align: middle; // Match the inputs
}
// Text input groups
// -------------------------
.input-group-addon {
.box-sizing(border-box);
padding: 6px 8px;
font-size: @font-size-base; font-size: @font-size-base;
font-weight: normal; font-weight: normal;
line-height: @line-height-base; line-height: @line-height-base;
...@@ -471,223 +472,61 @@ select:focus:invalid { ...@@ -471,223 +472,61 @@ select:focus:invalid {
text-shadow: 0 1px 0 #fff; text-shadow: 0 1px 0 #fff;
background-color: @grayLighter; background-color: @grayLighter;
border: 1px solid #ccc; border: 1px solid #ccc;
}
.add-on,
.btn,
.btn-group > .dropdown-toggle {
vertical-align: top;
border-radius: 0;
}
.active {
background-color: @state-success-background;
border-color: @state-success-text;
}
} }
.input-prepend { // Reset rounded corners
.add-on, .input-group input:first-child,
.btn { .input-group .uneditable-input:first-child,
margin-right: -1px; .input-group-addon:first-child {
} .border-left-radius(@border-radius-base);
.add-on:first-child,
.btn:first-child {
// FYI, `.btn:first-child` accounts for a button group that's prepended
border-radius: @input-border-radius 0 0 @input-border-radius;
}
} }
.input-group-addon:first-child {
.input-append { border-right: 0;
input,
select,
.uneditable-input {
border-radius: @input-border-radius 0 0 @input-border-radius;
+ .btn-group .btn,
+ .btn-group .btn:last-child {
border-radius: 0 @input-border-radius @input-border-radius 0;
}
}
.add-on,
.btn,
.btn-group {
margin-left: -1px;
}
.add-on:last-child,
.btn:last-child,
.btn-group:last-child > .dropdown-toggle {
border-radius: 0 @input-border-radius @input-border-radius 0;
}
} }
.input-group input:last-child,
// Remove all border-radius for inputs with both prepend and append .input-group .uneditable-input:last-child,
.input-prepend.input-append { .input-group-addon:last-child {
input, .border-right-radius(@border-radius-base);
select,
.uneditable-input {
border-radius: 0;
+ .btn-group .btn {
border-radius: 0 @input-border-radius @input-border-radius 0;
}
}
.add-on:first-child,
.btn:first-child {
margin-right: -1px;
border-radius: @input-border-radius 0 0 @input-border-radius;
}
.add-on:last-child,
.btn:last-child {
margin-left: -1px;
border-radius: 0 @input-border-radius @input-border-radius 0;
}
.btn-group:first-child {
margin-left: 0;
}
} }
.input-group-addon:last-child {
border-left: 0;
// SEARCH FORM
// -----------
input.search-query {
padding-right: 14px;
padding-right: 4px \9;
padding-left: 14px;
padding-left: 4px \9; /* IE8 doesn't have border radius, so don't indent the padding */
margin-bottom: 0; // Remove the default margin on all inputs
border-radius: @input-border-radius-search;
}
/* Allow for input prepend/append in search forms */
.form-search .input-append .search-query,
.form-search .input-prepend .search-query {
border-radius: 0; // Override due to specificity
}
.form-search .input-append .search-query {
border-radius: @input-border-radius-search 0 0 @input-border-radius-search;
}
.form-search .input-append .btn {
border-radius: 0 @input-border-radius-search @input-border-radius-search 0;
} }
.form-search .input-prepend .search-query {
border-radius: 0 @input-border-radius-search @input-border-radius-search 0;
}
.form-search .input-prepend .btn {
border-radius: @input-border-radius-search 0 0 @input-border-radius-search;
}
// HORIZONTAL & VERTICAL FORMS
// ---------------------------
// Common properties
// -----------------
.form-search, // Button input groups
.form-inline, // -------------------------
.form-horizontal { .input-group-btn,
input, .input-group-btn .btn {
textarea, white-space: nowrap;
select,
.help-inline,
.uneditable-input,
.input-prepend,
.input-append {
display: inline-block;
margin-bottom: 0;
vertical-align: middle;
}
// Re-hide hidden elements due to specifity
.hide {
display: none;
}
}
.form-search label,
.form-inline label,
.form-search .btn-group,
.form-inline .btn-group {
display: inline-block;
}
// Remove margin for input-prepend/-append
.form-search .input-append,
.form-inline .input-append,
.form-search .input-prepend,
.form-inline .input-prepend {
margin-bottom: 0;
} }
// Inline checkbox/radio labels (remove padding on left) .input-group-btn > .btn {
.form-search .radio, float: left; // Collapse white-space
.form-search .checkbox, border-radius: 0;
.form-inline .radio, + .btn {
.form-inline .checkbox { border-left: 0;
display: inline-block;
padding-left: 0;
label {
margin-bottom: 0;
vertical-align: middle;
} }
} }
// Remove float and margin, set to inline-block .input-group-btn.btn-group {
.form-search .radio input[type="radio"], display: table-cell;
.form-search .checkbox input[type="checkbox"],
.form-inline .radio input[type="radio"],
.form-inline .checkbox input[type="checkbox"] {
float: left;
margin-right: 3px;
margin-left: 0;
}
// Margin to space out fieldsets
.control-group {
margin-bottom: @line-height-base / 2;
}
// Legend collapses margin, so next element is responsible for spacing
legend + .control-group {
margin-top: @line-height-base;
-webkit-margin-top-collapse: separate;
} }
// Prepend
// Horizontal-specific styles .input-group-btn {
// -------------------------- &:first-child > .btn:last-child,
&.btn-group:first-child > .btn {
.form-horizontal { border-right: 0;
// Increase spacing between groups
.control-group {
margin-bottom: @line-height-base;
.clearfix();
}
// Float the labels left
.control-label {
float: left;
width: @component-offset-horizontal - 20;
padding-top: 5px;
text-align: right;
} }
// Move over all input controls and content &:first-child > .btn:first-child,
.controls { &.btn-group:first-child > .btn {
margin-left: @component-offset-horizontal; border-radius: @border-radius-base 0 0 @border-radius-base;
}
// Remove bottom margin on block level help text since that's accounted for on .control-group
.help-block {
margin-bottom: 0;
}
// And apply it only to .help-block instances that follow a form control
input,
select,
textarea,
.uneditable-input,
.input-prepend,
.input-append {
+ .help-block {
margin-top: @line-height-base / 2;
} }
}
// Append
.input-group-btn {
&:last-child > .btn:first-child,
&.btn-group:last-child > .btn:first-child {
border-left: 0;
} }
// Move over buttons in .form-actions to align with .controls &:last-child > .btn:last-child,
.form-actions { &.btn-group:last-child > .btn {
padding-left: @component-offset-horizontal; border-radius: 0 @border-radius-base @border-radius-base 0;
} }
} }
...@@ -76,8 +76,8 @@ ...@@ -76,8 +76,8 @@
// Buttons // Buttons
// ------------------------- // -------------------------
@btn-background: #fff; @btn-background: #fafafa;
@btn-background-highlight: darken(#fff, 10%); @btn-background-highlight: darken(@btn-background, 10%);
@btn-border: #bbb; @btn-border: #bbb;
@btn-backround-primary: @link-color; @btn-backround-primary: @link-color;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment