You are here

function colors_build_css in Colors 7

Same name and namespace in other branches
  1. 8 colors.module \colors_build_css()

Builds a CSS string based on a selector and a color configuration.

Parameters

$selector: The selector used to build the CSS string.

$colors: The color configuration used to build the CSS string.

Return value

The constructed CSS string.

1 call to colors_build_css()
colors_create_css in ./colors.module
Retrieves or generates a CSS file with a given module's selector.

File

./colors.module, line 336
Provides an API to match selectors with a color configuration.

Code

function colors_build_css($selector, $colors, $module = 'colors', $default_colors = array()) {

  // Fetch color mapping.
  $color_mapping = colors_invoke($module, 'colors_get_color_mapping');
  if (empty($colors)) {
    if (empty($default_colors)) {
      return;
    }
    $colors = $default_colors;
  }

  // Rewrite the selector if needed
  $css = colors_invoke($module, 'colors_build_selector', drupal_html_class($selector));
  $css .= ' {';
  foreach ($colors as $option => $color) {
    $css .= $color_mapping[$option] . ': ' . $color . ';';
  }
  $css .= ' } ';
  return $css;
}