The USWDS base theme does not currently include any default styling for unpublished nodes (node-unpublished class) or unpublished comments (comment-unpublished class). It would be useful if the USWDS base theme included some simple styles out of the box to visually notify site users when the items they are viewing aren't published. A simple background color change could be a good place to start.
For 508 compliance a conditional div containing the word unpublished run through the t function in supplied node.tpl.php and comment.tpl.php files could be even more useful. What are your thoughts @brockfanning? I am happy to supply a patch for this.
Comment | File | Size | Author |
---|---|---|---|
#13 | missing-unpublished-state-2934688-d8-13.patch | 9.88 KB | brockfanning |
Comments
Comment #2
JayDarnellAttached is a potential patch to add some basic styling for unpublished comments and unpublished nodes as well as a small conditional mark tag with t('unpublished') contained inside.
The changes include:
Comment #3
brockfanning CreditAttribution: brockfanning commentedThanks @JayDarnell, I think this definitely needs doing. My only hesitation is because I'm wondering if it can be done without overriding the templates. If so, it seems like that would be preferable, since it would work whether or not any subthemes may have overridden a node/comment template.
I know the class can be added without overriding the template, but I'm not sure about how the tag would be done.
Comment #4
JayDarnellHi @brockfanning, good point. I modeled this update after what the Zen base theme does and after reading some discussions here on D.O about how to do something similar in D8.
The way I see I it, for new projects using USWDS moving forward the unpublished tag will already be in place in the provided comment and node templates. I'm not sure if we would need to note this anywhere in the project documentation so site builders looking to use the base theme know to clone the templates provided by USWDS instead of those provided by core. It couldn't hurt but I imagine most themers may already know to check the base them for templates to override...
For other projects already in the wild this shouldn't have any negative impact if they're already running their own custom comment and node templates right? We already had our own on the LINCS project for example and adding this to the base theme had no negative impact on us. In these cases site builders will get the benefit of the background color styling for the unpublished items but they won't get the additional mark tag unless they decide to copy that snippet into their own template.
Truth be told, I came up empty handed trying to think of a better way to do this.
Comment #5
brockfanning CreditAttribution: brockfanning commentedThat makes sense, Jay. Here are some comments on the patch:
A nitpick, but in the interest of CSS selector simplicity, wouldn't it still work without the "node." and "comment."?
Could we get by without this file, by consulting variables['status'] instead of variables['unpublished'] in the template?
Technically shouldn't this be templates/comment/comment.tpl.php?
Possible whitespace issue.
Technically shouldn't this be templates/node/node.tpl.php?
Possible whitespace issue.
Comment #6
brockfanning CreditAttribution: brockfanning commentedForgot to add, if possible can you add a little doc above the CSS lines, like
/* Help for admins */
?Comment #7
JayDarnellHi @brockfanning. Thanks for the feedback. I'll rework and submit a fresh patch as soon as possible.
Comment #8
JayDarnellHello again @brockfanning. I didn't exactly follow your comments regarding possible white space issues but I've rerolled the patch with the rest of your recommendations.
Comment #9
brockfanning CreditAttribution: brockfanning commentedLooking good Jay. To elaborate on the whitespace issue - for example the line above
<?php if (!$status): ?>
has whitespace (four spaces), as does the line below that section. And similar for the comment template.Comment #10
JayDarnellThanks for clarifying @brockfanning. I should be able to submit a follow-up patch sometime today.
Comment #11
JayDarnellAs promised here is an updated patch without the unnecessary white space.
Comment #13
brockfanning CreditAttribution: brockfanning commentedThanks @JayDarnell!
I'm attaching a hopefully equivalent D8 version of the patch for review.
Comment #15
brockfanning CreditAttribution: brockfanning commented