Closed (fixed)
Project:
Drupal core
Version:
9.0.x-dev
Component:
theme system
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
2 Mar 2020 at 19:22 UTC
Updated:
23 Mar 2020 at 14:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bnjmnmEvaluation of the five functions in stable.theme
☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️
stable_preprocess_links()There was already agreement in #3097890: Remove all @deprecated code in core themes that this was unnecessary for Drupal 9. It was not removed because it should remain in Stable. It will not be part of Stable 9 and is not necessary for core themes.
☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️
stable_preprocess_image_widget()Added in #3033279: Move markup from template_preprocess_image_widget to a template. This adds file size to file-link templates inside of image widgets. That issue mistakenly added file_size whenever present to core's file-link template, something that is also occurring in Claro, which prompted this followup: #3117430: file-link template should not always display file_size.
The approach of stable_preprocess_image_widget() is not ideal (adding markup in #suffix), but a more elegant solution is not straightforward enough to be in-scope for this issue. Unfortunately, this means copying this not-perfect approach to Umami, Bartik and Seven (with a @todo for the issue aiming to find a better solution). @lauriii agreed that the more elegant solution is best applied in a different issue.
☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️☠️
stable_library_info_alter()stable_element_info_alter()stable_process_text_format()These three were added in #2881212: Formatting guidelines toggle script relies on Classy selectors. This issue removed CSS styling and class additions from filter.module that should have been included in the theme layer. These functions were added to stable.theme so the changes in filter.module didn't break BC.
I opted for an approach that did not use functions in the .theme file.
- The class additions are now done in new templates for filter-wrapper, filter-guidelines, and filter-help (note that the .filter-list class added in Stable did not need to be addressed as this class isn't targeted anywhere).
- A new /filter library was added to each theme, and configured to extend both of core's filter libraries. In Seven, Bartik and Umami, a copy of filter.admin.css is used by this library. Claro uses the CSS that was previously overriding Stable's copy.
Comment #3
lauriii+1 for cleaning this up in #3117430: file-link template should not always display file_size.
Why do we have to check if the suffix has been already set?
Comment #4
bnjmnm#3 right, it's unnecessary to check the suffix since it's being overwritten, not appended.
Comment #5
lauriiiTested manually on a node form with all themes (Umami, Bartik, Seven, Claro). Both, formatted text and image / file upload widgets seem to work as expected. I also double checked that all themes have template override for
file-link.html.twigto make sure that the filesize isn't rendered twice.Comment #6
bnjmnmAs an additional assurance, I tested this for regressions with Wraith with all four core themes. I checked admin/content (for the preprocess_links() removal) and with a node edit page that covers the other elements impacted in this issue: an already uploaded image that displays file size and a body field with text filter. No differences were spotted.
Comment #7
bnjmnmHere's an attempt to make the choices in this patch more easily understood.
First, I've attached a version the patch from #4, but created using
diff -C -C origin/9.0.x ...instead of justdiff origin/9.0.x .... This makes it clearer that filter.admin.css was copied from Stable to Bartik, Umami, and Seven, with the only changes being image paths. However, this also results in a patch that reports that the newcontainer--text-format-filter(something).html.twigtemplates are copied from media library. This isn't the case -- they are just quite similar.Here's a summary of what was done for each function that needed functionality replicated in core themes:
stable_library_info_alter()adds the filefilter.admin.cssto two libraries:filter/drupal.filter.admin, andfilter/drupal.filternfilter.admin.cssas it has its own filter styling. However, it was necessary to change how Claro loaded its filter styling. Previously, it did so by overriding the request for Stable's filter.admin.css. Since that asset will no longer be loaded, Claro now loads filter.admin.css via a newly-createdclaro/filterlibrary, which loads as an extension of core's filter libraries<code>filter/drupal.filter.admin: - claro/filter filter/drupal.filter: - claro/filterfilter.admin.css, which is loaded via a new(themename)/filterlibrary that load as an extension offilter/drupal.filter.adminandfilter/drupal.filterstable_element_info_alter()addsstable_process_text_format()as a #process callback for filter elements. This callback adds classes to several parts of the filter.TextFormat.phpwas updated so the text format element recognizes three new templates: container--text-format-filter-wrapper, container--text-format-filter-help, container--text-format-filter-guidelines. These three templates are where the elements get the classes.filter-wrapper, .filter-help, .filter-guidelinesstable_preprocess_image_widget()adds file size markup to the file-link element in the render array #suffixComment #8
alexpottI've looked for differences in the theme out but can't find any. This looks good and the next step on the path towards decouple all the themes from stable.
Committed 5c5ca6d and pushed to 9.0.x. Thanks!