Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp button and input vars while fixing #21587 #22287

Merged
merged 2 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scss/_button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@
//

.btn + .dropdown-toggle-split {
padding-right: $btn-padding-x * .75;
padding-left: $btn-padding-x * .75;
padding-right: $input-btn-padding-x * .75;
padding-left: $input-btn-padding-x * .75;

&::after {
margin-left: 0;
}
}

.btn-sm + .dropdown-toggle-split {
padding-right: $btn-padding-x-sm * .75;
padding-left: $btn-padding-x-sm * .75;
padding-right: $input-btn-padding-x-sm * .75;
padding-left: $input-btn-padding-x-sm * .75;
}

.btn-lg + .dropdown-toggle-split {
padding-right: $btn-padding-x-lg * .75;
padding-left: $btn-padding-x-lg * .75;
padding-right: $input-btn-padding-x-lg * .75;
padding-left: $input-btn-padding-x-lg * .75;
}


Expand Down
10 changes: 4 additions & 6 deletions scss/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
.btn {
display: inline-block;
font-weight: $btn-font-weight;
line-height: $btn-line-height;
text-align: center;
white-space: nowrap;
vertical-align: middle;
user-select: none;
border: $input-btn-border-width solid transparent;
@include button-size($btn-padding-y, $btn-padding-x, $font-size-base, $btn-border-radius);
@include button-size($input-btn-padding-y, $input-btn-padding-x, $font-size-base, $input-btn-line-height, $btn-border-radius);
@include transition($btn-transition);

// Share hover and focus styles
Expand Down Expand Up @@ -137,12 +136,11 @@ fieldset[disabled] a.btn {
//

.btn-lg {
// line-height: ensure even-numbered height of button next to large input
@include button-size($btn-padding-y-lg, $btn-padding-x-lg, $font-size-lg, $btn-border-radius-lg);
@include button-size($input-btn-padding-y-lg, $input-btn-padding-x-lg, $font-size-lg, $line-height-lg, $btn-border-radius-lg);
}

.btn-sm {
// line-height: ensure proper height of button next to small input
@include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-sm, $btn-border-radius-sm);
@include button-size($input-btn-padding-y-sm, $input-btn-padding-x-sm, $font-size-sm, $line-height-sm, $btn-border-radius-sm);
}


Expand Down
40 changes: 22 additions & 18 deletions scss/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
width: 100%;
// // Make inputs at least the height of their button counterpart (base line-height + padding + border)
// height: $input-height;
padding: $input-padding-y $input-padding-x;
padding: $input-btn-padding-y $input-btn-padding-x;
font-size: $font-size-base;
line-height: $input-line-height;
line-height: $input-btn-line-height;
color: $input-color;
background-color: $input-bg;
// Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214.
Expand Down Expand Up @@ -95,20 +95,20 @@ select.form-control {
// For use with horizontal and inline forms, when you need the label text to
// align with the form controls.
.col-form-label {
padding-top: calc(#{$input-padding-y} - #{$input-btn-border-width} * 2);
padding-bottom: calc(#{$input-padding-y} - #{$input-btn-border-width} * 2);
padding-top: calc(#{$input-btn-padding-y} - #{$input-btn-border-width} * 2);
padding-bottom: calc(#{$input-btn-padding-y} - #{$input-btn-border-width} * 2);
margin-bottom: 0; // Override the `<label>` default
}

.col-form-label-lg {
padding-top: calc(#{$input-padding-y-lg} - #{$input-btn-border-width} * 2);
padding-bottom: calc(#{$input-padding-y-lg} - #{$input-btn-border-width} * 2);
padding-top: calc(#{$input-btn-padding-y-lg} - #{$input-btn-border-width} * 2);
padding-bottom: calc(#{$input-btn-padding-y-lg} - #{$input-btn-border-width} * 2);
font-size: $font-size-lg;
}

.col-form-label-sm {
padding-top: calc(#{$input-padding-y-sm} - #{$input-btn-border-width} * 2);
padding-bottom: calc(#{$input-padding-y-sm} - #{$input-btn-border-width} * 2);
padding-top: calc(#{$input-btn-padding-y-sm} - #{$input-btn-border-width} * 2);
padding-bottom: calc(#{$input-btn-padding-y-sm} - #{$input-btn-border-width} * 2);
font-size: $font-size-sm;
}

Expand All @@ -120,8 +120,8 @@ select.form-control {
// For use with horizontal and inline forms, when you need the legend text to
// be the same size as regular labels, and to align with the form controls.
.col-form-legend {
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
padding-top: $input-btn-padding-y;
padding-bottom: $input-btn-padding-y;
margin-bottom: 0;
font-size: $font-size-base;
}
Expand All @@ -133,10 +133,10 @@ select.form-control {
// horizontal form layout.

.form-control-static {
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
padding-top: $input-btn-padding-y;
padding-bottom: $input-btn-padding-y;
margin-bottom: 0; // match inputs if this class comes on inputs with default margins
line-height: $input-line-height;
line-height: $input-btn-line-height;
border: solid transparent;
border-width: $input-btn-border-width 0;

Expand All @@ -157,26 +157,30 @@ select.form-control {
// issue documented in https://github.com/twbs/bootstrap/issues/15074.

.form-control-sm {
padding: $input-padding-y-sm $input-padding-x-sm;
padding: $input-btn-padding-y-sm $input-btn-padding-x-sm;
font-size: $font-size-sm;
line-height: $input-btn-line-height-sm;
@include border-radius($input-border-radius-sm);
}

select.form-control-sm {
&:not([size]):not([multiple]) {
height: $input-height-sm;
$select-border-width: ($border-width * 2);
height: calc(#{$input-height-sm} + #{$select-border-width});
}
}

.form-control-lg {
padding: $input-padding-y-lg $input-padding-x-lg;
padding: $input-btn-padding-y-lg $input-btn-padding-x-lg;
font-size: $font-size-lg;
line-height: $input-btn-line-height-lg;
@include border-radius($input-border-radius-lg);
}

select.form-control-lg {
&:not([size]):not([multiple]) {
height: $input-height-lg;
$select-border-width: ($border-width * 2);
height: calc(#{$input-height-lg} + #{$select-border-width});
}
}

Expand Down Expand Up @@ -253,7 +257,7 @@ select.form-control-lg {
.form-control-success,
.form-control-warning,
.form-control-danger {
padding-right: ($input-padding-x * 3);
padding-right: ($input-btn-padding-x * 3);
background-repeat: no-repeat;
background-position: center right ($input-height / 4);
background-size: ($input-height / 2) ($input-height / 2);
Expand Down
9 changes: 5 additions & 4 deletions scss/_input-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
//

.input-group-addon {
padding: $input-padding-y $input-padding-x;
padding: $input-btn-padding-y $input-btn-padding-x;
margin-bottom: 0; // Allow use of <label> elements by overriding our default margin-bottom
font-size: $font-size-base; // Match inputs
font-weight: $font-weight-normal;
line-height: $input-line-height;
line-height: $input-btn-line-height;
color: $input-color;
text-align: center;
background-color: $input-group-addon-bg;
Expand All @@ -79,12 +79,13 @@

// Sizing
&.form-control-sm {
padding: $input-padding-y-sm $input-padding-x-sm;
padding: $input-btn-padding-y-sm $input-btn-padding-x-sm;
font-size: $font-size-sm;
@include border-radius($input-border-radius-sm);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains trailing whitespace

&.form-control-lg {
padding: $input-padding-y-lg $input-padding-x-lg;
padding: $input-btn-padding-y-lg $input-btn-padding-x-lg;
font-size: $font-size-lg;
@include border-radius($input-border-radius-lg);
}
Expand Down
41 changes: 17 additions & 24 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ $grid-gutter-widths: (
//
// Define common padding and border radius sizes and more.

$line-height-lg: (4 / 3) !default;
$line-height-lg: 1.5 !default;
$line-height-sm: 1.5 !default;

$border-width: 1px !default;
Expand Down Expand Up @@ -338,9 +338,18 @@ $table-inverse-color: $body-bg !default;
//
// For each of Bootstrap's buttons, define text, background and border color.

$btn-padding-x: 1rem !default;
$btn-padding-y: .5rem !default;
$btn-line-height: 1.25 !default;
$input-btn-padding-x: 1rem !default;
$input-btn-padding-y: .5rem !default;
$input-btn-line-height: 1.25 !default;

$input-btn-padding-x-sm: .5rem !default;
$input-btn-padding-y-sm: .25rem !default;
$input-btn-line-height-sm: 1.5 !default;

$input-btn-padding-x-lg: 1rem !default;
$input-btn-padding-y-lg: .5rem !default;
$input-btn-line-height-lg: 1.5 !default;

$btn-font-weight: $font-weight-normal !default;
$btn-box-shadow: inset 0 1px 0 rgba($white,.15), 0 1px 1px rgba($black,.075) !default;
$btn-focus-box-shadow: 0 0 0 2px rgba($brand-primary, .25) !default;
Expand Down Expand Up @@ -372,12 +381,6 @@ $btn-danger-border: $btn-danger-bg !default;

$btn-link-disabled-color: $gray-light !default;

$btn-padding-x-sm: .5rem !default;
$btn-padding-y-sm: .25rem !default;

$btn-padding-x-lg: 1.5rem !default;
$btn-padding-y-lg: .75rem !default;

$btn-block-spacing-y: .5rem !default;

// Allows for customizing button radius independently from global border radius
Expand All @@ -390,10 +393,6 @@ $btn-transition: all .2s ease-in-out !default;

// Forms

$input-padding-x: .75rem !default;
$input-padding-y: .5rem !default;
$input-line-height: 1.25 !default;

$input-bg: $white !default;
$input-bg-disabled: $gray-lighter !default;

Expand All @@ -413,15 +412,9 @@ $input-color-focus: $input-color !default;

$input-color-placeholder: $gray-light !default;

$input-padding-x-sm: .5rem !default;
$input-padding-y-sm: .25rem !default;

$input-padding-x-lg: 1.5rem !default;
$input-padding-y-lg: .75rem !default;

$input-height: (($font-size-base * $input-line-height) + ($input-padding-y * 2)) !default;
$input-height-lg: (($font-size-lg * $line-height-lg) + ($input-padding-y-lg * 2)) !default;
$input-height-sm: (($font-size-sm * $line-height-sm) + ($input-padding-y-sm * 2)) !default;
$input-height: (($font-size-base * $input-btn-line-height) + ($input-btn-padding-y * 2)) !default;
$input-height-lg: (($font-size-lg * $input-btn-line-height-lg) + ($input-btn-padding-y-lg * 2)) !default;
$input-height-sm: (($font-size-sm * $input-btn-line-height-sm) + ($input-btn-padding-y-sm * 2)) !default;

$input-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s !default;

Expand Down Expand Up @@ -479,7 +472,7 @@ $custom-radio-checked-icon: str-replace(url("data:image/svg+xml;charset=utf8,%3C
$custom-select-padding-x: .75rem !default;
$custom-select-padding-y: .375rem !default;
$custom-select-indicator-padding: 1rem !default; // Extra padding to account for the presence of the background-image based indicator
$custom-select-line-height: $input-line-height !default;
$custom-select-line-height: $input-btn-line-height !default;
$custom-select-color: $input-color !default;
$custom-select-disabled-color: $gray-light !default;
$custom-select-bg: $white !default;
Expand Down
3 changes: 2 additions & 1 deletion scss/mixins/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@
}

// Button sizes
@mixin button-size($padding-y, $padding-x, $font-size, $border-radius) {
@mixin button-size($padding-y, $padding-x, $font-size, $line-height, $border-radius) {
padding: $padding-y $padding-x;
font-size: $font-size;
line-height: $line-height;
@include border-radius($border-radius);
}