public function GridStackStylizer::rootStyles in GridStack 8.2
Builds aggregated styles based on the provided settings.
This is not saved to public directory due to too small a portion. Not a big deal, as it is always unique to an edited page, not re-usable. Aside it is recommended by lighthouse relevant for the above-fold rules.
File
- src/
GridStackStylizer.php, line 211
Class
- GridStackStylizer
- Implements GridStackStylizerInterface.
Namespace
Drupal\gridstackCode
public function rootStyles(array &$element, array $styles, array $settings) {
if ($rules = $this
->style()
->parseStyles($styles, TRUE)) {
$css = implode('', reset($rules));
$element['#attached']['html_head'][] = [
[
'#tag' => 'style',
'#value' => $css,
'#weight' => 1,
],
'gridstack-style-' . key($rules),
];
if (!empty($settings['_ipe'])) {
$element['#attributes'] = isset($element['#attributes']) ? $element['#attributes'] : [];
$this
->builder()
->rootAttributes($element['#attributes'], $styles);
}
}
}