nuvoleweb / ui_patterns

[NOTE] Development has moved to https://drupal.org/project/ui_patterns
https://drupal.org/project/ui_patterns
GNU General Public License v2.0
85 stars 56 forks source link

The logic of the module does not correspond to SMACSS #324

Open kvantstudio opened 3 years ago

kvantstudio commented 3 years ago

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;
    }
  }
}
geek-andi commented 2 years ago

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