ausybenelux / Ocelot

Ocelot is a theming starter kit for drupal 7.
5 stars 2 forks source link

Simple helpers for maps #203

Closed sqndr closed 8 years ago

sqndr commented 8 years ago

Since the colors and timings are now sass maps, let's include some functions to get the colors and timings.

Example:

@function get-color($color) {
  @if map-has-key($color-scheme, $color) {
    @return map-get($color-scheme, $color);
  } @else {
    @error "ERROR: The color is not availible.";
  }
}

Based in this, we could add simple helpers mixins:

/// Mixin to set the background color.
///
/// @group utils
///
/// @param {color} $color - The background color. Note: This can only be a
/// variable from the color schema.
@mixin bg-color($color) {
  background-color: get-color($color);
};

/// Mixin to set the text color.
///
/// @group utils
///
/// @param {color} $color - The text color. Note: This can only be a
/// variable from the color schema.
@mixin text-color($color) {
  color: get-color($color);
};
rob-bar commented 8 years ago

Yeah that is a good idea, only the syntax should be as short as possible. get-color should be color() and it can be placed as a shortcut in shortcuts.scss. In shortcuts that color function should use the mg shortcut and the check @if map-has-key($color-scheme, $color) { should be in the mg function :+1: for color shortcut :-1: for the text-color bg-color because there is no added value here, correct me if there is an advantage. With this we introduce 3 lines of code in the baserepo to output one-line of css. This feels like overkill.

a background color or color can just be.

background-color: color(name);
color: color(name);
sqndr commented 8 years ago

:+1:

Let's leave the mixins out. Valid reasoning!

rob-bar commented 8 years ago

Will close this one....see https://github.com/Crosscheck/Jacket/issues/4