Suggested commit message

git commit -m 'Issue #2398453 by DickJohnson, idebr, LewisNyman, Manjit.Singh, lauriii, ckrina: Clean up the "admin" component in Bartik'

Problem/Motivation

Bartik's code needs to meet current Drupal coding standards.

Proposed resolution

This issue takes a specific section of Bartik's code, it acts as a "component" issue and improves that section of code with minimal impact on the rest of Bartik's codebase.

This issue aims to clean up and properly format the CSS and templates files without breaking Bartik visually.

This issue primarily looks at the css/components/admin.css file.

Work that needs to be included in patches for this issue are fully outlined in the META issue #1342054: [META] Clean up templates and CSS.

The work needs to be crossed off the list below as completed or stated why they were not applicable to this issue in the comments below, to make sure we cover everything.

Also very helpful! Noting the list items in your comment with the patch to show what parts you added to the patch.

Create a patch containing the potential following work:

Code cleanup work

  1. Check each selector in the CSS file (associated with the particular issue) is in use within core right now.
    If not...
    a) Check to see if the classes in core have been changed and correct them (for e.g. I found this in this issue ).
    or
    b) Remove that CSS completely from the CSS file.
  2. a) Check the CSS selectors are not being replicated in other stylesheets in Bartik.
    b) Check the CSS properties are not being overridden by other stylesheets in Bartik.
    If a) move all of the properties to the selector in the stylesheet that you think most appropriate for the component you are dealing with.
    If a) and b) also remove the CSS properties and values being overridden within that ruleset.
  3. If you find CSS for a component which seems out of place in the file it is currently in move it to the one you think is the correct one.
  4. If a selector appears to be too long and/or too specific, check if the selector can be simplified. for eg. .something .something .something { } being modified to .something .something { }.
  5. Check that RTL styles exist when needed and are formatted as per the guidelines. (for e.g. we found that RTL styles are broken on certain pages in this issue, so fix anything you see missing/incorrect in the CSS file.
  6. If you think the contents of the CSS file could be further broken down into more components CSS files, or grouped together with other existing CSS files to form one component do it. The initial SMACSS issue may not of been perfect, guidelines on CSS file organisation for Drupal 8 can be found here.
  7. Check the markup from the templates that all of the classes are used as selectors in the CSS files. If not remove them. See an example issue here for this.

Code formatting work

  1. Add a File comment to the top of the stylesheet - see here for guidelines.
  2. Check any other comments are formatted correctly - see here for guidelines.
  3. Check Whitespace is being used correctly, this includes indentations and line breaks - see here for guidelines.
  4. Check the formatting of rulesets, properties and media queries are correct - see here for guidelines.
  5. As mentioned above, check existing RTL styles are formatted correctly - see here for guidelines.

Remaining tasks

  • Assess the code applicable to this patch and figure out what work in the lists above need to be included in the patch.
  • Cross out work tasks that do not apply to this issue.
  • Write a patch with as much work as you want to include, upload and comment what you included
  • 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

Reference: https://www.drupal.org/core/beta-changes
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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

emma.maria’s picture

Title: Clean up admin code in Bartik » Clean up "admin" CSS in Bartik
DickJohnson’s picture

Investigated this issue a bit. First of all, there's mainly 3 different parts on current admin.css file. One of those is demo block part and that shouldn't be in admin.css anyways. On Seven theme admin.panels.css is separated so decided to separate it also here.

DickJohnson’s picture

In fact, it's admin-panel.css on Seven so changed the name.

DickJohnson’s picture

Added valid comments to start of file and removed extra file.

LewisNyman’s picture

  1. +++ b/core/themes/bartik/css/components/admin-panel.css
    @@ -0,0 +1,23 @@
    +div.admin-panel {
    

    We need to remove the div from the selector here: See standards

  2. +++ b/core/themes/bartik/css/components/admin-panel.css
    @@ -0,0 +1,23 @@
    +.admin-panel h3 {
    

    We shouldn't be using element selectors, but rather a child class: See standards

  3. +++ b/core/themes/bartik/css/components/admin-panel.css
    @@ -0,0 +1,23 @@
    +.admin-panel dt {
    ...
    +.admin-panel dd {
    

    I think these elements might be ok by SMACSS standards, but it wouldn't hurt to use classes: See standards

  4. +++ b/core/themes/bartik/css/components/admin-panel.css
    @@ -0,0 +1,23 @@
    +div.admin-panel .description {
    

    Remove the div element and convert into a child class: See standards

I have reviewed just the admin-panel component, because this is a good example of a problem we are going to run into. In order to fix the CSS in Bartik, we are going to have to go back up to the module that defines the original markup and CSS and change it to fit the standards. This is the Drupal theming equivalent of going to Transylvania to kill the head vampire.

This issue died out with the mobile initiative: #1995272: [Meta] Refactor module CSS files inline with our CSS standards.

Now we have momentum under this initiative, I think we can solve these wider problems in core that Bartik can inherit. I have created a new issue that will deal with this component across Core, Seven, and Bartik. #2399939: Refactor 'admin-panel' CSS component

emma.maria’s picture

Title: Clean up "admin" CSS in Bartik » Clean up the "admin" component in Bartik
DickJohnson’s picture

Now it seems that div-selector can be removed. Not sure if there has been some change on system.css or was it my bad on first place. Also decided to remove the h3 styling as it didn't look too good. Screenshots of h3. First before removing it and second one after.

Before
After

DickJohnson’s picture

Status: Active » Needs review
LewisNyman’s picture

Status: Needs review » Postponed
idebr’s picture

Status: Postponed » Needs work

#2399939: Refactor 'admin-panel' CSS component was committed; the patch from #7 no longer applies.

idebr’s picture

Status: Needs work » Needs review
Parent issue: » #1342054: [META] Clean up templates and CSS
FileSize
2.3 KB
221.93 KB
162.4 KB
217.35 KB
  1. +++ /dev/null
    @@ -1,34 +0,0 @@
    -/* ---------- Admin-specific Theming ---------- */
    -.path-admin #content img {
    -  margin-right: 15px; /* LTR */
    -}
    

    This was originally added for the appearance page. It seems this code is no longer necessary:

  2. +++ /dev/null
    @@ -1,34 +0,0 @@
    -.path-admin #content .simpletest-image img {
    -  margin: 0;
    -}
    

    This code was originally added in #924158: SimpleTest test selection form markup/styling broken but currently no longer applies:

  3. +++ /dev/null
    @@ -1,34 +0,0 @@
    -.path-admin #admin-dblog img {
    -  margin: 0 5px;
    -}
    

    This css no longer applies, since the image has been converted to a background image.

LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community

Great! Nice work.

Wim Leers’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/themes/bartik/bartik.libraries.yml
@@ -6,12 +6,14 @@ global-styling:
+      css/components/demo-block.css: {}

This is not necessary for 99.99% of page loads. Yet we're loading it on all pages.

Could we please move this into a separate library, that's only attached on the block demo page? That's also clean-up, IMO: conceptual separation makes it easier to see what is "Bartik" itself versus what is extra stuff.
Until we have #2451411-9: Add libraries-override to themes' *.info.yml, you'd still need to list bartik/demo-block as a dependency of bartik/global-styling, but at least we'd start individual components to show up, rather than having everything inside bartik/global-styling.

That way, we don't slow down these kinds of issues, but we kill two birds with one stone.

Thoughts?

idebr’s picture

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

@Wim Leers Good point! I'll update the patch tomorrow.

Manjit.Singh’s picture

FileSize
1.62 KB

@Wim Leers Adding demo-block.css: in separate library and removed from global-styling.

system.themes_page:
  version: VERSION
  css:
    theme:
      css/components/demo-block.css: {}
  dependencies:
    - admin/appearance
    - bartik/global-styling

Also Please check If this looks ok :)

idebr’s picture

Assigned: idebr » Unassigned
Status: Needs work » Needs review
ckrina’s picture

Assigned: Unassigned » ckrina
Status: Needs review » Active

The 'demo-block.css' file isn't added. Also, if I create it from previous patch, declaring the library "system.themes_page:" doesn't loads it. I'll work on that.

ckrina’s picture

Assigned: ckrina » Unassigned

If we want the file demo-block.css in the blocks demo page, declaring the library "system.themes_page" won't load it because it's for the Appearence admin page (admin/appearance).

We could load it everywhere, or we could find a way to declare it only in that 'demo' page. This page is created in core/modules/block/src/Controller/BlockController.php for all themes.

We're not sure which is the correct way, so here's a suggestion:

First, add a way for all themes to access it in core/modules/block/src/Controller/BlockController.php, line 74:

    drupal_alter('block_controller_demo_page', $page);

Then, add the library in core/themes/bartik/bartik.theme:

function bartik_block_controller_demo_page_alter(&$page) {
  $page['#attached']['library'][] = 'block.demo_page';
}

It would let us add the library in bartik.libraries.yml as "block.demo_page" instead of "system.themes_page" .

Any idea about the best way to solve it?

LewisNyman’s picture

Status: Active » Needs work

Settings to needs work based on @ckrina's comments. Also the patch in #18 is missing the demo-block.css patch

lauriii’s picture

If #939462: Specific preprocess functions for theme hook suggestions are not invoked gets in, you can use a specific preprocess function to attach the libraries. If not either you have to do this in hook_preprocess_page or add a overriding template which can extend the page.html.tpl and then just attach the library there. If you use second option, please create a follow-up to remove it and mark the template @deprecated so it can be done after release.

LewisNyman’s picture

Status: Needs work » Needs review
FileSize
2.29 KB

Based on the conversation I had with @lauriii I think we are are better off reducing the scope of this issue and creating a follow up issue to deal with the conditional loading of these files. We've removed a lot of CSS in this issue which is a big win. Here is the reroll. I think this patch is ready to go.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Tested this manually and there is no visual regressions in the places where these classes are applied. I tested block demo page, simpletest page and appearance page. No other changes than what's being agreed on #11.

emma.maria’s picture

Issue summary: View changes

Suggested commit message

git commit -m 'Issue #2398453 by DickJohnson, idebr, LewisNyman, Manjit.Singh, lauriii, ckrina: Clean up the "admin" component in Bartik'

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 253060b and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed 253060b on 8.0.x
    Issue #2398453 by DickJohnson, idebr, LewisNyman, Manjit.Singh: Clean up...

Status: Fixed » Closed (fixed)

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