forked from thoughtbot/bourbon
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored background-image mixin plus better compact function written
in ruby. Works with rails 3.1
- Loading branch information
Phil LaPier
committed
Jul 15, 2011
1 parent
485e74e
commit ac07c99
Showing
8 changed files
with
126 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@function gradient($pos: top, $G1: false, $G2: false, | ||
$G3: false, $G4: false, | ||
$G5: false, $G6: false, | ||
$G7: false, $G8: false, | ||
$G9: false, $G10: false) { | ||
// Detect what type of value exists in $pos | ||
$pos-type: type-of(nth($pos, 1)); | ||
|
||
// If $pos is missing from mixin, reassign vars and add default position | ||
@if $pos-type == color or transparent { | ||
$G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5; | ||
$G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos; | ||
$pos: top; // Default position | ||
} | ||
|
||
$full: compact($G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10); | ||
@return join($pos, $full, comma); | ||
//@return $pos, $full; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ class Railtie < ::Rails::Railtie | |
end | ||
end | ||
end | ||
|
||
require "bourbon/sass_extensions" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Bourbon::SassExtensions | ||
end | ||
|
||
require "bourbon/sass_extensions/functions" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Bourbon::SassExtensions::Functions | ||
end | ||
|
||
%w(compact).each do |func| | ||
require "bourbon/sass_extensions/functions/#{func}" | ||
end | ||
|
||
module Sass::Script::Functions | ||
include Bourbon::SassExtensions::Functions::Compact | ||
end | ||
|
||
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug? | ||
class Sass::Script::Functions::EvaluationContext | ||
include Sass::Script::Functions | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Compact function pulled from compass | ||
module Bourbon::SassExtensions::Functions::Compact | ||
|
||
def compact(*args) | ||
sep = :comma | ||
if args.size == 1 && args.first.is_a?(Sass::Script::List) | ||
args = args.first.value | ||
sep = args.first.separator | ||
end | ||
Sass::Script::List.new(args.reject{|a| !a.to_bool}, sep) | ||
end | ||
|
||
end |