10000 592 move components to use new single directory components module by ctorgalson · Pull Request #598 · localgovdrupal/localgov_base · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

592 move components to use new single directory components module #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ctorgalson
Copy link
Contributor

For the moment, this does the following:

  1. declares drupal:SDC as a theme dependency
  2. adds a replacement localgov_base:prev-next component at components/prev-next/
  3. adds a replacement localgov_base:icon component at components/icon/
  4. replaces theme template icon.html.twig with localgov:icon in new localgov_base:prev-next component only
  5. replaces all localgov_base uses of prev-next.html.twig with the new localgov_base:prev-next component
  6. marks "DEPRECATED" but retains css/components/prev-next.css
  7. marks "DEPRECATED" but retains templates/_components/prev-next.html.twig

How to test

Verify that no style or functional changes have crept-in. Mostly, this PR consists of moving twig templates and css, and updating other twig templates to reflect the new locations.

How can we measure success?

We can check that the expected markup/behaviour is present at content pages using each of the templates consuming the new component (obviously these changes don't exist on the live demo site):

The changes here also anticipate that subthemes and other modules may be directly consuming the existing files and does not remove them.

Have we considered potential risks?

Images

The markup and CSS are identical to what's currently in production.

Accessibility

No changes of this kind have been made.

Slightly changes the API to make it easier to use elsewhere without
needing to rely on the subdirectory structure of localgov_base:
icon_path in this version is a namespaced string representing the
*complete* path to the directory that actually contains the required
icons.

Existing template left in place and probably will be even if we replace
it in all localgov_base usage since we don't know what subthemes rely on
it.
It's present in core now, but it's not automatically enabled. Since this
branch requires it, it must be declared as a theme dependency.
Officially, these will be superseded by localgov:prev-next, though
they'll presumably be retained for a time because we don't know which
sub-themes/modules may have used them directly.
The Twig is largely identical to the original, with only a little
regularization of variables, and use of the new localgov_base:icon SDC
component.

The CSS is unmodified.
To test, load LGD demo content from
/births-deaths-marriages-and-citizenship/marriage-and-civil-partnerships/step-by-step/get-married-4
Test using LGD demo content
/publications/publications-cover-page-demo-content/petitions-scheme-publications-demo-content
SDC enforces data types, so this is now unneeded.
@ctorgalson ctorgalson marked this pull request as draft August 29, 2024 13:43
@ctorgalson
Copy link
Contributor Author
ctorgalson commented Aug 29, 2024

@markconroy here's my first attempt. The TL;DR is:

  • I added the new component
  • I didn't remove the existing components
  • I created a replacement for icon.html.twig but only used it inside the new component (a future issue/PR could address the continuing use of icon.html.twig by localgov_base)
  • we need to decide how to address the localgov disable css setting

@markconroy
Copy link
Member

Thanks Christopher.

For the "Icon" component, is there any issue with sites (sub themes) that currently use the icon template? I'm guessing they are using something like

@include {% @localgov_base/inclues/icon.html.twig %}

But now that will update to something like

@include {% localgov_base:icon with ... %}

Does that mean we are going to break current sites?

@ctorgalson
Copy link
Contributor Author

@markconroy That's why I left the original files in place with a big DEPRECATION comment at the top.

I could also update icon.html.twig to use the new SDC.

@ctorgalson
Copy link
Contributor Author
ctorgalson commented Aug 30, 2024

@petrillek pointed out to me that I've been rashly passing variables through twig 🙄. I'll correct that on Monday.

@ctorgalson
Copy link
Contributor Author

This sh 8000 ould stay in draft status for the moment: there's an issue with variable data types in *.component.yml that makes it easy to get a wsod.

@ctorgalson
Copy link
Contributor Author

This should stay in draft status for the moment: there's an issue with variable data types in *.component.yml that makes it easy to get a wsod.

I've fixed that up, as well as converting the add-to-calendar template/library to a new SDC.

As with the other component, I've left the existing template and library files in place but added a DEPRECATED notice at the top of each file: so localgov_base doesn't currently use these, but sub-themes that do won't be impacted.

@ctorgalson ctorgalson marked this pull request as ready for review September 4, 2024 09:49
@ctorgalson
Copy link
Contributor Author

Not sure what's going on in that failing test; seems unrelated.

The component works without this, but only because _other_ code requires
the same dependencies.
These files were moved into SDCs unmodified. This change removes them
and updates the library definitions to use the files within the SDCs.

We retain the deprecation notices on the library definitions since we'd
like theme-users to use the SDCs.
The relevant library now uses the SDC component's js directly.
@stephen-cox
Copy link
Member

Discussing at Merge Tuesday - with @markconroy to review

@ctorgalson
Copy link
Contributor Author

Thanks @markconroy. Been moving recently and lost the plot with these issues :)

@markconroy
Copy link
Member

No worries @ctorgalson

It's a bit of a large issue to get the head back into after not looking at it for a while.

@markconroy
Copy link
Member

@ctorgalson I think this is ready to merge.

Do you want to give it a final test (especially as I have removed SDC as a dependency since it's now deprecated).
https://www.drupal.org/docs/core-modules-and-themes/deprecated-and-obsolete#s-single-directory-components-sdc

@ctorgalson
Copy link
Contributor Author

@markconroy The standalone module is deprecated, but don't we need to declare it as a dependency to ensure the core module is enabled?

@markconroy
Copy link
Member

I don't think so, it's now a service or something that in Drupal core, and not a module at all any more, so should "just work". I think it's this file:
web/core/lib/Drupal/Core/Render/Element/ComponentElement.php

I removed it from our localgov_base.info.yml file and cleared the cache and all seemed fine.

Copy link
Member
@markconroy markconroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


Thanks to Big Blue Door for sponsoring my time to work on this.

@finnlewis
Copy link
Member

@markconroy we're a bit scared of this, it looks big! Waiting for your availability to discuss and liaise on the merge and release.

Sounds really cool though! Thanks @ctorgalson

@markconroy
Copy link
Member

It is big. It could open up a whole new paradigm for our frontend system.

We are just testing it here with two components (icon and add-to-calendar) that we could easily revert if needed. Really, all that is happening is that the templates for those things are moving to somewhere else in the theme.

In the future we can move more things, such as "Card view mode" so that if we wanted to have a card template for node and for user and for product and for paragraph etc, they could all extend from the same template. Pretty cool!

@markconroy
Copy link
Member

@ctorgalson Perhaps you could come along to Tech Group Drop-in on Wednesday to help talk through what we are doing with this PR?

@ctorgalson
Copy link
Contributor Author

@markconroy I can. Did it change from Thursday to Wednesday? (If so, can I get the Zoom link from you?)

@markconroy
Copy link
Member

You can register here, so it will pop into your calendar for you - https://lu.ma/g5nsdt8b

@finnlewis
Copy link
Member

To test, install demo on default install and check event content type:

https://localgov.ddev.site/events/sports-player-year-awards-2022

Copy link
Member
@finnlewis finnlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me locally!

@finnlewis finnlewis merged commit 3d401cd into 1.x Nov 28, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0