mdb-ui-kit/scss/_buttons.scss

238 lines
5.3 KiB
SCSS
Raw Normal View History

// specification: https://www.google.com/design/spec/components/buttons.html
@mixin typo-button($color-contrast: false) {
font-size: $mdb-btn-font-size-base;
font-weight: 500;
text-transform: uppercase;
//line-height: 1;
letter-spacing: 0;
@if ($color-contrast) {
opacity: 0.87;
2015-11-04 23:34:47 +03:00
}
}
// mdb default buttons are flat by default
// synchronized with mdl 11/23/15
.btn,
.input-group-btn .btn {
position: relative;
padding: 8px 30px;
margin: 10px 1px;
text-decoration: none;
cursor: pointer;
background: transparent;
border: 0;
border-radius: $border-radius;
outline: 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 typo-button();
2014-10-03 15:58:24 +04:00
&::-moz-focus-inner {
border: 0;
}
//---
// btn-flat
&:not(.btn-raised) {
@include variations(unquote(".btn"), unquote(""), color, $mdb-text-color-primary);
box-shadow: none;
&:not(.btn-link) {
&:hover,
&:focus {
// spec: flat/light bg Hover: 20% #999999
background-color: rgba(#999, (20 / 100));
.theme-dark & {
// spec: dark bg Hover: 15% #CCCCCC
background-color: rgba(#ccc, (15 / 100));
}
}
}
}
//--
// color variations
&.btn-raised,
2015-12-09 00:08:18 +03:00
&.btn-fab,
.btn-group-raised & {
@include background-variations(unquote(".btn"), unquote(""), $mdb-btn-background-color);
}
//---
// btn-raised
2015-12-09 00:08:18 +03:00
&.btn-raised,
.btn-group-raised & {
&:not(.btn-link) {
@include shadow-2dp();
2015-11-22 19:23:34 +03:00
2015-12-09 00:08:18 +03:00
// colors on hover, focus, active
&:hover,
&:focus,
&.active,
&:active {
// FIXME: SPEC - this should be the 600 color, how can we get that programmatically if at all? Or are we limited to the color palette only?
// SASS conversion note: please mirror any content change in _mixins-shared.scss button-variations-content
2015-12-09 00:50:15 +03:00
@include button-variations(unquote(".btn"), "", $mdb-btn-background-color);
// Spec:
// - Raised Light/Light theme no hover.
// - Raised Dark/Dark theme Hover color: 600
.theme-dark & {
2015-12-09 00:50:15 +03:00
//
}
2015-11-22 19:23:34 +03:00
}
2015-12-09 00:08:18 +03:00
// shadow on active
&.active,
2015-11-22 19:23:34 +03:00
&:active {
2015-12-09 00:08:18 +03:00
&,
&:hover {
@include shadow-4dp();
}
}
2015-12-09 00:08:18 +03:00
// shadow on focus
// Focus should take precedence over active, so specificity is needed
&:focus {
&,
&.active,
&:active {
&,
&:hover {
@include focus-shadow();
}
}
2015-11-22 19:23:34 +03:00
}
}
}
2015-11-22 19:23:34 +03:00
&.btn-fab {
// see above for color variations
position: relative;
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 rgba($black, 0.12), 0 1px 1px 0 rgba($black, 0.24);
2014-10-03 15:58:24 +04:00
.ripple-container {
border-radius: 50%;
}
2014-10-03 15:58:24 +04:00
&.btn-fab-mini,
.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
fieldset[disabled][disabled] &,
&.disabled,
&:disabled,
&[disabled][disabled] {
// spec: light theme: Disabled text: 26% $black
color: rgba($black, (26 / 100));
.theme-dark & {
// spec: dark theme: Disabled text: 30% $white
color: rgba($white, (30 / 100));
2014-10-03 15:58:24 +04:00
}
// flat buttons lose transparency
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;
//border-radius: 2px;
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 variations(unquote(".btn"), unquote(""), background-color, $mdb-btn-background-color);
}
}
.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
}