Problem/Motivation
Bartik's code needs to meet current Drupal coding standards.
Proposed resolution
This is the current design of comments in Bartik.

It is important that the work in this issue does not change the design.
Work to be carried out:
- All CSS in Bartik for comments is kept within the comments.css file in Bartik's CSS component folder.
- The selectors used in the component file need to follow best practices here. If selectors need to be changed also make sure to go to the comment.html.twig template and make the changes their too.
- Check that the contents of the CSS file are formatted correctly and follow the coding standards, see the #1342054: [META] Clean up templates and CSS for things to check and links to the standards
Remaining tasks
- Assess the code and figure out what work oulined above need to be included in the patch.
- Write a patch with as much work as you want to include, upload and comment what changed you have included with an interdiff
- Review the patch - code review and visual changes
- Upload screenshots to show nothing/something is broken on the frontend
User interface changes
None, we are cleaning up CSS and markup in templates. The use of Bartik's UI and design will stay the same.
API changes
n/a
Beta phase evaluation
| Issue category | Task because it is a code clean up overhaul of a theme. |
|---|---|
| Unfrozen changes | Unfrozen because it only refactors CSS and templates, no changes to UI or APIs |
| Prioritized changes | The main goal of this issue is usability and performance. We want Bartik code to be up to date and something to be proud of. |
| Disruption | No disruption it's only refactoring code not changing how to use the theme |
| Comment | File | Size | Author |
|---|---|---|---|
| #58 | screenshot-2398461-58.png | 316.59 KB | rachel_norfolk |
| #57 | interdiff-52-55-full.txt | 771 bytes | jp.stacey |
| #55 | 2398461-55.patch | 7.97 KB | idebr |
| #55 | interdiff-55-52.txt | 590 bytes | idebr |
| #53 | patched_node_published.png | 106.61 KB | jp.stacey |
Comments
Comment #1
emma.mariaComment #2
DickJohnson commentedOk, spend some time on testing comments and looking the code.
1. Comment arrow is currently broken. Before starting to actually work with this I fixed it to #2398531: Some images not showing up after SMACSS split
2. Unpublished content is kinda impossible to notice as Bartik current styles are overriding cores unpublished styles. We're adding a tiny pink borders to comment arrow when unpublished (see screenshot), but it took me like few minutes to notice there's actually something. Related to this theres few issues around on this f.ex on #1854376: Bartik overrides unpublished style from node.css
On 2. I'd rather add the pink background.

