Problem/Motivation

As part of our roadmap to stable (#3345922: Single Directory Components module roadmap: the path to beta and stable), we want to include some Single Directory Components into Drupal core's front-end facing themes.

Let's have this issue to track all the efforts in this direction. Ideally, we'll have one issue per attempted component linked as a children to this one.

Instructions

  1. Create a new issue for Drupal core with the title: Create new SDC component for Olivero (name). Make sure to change name to the actual component's name.
  2. Paste the Component Issue Template, and fill in the specifics about the chosen component.
  3. Add the SDC Sprint DrupalConNA 2023 tag to the issue, if you are creating it during DrupalConNA 2023.
  4. Add the newly create issue as a child of this issue. And leave a comment here.

Component Issue Template

<h3 id="summary-problem-motivation">Problem/Motivation</h3>
Single directory components (SDC) is a new way to theme Drupal. Instead of scattering related files around your theme, they're contained to one directory. The primary issue for SDC is at #3313520: Single-directory components in core.

This issue is postponed on #3352256: Move code from the experimental SDC module to core, since we cannot make Olivero depend on an experimental module. In any case, this issue can (and should) be worked in parallel.

<h4><em>Name</em> component</h4>

As part of SDC's roadmap (see #3345922: Single Directory Components module roadmap: the path to beta and stable), we want to convert Olivero components to use SDC. For this task I'm choosing the <em>Name</em> component, which includes markup, CSS, and JS.

This component is a good fit because: <em>enter details</em>

This component involves the following Twig templates, CSS, JS, assets, and libraries:

<ol>
  <li><em>List involved files and systems here</em></li>
</ol>

<h3>Testing instructions</h3>

<ol>
  <li><em>Add testing instructions here.</em></li>
  <li><em>Point out any automated tests that cover this component's refactor.</em></li>
</ol>

Issue fork drupal-3364672

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

e0ipso created an issue. See original summary.

e0ipso’s picture

Issue summary: View changes
e0ipso’s picture

I added the, previously existing issue, #3347235: Create new SDC component for Olivero (tabs) as a child to this one.

e0ipso’s picture

Issue summary: View changes
dieterholvoet’s picture

Component: render system » Olivero theme
xmacinfo’s picture

Any dependency between Olivero and SDC must be optional so that a user is not obligated to enable SDC just to use Olivero or take Olivero as a base theme.

xmacinfo’s picture

I'd prefer that you create a clone of Olivero rather than force Olivero to use SDC.

xmacinfo’s picture

As I mentioned in other SDC issues, SDC should always be optional and not enabled by default by any existing core theme or core modules.

xmacinfo’s picture

As I mentioned in another ticket, when using Olivero as a base theme, will we be able to remove some or all SDC components and replace those with regular Twig templates?

In general SDC components are welcome. But I still expect to use the current theme layer as is, even if I use Olivero as a base theme. We may still built themes with or without SDC components. But if Olivero is forcing us to use SDC, some of us will not be able to use Olivero as a base theme.

e0ipso’s picture

@xmacinfo it was decided, a long time ago, that single directory components are the way to approach components in Drupal core, and that core will recommend this approach for contrib, and custom modules and themes. This decision is beyond the scope of this ticket and can be reviewed at length in #3313520: Single-directory components in core and #3340712: Add Single Directory Components as a new experimental module. If you disagree, or want to revise this decision, please open a new issue with that as its clear goal. I will be happy to engage there as well.

However, since I don't want to leave you hanging until that issue happens (or not), I will address your comments here.

With that context in mind:

I'd prefer that you create a clone of Olivero rather than force Olivero to use SDC.

If Olivero is to benefit from components, it shoudl do so by using SDC (as per the decision above). We can argue weather or not Olivero benefits from components, this would definitely be in scope for this issue. I do believe it does, but I think Olivero maintainers like @mherchel can elaborate better on this, since he has already given his go ahead on this.

With regards to creating a clone, I don't think it's feasible to maintain two exact themes in core, but again this is a conversation to be had with others since I will not be on the hook for maintaining this hypothetical clone.

As I mentioned in other SDC issues, SDC should always be optional and not enabled by default by any existing core theme or core modules.

I see in our profiles that English is not the first language of either of us. I am interpreting the use of "should" here as "my preference is". Let me know if that is wrong.

Can you share your rationale of why this is your preference? Bear in mind that the community has already decided, through the appropriately painful :-P channels, that the way to do components in core is using SDC and not an alternative approach.

Obligatory reminder here is that no module or theme can enable or disable SDC more that it can enable or disable Form API, the routing system, or the batch API. These are tools that are baked into core itself.

But if Olivero is forcing us to use SDC, some of us will not be able to use Olivero as a base theme.

I am also intrigued about this. What is the reason that will make it impossible for you not to use SDC? Is it personal preference, or is it something else I am missing?

will we be able to remove some or all SDC components and replace those with regular Twig templates?

In the end Twig will still be the render engine (if you choose to keep it), so you can override the templates that embed the components to include your twig templates. For that you'll need to copy the templates of the components being embedded, create the libraries manually, and then attach them. All of that can live in your theme, the one that extends from Olivero.

Keep in mind that SDC, and the policy to use it in core, is not designed to ease the process of getting rid of it. If you feel strongly that it should, I encourage you to create an issue to that end that explains the reasons of why you think many people should want to remove SDC.

xmacinfo’s picture

I see in our profiles that English is not the first language of either of us. I am interpreting the use of "should" here as "my preference is". Let me know if that is wrong.

The way I use “should” is to to indicate correctness, like in English. In French “should” = “must”, which misses some nuances between the two.

In other words, we, the Drupal community, should let developers use SDC or plain Twig templates. Thankfully, we can already do that. 😀

As a developer, and when chatting with other developers, we do not always want or need to use a components system; we create a bunch of templates and add CSS/JavaScript and that's it. However, most front-end devs (we can include themers) prefer using well define reusable components. That was, until now, hard to do in Drupal, and varied a lot between developers and themes teams. SDC helps standardizing components usage and their documentation and will push Drupal to new levels. I agree with that.

The core community wants standards and good documentation. I agree with that.

So the problem, which is not a problem, is, as a developer, do I create Twig templates as I did since Drupal 8 and use a few CSS files loaded through libraries, and be done with it, or I am forced to use the new SDC. This is not a problem as you told me. 😀

When building a custom them, we (the dev team on that project) will be able to use either SDC or plain old Twig templates.

Which leads to base themes. Can we use a base theme built on SDC (here I think about Olivero) and replace, let’s consider, component A and B and replace those with plain old Twig templates? If yes, then my problem is solved and I need not worry anymore.

I like Olivero so much that I use it as a base theme.

martijn de wit’s picture

xmacinfo did you already try the new theme/template generator in Drupal ? aka starterkit_theme

xmacinfo’s picture

@Martijn de Wit

Yes, I did. But that does not create a theme inheriting from a base theme.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adanbouzoua made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.