Problem/Motivation
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.
As part of SDC's roadmap (see #3345922: Single Directory Components module roadmap: the path to beta and stable), we want to convert an Umami component to use SDC. For this task I'm choosing the card view mode component, which includes markup and CSS.
Testing instructions
Make sure you have SDC module enabled, if enabling via drush si demo_umami it will be installed by the profile
Clear caches
Test umami footer blocks - you should see HTML like the screenshot below showing that the block is being rendered via a component.

Components description
Common Footer Block contains:
1. Optional image
2. Title
3. Content
Title component contains:
1. specific Drupal properties: title_prefix, title_suffix
2. optional html tag as property
3. In the future, it will allow us to control the typography of the site through css classes. EG: `.umami-title--h1 {}` what is better that `h1 {}`
In terms of BEM: https://en.bem.info/methodology/quick-start/#block `You also shouldn't use CSS tag or ID selectors when using BEM.`
Optional follow up
Create follow up issue for footer menu, Which seems equal in terms of CSS with recipe tags list over this footer.
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | Screenshot 2023-10-01 at 7.16.30 PM.png | 433.36 KB | smustgrave |
| #33 | Screenshot 2023-10-01 at 7.16.22 PM.png | 507.67 KB | smustgrave |
| #26 | Screenshot 2023-09-05 at 10.48.45 AM.png | 389.47 KB | smustgrave |
| #26 | Screenshot 2023-09-05 at 10.48.08 AM.png | 461.36 KB | smustgrave |
Issue fork drupal-3368102
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:
- 3368102-create-new-sdc
changes, plain diff MR !4695
Comments
Comment #2
gauravvvv commentedI have attached the patch with new component for menu footer. please review
Comment #3
smustgrave commentedVerified on 11.x that the block renders the same as before.
Comment #4
lauriiiShould we remove comments here? Seems like a lot to include all of this in every component.
Shouldn't configuration be documented in the schema? Wondering if this should be triggering schema validation 🤔
Should we use
onlyhere to avoid passing down context?Comment #5
gauravvvv commentedAddressed feedback in #4, attached interdiff for same. please review
Comment #6
smustgrave commented+{{ dump(configuration)}}Comment #7
gauravvvv commentedRemoved dump, attached interdiff. please review
Comment #8
smustgrave commentedSeems points in #4 have been addressed.
Comment #9
e0ipsoMy main concern is about coupling between the component and the host template. This is an issue that happens when refactoring existing code, and will likely be less so when writing components from scratch.
$schema: https://git.drupalcode.org/project/drupal/-/raw/10.1.x/core/modules/sdc/...
It took me a moment to find this, so I am posting it.
https://www.drupal.org/docs/develop/user-interface-standards/interface-t...
It seems this is the correct capitalization (sentence like), according to our style guide.
Accordig to the use of this below, this is not an array but an object.
Also, I believe we should simplify this and skip this. This couples the component to a block, which is not desirable. Moreover, this is only used to build up a set of classes.
IMHO we should have a prop that allows the host template pass additional classes if we need them. Hence the block will send the provider, but something else will not.
Same principle applies to the plugin_id.
This is an invalid key. Slots do not provide an schema, only some basic metadata.
Maybe replace with:
The menu-footer.css should be free of references to host template classes.
The internal component template should be independent from where it's placed. IMO we should not reference Drupal constructs like "block", or "menu".
This same comment may apply elsewhere in the patch.
Here we are not passing the content slot as a twig block, instead we are passing it as an undocumented prop.
Also, we should use the simplified syntax when the label and the name of the variable are the same.
becomes
Comment #10
gauravvvv commentedI have addressed above feedback, only point 6 is left. Attached interdiff for same
Comment #11
smustgrave commentedFor point 6 in #9 didn't test yet.
Comment #14
finnsky commentedWhat i see now. We have
- 2 footer blocks which contains title and content
- 2 equal menus (footer menu and recipe tags)
Will try with this approach
Comment #15
finnsky commentedPushed footer block. Gonna check menu in separated commit.
Comment #16
finnsky commentedComment #17
smustgrave commentedCC failure.
Also if #3367152: Create new SDC component for Footer promo is being combined will need an issue summary update.
Comment #18
finnsky commentedAdded `blockfooter` to CSpell dictionary.
Comment #19
andypostThere's already
blockrecipein dictionary so it's ok to update it with new blockComment #20
andypostComment #22
smustgrave commentedClosed #3367152: Create new SDC component for Footer promo as a duplicate.
Tagging for issue summary update now.
Comment #23
finnsky commentedComment #24
finnsky commentedComment #25
finnsky commentedComment #26
smustgrave commentedBefore
After
So only difference I see is that the image is smaller but actually seems better. Think this is good.
Comment #27
lauriiiPosted comment on the MR
Comment #28
smustgrave commented@lauriii this good to be marked back to RTBC?
Comment #29
smustgrave commentedGoing to remark but if you get a chance @lauriii
Comment #30
lauriiiMoving to needs review to resolve the discussion in the MR
Comment #31
finnsky commentedComment #32
smustgrave commentedBelieve random familiar. Rerunning tests.
Comment #33
smustgrave commentedAs I thought was random
Before
After
May need submaintainer sign off but the image changed in sign, see before/after screenshots. But personally I think it looks better and actually shows the full image, so marking it.
Comment #34
finnsky commentedRebased.
Comment #35
e0ipso+1 that the image looks better now.
Comment #39
lauriiiCommitted 0852886 and pushed to 11.x. Also cherry-picked to 10.2.x. Thanks!