Comment #3
DickJohnson commentedThe code for unpublished comments also exists both in comments.css and content.css. I think on this issue we're not going to change content.css, right?
Comment #4
DickJohnson commentedAnd a patch.
Don't consider this to be ready. Just sending it to testbot.
Comment #6
emma.mariaComment #8
idebr commentedSetting back to 'Needs work' per #4
Comment #9
lauriiiI don't think there should be empty row
Comment #10
DickJohnson commentedLets take a new start here.
Comment #11
DickJohnson commented1. .comment h2.title removed as there's no h2 in .comment. There's h3 in .comment and h2 in .comment-wrapper
2. @lewisnyman pointed out that we're not making visual changes on these, so I'll revert the mention about unpublished colors.
3. Made some changes to template.
4. Made some changes to css-file based on changes on template
5. The missing arrow bug was already fixed on other issue.
A patch as attachment. Don't think it's ready, but some feedback would be great.
Comment #13
mukeysh commentedpatch for comment.css there is an extra space .comment-footer { display: table-row; } and added outline: none in comment subject field
Comment #14
mukeysh commentedComment #15
lauriiiSetting to needs review so the testbot triggers
Comment #16
emma.mariaThanks @Mukeysh for creating a patch. Your latest patch does not contain the work from #11. Patches need to follow on from a previous patch if one exists in the issue already. Apply the patch to your copy of Drupal, add the changes you want to add and then create and upload a new patch from that.
Comment #17
emma.mariaComment #18
emma.mariaSome feedback for patch in #11
Commenting implies the comment form. These are styles for the comment display so change to just "comment".
Needs a blank line below the file comment see here.
This property needs to be kept for the h2.title in the comments wrapper, the selector is currently incorrect and the h2 has lost it's margin-bottom in Core. Plus add a good selector to the h2.title such as .comments__title, we don't want to avoid using elements in the selector.
For some reason the comment author post date has lost it's styles ^^
This is needed as required classes are being added by this.
Comment #19
emma.mariaScreenshot for point 3 in #18 to show why we need to keep this property for the h2.title in the Comment wrapper
Comment #20
emma.mariaThis needs to be .comment__content to follow standards.
The comment-parent class is not being used anywhere in core so we can remove this class from the template.
.comment should be taken out of this selector and we should keep the word time. Therefore the selector should be .comment__time
.comment should be taken out of the selector, .comment__permalink implies that is is part of the comment component.
Comment #21
DickJohnson commentedWorked a bit on this. Didn't yet fix all things mentioned by emmamaria.
Comment #22
DickJohnson commentedYou can forget the one in #21. Something went wrong.
Comment #23
lauriiiI guess we still have to print the parent item and print content attributes. Maybe we just remove the class as Emma suggested?
Comment #24
emma.mariaUnassigning so someone can review the latest patch by @lauriii.
Comment #25
rachel_norfolkReviewing...
Comment #26
rachel_norfolkLooking back at #20 Emma's list, I've found a couple of things still need updating, so here's an update that I believe includes all 4 requirements at #20.
Comment #27
idebr commentedThe .comment styling is now added twice in the stylesheet
An
<img/>element has 0 margin by default. This code can be removedSame here
This should be .comment__arrow since it is nested in .comment
This should be .comment__text since it is nested in the .comment component
.comment-footerclass. This should be.comment__footersince it is nested in the .comment component.Comment #28
rachel_norfolkComment #29
rachel_norfolkI've incorporated all of idebr's comments at #26 and also noted that the comment-arrow border colours that used to be defined in colors.css are (rightly) not there any more - so I've added them here. I *believe* that falls within the scope of this issue - I'm happy to create a new one if required...
Comment #30
rachel_norfolkAlso note that I'm unsure about renaming some of the classes still using old comment-xxx structure in there. I *think* they should be converted but want to check...
Comment #31
idebr commentedComments should end in a full stop.
This
<h2>used to belong to the comment-wrapper. If we remove it here, we should at least open a followup to reapply it to the comment-wrapperThis breaks the username display, since the attribute now applies to the wrapper instead of the child element.
This selector should be .comment__time per #20.3
Use the shorthand color code when possible, eg. #fff. If you copied the selector from colors.css, please remove it from the original file.
This should be .comment__text since it is a child element of .comment
unpublished is a modifier, so the selector should be .comment--unpublished
The markup should be .comment__footer since it is a child element of .comment. The css does not appear to do anything, since its parent is not a table. If so, it can be removed.
Some other points that are not in the patch:
Comment #32
jp.stacey commentedI'm going to look at this today after around 2.30-3pm UTC unless anyone else wants to work on it.
Comment #33
emma.mariaGo for it @jp.stacey! Looking forward to your patch. If you need help do leave us a comment.
Also thanks @idebr for the great guidance, these Bartik issues are a treat for novices to work on :)
Comment #34
jp.stacey commentedThe patch in #29 is out of date, so I've re-rolled it with a slight tweak ("commment__content") and attached. I've interdiffed manually and it looks right. I think it's the font-family statement that was preventing #29 applying.
I'll now look at @idebr's feedback - thanks for that! If I don't get that done by 1700UTC then I'll be at a meeting so I'll try to remember to unassign it!
Comment #35
idebr commentedThanks @jp.stacey! There's no rush, so feel free to work on it at your own pace.
Comment #36
jp.stacey commentedPlease find a patch attached, plus interdiff. I think this covers all feedback from @idebr in #31, minus their original point 2, but plus the second extra point mentioned. Outstanding points are therefore:
* **Feedback #2: This h2 used to belong to the comment-wrapper. If we remove it here, we should at least open a followup to reapply it to the comment-wrapper**: I didn't want to make the call for how to open the followup, what parent issue to assign it to etc.
* **Extra point #1: typography.css contains a selector p.comment-time that should be updated with the new markup.** As above, I think this might be best suited to opening a followup, to fix once this and #2398447: Remove the "typography" CSS file in Bartik are both closed. Otherwise the overlap means we might get into a race condition with that other ticket!
As an addendum, unfortunately I've also just hosed my local D8 build, just as I was testing my last bit of code: changing of comment selector from .comment.unpublished to comment--unpublished (so using Twig string concatenators.) I believe what's in the patch is syntactically correct but I would appreciate other eyes specifically on that bit.
Comment #37
jp.stacey commented(Oh, weirdly #2398447: Remove the "typography" CSS file in Bartik is showing as crossed out in my new comment, but not in @idebr's. So possibly that work can be done here.)
Comment #38
idebr commentedThanks for working on this, jp.stacey! I have done another review and found a few more things before this can be commited.
Let's reintroduce this selector as
.comment-wrapper h2to prevent this style from being lost.This selector is necessary to win specificity over .field-type-image img. Let's introduce a new selector
.comment .field-type-image imgwith just themargin: 0declaration as a comment to indicate the selector is overqualified to win specificity over.field-type-image imgThe border color overrides are used to fix the white borders when a node is unpublished and gets a light red background-color. An unpublished comment has no background-color, so
.comment--unpublished .comment__text .comment__arrowcan be removed. The selector is overqualified and can be rewritten as.node--unpublished .comment__arrowThis selector no longer applies since the class has been changed to comment__footer in the html markup. Since the parent is not displayed as a table, this selector can probably be removed. Please test manually to confirm.
Comment #39
jp.stacey commentedThanks, @idebr. Looking at this now.
Comment #40
jp.stacey commentedAttached patch and interdiff.
@idebr, referring to your most recent round of changes:
1.
#content h2incontent.csstakes precedence unless this selector is#content .comment-wrapper h2so I've used that.2. I've copied this verbatim as you requested, but this would affect all fields of type image on comments, not just attribution images. Do we care?
3. Done
4. Done: looks fine here in Chrome. As you say I can't see
display: table-rowdoing much inside non-table elements.I've yet to open the two followup tickets I detailed in #36. Anyone willing to take responsibility for their correct metadata? :)
Comment #41
jp.stacey commentedComment #42
idebr commentedThis is looking really good, thanks jp.stacey :)
Excellent! In a case like this where we use an overqualified selector to override styling from other selectors, please add a comment why the selector is overqualified. For an example, have a look at the Seven theme: http://cgit.drupalcode.org/drupal/tree/core/themes/seven/css/components/...
/* This is required to win over specificity of [dir="rtl"] .tabs__tab */That's a good point. Let's not add any more overrides then necessary and switch the selector to
.comment .field-name-user-picture img. This selector is also overqualified, so it needs a similar comment as above to make clear the selector is overqualified to override.field-type-image img.Regarding the follow-ups:
Comment #43
jp.stacey commentedOK, attached is a file and interdiff with the most recent round of changes for review.
Comment #44
idebr commentedThanks @jp.stacey! I did a manual test as well to confirm nothing broke. Screenshots here:
Before/after:

