mdb-ui-kit/scss/_buttons.scss

206 lines
4.5 KiB
SCSS
Raw Normal View History

// specification: https://www.google.com/design/spec/components/buttons.html
// mdb default buttons are flat by default
.btn {
position: relative;
margin-bottom: $mdb-btn-margin-bottom; // just enough room so that focus shadows aren't covered up
font-size: $mdb-btn-font-size;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 0;
cursor: pointer;
background-color: transparent;
border: 0;
outline: none;
box-shadow: none;
transition: box-shadow 0.2s $mdb-animation-curve-fast-out-linear-in, background-color 0.2s $mdb-animation-curve-default, color 0.2s $mdb-animation-curve-default;
will-change: box-shadow, transform;
@include undo-bs-tab-focus();
2014-10-03 15:58:24 +04:00
2015-12-21 19:28:56 +03:00
// kill focus outline on firefox
//button::-moz-focus-inner {
// border: 0;
//}
//--
// Colors
// flat removes bg, add color variations to text
@include mdb-button-color();
// fab and raised
// - colored, add their text and bg
// - hover color contrasted
// - shared shadow state on hover/active/focus
2015-12-09 00:08:18 +03:00
&.btn-fab,
&.btn-raised,
2015-12-09 00:08:18 +03:00
.btn-group-raised & {
@include mdb-button-colored();
// contrast bg colors on hover, focus, active
@include mdb-hover-focus-active() {
@include mdb-button-colored-bg(true);
//border: 1px solid $red;
}
// enlarged shadow on hover, focus
@include hover-focus() {
//border: 1px solid $blue;
@include shadow-4dp();
}
// :active - momentary press: big shadow, release and it is gone
// .active - persistent big shadow
&.active,
&:active {
@include focus-shadow();
//border: 1px solid $green;
}
}
//---
// btn-raised
&.btn-raised,
.btn-group-raised & {
// baseline shadow
@include shadow-2dp();
// reverse any of the above for links
&.btn-link {
box-shadow: none;
@include mdb-hover-focus-active() {
box-shadow: none;
2015-11-22 19:23:34 +03:00
}
}
@include mdb-disabled() {
box-shadow: none;
}
}
2015-11-22 19:23:34 +03:00
2015-12-17 18:47:55 +03:00
// https://www.google.com/design/spec/components/buttons-floating-action-button.html
&.btn-fab {
// see above for color variations
width: $mdb-btn-fab-size;
min-width: $mdb-btn-fab-size;
height: $mdb-btn-fab-size;
padding: 0;
margin: auto;
overflow: hidden;
font-size: $mdb-btn-fab-font-size;
line-height: normal;
border-radius: 50%;
box-shadow: 0 1px 1.5px 0 $gray-lighter, 0 1px 1px 0 $gray-light;
2014-10-03 15:58:24 +04:00
.ripple-container {
border-radius: 50%;
}
2014-10-03 15:58:24 +04:00
&.btn-fab-sm,
.btn-group-sm & {
width: $mdb-btn-fab-size-mini;
min-width: $mdb-btn-fab-size-mini;
height: $mdb-btn-fab-size-mini;
2014-10-03 15:58:24 +04:00
&.material-icons {
top: ($mdb-btn-icon-size-mini - $mdb-btn-fab-font-size) / 2;
left: ($mdb-btn-icon-size-mini - $mdb-btn-fab-font-size) / 2;
}
}
2014-10-03 15:58:24 +04:00
i.material-icons {
position: absolute;
top: 50%;
left: 50%;
width: $mdb-btn-fab-font-size;
line-height: $mdb-btn-fab-font-size;
transform: translate(-($mdb-btn-fab-font-size / 2), -($mdb-btn-fab-font-size / 2));
2014-10-03 15:58:24 +04:00
}
}
2014-10-03 15:58:24 +04:00
// Align icons inside buttons with text
i.material-icons {
vertical-align: middle;
}
// Size variations
&.btn-lg,
.btn-group-lg & {
font-size: $mdb-btn-font-size-lg;
}
&.btn-sm,
.btn-group-sm & {
padding: 5px 20px;
font-size: $mdb-btn-font-size-sm;
}
}
2014-10-03 15:58:24 +04:00
// Disabled buttons and button groups
.btn,
.input-group-btn .btn,
.btn-group,
.btn-group-vertical {
// have to ratchet up the specificity to kill drop shadows on disabled raised buttons
@include mdb-disabled() {
color: $mdb-btn-disabled;
.theme-dark & {
color: $mdb-btn-disabled-dark;
2014-10-03 15:58:24 +04:00
}
// flat buttons shouldn't lose transparency on disabled hover/focus
&,
&:hover,
&:focus {
background: transparent;
}
// no box-shadow on raised - need specificity
//&.btn-raised,
//&.btn-group-raised {
// &,
// &.active,
// &:active,
// &:focus:not(:active) {
// box-shadow: none;
// }
//}
}
2014-10-03 15:58:24 +04:00
}
// btn-group variations
.btn-group,
.btn-group-vertical {
position: relative;
margin: 10px 1px;
2014-10-03 15:58:24 +04:00
// spec: https://www.google.com/design/spec/components/buttons.html#buttons-toggle-buttons
&.open {
.dropdown-toggle {
//box-shadow: none;
}
> .dropdown-toggle.btn {
@include mdb-button-colored-bg();
}
}
.dropdown-menu {
border-radius: 0 0 $border-radius $border-radius;
}
&.btn-group-raised {
@include shadow-2dp();
}
.btn + .btn,
.btn,
.btn:active,
.btn-group {
margin: 0;
}
2014-10-03 15:58:24 +04:00
}