(First, verify that the preprocess changes have been made. #2322163: [meta] Consensus Banana Phase 1, move CSS classes from preprocess to twig templates.)
Preprocess changes are done.
The templates will be copied in another issue. #2424533: Copy views templates to Classy
- Remove all classes from the core module's template. Remove all classes added with addClass and ones that are hard-coded in the template.
- If there are classes that are required for basic functionality, discuss whether they should be kept.
- If there is CSS from the module, or anywhere else, referring to the class, discuss removing it or moving it to Bartik&Seven. Do not move the CSS to Classy.
Twig Templates to modify
core/modules/views/templates/views-exposed-form.html.twig
core/modules/views/templates/views-mini-pager.html.twig
core/modules/views/templates/views-more.html.twig
core/modules/views/templates/views-view-field.html.twig
core/modules/views/templates/views-view-fields.html.twig
core/modules/views/templates/views-view-grid.html.twig
core/modules/views/templates/views-view-grouping.html.twig
core/modules/views/templates/views-view-list.html.twig
core/modules/views/templates/views-view-mapping-test.html.twig
core/modules/views/templates/views-view-opml.html.twig
core/modules/views/templates/views-view-row-opml.html.twig
core/modules/views/templates/views-view-row-rss.html.twig
core/modules/views/templates/views-view-rss.html.twig
core/modules/views/templates/views-view-summary-unformatted.html.twig
core/modules/views/templates/views-view-summary.html.twig
core/modules/views/templates/views-view-table.html.twig
core/modules/views/templates/views-view-unformatted.html.twig
core/modules/views/templates/views-view.html.twig
Comment | File | Size | Author |
---|---|---|---|
#58 | interdiff.txt | 1.35 KB | Manuel Garcia |
#58 | remove_classes_from-2349775-58.patch | 19.41 KB | Manuel Garcia |
#54 | Content_d8.local_-_2015-05-15_11.08.38.png | 27.94 KB | tombo |
#54 | Content_d8.local_-_2015-05-15_11.01.47.png | 30.41 KB | tombo |
#54 | Content_d8.local_-_2015-05-15_11.00.54.png | 22.28 KB | tombo |
Comments
Comment #1
mortendk CreditAttribution: mortendk commentedmoved templates & cleaned out classes
Comment #3
mortendk CreditAttribution: mortendk commentedComment #4
mortendk CreditAttribution: mortendk commentedre roll
Comment #6
davidhernandezThis should be postponed until #2329917: Move views classes from preprocess to templates is in.
Comment #7
davidhernandezUnpostponing. I created another issue to just copy the templates, like we did with System. We can continue to use this one to remove the classes from core.
#2424533: Copy views templates to Classy
Comment #8
davidhernandezComment #9
davidhernandezThe templates have been copied to Classy, so we can try to remove the classes.
Comment #10
Manuel Garcia CreditAttribution: Manuel Garcia commentedHere's a brave new patch -=)
Comment #11
davidhernandez"visually-hidden" classes are functional, so they need to stay.
Comment #12
Manuel Garcia CreditAttribution: Manuel Garcia commentedYou're right, I got carried away...
Comment #13
dawehnerpager__items are used by the javascript, please test those bits to ensure things still works. Ajax view ... with a mini pager
Comment #15
davidhernandezWe'll probably want to prefix the ones using javascript. (js-) a la #2431671: [meta] Add in js- prefixed classes for separation of JS & CSS functionality
I'm honestly surprised there are only 11 fails (from two tests.)
Comment #16
Manuel Garcia CreditAttribution: Manuel Garcia commentedGood catch dawehner. I've tested the attached (with stark enabled) using a minipager with ajax, its now working.
I also tested an exposed filter using ajax, it also works.
Comment #19
dawehnerThank you for manually testing it. It looks fine for me now.
Comment #20
davidhernandezRTBCing a red patch?
I think we should still do the js- prefixing, unless there is an argument against it.
Comment #21
Manuel Garcia CreditAttribution: Manuel Garcia commentedThis should fix the failing tests.
@davidhernandez do you think we should include a change to the views classes for js- prefixing in this patch, or tackle that on a different issue?
Comment #22
dawehnerMh, the test now is much less readable ... too bad, anyway, can we open up a follow up to use and for those bits? This would improve a lot the semantics of the code.
Comment #23
star-szrInteresting, I thought most tests used Classy. So far we haven't had to do much of this type of thing.
Minor: concatenating should always have spaces around the dot per https://www.drupal.org/coding-standards#concat.
Comment #24
davidhernandezIt's not a webtest, it is extending ViewUnitTestBase. So it is not setting a theme? Even though it is checking markup. We could probably get it to use Classy, but I think that is the wrong direction. We want to remove the reliance on Classy in tests, not add more. What would be better is to not have these tests verify output by looking for a CSS class.
Regarding the js- prefix. It is the only way to get the class out of the core template. If we split them here, we can remove the use for styling in the core template. The one downside, since we'd have the change the javascript, is we'd have to make changes to Pager. It doesn't look that bad though. One line changes to a js file, two templates, and a test or two.
Comment #25
Manuel Garcia CreditAttribution: Manuel Garcia commented@dawehner Yeah i couldn't think of a way to make the test easier to read :S
@Cottser thanks! Fixing that on this patch now.
@davidhernandez I agree about the tests. Not sure I follow, but in my opinion we should tackle switching to js- css classes on a separate issue.
Comment #26
mortendk CreditAttribution: mortendk commented@manuel go with the js-prefix so we get it fixed right away :)
is what our documentation is also saying
Comment #27
Manuel Garcia CreditAttribution: Manuel Garcia commentedAlright, the attached patch includes the following:
Replaced all instances of:
view-dom-id-
withjs-view-dom-id-
pager__items
withjs-pager__items
I did not tackle the classes on
views-view-table.html.twig
(responsive-enabled
andsticky-enabled
) because these are not views specific, but used throughout core, so perhaps we should change those on a separate issue.Comment #28
dawehnerSo this is super confusing, honestly. For me we basically loose quite some of the semanticness of those css classes? Maybe this is simply something we don't care about?
Comment #29
davidhernandezI should have explained this better. Apologies. See here for some background on the js- prefixing. #2431671: [meta] Add in js- prefixed classes for separation of JS & CSS functionality
Instead of changing the CSS class to have a prefix, add another class with the prefix. So we end up with:
The CSS should remain unchanged, and use
.pager__items
. The JS is changed to usejs-pager__items
. This way we can leave the js- class in the core template, but remove the class that adds styles. This allows us to remove all the styling from the core template, but maintain the JS functionality.Also, I'm thinking it isn't necessary to add the js- prefix to the dom-id classes, since they aren't being used for styles.
Comment #30
star-szrI think we should especially add the js- prefix to the dom-id classes, because frankly I'm sick of explaining to people what they are for ;P
Comment #31
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedRerolling because #2187113: Incorrect usage of attributes in twig templates resulting in possible duplicate attributes. got in.
@davidhernandez thanks for the explanation, I will tackle that next (.pager__items)
I agree with Cottser that we should add the js- prefix to the dom-id classes... it makes a lot of sense to me to add the prefix because they are only used for javascript.
Comment #32
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedHere it is without removing pager__items from the system pager nor classy, and adding js- prefix to all.
I manually tested that ajax enabled views minipager, normal pager and exposed filters work.
I am now getting failures on AggregatorRenderingTest and PagerTest, but I don't understand why. The class being tested for is still in the core template, we're just adding a new one... let's see if the bot finds the same, if it does I could use some help figuring this out.
Comment #34
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedOK, learning a bit of xpath madness along the way. Hopefully this one will come back green.
Comment #35
brahmjeet789 CreditAttribution: brahmjeet789 commentedComment #37
davidhernandez@brahmjeet789, what were you trying to improve with your patch? Please leave a comment and an interdiff so we know what you were trying to do.
Comment #38
davidhernandezLooking at #34 it looks like a few templates were missed.
views-view-grid.html.twig
views-view-summary.html.twig
views-view-summary-unformatted.html.twig
Probably somethings can be removed from views-view-table.html.twig. I'm not sure if we want to remove the row and column classes, but there are views-field- type classes that can probably go. There are a few other templates to fix. I didn't list them all.
Comment #39
Manjit.Singhremoving classes from :
views-view-grid.html.twig
views-view-summary.html.twig
views-view-summary-unformatted.html.twig
@davidhernandez have we need to remove classes from classy's view templates also ? For now i have removed only from
/core/modules/views/templates/
. Please verify.Comment #40
Manjit.Singhforget to trigger test bot :)
Comment #41
davidhernandez@Manjit, no, do not remove classes from Classy templates.
Comment #42
Manjit.Singhok !! then patch would be fine i guess :)
Comment #43
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedWe should manually verify (using stark theme) that the grid actually works as a grid without these classes. To me it would make no sense to remove these if the grid style stops working without them.
This would break the alignment options functionality, again, we should manually test this using stark.
Yes, totally missed those earlier.. thanks!
Comment #44
saki007sterManually tested this and alignment does break in the stark theme. See the screenshot of stark theme - admin people view in grid view with and without classes.
Comment #45
saki007sterUpdated the patch
Comment #46
saki007sterComment #47
saki007sterComment #48
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedThanks @saki007ster for the testing and the updated patch.
On the interdiff:
These should be ok to be removed in my opinion.
Comment #49
saki007ster@Manuel Garcia updated the patch and interdiff.
Comment #50
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedThank you @saki007ster - I have fixed just a tiny missing space for coding standards, and reviewed all other templates on
core/modules/views/templates/
directory, nothing else to do that I can see. I'd say this patch is good to go!Comment #51
tombo CreditAttribution: tombo as a volunteer commentedI'm reviewing this patch
Comment #52
tombo CreditAttribution: tombo as a volunteer commentedAdded screenshots for grid, pager item
Comment #53
tombo CreditAttribution: tombo as a volunteer commentedformatted list screenshot
Comment #54
tombo CreditAttribution: tombo as a volunteer commentedscreenshots for more link, unformatted, table display. these seem fine. I'm done adding screenshots.
Comment #55
dawehnerIt seems alright now even it is a bit sad to have both classes available.
Comment #56
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedthanks @tombo for the screenshots!
@dawehner thnx for rtbcing! - the reason to have both classes is to make it simpler to remove all styling form the core template, keeping the js functionality (see comment #29).
Comment #57
alexpottAre we sure that this documentation is correct? Afaics this will now have no classes at all. I know this is not introduced by this patch but we are changing a line here.
Why are we removing classes from classy?
Comment #58
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedThanks @alexpott for the input,
About 1. - Good point, I've updated the documentation on that to be a little more generic, since not all classes are for styling purposes now. If anyone has a better idea on what to say here let me know.
About 2. -
Good catch, that change got introduced on #39 and only @davidhernandez noticed... oops! I've moved that out of this patch now.
We're actually changing that for the new js- prefixed one, so not a removal ;)
Comment #59
Manjit.SinghChanges in #58 looks fine.
Comment #60
alexpottCommitted 1827c1e and pushed to 8.0.x. Thanks!
I think we should just copy the text from views-view.html.twig. ie
attributes: Remaining HTML attributes for the element.
And considering this is test code I think we should fix it here. Fixed on commit.Comment #62
nod_Comment #63
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedCheers @alexpott!
Comment #65
brahmjeet789 CreditAttribution: brahmjeet789 as a volunteer and at gai Technologies Pvt Ltd commented