Comment #45
DickJohnson commentedRun some tests with BackstopJS and everything looks good. RTBC++
Comment #46
alexpottWhat does an unpublished comment look like now?
What does an unpublished comment on a published node and on an unpublished node look like? And what does a published comment on an unpublished node look like?
Comment #47
DickJohnson commentedGood catch.
Comment #48
idebr commented@DickJohnson The border colors are to blend in with unpublished nodes that have a light red background. Unpublished comments have no background-color, as you noticed yourself in #2422113: Unpublished comments have lost their styles in D8
Comment #49
DickJohnson commentedI still don't get what I'm missing. After my latest patch unpublished comments look like:

And unpublished nodes have pink background.
Comment #50
idebr commentedLooks like your browser has zoomed out
Comment #51
emma.mariaYour browser indeed has zoomed in. I did that earlier without realising and panicked!
Can we be super awesome and replace the arrow with a CSS3 triangle styling instead of the crappy image? The quality and fragility of the image is not great. If you look closely the image doesn't even join up with the comment box there are gaps. Also in core we are moving away from relying on images for things.
Also once we have that in place we can even raise a follow up issue for the design of unpublished comments to have a much cleaner design. I was thinking the comment box with arrow could have the pink colour set rather than the whole wrapper as it looks a little rough right now.
Thanks!
Comment #52
idebr commentedI replaced the comment arrow with a css triangle. The technique is explained on CSS tricks: http://css-tricks.com/snippets/css/css-triangle
The patch is based on #43, since the interdiff in #47 suggests an oversight by DickJohnson on the
.unpublishedselectorComment #53
jp.stacey commented@idebr that's a neat drop-in and good to get rid of the image.
I've reviewed the patch in #52 and it applies cleanly. I've also reviewed published and unpublished nodes' comment threads, before and after the patch is applied. They look great to me and the only difference seems to be the welcome return of the margin under h2.title.
However, I can't for the life of me detect the nuances mentioned by @alexpott between the 2^3=8 different states: patched/unpatched; node published/unpublished; comment approved/unapproved. The only obvious difference to me for unapproved comments is they get a right-hand margin (left-hand in RTL).
I've therefore uploaded screenshots of all states (4, not 8, but the thread always contains a comment, a reply and an unapproved) so maybe if there are still changes on this ticket, we can discuss with reference to these.
Comment #54
idebr commentedPatch no longer applies after #2422113: Unpublished comments have lost their styles in D8 was committed. I'll work on a reroll.
Comment #55
idebr commentedRerolled the patch and applied the unpublished styling that was already available for nodes to comments as well.
Comment #56
idebr commentedComment #57
jp.stacey commentedReviewed +1 here: patch applies cleanly, visuals look exactly the same to me as with patch from #52!
The interdiff on #55 didn't take into account the rerolling owing to #2422113: Unpublished comments have lost their styles in D8, so I attach another for reference which is literally every line change: a bit noisier that way, but it might be of use.
It'd be great to get another review of this soon, so we don't have to keep rerolling to hit the moving target of HEAD.
Comment #58
rachel_norfolkPatch applies to latest head,
code looks good,
loving the inline css triangle,
screenshot shows no noticeable visual changes.
I'd say it's a good patch! :-)
Comment #59
webchickSorry, this dropped off my radar. Changes look good, are isolated to Bartik, and testing looks nice and thorough. Thanks!
Committed and pushed to 8.0.x.