Skip to content

Commit

Permalink
Syntax change
Browse files Browse the repository at this point in the history
  • Loading branch information
triblondon committed Feb 19, 2014
1 parent 9a6266e commit 77ebda2
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 152 deletions.
19 changes: 8 additions & 11 deletions main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ $o-colors-is-silent: true !default;

// Output use case placeholders and (if noisy) concrete classes
@each $usecase in $o-colors-usecase-list {
$selector: 'o-colors-' + nth($usecase,1);
@if (nth($usecase,2) != default) {
$selector: $selector + '--' + nth($usecase,2);
}
$selector: 'o-colors-' + nth($usecase,1) + '-' + nth($usecase,3);
@if (not $o-colors-is-silent) {
$selector: $selector + ', .' + $selector;
}
%#{$selector} {
@if nth($usecase,4) == text {
color: _oColorsGetPaletteColor(nth($usecase,3));
} @else if nth($usecase,4) == background {
background-color: _oColorsGetPaletteColor(nth($usecase,3));
} @else if nth($usecase,4) == border {
border-color: _oColorsGetPaletteColor(nth($usecase,3));
@if nth($usecase,3) == text or nth($usecase,3) == all {
color: _oColorsGetPaletteColor(nth($usecase,2));
} @else if nth($usecase,3) == background or nth($usecase,3) == all {
background-color: _oColorsGetPaletteColor(nth($usecase,2));
} @else if nth($usecase,3) == border or nth($usecase,3) == all {
border-color: _oColorsGetPaletteColor(nth($usecase,2));
}
}
}
Expand All @@ -35,4 +32,4 @@ $o-colors-is-silent: true !default;
%#{$selector} {
background-color: #{nth($color,2)};
}
}
}
35 changes: 21 additions & 14 deletions src/scss/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,38 @@
}
}
@warn "Undefined color '" + $name + "' used";
@return black
@return black;
}

@function _oColorsGetUseCase($name, $variant) {
@function _oColorsGetUseCase($name, $property) {
@each $usecase in $o-colors-usecase-list {
@if (nth($usecase, 1) == $name and nth($usecase, 2) == $variant) {
@if (length($usecase) == 5) {
@if(nth($usecase,5) == DEPRECATED) {
@warn "Deprecated use-case name '" + $name + "', variant '" + $variant + "' used";
}
@if (($property and $name == nth($usecase, 1) and $property == nth($usecase, 3)) or (not $property and $name == nth($usecase, 1) + '-' + nth($usecase, 3))) {
@if (length($usecase) == 4 and nth($usecase,4) == DEPRECATED) {
@warn "Deprecated use-case name '" + $name + "', variant '" + $variant + "' used";
}
@return _oColorsGetPaletteColor(nth($usecase,3));
@return _oColorsGetPaletteColor(nth($usecase,2));
}
}
@return undefined;
}

@function oColorsGetColorFor($name, $variant: "default") {
$color: _oColorsGetUseCase($name, $variant);
@if ($color == undefined) {
$color: _oColorsGetUseCase($name, default);
@function oColorsGetColorFor($namelist, $property: null) {
$color: undefined;
@each $name in $namelist {
@if ($color == undefined) {
$color: _oColorsGetUseCase($name, $property);
}
@if ($color == undefined and $property != null) {
$color: _oColorsGetUseCase($name, all);
}
}
@if ($color == undefined) {
@warn "Undefined use-case: name '" + $name + "', variant '" + $variant + "' used";
$error: "Undefined use-case: can\'t resolve '" + $namelist + "' to a colour";
@if ($property) {
$error: $error + " for property '" + $property;
}
@warn $error;
$color: black;
}
@return $color;
}
}
Loading

0 comments on commit 77ebda2

Please sign in to comment.