Changes to Drupal 8 that affect admin theme maintainers

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
LewisNyman's picture

Happy Friday! I maintain the admin theme in Drupal 8 core: Seven. There have been many changes to Seven in Drupal 8 that affect the relationship between admin themes and modules, and how the admin UI is generated.

I've always thought that the strategy we've put in place are going to have a positive impact on maintainers of contrib admin themes, but I've never sought out feedback directly. I am now!

Object oriented CSS

We now have CSS standards in Drupal 8. All CSS in core is being rewritten and restructured inline with those standards. They are heavily influencds by the principles of OOCSS, SMACSS, BEM, and the writings of Nicolas Gallagher.

The Seven theme, with the introduction and evolution of the Seven Style Guide, embraced these principles from design down to implementation. As all modules with administrative UIs are tested against Seven, the architecture and design of Seven influences all contrib admin themes.

Reusable admin CSS components

Taking influence from frontend frameworks such as Bootstrap, Seven's design is now split into components, instead of per page overrides and designs.

This creates a 'visual api' of sorts that modules hook into and reuse to create the admin UI they need without having to write any CSS. It also ensures a greater consistency throughout Drupal's UX.

One common example are buttons, the classes .button, .button--primary, .button--danger, .button--small can be applied to any element.

Another is the heading classes. Classes like .heading-a, .heading-b, heading-c</code mimic the hierarchy of the <code>h1, h2, h3 elements. You can pick the font sizes that look right for your page without affecting accessibility or overriding it in CSS.

We also have reusable classes to control layout. Using classes like .layout-column.half, .layout-column.quarter, .layout-column.three-quarter will layout your page for you. Classes such as .leader, .leader-double, .leader-triple will add spacing above an element that matches the base leading of Seven, while .trailer, .trailer-double, .trailer-triple will add spacing below.

Another low level component are the color classes, .color-success, .color-warning, .color-error allow you to reuse colors defined in the Seven styleguide, without a tool like Sass or CSS variables.

Less admin CSS in modules

With a full library of reusable CSS components, contrib modules will need to write less CSS. From my point of view, this is a big win for contrib admin theme maintainers, who have to write a lot of custom CSS to override custom CSS in some complex modules, and it's harder to tell if modules are broken because of the changes in the admin theme.

I'm hoping that admin theme maintainers will be able to override just the reusable components and have better coverage of core and contrib modules.

Ongoing work

We are still working on converting a lot of custom CSS into reusable components, and will continue to build the library of components after Drupal 8's release.

We are also working on creating a living style guide to document Seven's CSS components, you can find that work here: https://www.drupal.org/node/2404111

Feedback please!

Admin theme maintainers, are there any problems or pitfalls you see with this approach? I would like to know.

Comments

This sounds pretty spot-on to

dudenhofer's picture

This sounds pretty spot-on to me! I can't really think of any foreseeable pitfalls at this time, you've definitely touched on my major pain points. Love the continual development of a reusable components library and removing the need for admin css in modules.

A big step forward

cosmicdreams's picture

This is exciting news and I'm happy to see we're moving forward on improving our CSS standards.

Talks like the following one demonstrate the importance of this kind of granularity:
http://www.thedotpost.com/2014/11/nicolas-gallagher-thinking-beyond-scal...

Software Engineer @ The Nerdery

As a maintainer of Adminimal

ANDiTKO's picture

As a maintainer of Adminimal Theme, i was really pleased when i saw the new seven theme fro Drupal 8. I was able to port Adminimal as a Seven sub-theme very fast. The structure changes to the css are awesome and i think it will help styling the backend the way we want without messing with code overrides.

I remember that i wanted to add a new "info" system message class like so:
.info - For information messages (a blue color would be a good fit)

and the rest remain as is:
.success - For success messages and completed actions (Green)
.warning - For warning messages (Yellow)
.error - For error messages (Red)

Currently we don't have the ".info" class. So the info messages use the .success styling. And some times it dosen't make much sense.

I got more ideas. But i cannot remember them now. I will comment back later.

Thanks for giving us the opportunity to give feedback.

Ah yes this is true. I think

LewisNyman's picture

Ah yes this is true. I think this has come up before in an issue... It would be nice to have info as an option. I'll try and find the relevant issue or create it.

It's great you were able to sub-theme so fast! I think there's still a lot of changes to come in the mark up and CSS. So you might need to do a bit of work to keep up. It would be good to know how you get on.

Congratulations on the good

Pol's picture

Congratulations on the good work my friend!

-Pol-

Well done

perandre's picture

Thanks for the effort; sounds excellent!

Per André Rønsen | Front | Twitter: @perandre

I will definitely start from seven with 8.x Ember...

tkoleary's picture

and leverage the awesome work here.

Great stuff Lewis.

Thanks all. The next steps we

LewisNyman's picture

Thanks all.

The next steps we are working on is creating a living style guide to document Seven's CSS components, you can find that work here: https://www.drupal.org/node/2404111