function Helper::accentRadios

Same name and namespace in other branches
  1. 11.x core/themes/admin/src/Helper.php \Drupal\admin\Helper::accentRadios()

Accent color element.

File

core/themes/admin/src/Helper.php, line 84

Class

Helper
Admin helper methods.

Namespace

Drupal\admin

Code

public static function accentRadios(array $element) : array {
  $options = array_keys($element['#options']);
  foreach ($options as $values) {
    // Old way.
    $element[$values]['#attributes']['data-gin-accent'] = $element[$values]['#return_value'];
    // New way.
    $accent_colors = self::accentColors();
    $preset = $element[$values]['#return_value'];
    $element[$values]['#attributes']['style'] = '--accent-base: ' . $accent_colors[$preset]['hex'] . ';';
  }
  return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.