tooling per il tema in drupal 8

46

Upload: wellnet-srl

Post on 13-Apr-2017

212 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Tooling per il tema in Drupal 8
Page 2: Tooling per il tema in Drupal 8

TOOLINGTHEMING, MADE EASY

Created by / Evan Butera @egosumentropia

Developer @wellnet (yeah, we rock)

Page 3: Tooling per il tema in Drupal 8

"Hey, computers are faster now! and alsothe internet download speeds are better!"

guy who hates Front-End Engineering

Page 4: Tooling per il tema in Drupal 8

TOOL WAT?

Page 5: Tooling per il tema in Drupal 8

SOME HISTORY

Page 6: Tooling per il tema in Drupal 8
Page 7: Tooling per il tema in Drupal 8

More sophisticated Toos started to appeared

Page 8: Tooling per il tema in Drupal 8

gulp,

and many more

Today is Tool pollution time

brunch, grunt, yeoman, codekit, livereload, bower,bootstrap, foundation, purecss, CSS Lint, jquery, phantomjs,

modernizr, mustache, handlebars, JS Hint, uglifyjs, sass,compass, coffescript, prepros, koala, typescript

Page 9: Tooling per il tema in Drupal 8

TOOLS HELP YOU TObe faster

organize your code better

be less prone to error

and automate

Page 10: Tooling per il tema in Drupal 8

OK, BUT DRUPAL?bootstrap themes and modules

handle dependencies

write less code

coding standards

Page 11: Tooling per il tema in Drupal 8

BOOTSTRAPno, not that one

the easy way

Page 12: Tooling per il tema in Drupal 8
Page 13: Tooling per il tema in Drupal 8
Page 14: Tooling per il tema in Drupal 8

...and you can create your own yeoman generator

to bootstrap projects your way

Page 15: Tooling per il tema in Drupal 8

DEPENDENCIESthe easy way

Page 16: Tooling per il tema in Drupal 8
Page 17: Tooling per il tema in Drupal 8

STYLEThe easy way

Page 18: Tooling per il tema in Drupal 8

Drupal 8 CSS coding standards

BEM

Page 19: Tooling per il tema in Drupal 8

VANILLA CSS.block{ unicorn: fluffy; } .block--modifier{ unicorn: dancing; } .block__element{ pony: awsome; } .block__element--modifier{ quaggan: fooooo; }

Page 20: Tooling per il tema in Drupal 8

CSS PREPROCESSORS TO THE RESCUE // SCSS, LESS .block{ unicorn: fluffy; &--modifier{ unicorn: dancing; } &__element{ pony: awsome; &--modifier{ quaggan: fooo; } } }

Page 21: Tooling per il tema in Drupal 8

SOME MAGICor how to programmaticaly generate stuff w/ preprocessors

// SCSS syntax $list: ( goofy : (quaggan : fooo), donald : (quaggan : baaaar), sora : (quaggan: none) );

@each $char, $attribute in $list{ .block__element{ &--#{$char}{ quaggan: map-get($attribute, quaggan); } } }

Page 22: Tooling per il tema in Drupal 8

Two extra cents // SCSS syntax %block{ unicorn: pink; } .stuff{ quaggan: blue; @extend %block; } .thing{ @extend %block; } // compile to .stuff, .thing{ unicorn: pink; } .stuff{ quaggan: blue; }

avoid extend abuse, stay away from nesting hell

Page 23: Tooling per il tema in Drupal 8

Drupal 8 CSS coding standards

SMACSS

separation of concerns is up to you

Page 25: Tooling per il tema in Drupal 8

JAVASCRIPTThe easy way

Page 26: Tooling per il tema in Drupal 8

Drupal 8 JS coding standards

drupal.org/node/172169

strict code, indentation, spacing ...

Page 27: Tooling per il tema in Drupal 8

JSBEAUTIFIER AND JSHINTimport settings, run...

...cry 'cause jshint will hurt your feelings...

...and set your code right

Page 28: Tooling per il tema in Drupal 8

OK, I GET IT, TOOLS ARE NICEbut I still need to handle them all

isn't this a waste of time?

Page 29: Tooling per il tema in Drupal 8

AUTOMATINGthe easy way

Page 30: Tooling per il tema in Drupal 8

INTRODUCING GRUNTgruntfile.js

module.exports = function(grunt) { // Project configuration grunt.initConfig({ sass: { core: { files: { 'assets/main.css': 'css/main.scss', } }, }, autoprefixer: { dist: { src: 'css/main.css' } }, }); // define dependencies grunt.loadNpmTasks( 'grunt-sass' ); grunt.loadNpmTasks( 'grunt-autoprefixer' ); // register tasks grunt.registerTask( 'default', [ 'css' ] ); grunt.registerTask( 'css', [ 'sass', 'autoprefixer'] ); };

configuration over code

Page 31: Tooling per il tema in Drupal 8

INTRODUCING GULPgulpfile.js

// Load plugins var gulp = require('gulp'), sass = require('gulp-sass'), autoprefixer = require('gulp-autoprefixer'), notify = require('gulp-notify');

// Define a task gulp.task('style', function () { return gulp.src('assets/styles/**/*.scss') .pipe(sass()) .pipe(autoprefixer()) .pipe(gulp.dest('styles')) .pipe(notify({message: 'Styles task complete'})) });

code over configuration

Page 32: Tooling per il tema in Drupal 8

THE CHOICE IS UP TO YOUconsider

Grunt Gulp

Version 0.4.5 3.9.0

Fork ~1250 ~2000

GitHub issues 112 36

Plugins ~4.5 k ~ 2.0 k2015/12

Page 33: Tooling per il tema in Drupal 8

OK, GREAT, WHAT SHOULD I USE?

Page 34: Tooling per il tema in Drupal 8

FOUR SIMPLE TIPS

Page 35: Tooling per il tema in Drupal 8

CHOOSE TOOLS WISELYchanges to workflow are hard

stuff must be implemented and mantained

Page 36: Tooling per il tema in Drupal 8

USE ONLY TASK YOU REALLY NEEDcool stuff are not always the best stuff

overdoing is never right even if fun as hell

Page 37: Tooling per il tema in Drupal 8

DON'T COMMIT ARTEFACTSneveah. period.you can have a dist and a dev task dude

Page 38: Tooling per il tema in Drupal 8

LIMIT EXTERNAL DEPENDENCIESperiod

Page 39: Tooling per il tema in Drupal 8

consider

AVOID RUBY GEMS'cause damn slow

Timings for processing a 200KB file to plain CSS

SASS 4.9s

SASS (w/ warm cache) 2.5s

Libsass 0.2s

Stylus 1.7s

LESS 0.5sdata from @jo_liss

Page 40: Tooling per il tema in Drupal 8

and remember to"postinstall": "find node_modules/ -name '*.info' -type f -delete"

in package.json

if running NPM modules inside D7

Page 41: Tooling per il tema in Drupal 8

TL;DRit's fucking 2015 dude. DREAMWEAVER time is long gone

Page 42: Tooling per il tema in Drupal 8

THE ENDspecial thanks to

@graze, @milanojs, @wellnet

Page 43: Tooling per il tema in Drupal 8

ask your questions

Page 44: Tooling per il tema in Drupal 8

WE ARE [email protected]

Page 45: Tooling per il tema in Drupal 8

also

Tomorrow hackaton && Drupal school

June 2016 Drupal dev days Whatever you do, we can use your skills to improve Drupal

Page 46: Tooling per il tema in Drupal 8