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

Reference: https://www.drupal.org/core/beta-changes
Unfrozen changes Unfrozen because it only changes CSS and HTML
CommentFileSizeAuthor
#70 reusable-colors-2336141-56.patch5.75 KBlauriii
#64 interdiff.txt1.23 KBlauriii
#64 reusable-colors-2336141-63.patch5.76 KBlauriii
#59 interdiff.txt1.56 KBLewisNyman
#58 reusable-colors-2336141-56.patch5.75 KBlauriii
#56 twig-2308187-34.patch23.11 KBlauriii
#56 interdiff.txt630 byteslauriii
#51 color-warning.png206.58 KBemma.maria
#51 color-error.png167.84 KBemma.maria
#49 reusable-colors-2336141-49.patch6.53 KBLewisNyman
#44 reusable-colors-2336141-44.patch7.64 KBlauriii
#43 Screenshot 2014-11-14 14.28.14.jpg587.5 KBLewisNyman
#43 Screenshot 2014-11-14 14.28.00.jpg427.86 KBLewisNyman
#43 interdiff.txt2.49 KBLewisNyman
#43 reusable-colors-2336141-43.patch6.87 KBLewisNyman
#37 interdiff.txt1.22 KBlauriii
#37 reusable-colors-2336141-37.patch4.38 KBlauriii
#35 interdiff.txt1.26 KBlauriii
#35 reusable-colors-2336141-35.patch4.35 KBlauriii
#32 interdiff.txt550 byteslauriii
#32 reusable-colors-2336141-32.patch5.22 KBlauriii
#30 status-report-after.png6.6 KBrteijeiro
#30 status-report-before.png6.55 KBrteijeiro
#30 interdiff.txt530 bytesrteijeiro
#30 reusable-colors-2336141-30.patch5.19 KBrteijeiro
#27 interdiff.txt1.11 KBrteijeiro
#27 reusable-colors-2336141-27.patch4.87 KBrteijeiro
#23 interdiff.txt338 bytesstefika
#23 reusable-colors-2336141-21.patch3.76 KBstefika
#17 reusable-colors-2336141-11-17-interdiff.txt939 bytesbalagan
#17 reusable-colors-2336141-17.patch3.76 KBbalagan
#15 reusable-colors-2336141-11-15-interdiff.patch939 bytesbalagan
#15 reusable-colors-2336141-15.patch3.76 KBbalagan
#11 reusable-colors-2336141-11.patch3.76 KBbalagan
#5 resuable-colors-2336141-5.patch3.96 KBemma.maria
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bojhan’s picture

Lets implement our:

Yellow
Green
Red

Color scheme

emma.maria’s picture

Assigned: Unassigned » emma.maria
LewisNyman’s picture

Issue summary: View changes

Updated summary

LewisNyman’s picture

Issue summary: View changes

Changed color-ok to color-success because we don't want the colour to be applied when the status is just 'ok'

emma.maria’s picture

Assigned: emma.maria » Unassigned
Status: Active » Needs review
FileSize
3.96 KB

I 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.

Status: Needs review » Needs work

The last submitted patch, 5: resuable-colors-2336141-5.patch, failed testing.

lauriii’s picture

Issue tags: +Needs reroll

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: resuable-colors-2336141-5.patch, failed testing.

balagan’s picture

Assigned: Unassigned » balagan
balagan’s picture

Rerolled the patch in comment #5

balagan’s picture

Assigned: balagan » Unassigned
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: reusable-colors-2336141-11.patch, failed testing.

balagan’s picture

Assigned: Unassigned » balagan
balagan’s picture

Fixed wrong filename (color.css -> colors.css)

balagan’s picture

balagan’s picture

Hope to get patch names right this time.

balagan’s picture

Assigned: balagan » Unassigned
Status: Needs work » Needs review

The last submitted patch, 15: reusable-colors-2336141-15.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 17: reusable-colors-2336141-17.patch, failed testing.

balagan’s picture

