|
/* |
|
Our buttons' core scss. |
|
-- |
|
Note that the scss in this file can read any variables that have been set up to the point |
|
when the compiler loads it. |
|
*/ |
|
|
|
//-- our core button code |
|
@mixin button-base { |
|
display: inline-block; |
|
vertical-align: middle; |
|
margin: $button-margin; |
|
font-family: $button-font-family; |
|
|
|
padding: $button-padding; |
|
|
|
-webkit-appearance: none; |
|
border: 1px solid transparent; |
|
border-radius: $button-radius; |
|
transition: $button-transition; |
|
|
|
font-size: $button-font-size-default; |
|
line-height: 1; |
|
text-align: center; |
|
cursor: pointer; |
|
} |
|
|
|
//-- paints look-and-feel over our core button code. |
|
@mixin button-style( |
|
$background: $button-background, |
|
$background-hover: $button-background-hover, |
|
$color: $button-color, |
|
$background-hover-lightness: $button-background-hover-lightness |
|
) { |
|
@include button-base; |
|
background-color: $background; |
|
color: $color; |
|
|
|
&:hover, &:focus { |
|
background-color: $background-hover; |
|
color: $color; |
|
} |
|
} |
|
|
|
//-- to make a hollow button, remove background fills |
|
@mixin button-hollow { |
|
&, |
|
&:hover, &:focus { |
|
background-color: transparent; |
|
} |
|
|
|
&.disabled, |
|
&[disabled] { |
|
&, |
|
&:hover, &:focus { |
|
background-color: transparent; |
|
} |
|
} |
|
} |
|
|
|
//-- paints border and hover styles over button-hollow |
|
@mixin button-hollow-style( |
|
$color: $button-background, |
|
$hover-lightness: $button-hollow-hover-lightness, |
|
$border-width: $button-hollow-border-width |
|
) { |
|
@include button-base; |
|
$color-hover: scale-color($color, $lightness: $hover-lightness); |
|
|
|
border: $border-width solid $color; |
|
color: $color; |
|
|
|
&:hover, &:focus { |
|
border-color: $color-hover; |
|
color: $color-hover; |
|
&.disabled, |
|
&[disabled] { |
|
border: $border-width solid $color; |
|
color: $color; |
|
} |
|
} |
|
} |
|
|
|
/* |
|
The "main" mixin that pulls it all together. |
|
-- |
|
This one @includes the main button-base mixin, and what parameters you give it when you call |
|
it decide the look and feel of your final button. You can do a *whole lot* with very little code this way - it's all offloaded |
|
to a common mixin that you can reuse a million different ways. |
|
*/ |
|
@mixin button( |
|
$style: hollow, |
|
$background: $button-background, |
|
$background-hover: $button-background-hover, |
|
$color: $button-color |
|
) { |
|
@if $style == solid { |
|
@include button-style($background, $background-hover, $color); |
|
} @else if $style == shaded { |
|
@include button-style(rgba($background, 0.2), rgba($background, 0.6), $color); |
|
} @else { |
|
// this is our default, if the style provided doesn't match. |
|
// this will make a default hollow button style |
|
@include button-hollow; |
|
@include button-hollow-style($background); |
|
} |
|
} |