backdrop-contrib / recipes

Recipes are collections of configuration files to make our lives easier :)
GNU General Public License v2.0
0 stars 3 forks source link

Use Recipes Module to Manage CSS for Recipes #4

Open stpaultim opened 3 weeks ago

stpaultim commented 3 weeks ago

@hosef and I recently discussed an idea that might work well as part of this module.

Assumptions:

  1. That one definition of what makes a recipe a recipe is that upon installation it adds and modifies configuration and then it's job is done. It could be disabled and unistalled and the recipe will continue to work as expected.
  2. One of the biggest limitations for this model is the inablity to include css with the recipe to make the content and configuration of the recipe look good. Including CSS with a recipe would normally require that the module continue to be enabled.

Proposal:

That one function of the Recipe module is that it tracks and manages css files for recipes. That upon installation of a recipe, the Recipe module checks a predetermined location in the recipe file structure for css files. If a css file exists, that css file is moved to the files folder and then managed by the Recipe module.

The Recipe modules would then do the following:

  1. Use something like hook_preprocess_page to add a unique class to the body field for each recipe, to make it easier to add css specific to a recipe without conflicts.
  2. Make sure that the css files for each active recipe are loaded.
  3. Track the css files that have been loaded by recipes, allowing a site manager to disable or delete any of them in the future, if they are no longer needed.

The idea here is that all recipes could/should includes a dependency on the Recipe module, which allows them to turn over management of any css they need to the Recipe module, making the recipe itself unnecessary after installation.

The functionality proposed here is different from the currently proposed functionality (which is unfinished). Maybe, we could release the Recipe module with the functionality proposed here ASAP and then add the originally intended functionality at a later date.

Or the functionality proposed here could be built into a completely different module.

In my opinion, this functionality (described here) would be relatively easy to implement and would help us move recipes along.

stpaultim commented 3 weeks ago

My thoughts. As someone who has been putting a lot of time into the idea of recipes, I think this would address one of my biggest frustrations and help us settle on a clear definition of a recipe as something that can be disabled.

This might also allow for something that @hosef has called micro themes. Micro themes, would simply be a kind of recipe that provides styles for a specific component(s) on a site. Example: a micro theme recipe, might include a small css style sheet that simply makes changes to the header or footer region of a site.

This micro stylesheet could be distributed as a recipe and the style sheet managed by the recipes module. These micro-themes could be enabled or disabled in the UI of the Recipe module.

olafgrabienski commented 3 weeks ago

Have you considered or even tried to use the CSS Injector module to provide CSS styles for a recipe? (If that works, it's an interesting alternative, in my opinion.)

stpaultim commented 3 weeks ago

@olafgrabienski

We have discussed the possibility of using CSS injector with Recipes. It has been my intention to at least test that method as a possibility. Off hand, I'm not certain how CSS Injector stores the CSS and how easy it would be to pass along CSS from a Recipe into CSS injector.

Having said that. I'm pretty sure, that the solution I'm suggesting here would be a BETTER solution for recipes in the long run. But, using CSS injector might be a good interim solution.

These recipes are targeted at Site Architects and I do like the idea of providing them with a UI to make changes to the CSS for a recipe.

It's on my list to experiment a bit with this as an option.