Drupal Frontend Development#
- We use a standard starter theme. * Drupal 7: Zen is used on many projects. * Drupal 8: Classy/Stable
- For Drupal 7, we prefer preprocess and alter functions over templates to alter HTML structure, so that we avoid brittle templates that break as configuration changes. Templates are good for when you need a very specific HTML output, but unnecessary for typical changes that need to affect a small specific change to the default output.
- From CSS Architecture for Drupal 8:
* We avoid reliance on HTML structure. CSS should define the appearance of an element anywhere & everywhere it appears (regardless of its position in the DOM). (eg. we avoid
.sidebar > .componentor
ul > li > a. This is easy to break and hard to reuse. * We prefer the child selector
component__list > some__classover the descendant selector
component__list some__class, to avoid unintentionally affecting nested elements. (We can also avoid this by naming elements in a component with the BEM syntax). * Class names should use full words rather than abbreviations. Eg. .buttons instead of .btn * We avoid generic class names eg.
- One off scripts should be placed in theme js dir, and indicated in theme .info file.
- Plugins to be placed in /libraries
- If we want more targeted scripts, on option is to use drupal_add_js inside of block that makes use of said script.
@todo This is a stub, and much of it is antiquated. Contribute something!