It passes tests on my local machine, requeing.

stefika’s picture

Status: Needs work » Needs review
FileSize
3.76 KB
338 bytes

Fixed css comments.

The last submitted patch, 17: reusable-colors-2336141-17.patch, failed testing.

lauriii’s picture

Status: Needs review » Needs work

The last submitted patch, 23: reusable-colors-2336141-21.patch, failed testing.

rteijeiro’s picture

Status: Needs work » Needs review
FileSize
4.87 KB
1.11 KB

Fixed the test.

balagan’s picture

Status: Needs review » Reviewed & tested by the community

It still needs screenshots.

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

Putting back for the screenshots :)

rteijeiro’s picture

FileSize
5.19 KB
530 bytes
6.55 KB
6.6 KB

Now it's fixed. Icons and colors appear correctly.

BEFORE

AFTER

Status: Needs review » Needs work

The last submitted patch, 30: reusable-colors-2336141-30.patch, failed testing.

lauriii’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs screenshots
FileSize
5.22 KB
550 bytes

Tested 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.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/system/system.admin.inc
    @@ -170,10 +170,12 @@ function template_preprocess_status_report(&$variables) {
    +      'class' => 'color-warning',
    ...
    +      'class' => 'color-error',
    

    I thought we were trying to not put classes in code.

  2. +++ b/core/modules/system/system.admin.inc
    @@ -193,6 +195,7 @@ function template_preprocess_status_report(&$variables) {
    +    $variables['requirements'][$i]['severity_class'] = isset($severity['class']) ? $severity['class'] : NULL;
    
    +++ b/core/modules/system/templates/status-report.html.twig
    @@ -25,20 +25,24 @@
    -    <tr class="{{ requirement.severity_status }}">
    -      <td class="status-icon">
    -        <div title="{{ requirement.severity_title }}">
    -          <span class="visually-hidden">{{ requirement.severity_title }}</span>
    -        </div>
    -      </td>
    -      <td class="status-title">{{ requirement.title }}</td>
    -      <td class="status-value">
    -        {{ requirement.value }}
    -        {% if requirement.description %}
    -          <div class="description">{{ requirement.description }}</div>
    -        {% endif %}
    -      </td>
    -    </tr>
    +    {% if requirement.severity_class %}
    +      <tr class="{{ requirement.severity_class }}">
    +    {% else %}
    +      <tr>
    +    {% endif %}
    +        <td class="status-icon">
    +          <div title="{{ requirement.severity_title }}">
    +            <span class="visually-hidden">{{ requirement.severity_title }}</span>
    +          </div>
    +        </td>
    +        <td class="status-title">{{ requirement.title }}</td>
    +        <td class="status-value">
    +          {{ requirement.value }}
    +          {% if requirement.description %}
    +            <div class="description">{{ requirement.description }}</div>
    +          {% endif %}
    +        </td>
    +      </tr>
    

    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.

LewisNyman’s picture

Great thanks Alex. Next steps:

1. Remove the additional fixes that are out of scope
2. Change the severity-class variable to a severity
3. Add the class in the template: class="color-{{severity}}"

lauriii’s picture

Status: Needs work » Needs review
FileSize
4.35 KB
1.26 KB

I 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.

LewisNyman’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/css/system.admin.css
@@ -223,10 +223,10 @@ table.system-status-report td.status-icon div {
-table.system-status-report tr.error td.status-icon div {

+++ b/core/modules/system/templates/status-report.html.twig
@@ -25,20 +25,24 @@
+        <td class="status-icon">

This 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 with table.system-status-report td.status-icon--error div

lauriii’s picture

Status: Needs work » Needs review
FileSize
4.38 KB
1.22 KB

Thats a good idea. I did the monkey job!

LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community

Great, this looks good. Well done.

tim.plunkett’s picture

Title: Create reusable colour classes » Create reusable color classes

We still have CSS like this from system.theme.css:

.messages--status,
.ok {
  color: #325e1c;
}

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?

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

LewisNyman’s picture

Status: Needs review » Needs work

How does this change play out with #2227401: Apply the seven style guide to the status report?

This 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.

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?

I like that idea! Let's do that. Setting to needs work.

LewisNyman’s picture

Status: Needs work » Needs review
FileSize
6.87 KB
2.49 KB
427.86 KB
587.5 KB

I'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.

lauriii’s picture

FileSize
7.64 KB

Rerolled the patch. Everything looked good. Someone could double check this. This looks like RTBC to me.<

DomoSapiens’s picture

Tested 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"?

lauriii’s picture

Thanks 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? :)

DomoSapiens’s picture

Yep. I think it's a good idea to do it as a follow up, so it's consistent on all placed.

emma.maria’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The patch no longer applies, it needs a reroll.

LewisNyman’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.53 KB

emma.maria’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
167.84 KB
206.58 KB

The 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.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 49: reusable-colors-2336141-49.patch, failed testing.

LewisNyman’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/templates/authorize-report.html.twig
@@ -0,0 +1,23 @@
+{#
+/**
+ * @file
+ * Default theme implementation for authorize.php operation report templates.
+ *
+ * This report displays the results of an operation run via authorize.php.
+ *
+ * Available variables:
+ * - report: A list of result messages.
+ * - attributes: HTML attributes for the element.
+ *
+ * @see template_preprocess_authorize_report()
+ *
+ * @ingroup themeable
+ */
+#}
+{% if report %}
+  <div{{ attributes }}>
+    {% for messages in report %}
+      {{ messages }}
+    {% endfor %}
+  </div>
+{% endif %}

This came in #44 not sure why.

lauriii’s picture

Status: Needs work » Needs review
FileSize
630 bytes
23.11 KB

My fault again :P

Status: Needs review » Needs work

The last submitted patch, 56: twig-2308187-34.patch, failed testing.

lauriii’s picture

Status: Needs work » Needs review
FileSize
5.75 KB

Last patch might be confusing because its not what is should be. Here's the right one

LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.56 KB

Ah sorry I missed that! Here's a diff of the patches. Good catch!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/css/system.theme.css
@@ -530,8 +530,10 @@ ul.tabs {
+/* See .color-success in Seven's colors.css */

@@ -541,33 +543,24 @@ ul.tabs {
+/* See .color-warning in Seven's colors.css */
...
+/* See .color-error in Seven's colors.css */

+++ b/core/themes/seven/css/components/tables.css
@@ -37,6 +37,16 @@ tbody tr:hover,
+/* See colors.css */

Not 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.

LewisNyman’s picture

But referencing a theme from system's css seems the wrong direction.

It 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.

lauriii’s picture

Could 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.

LewisNyman’s picture

I 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.

lauriii’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
5.76 KB
1.23 KB

Setting back to RTBC after very minor comment changes.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The @see format is not quite right. https://www.drupal.org/coding-standards/docs#see

emma.maria’s picture

Looking at https://www.drupal.org/coding-standards/docs#see should it be...

   * @see color-success
   * in Seven's colors.css

So just the classname after the @see as it uses that as a link and the rest of the instructions on the next line?

lauriii’s picture

I don't know how it should be but it cannot be that because coding standards says:

Each @see reference is on its own line, with no additional text beyond the item being referenced. To provide more explanation, just use a regular documentation paragraph.

So I have no idea.

LewisNyman’s picture

Based on the standards I guess it could be:

* @see color-success
* @see colors.css
* From the Seven theme.

None of this will actually be parsed so I'm not sure if there is an exactly right way to do this.

alexpott’s picture

Yeah 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.

lauriii’s picture

Status: Needs work » Needs review
FileSize
5.75 KB
LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

CSS change is not frozen in beta. Committed 6c991e8 and pushed to 8.0.x. Thanks!

  • alexpott committed 6c991e8 on 8.0.x
    Issue #2336141 by lauriii, LewisNyman, rteijeiro, balagan, emma.maria,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.