From 440c4566ae5afef73aaa4f13a40a7e5d69187f50 Mon Sep 17 00:00:00 2001 From: Vince Speelman Date: Thu, 29 Aug 2013 10:59:02 -0400 Subject: [PATCH] Add tint-shade-stack color stack allow users to create a stack that includes both shaded and tinted versions of a color. --- compass/stylesheets/toolkit/_colours.scss | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/compass/stylesheets/toolkit/_colours.scss b/compass/stylesheets/toolkit/_colours.scss index 7d77746..78102dc 100644 --- a/compass/stylesheets/toolkit/_colours.scss +++ b/compass/stylesheets/toolkit/_colours.scss @@ -60,6 +60,33 @@ $colour-stack-amounts: $color-stack-amounts !default; } } +@function conjoin($lists, $separator: auto) { + $return: (); + @each $list in $lists { + $return: join($return, $list, $separator); + } + @return $return; +} + +@function tint-shade-stack($colour, $amounts...) { + @if length($amounts) > 0 { + $shaded: colour-stack($colour, black, $amounts); + $shaded-short: conjoin(nth($shaded, 2) nth($shaded, 3)); + $tinted: colour-stack($colour, white, $amounts); + $tinted-short: conjoin(nth($tinted, 2) nth($shaded, 3) nth($tinted, 4)); + $tint-shade-stack: join($shaded-short, $tinted-short); + @return join($colour, $tint-shade-stack); + } + @else { + $shaded: colour-stack($colour, black); + $shaded-short: conjoin(nth($shaded, 2) nth($shaded, 3)); + $tinted: colour-stack($colour, white); + $tinted-short: conjoin(nth($tinted, 2) nth($tinted, 3) nth($tinted, 4)); + $tint-shade-stack: join($shaded-short, $tinted-short); + @return join($colour, $tint-shade-stack); + } +} + ////////////////////////////// // Creates an even scale from one color to another ////////////////////////////// @@ -99,4 +126,4 @@ $colour-scale-shades: $color-scale-shades !default; } @return $list; -} \ No newline at end of file +}