ui_patterns icon indicating copy to clipboard operation
ui_patterns copied to clipboard

The logic of the module does not correspond to SMACSS

Open kvantstudio opened this issue 4 years ago • 1 comments

All components have the CSS_AGGREGATE_DEFAULT group, and must have CSS_AGGREGATE_THEME. The CSS files of the components are loaded before the CSS files of the theme. This is a big mistake! So far, the solution to the problem is the following. Now i use hook_css_alter

function hook_css_alter(&$css, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {  
  foreach ($css as $path => $item) {
    if (preg_match("/templates\/patterns/", $path)) {
      $css[$path]['group'] = CSS_AGGREGATE_THEME;
    }
  }
}

kvantstudio avatar Mar 09 '21 12:03 kvantstudio

I can confirm this. Also setting the smacss in the component library definition - as described in the docs - does not seem to have any effect:

  libraries:
    - lb_columns:
       css:
         theme:
           lb_columns.css: {}

I would be interested if there is any reasoning behind the module behavior. I could think of that components can live in modules or themes so it would probably not appropriate to set component css always to theme.

Find the reference to drupal css architecture: https://www.drupal.org/docs/develop/standards/css/css-architecture-for-drupal-9#separate-concerns

geek-andi avatar Feb 16 '22 11:02 geek-andi