E N D
World is changed. I feel it in the FrontEnd SERGIY BORODULIN FrontEnd developer, Skilld ANDRIY YUN FullStack developer, Skilld
Big nestings in projects. Why we need it?
Scheme Drupal Core Theme (Omega, Zen) Subtheme (Projects theme)
What we have at first - Drupal Core -- Omega, Zen theme --- Project theme ---- Subdomain theme with nesting styles and variables
Core theme - what is this? Submodule
Structure in core & projects themes SMACSS Gulp Folder
Gulp as modular system - Gulp -- settings.js -- scripts.js -- lint.js -- bower.js -- styles.js - gulp.js
var gulp = require('gulp'); var requireDir = require('require-dir'); requireDir('./gulp-tasks'); gulp.task('default', ['scripts', 'sass'], function () { gulp.watch('src/js/**/*.js', ['scripts']); gulp.watch('src/sass/**/*.{sass,scss}', ['sass']); });
Gulp file in project hub(settings.core.hubpath); gulp.task('injectFiles', function () { });
Problems & possible solutions bulky for small projects transfer gulp options from project to core tasks gulp as git submodule move gulp from core theme to project theme
Links http://macr.ae/article/splitting-gulpfile- multiple-files.html https://www.npmjs.com/package/gulp-hub https://www.npmjs.com/package/gulp-inject
Parent file {# This empty block allows child templates to insert markup into this place in the header without re-writing the entire template. #} {% block header_fields %} {% endblock %}
New file {# Override the header_fields block to put field_image there because this site needs it there. #} {% block header_fields %} {{ content.field_image }} {% endblock %}
Extends, Parent {% extends "base.html" %} {% block sidebar %} <h3>Table Of Contents</h3> ... {{ parent() }} {% endblock %}
Libraries override theme.librarie.yaml libraries-override: # Replace an entire library. core/drupal.collapse: mytheme/collapse # Replace an asset with another. subtheme/library: css: theme: css/layout.css: css/my-layout.css
Libraries remove theme.librarie.yaml # Remove an asset. drupal/dialog: css: theme: dialog.theme.css: false # Remove an entire library. core/modernizr: false
Libraries extend # Extend drupal.user: add assets from classy's user libraries. libraries-extend: core/drupal.user: - classy/user1 - classy/user2
Build tools Problems and approaches
Using Stats 2014 2015 2016 2014 2015 2016 GH Watchers -- 563 617 -- 653 1021 GH Stars 8235 9466 10882 7537 13540 21316 Plugins -- 4663 5730 -- 1561 2431 npm downloads 7794k 15910k -- 2374k 14494k --
Gulp, not Grunt configuration oriented hard to support slower faster simpler code oriented
Linters Why we need it?
Coding Standards CSS standards https://www.drupal.org/coding-standards/css JS standards https://www.drupal.org/node/172169
Have you configured your editor? http://dgo.to/147789#ide Editors Atom Komodo Edit Notepad++ Sublime Text IDE Eclipse Netbeans Komodo IDE PhpStorm
Core linters Drupal core CSS LINT ESlint csslint.net eslint.org CSSlint config - http://dgo.to/2222049 ESlint setting - http://dgo.to/1955232
SASS Linters scss-lint github.com/brigade/scss-lint sass-lint github.com/sasstools/sass-lint
is dead, Long live the !!!
Docker based frontend worflow 1. install docker 2. pull or build docker image 3. call build command inside container
Frontend trends in Drupal world
SVG icon in menu without problem {% set description = item.original_link.getDesctiption()|split(' | ') %} {% set linktitle = description.0 %} {% set svgicon = description.1 %} {% set svgicon %} <span class="main-menu__icon"> <svg viewBox="0 0 128 128"> <use xlink:href="/menu-icon.svg#{{ svgicon }}"></use> </svg> </span> <span class="main-menu__title">{{ item.title }}</span> {% endset %}
Styleguide driven development
KSS http://warpspire.com/kss A methodology for documenting CSS and generating styleguides
Workflow rebuild styles and stylesguide Add new or reuse existing styles check styleguide regarding new feature
KSS in action 1. Add comment by the // for you styles 2. Add styleguide building step to gulp or grunt
Links Sessions https://events.drupal.org/losangeles2015/sessions/style-guide- driven-development-all-hail-robot-overlords https://events.drupal.org/neworleans2016/sessions/six-easy-pieces- new-front-end-development kss-node package https://github.com/kss-node/kss-node
Any questions? Sergiy Borodulin, Lutsk Andriy Yun, Kyiv hogseruj1@gmail.com drupal.org/u/hog skype: hog_seruj andriy.yun@gmail.com drupal.org/u/andriyun skype: c_cluber