- Issue created by @alemadlei
- πΊπΈUnited States mherchel Gainesville, FL, US
I want to give a hearty +100 to this. It's something that I've been thinking about for a while.
Updating IS with next steps
- Find out who needs to give sign off
- Get sign off on the initial idea
- Figure out technical implantation (this will require DA staff as well as core changes)
- πΊπΈUnited States thejimbirch Cape Cod, Massachusetts
This has been asked of us many times in the recipes realm. Recipes themselves don't have anything to do with Single Directory Components (SDC), but could require them using the recipe's composer.json file. The dependency for that requirement could be unpacked to the project's composer.json file so it would be have like a contrib project and would be updatable from the source.
I assume you wouldn't need to do anything to SDCs to make that work. Just make them available from a composer or asset packagist.
If Drupal defines a new package type, say
drupal-sdc
, you would then want to open an issue with composer/installers to add that package type. Here is the drupal-recipe pull request for reference.You would then need to define a place to put the SDCs. With recipes, we did that by adding an installer-path to the drupal/recommended-project and drupal/legacy-project composer templates π Add support for recipes to drupal/recommended-project and drupal/legacy-project Fixed .
"Change the discovery mechanism for SDC." sounds like the perfect description for that last step and far from my expertise to comment on.
Love this idea!
- πΊπΈUnited States sea2709 Texas
I see that many components using variables from the theme, especially theme's colors, font styles, etc.. Just wondering, if components are something separate from the theme, will we need to have some guidelines or standards about how to define variables or how to pass variables from theme to components. Just want to share my thoughts!
- π¨π·Costa Rica alemadlei
Hey sea2709,
That's one way to implement it, however, you could also try to define broad CSS variables with default values or use CSS layers so that they are easy to override.
Some people also use Tailwind when defining their components, and those clases are standardized elsewhere.
- πΊπΈUnited States sea2709 Texas
you could also try to define broad CSS variables with default values or use CSS layers so that they are easy to override.
Yeah, this is what I meant, we need to have a guidelines about how to build outside / dependent components to make them work well with themes later on.
One more thing came across my mind is when we have a set of base components and apply these components for different projects. So there might be a chance that we want to add more properties, more slots for components. From what I understand, we don't have this ability at this moment, the way we do is to replace a component by another component in case we want to extend it.
- e0ipso Can Picafort
I know that I could create a theme or module and them have my components there, but it kind of feels like an unnecesary / annoying requirement.
When we were on the drawing board, this was considered. However it was discarded because Drupal does not have a way to deal with name collisions in composer packages. It does however have one for modules. This way we were able to reliably determine the component prefix.
The important question here is: why does it feel like an unnecesary / annoying requirement?
I'd like to clarify this part of the IS before moving forward with this.
- π¨π·Costa Rica alemadlei
Hi e0ipso,
So my train of though is as follows:
* The way I write SDC I try to avoid dependency to other Drupal things. I know they are flexible enough so that you can build them any way you want, but I try to have them be completly agnostic regarding what environment they are in (my larger goal is that maybe I could use them on Wordpress or Laravel projects in the future).
* Having a theme wrapper or a module wrapper to just include a components folder kind of feels (and I know this is my own opinion) unncesesary because you are not adding anything else other than the components folder.
* Recipes right now are something that don't require a module or theme to be created. They exist and they can be used in a project by running the script. Related to recipes, checking the Drupal source, once installed recipes have their own folders, no need for modules or themes. So I feel kind of envious towards that, and think that SDCs could also have their own folder for contrib and custom. That way they can be shared trough composer or custom repositories.