Skip to content

Commit

Permalink
Fix for shiny and pill buttons in grayscale
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil LaPier committed Jan 27, 2012
1 parent a83340e commit e679332
Showing 1 changed file with 100 additions and 46 deletions.
146 changes: 100 additions & 46 deletions app/assets/stylesheets/addons/_button.scss
Expand Up @@ -7,8 +7,6 @@

// Grayscale button
@if $base-color == grayscale($base-color) {
@debug "gray button";

@if $style == simple {
@include simple($base-color, $grayscale: true);
}
Expand All @@ -24,8 +22,6 @@

// Colored button
@else {
@debug "not grayscale";

@if $style == simple {
@include simple($base-color);
}
Expand All @@ -38,26 +34,27 @@
@include pill($base-color);
}
}

}

@mixin simple ($base-color, $grayscale: false) {
$stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%);
$border: adjust-color($base-color, $saturation: 9%, $lightness: -14%);

// Simple Button
//************************************************************************//
@mixin simple($base-color, $grayscale: false) {
$color: hsl(0, 0, 100%);
$border: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
$inset-shadow: adjust-color($base-color, $saturation: -8%, $lightness: 15%);
$stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%);
$text-shadow: adjust-color($base-color, $saturation: 15%, $lightness: -18%);
$color: hsl(0, 0, 100%);

@if lightness($base-color) > 70% {
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}

@if $grayscale == true {
$stop-gradient: grayscale($stop-gradient);
$border: grayscale($border);
$color: grayscale($color);
$inset-shadow: grayscale($inset-shadow);
$stop-gradient: grayscale($stop-gradient);
$text-shadow: grayscale($text-shadow);
}

Expand All @@ -75,13 +72,13 @@

&:hover {
$base-color-hover: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
$stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -7%, $lightness: 5%);
$stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%);

@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
$inset-shadow-hover: grayscale($inset-shadow-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
}

@include box-shadow (inset 0 1px 0 0 $inset-shadow-hover);
Expand All @@ -103,22 +100,34 @@
}
}


// Shiny Button
//************************************************************************//
@mixin shiny($base-color, $grayscale: false) {
$second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33);
$third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48);
$fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46);
$border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81);
$color: hsl(0, 0, 100%);
$border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81);
$border-bottom: adjust-color($base-color, $red: -126, $green: -127, $blue: -122);
$color: hsl(0, 0, 100%);
$inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12);
$text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114);
$fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46);
$inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12);
$second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33);
$text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114);
$third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48);

@if lightness($base-color) > 70% {
$color: hsl(0, 0, 20%);
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}

@include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%);
@if $grayscale == true {
$border: grayscale($border);
$border-bottom: grayscale($border-bottom);
$fourth-stop: grayscale($fourth-stop);
$inset-shadow: grayscale($inset-shadow);
$second-stop: grayscale($second-stop);
$text-shadow: grayscale($text-shadow);
$third-stop: grayscale($third-stop);
}

border: 1px solid $border;
border-bottom: 1px solid $border-bottom;
@include border-radius(5px);
Expand All @@ -127,43 +136,69 @@
display: inline;
font-size: 14px;
font-weight: bold;
@include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%);
padding: 7px 20px 8px;
text-decoration: none;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 1px $text-shadow;

&:hover {
$first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18);
$first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18);
$second-stop-hover: adjust-color($base-color, $red: -66, $green: -62, $blue: -51);
$third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66);
$third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66);
$fourth-stop-hover: adjust-color($base-color, $red: -86, $green: -80, $blue: -63);

@include linear-gradient(top, $first-stop-hover 0%, $second-stop-hover 50%, $third-stop-hover 50%, $fourth-stop-hover 100%);
@if $grayscale == true {
$first-stop-hover: grayscale($first-stop-hover);
$second-stop-hover: grayscale($second-stop-hover);
$third-stop-hover: grayscale($third-stop-hover);
$fourth-stop-hover: grayscale($fourth-stop-hover);
}

cursor: pointer;
@include linear-gradient(top, $first-stop-hover 0%,
$second-stop-hover 50%,
$third-stop-hover 50%,
$fourth-stop-hover 100%);
}

&:active {
$inset-shadow-active: adjust-color($base-color, $red: -111, $green: -116, $blue: -122);

@if $grayscale == true {
$inset-shadow-active: grayscale($inset-shadow-active);
}

@include box-shadow(inset 0 0 20px 0 $inset-shadow-active, 0 1px 0 #fff);
}
}


// Pill Button
//************************************************************************//
@mixin pill($base-color, $grayscale: false) {
$stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%);
$color: hsl(0, 0, 100%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: -11%, $lightness: -26%);
$color: hsl(0, 0, 100%);
$inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%);
$text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%);
$inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%);
$stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%);
$text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%);

@if lightness($base-color) > 70% {
$color: hsl(0, 0, 20%);
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}

@include linear-gradient ($base-color, $stop-gradient);
@if $grayscale == true {
$border-bottom: grayscale($border-bottom);
$border-sides: grayscale($border-sides);
$border-top: grayscale($border-top);
$inset-shadow: grayscale($inset-shadow);
$stop-gradient: grayscale($stop-gradient);
$text-shadow: grayscale($text-shadow);
}

border: 1px solid $border-top;
border-color: $border-top $border-sides $border-bottom;
@include border-radius(16px);
Expand All @@ -173,35 +208,54 @@
font-size: 11px;
font-weight: normal;
line-height: 1;
@include linear-gradient ($base-color, $stop-gradient);
padding: 3px 16px 5px;
text-align: center;
text-shadow: 0 -1px 1px $text-shadow;
-webkit-background-clip: padding-box;

&:hover {
$base-color-hover: adjust-color($base-color, $lightness: -4.5%);
$base-color-hover: adjust-color($base-color, $lightness: -4.5%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%);
$stop-gradient-hover: adjust-color($base-color, $hue: 8, $saturation: -4%, $lightness: -15.5%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%);
$text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%);
$text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%);

@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
$border-bottom: grayscale($border-bottom);
$border-sides: grayscale($border-sides);
$border-top: grayscale($border-top);
$inset-shadow-hover: grayscale($inset-shadow-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
$text-shadow-hover: grayscale($text-shadow-hover);
}

@include linear-gradient ($base-color-hover, $stop-gradient-hover);
border: 1px solid $border-top;
border-color: $border-top $border-sides $border-bottom;
@include box-shadow(inset 0 1px 0 0 $inset-shadow-hover);
cursor: pointer;
@include linear-gradient ($base-color-hover, $stop-gradient-hover);
text-shadow: 0 -1px 1px $text-shadow-hover;
-webkit-background-clip: padding-box;
}

&:active {
$active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%);
$border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%);
$active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%);
$border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%);
$border-bottom-active: adjust-color($base-color, $hue: 11, $saturation: 6%, $lightness: -31%);
$inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%);
$text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%);
$inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%);
$text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%);

@if $grayscale == true {
$active-color: grayscale($active-color);
$border-active: grayscale($border-active);
$border-bottom-active: grayscale($border-bottom-active);
$inset-shadow-active: grayscale($inset-shadow-active);
$text-shadow-active: grayscale($text-shadow-active);
}

background: $active-color;
border: 1px solid $border-active;
Expand Down

0 comments on commit e679332

Please sign in to comment.