Problem/Motivation
There are situations where modules want to define colours that are consistent of the Seven theme, in some situations we've just copied over the colour values that are defined in the Seven theme, in some situations the modules just make up their own colours and it looks inconsistent.
If another admin theme wants to use different colours, they have to override the module CSS in every situation, which scales really badly once you contrib is involved.
Proposed resolution
Create reuseable classes that allow modules to use colours defined in the Seven theme without creating more CSS to override.
Bootstrap does this with helper classes, I think we should combine the text and background elements into two helper classes:
<tr class="color-warning">Yellow</tr>
<tr class="color-error">Red</tr>
Remaining tasks
Write a patch to add the CSS
Find an example situation to implement these classes as an example
User interface changes
None
API changes
New reuseable classes!
Beta phase evaluation
Unfrozen changes | Unfrozen because it only changes CSS and HTML |
---|
Comment | File | Size | Author |
---|---|---|---|
#70 | reusable-colors-2336141-56.patch | 5.75 KB | lauriii |
#43 | Screenshot 2014-11-14 14.28.00.jpg | 427.86 KB | LewisNyman |
#27 | reusable-colors-2336141-27.patch | 4.87 KB | rteijeiro |
#17 | reusable-colors-2336141-17.patch | 3.76 KB | balagan |
#15 | reusable-colors-2336141-15.patch | 3.76 KB | balagan |
Comments
Comment #1
Bojhan CreditAttribution: Bojhan commentedLets implement our:
Yellow
Green
Red
Color scheme
Comment #2
emma.mariaComment #3
LewisNymanUpdated summary
Comment #4
LewisNymanChanged color-ok to color-success because we don't want the colour to be applied when the status is just 'ok'
Comment #5
emma.mariaI have added colors.css to Seven for the helper classes.
As a proof of concept I have amended the Status report table to now use the new color classes.
I also noticed that the info class does not have any css associated with it and we have deprecated the ok green styling so I removed those two from the array. Also as a result I needed to add an if statement to the twig file to print 'class' when there is one present for the row.
Comment #7
lauriiiComment #10
balagan CreditAttribution: balagan commentedComment #11
balagan CreditAttribution: balagan commentedRerolled the patch in comment #5
Comment #12
balagan CreditAttribution: balagan commentedComment #14
balagan CreditAttribution: balagan commentedComment #15
balagan CreditAttribution: balagan commentedFixed wrong filename (color.css -> colors.css)
Comment #16
balagan CreditAttribution: balagan commentedComment #17
balagan CreditAttribution: balagan commentedHope to get patch names right this time.
Comment #18
balagan CreditAttribution: balagan commentedComment #21
balagan CreditAttribution: balagan commentedIt passes tests on my local machine, requeing.
Comment #23
stefika CreditAttribution: stefika commentedFixed css comments.
Comment #25
lauriiiComment #27
rteijeiro CreditAttribution: rteijeiro commentedFixed the test.
Comment #28
balagan CreditAttribution: balagan commentedIt still needs screenshots.
Comment #29
lauriiiPutting back for the screenshots :)
Comment #30
rteijeiro CreditAttribution: rteijeiro commentedNow it's fixed. Icons and colors appear correctly.
BEFORE
AFTER
Comment #32
lauriiiTested this manually and fixed a very minor bug on the code. I will RTBC this because its relatively simple change. I also updated the Issue summary to match the current solution.
Comment #33
alexpottI thought we were trying to not put classes in code.
So I guess this is fixing an out of scope bug. Please open a new issue - this is a normal task and the issue summary just does not cover this.
Comment #34
LewisNymanGreat thanks Alex. Next steps:
1. Remove the additional fixes that are out of scope
2. Change the
severity-class
variable to aseverity
3. Add the class in the template:
class="color-{{severity}}"
Comment #35
lauriiiI guess we need the change 2. because we dont want to print class for all the severities. We could also use Attribute for this case but for me it seems bigger change than this.
Comment #36
LewisNymanThis feel little bit dirty. We shouldn't use the color class to add icons.
Can we add the status to the status-icon class? So for example we replace the CSS selector '
table.system-status-report tr.color-error td.status-icon div
withtable.system-status-report td.status-icon--error div
Comment #37
lauriiiThats a good idea. I did the monkey job!
Comment #38
LewisNymanGreat, this looks good. Well done.
Comment #39
tim.plunkettWe still have CSS like this from system.theme.css:
Obviously without something like Sass, we'll have some amount of duplication, but should we include a comment in cases like this pointing to the new colors.css?
Comment #40
alexpottHow does this change play out with #2227401: Apply the seven style guide to the status report?
Comment #42
LewisNymanThis issue is an reuseable implementation of #2227401: Apply the seven style guide to the status report - we probably need a reroll now to take into account the style changes.
I like that idea! Let's do that. Setting to needs work.
Comment #43
LewisNymanI've added the comments as per Tim's suggestion. I've also remove some of the unused table styling that was sitting alongside messages styling. Everything seems fine on inspection. The update page used the
.warning
class still but it actually overrides it with it's own styling. We should shift it to use these color classes in a follow up.Comment #44
lauriiiRerolled the patch. Everything looked good. Someone could double check this. This looks like RTBC to me.<
Comment #45
DomoSapiens CreditAttribution: DomoSapiens commentedTested the patch and it works!
On the admin/reports/status I see the color-error and color-warning classes. On div.messages I would expect the same color classes. Why are the color classes not used on div.messages? So you would have "messages messages--status color-success" instead of "messages messages--status"?
Comment #46
lauriiiThanks a lot for your time on reviewing & testing this issue @DomoSapiens! We are going to do it in follow-up. In this issue we are only doing this for the admin page just as an example. Are you happy with that? :)
Comment #47
DomoSapiens CreditAttribution: DomoSapiens commentedYep. I think it's a good idea to do it as a follow up, so it's consistent on all placed.
Comment #48
emma.mariaThe patch no longer applies, it needs a reroll.
Comment #49
LewisNymanComment #51
emma.mariaThe patch applies cleanly.
When I go to the Status report page and inspect the warnings and error I see the following:
The error table row has the class .color-error and only receives it's colour styles from this selector.
The warning table row has the .color-warning and only receives it's colour styles from this selector.
Setting this to RTBC.
Comment #54
LewisNymanBack to RTBC
Comment #55
alexpottThis came in #44 not sure why.
Comment #56
lauriiiMy fault again :P
Comment #58
lauriiiLast patch might be confusing because its not what is should be. Here's the right one
Comment #59
LewisNymanAh sorry I missed that! Here's a diff of the patches. Good catch!
Comment #60
alexpottNot too sure about these comments. If anything they should be
/* @see colors.css*/
. But referencing a theme from system's css seems the wrong direction.Comment #61
LewisNymanIt is weird, but it's a good idea to reference the colours coming from the Seven Style Guide so it's clear they aren't colours picked at random. The weird this here is that we have global styling for messages in Drupal vs per-theme styling. Seems like a different discussion though.
Comment #62
lauriiiCould we use
/* @see colors.css*/
in the files and reference Seven styling guide on the colors.css? I think that simpler comment full fills most of the use cases on such comments.Comment #63
LewisNymanI would still like to reference the class. then it gives the colour a bit of semantic meaning. Let's just add @see to the comments. This isn't the only situation where we have module files that use colours from the Seven style guide. Unless we choose to make message styling theme specific then I don't think there's a way around it.
Comment #64
lauriiiSetting back to RTBC after very minor comment changes.
Comment #65
alexpottThe
@see
format is not quite right. https://www.drupal.org/coding-standards/docs#seeComment #66
emma.mariaLooking at https://www.drupal.org/coding-standards/docs#see should it be...
So just the classname after the @see as it uses that as a link and the rest of the instructions on the next line?
Comment #67
lauriiiI don't know how it should be but it cannot be that because coding standards says:
So I have no idea.
Comment #68
LewisNymanBased on the standards I guess it could be:
None of this will actually be parsed so I'm not sure if there is an exactly right way to do this.
Comment #69
alexpottYeah this sucks. I was wrong to worry about this - sorry. Let's go back to #58. Can someone re-upload so it is the latest patch on the issue.
Comment #70
lauriiiComment #71
LewisNymanComment #72
alexpottCSS change is not frozen in beta. Committed 6c991e8 and pushed to 8.0.x. Thanks!