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

Overwrite module defined patterns on theme layer #160

Open steffenr opened 6 years ago

steffenr commented 6 years ago

We want to build "kind-of" base components/ ui_patterns in a module. Those patterns can be used "as is" or can be overridden on theme-layer. Best example for such a usecase would be a slider - default would be a slick slider. The slider is fine for most cases, but in some special cases, we want to use a custom library for the slider in our theme. Instead of using a hook alter function or creating a new pattern, the theme-dev would just duplicate the pattern in the theme and change the libraries definition.

Right now the discovery is scanning for theme related files first and adds module defined patterns second. This could be easily changed. This should not break anything by the module.

I already created a small PR fixing this issue. #159 #

jigarius commented 5 years ago

I am facing a similar issue.

It will be great to support such overrides.

jigarius commented 5 years ago

I investigated the issue and ultimately it boiled down to something similar to PR 159. My solution ensures that the overrides get priority as follows (the one at the top gets least priority):

With this, one should be able to have some out-of-the-box patterns in a module or a base theme with the provision of overriding them in the project-specific theme.

It'll be great if you could review it soon (and the other PR I created for adding a menu link item for the ui pattern library page).

jigarius commented 4 years ago

Any luck with this one? I've used this on 3-4 prod projects. It'll be good if you could review and merge it.