Skip to content

Instantly share code, notes, and snippets.

@stephenway
Created October 8, 2012 23:33
Show Gist options
  • Save stephenway/3855629 to your computer and use it in GitHub Desktop.
Save stephenway/3855629 to your computer and use it in GitHub Desktop.
SASS Variable Image-Gradient

SASS Variable Image-Gradient

Summary

I try to make my themes as customizable by variables as possible. In this gist we setup default variables, then some helper variables and inject pieces of the background mixin based on what has been set in our default variables.

@import "compass/css3/images";
$default-use-box-bg-image: true !default;
$default-use-box-bg-gradient: true !default;
$box-bg-color: #999999;
$box-bg-image: "alt-bg.png"
[role="banner"] {
$box-bg: "" !default;
$gradient-bg: "" !default;
$darker-box-bg-color: darken($box-bg-color, 20);
@if $default-use-box-bg-image == true {
$box-bg: unquote("url('images/#{$box-bg-image}')");
} @else if $default-use-box-bog-image == false {
$box-bg: "";
}
@if $default-use-box-bg-gradient == true {
$gradient-bg: linear-gradient(top, $darker-box-bg-color, $box-bg-color, $darker-box-bg-color);
@include filter-gradient($box-bg-color, darken($box-bg-color, 20));
} @else if $default-use-box-bg-gradient == false {
$gradient-bg: "";
}
@include background($background-1: $box-bg, $background-2: $gradient-bg);
background-color: $box-bg-color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment