Problem/Motivation
core template files should not contain any classes that are not essential for functionality
Proposed resolution
Remove all classes that are not essential to functionality
If a class is used by javascript it must eather be prefixed with .js- or change to a data-attribute as a selector instead.
We want a clean seperation between javascript & css.
If a test fails, make sure its not testing on stark but on classy's template
Twig Templates to modify
- core/modules/system/templates/datetime-form.html.twig
- core/modules/system/templates/datetime-wrapper.html.twig
- core/modules/system/templates/details.html.twig
- core/modules/system/templates/dropbutton-wrapper.html.twig
dropbutton-wrapper is moved to its own issue, as it also contains classerenaming etc see comment #30
Remaining tasks
Visual test on all renamed js- based classes.
rewrite Dropbuttons css so its not depening on js- and its seprated
<div class="js-dropbutton-wrapper dropbutton-wrapper-theme">
<div class="js-dropbutton-widget dropbutton-widget-theme">
....
about classnames
Separate style from behavior by using dedicated classes for JavaScript manipulation rather than relying on classes already in use for CSS. This way, we can modify classes for style purposes without fear of breaking JS, and vice versa. To make the distinction clear, classes used for JavaScript manipulation should be prefixed with 'js-'. These JavaScript hooks must never be used for styling purposes. See the section ‘Formatting Class Names’ for more information on naming conventions.
https://www.drupal.org/node/1887918#separate-concerns
User interface changes
API changes
See parent issue(s) and related issue(s) for details,
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | interdiff-d-6-7.txt | 580 bytes | mortendk |
| #37 | d-7.diff | 1.54 KB | mortendk |
| #1 | issue-2407725-1.patch | 5.1 KB | sivaji_ganesh_jojodae |
| #3 | issue-2407725-3.patch | 4.04 KB | sivaji_ganesh_jojodae |
| #7 | core-d-template-cleanup.diff | 25.07 KB | mortendk |
Comments
Comment #1
sivaji_ganesh_jojodae commentedComment #3
sivaji_ganesh_jojodae commentedRestoring the
details-wrapperclass used in details.html.twig.Comment #5
davidhernandezPostponing this until we decide how we are moving forward. Keep an eye on #2348543: [meta] Consensus Banana Phase 2, transition templates to the starterkit theme for updates. Thanks.
Comment #6
davidhernandezUn-postponing. The templates have been copied to Classy, so all we need to do is remove classes from the original templates.
Comment #7
mortendk commented.details-wrapperis used by views-ui so not relevant (views-ui not copied to classy so no need for seperation).details-descriptionis purely cosmetic.dropbutton-widget is build on js the classname is changed to js-* to make it clear for the themer that this is a class thats used by js.
Comment #9
mortendk commentedComment #10
manjit.singh@mortendk Looking into #3 patch, Everything seems fine but Why automate test fails ?
Comment #11
manjit.singhRemove classes from
datetime-form.html.twigComment #12
mortendk commented@manjit: the "container-inline" class in
datetime-form.html.twigwas removed in the previous patch, also you forgot the rest of the patch ;)I added a missing test for js-dropbotton, see interdiff
Comment #13
mortendk commentedworks better when the patch is uploaded ;)
Comment #19
mortendk commentedset test to classy
Comment #21
mortendk commentedCant reproduce on my local everytest passes there, set to retest
Screenshots for dropbotton:

Comment #22
rteijeiro commented@mortendk is right. That tests are wrong even before applying this patch. I think it's a RTBC, check screenshots:
Views BEFORE
Views AFTER
Comment #24
davidhernandezYou are rtbc-ing a red patch. We have to have it come back green. If it is passing locally, but failing on testbot, that is something we need to look into.
Comment #25
alexpottThis makes me even more reserved about adding js- to classes that are in the template. Sure if javascript adds the class and does whatever.
Comment #26
mortendk commentedjs- classes must be added if a class is used for js, but what we might have to do is now refactor all of the css out of this mess & add in new classes etc.
I would suggest that we remove those files out of this commit so we can take each of the js infected files and clean them up, but dont hold the rest back ?
Comment #27
mortendk commentedComment #28
mortendk commentedthe dropbotton css component needs to be rewritten - would it make sense to move that to a seprate issue ?
Comment #29
mortendk commentedComment #30
mortendk commentedI have looked at the dropbutton component, and have decidet to remove it from this issue - create a seperate issue for it. Theres to amny otherthings going on inside of dropbutton that potentially can drag on forever (test, classname bikeshed etc)
Dropbotton issue
#2428193: make dropbutton component follow css coding standards
New patch uploaded without dropbutton-wrapper.html.twig
Comment #31
joelpittetThis is sketchy, removing this from core because it's functionality.
Everything else I'm cool with.
Comment #32
mortendk commented.form-required is used in /core/misc/states.js:
if i read it right it removes required with js from
<foo required>?looks like we have another case of .js-banana
Comment #33
mortendk commentedthe js dependency on the classes needs to be fixed with all the other js / css issues in #2408473: Rewrite form.css inline with our CSS standards
Comment #34
rteijeiro commentedOk, let's try to clean-up js classes in a different issue. Back to RTBC!
Comment #35
mortendk commentedComment #36
webchickNo longer applies, presumably because of #2378883: Convert existing drupal_render() KernelTestBase tests to PHPUnit tests.
This looks quite odd. Fortunately this hopefully won't be necessary anymore with that test now turned into unit tests instead.
Comment #37
mortendk commentedComment #38
mortendk commentedhurray ok lets see where this goes
Comment #39
DickJohnson commentedLooks good and solves the issues mentioned by @webchich on #36.
ps. In future decent naming and .patch in the end of file would rock.
Comment #40
alexpottChanging templates is permitted in beta. Committed 44323cf and pushed to 8.0.x. Thanks!