1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-17 21:49:09 +01:00

Revamp button mixins and pseudo states

* Remove .darken-button-states and .buttonBackground mixins (latter wasn't being used anyway)
* Create new .btn-pseudo-states mixin for setting button background and border colors for default and pseudo states
This commit is contained in:
Mark Otto 2013-02-02 19:16:15 -08:00
parent 2f7087eae9
commit 9480eb89cb
2 changed files with 25 additions and 55 deletions

View File

@ -109,64 +109,32 @@ input[type="button"] {
}
}
// Mixin for darkening only enabled buttons for link states
.darken-button-states (@background, @border) {
&:hover,
&:focus,
&:active {
background-color: darken(@background, 5%);
border-color: darken(@border, 10%);
}
&.disabled,
&[disabled],
fieldset[disabled] & {
&:hover,
&:focus,
&:active {
background-color: @background;
border-color: @border
}
}
}
// Alternate buttons
// --------------------------------------------------
.btn {
color: @btn-color;
background-color: @btn-background;
border-color: @btn-border;
.darken-button-states(@btn-background, @btn-border)
.btn-pseudo-states(@btn-background, @btn-border);
}
.btn-primary {
background-color: @btn-background-primary;
border-color: @btn-border-primary;
.darken-button-states(@btn-background-primary, @btn-border-primary)
.btn-pseudo-states(@btn-background-primary, @btn-border-primary);
}
// Warning appears as orange
.btn-warning {
background-color: @btn-background-warning;
border-color: @btn-border-warning;
.darken-button-states(@btn-background-warning, @btn-border-warning)
.btn-pseudo-states(@btn-background-warning, @btn-border-warning);
}
// Danger and error appear as red
.btn-danger {
background-color: @btn-background-danger;
border-color: @btn-border-danger;
.darken-button-states(@btn-background-danger, @btn-border-danger)
.btn-pseudo-states(@btn-background-danger, @btn-border-danger);
}
// Success appears as green
.btn-success {
background-color: @btn-background-success;
border-color: @btn-border-success;
.darken-button-states(@btn-background-success, @btn-border-success)
.btn-pseudo-states(@btn-background-success, @btn-border-success);
}
// Info appears as blue-green
.btn-info {
background-color: @btn-background-info;
border-color: @btn-border-info;
.darken-button-states(@btn-background-info, @btn-border-info)
.btn-pseudo-states(@btn-background-info, @btn-border-info);
}

View File

@ -383,31 +383,33 @@
border-bottom: 1px solid @bottom;
}
// Button backgrounds
// ------------------
.buttonBackground(@background-start, @background-end, @text-color: #fff, @text-shadow: 0 -1px 0 rgba(0,0,0,.25)) {
color: @text-color;
text-shadow: @text-shadow;
#gradient > .vertical(@background-start, @background-end);
border-color: darken(@background-end, 7.5%);
// Button psuedo states
// -------------------------
// Easily pump out default styles, as well as :hover, :focus, :active,
// and disabled options for all buttons
.btn-pseudo-states(@background, @border) {
background-color: @background;
border-color: @border;
&:hover,
&:active,
&.active {
color: @text-color;
background-color: @background-end;
background-position: 0 -15px;
&:focus,
&:active {
background-color: darken(@background, 5%);
border-color: darken(@border, 10%);
}
&:active,
&.active,
&[disabled],
&.disabled,
&[disabled],
fieldset[disabled] & {
background-image: none;
&:hover,
&:focus,
&:active {
background-color: @background;
border-color: @border
}
}
}
// Navbar vertical align
// -------------------------
// Vertically center elements in the navbar.