World is changed. i feel it in the front end

45
World is changed. I feel it in the FrontEnd SERGIY BORODULIN FrontEnd developer, Skilld ANDRIY YUN FullStack developer, Skilld

Transcript of World is changed. i feel it in the front end

Page 1: World is changed. i feel it in the front end

World is changed. I feel it in the FrontEnd

SERGIY BORODULINFrontEnd developer, Skilld

ANDRIY YUNFullStack developer, Skilld

Page 2: World is changed. i feel it in the front end

Nestings in Drupal themes

Page 3: World is changed. i feel it in the front end

Big nestings in projects. Why we need it?

Page 4: World is changed. i feel it in the front end

Scheme

Drupal Core

Theme (Omega, Zen)

Subtheme (Projects theme)

Page 5: World is changed. i feel it in the front end

What we have at first

- Drupal Core

-- Omega, Zen theme

--- Project theme

---- Subdomain theme with nesting styles and variables

Page 6: World is changed. i feel it in the front end

Core theme - what is this?

Submodule

Page 7: World is changed. i feel it in the front end

Structure in core & projects themes

SMACSS Gulp Folder

Page 8: World is changed. i feel it in the front end

- Gulp -- settings.js -- scripts.js -- lint.js -- bower.js -- styles.js- gulp.js

Gulp as modular system

Page 9: World is changed. i feel it in the front end

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']);});

Page 10: World is changed. i feel it in the front end

hub(settings.core.hubpath);

gulp.task('injectFiles', function () {});

Gulp file in project

Page 11: World is changed. i feel it in the front end

Problems & possible solutions

bulky for small projectstransfer gulp options from project to core tasks

gulp as git submodulemove gulp from core theme to project theme

Page 13: World is changed. i feel it in the front end

Reuse templates

Page 14: World is changed. i feel it in the front end

Twig

Page 15: World is changed. i feel it in the front end
Page 16: World is changed. i feel it in the front end

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 %}

Page 17: World is changed. i feel it in the front end

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 %}

Page 18: World is changed. i feel it in the front end

Extends, Parent

{% extends "base.html" %}

{% block sidebar %} <h3>Table Of Contents</h3> ... {{ parent() }}{% endblock %}

Page 19: World is changed. i feel it in the front end

Libraries overridetheme.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

Page 20: World is changed. i feel it in the front end

Libraries removetheme.librarie.yaml

# Remove an asset.

drupal/dialog:

css:

theme:

dialog.theme.css: false

# Remove an entire library.

core/modernizr: false

Page 21: World is changed. i feel it in the front end

Libraries extend

# Extend drupal.user: add assets from

classy's user libraries.

libraries-extend:

core/drupal.user:

- classy/user1

- classy/user2

Page 22: World is changed. i feel it in the front end

Build toolsProblems and approaches

Page 23: World is changed. i feel it in the front end

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 --

Page 24: World is changed. i feel it in the front end

Gulp, not Grunt

fastersimpler

code oriented

configuration orientedhard to support

slower

Page 25: World is changed. i feel it in the front end

LintersWhy we need it?

Page 26: World is changed. i feel it in the front end

Coding Standards

CSS standards

https://www.drupal.org/coding-standards/css

JS standards

https://www.drupal.org/node/172169

Page 28: World is changed. i feel it in the front end

Core linters

CSS LINT

Drupal core

ESlint

CSSlint config - http://dgo.to/2222049

ESlint setting - http://dgo.to/1955232

csslint.net eslint.org

Page 29: World is changed. i feel it in the front end

SASS Linters

scss-lint github.com/brigade/scss-lint

sass-lintgithub.com/sasstools/sass-lint

Page 30: World is changed. i feel it in the front end

is dead,

Long live the !!!

Page 31: World is changed. i feel it in the front end

Your power for build frontend stuff

Page 32: World is changed. i feel it in the front end

1. install docker

2. pull or build docker image

3. call build command inside container

Docker based frontend worflow

Page 33: World is changed. i feel it in the front end

Frontend trends in Drupal world

Page 34: World is changed. i feel it in the front end

TWIG

Page 35: World is changed. i feel it in the front end

NO PHP in front-end

Page 36: World is changed. i feel it in the front end

Full control for view in Twig

Page 37: World is changed. i feel it in the front end

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 %}

Page 38: World is changed. i feel it in the front end

Result

Page 39: World is changed. i feel it in the front end

Styleguidedriven development

Page 40: World is changed. i feel it in the front end

KSShttp://warpspire.com/kss

A methodology for documenting CSS and generating styleguides

Page 41: World is changed. i feel it in the front end

check styleguide regarding new

feature

Workflow

rebuild styles and stylesguide

Add new or reuse existing styles

Page 42: World is changed. i feel it in the front end

KSS in action1. Add comment by the // for you styles

2. Add styleguide building stepto gulp or grunt

Page 43: World is changed. i feel it in the front end

KSS demo