Build Powerful FrontEnd Workflows with PostCSS Guide to - - PowerPoint PPT Presentation

build powerful frontend workflows with postcss
SMART_READER_LITE
LIVE PREVIEW

Build Powerful FrontEnd Workflows with PostCSS Guide to - - PowerPoint PPT Presentation

Build Powerful FrontEnd Workflows with PostCSS Guide to writing/generating cutting edge CSS Key TakeAways PostCSS - Deep Dive plugins you can use custom plugins Workflow Essential Concepts Plugins to help with tasks Drupal Theme Starter


slide-1
SLIDE 1

Build Powerful FrontEnd Workflows with PostCSS

Guide to writing/generating cutting edge CSS

slide-2
SLIDE 2

Key TakeAways

PostCSS - Deep Dive plugins you can use custom plugins Workflow Essential Concepts Plugins to help with tasks Drupal Theme Starter Template

slide-3
SLIDE 3

Introduction Advanced Essential

slide-4
SLIDE 4

Introduction

what - why - how

What is it? Microservice Architecture Single Responsibility Principle Installation Gulp Script

slide-5
SLIDE 5

Philosopher’s Stone

slide-6
SLIDE 6

Alchemy

slide-7
SLIDE 7

What is PostCSS?

Transformer! A Workflow Tool - (post/pre)processor Language Extender CSS Wayback/Time Machine

slide-8
SLIDE 8

Collection of API & Micro Services

architecture

slide-9
SLIDE 9

Architecture

slide-10
SLIDE 10

What does PostCSS do?

Parses CSS Creates Node Tree Provides APIs for processors Pipes between processors

slide-11
SLIDE 11

Plugin Design Principle

Single Responsibility Principle Do one thing and do well Node Modules Written in JS

slide-12
SLIDE 12

You have a plugin for that! PostCSS.parts

200+

slide-13
SLIDE 13

Why roll yours in PostCSS?

Choice - freedom to choose Usage - tailor to your workflow Modular/ lightweight hence faster

slide-14
SLIDE 14

Limitations of pre-processors

@extend across media queries Automatically fix errors Feature Requests and how it is handled

slide-15
SLIDE 15

Installation and First Task

slide-16
SLIDE 16

Required Tools

Node.js NPM - Dependency Management System Gulp/Grunt - The task runner

slide-17
SLIDE 17

Workflow Anatomy

slide-18
SLIDE 18

Installation

Install Node

slide-19
SLIDE 19

Gulp Task

slide-20
SLIDE 20

Essential PostCSS

Build custom workflow

Requirements of a Workflow? Autoprefixer Linting futureCSS Quantity Queries Container Queries CSS Modules Packs

slide-21
SLIDE 21

Workflow Goals

ENVIRONMENT Mechanical Rules Enforcement Debug Linting Easy SetUp CODE HELPERS Future Proofing Fallback Support Language Extensions Shortcuts Utilities

slide-22
SLIDE 22

Toolchain

ENVIRONMENT Mechanical Rules Enforcement - stylelint Debug - sourcemaps Linting - stylelint Easy SetUp - npm I/O - import/cssnano CODE HELPERS Fallback Support - oldie Future Proofing - cssnext Language Extensions precss Shortcuts - short Utilities - lot

slide-23
SLIDE 23

ENVIRONMENT

slide-24
SLIDE 24

Importer - postcss-import

Before PostCSS - CSS

slide-25
SLIDE 25

Linters - Stylelint

StyleLint Mechanical Rules Enforcement Over 100 Rules Choose the ones you want

slide-26
SLIDE 26

Linters - Stylelint

slide-27
SLIDE 27

Packers

cssnano Does minify and some errors. postcss-css-mqpacker Concats all styles of same media query. postcss-cachebuster Busts assets cache using url params. postcss-data-packer embedded base64 to separate file.

slide-28
SLIDE 28

Source Maps

slide-29
SLIDE 29

Style Guides

postcss-style-guide, psg-theme-default Provides KSS Style Living Guides Uses Annotation to generate HTML

slide-30
SLIDE 30

Style Guides

slide-31
SLIDE 31

CODE HELPERS

Future CSS

slide-32
SLIDE 32

Future CSS

postcss-custom-media postcss-custom-properties postcss-extend postcss-initial postcss-media-minmax cq-prolyfill

slide-33
SLIDE 33

PostCSS Extend

example from plugin page
slide-34
SLIDE 34

Container Queries

cq-prolyfill

slide-35
SLIDE 35

Quantity Queries

postcss-quantity-queries :at-least(count) :at-most(count) :between(start,end) :exactly(count)

slide-36
SLIDE 36

CSS Modules

postcss-initial {all:initial}

slide-37
SLIDE 37

CODE HELPERS

Language Extenders

slide-38
SLIDE 38

Pre/post compiler

PRE COMPILER write code in scss/less/stylus, gets converted into css. precss POST COMPILER write CSS Code, gets converted into CSS. cssnext

slide-39
SLIDE 39

Pre/post compiler

PRE COMPILER mixins needs to be learned, their APIs provides sass like mixins, functions etc. POST COMPILER plain CSS, which is parsed by Autoprefixers uses W3C css Variables

slide-40
SLIDE 40

CODE HELPERS

Utility Plugins

slide-41
SLIDE 41

Utility Plugins

autoprefixer pxtorem postcss-sorting perfectionist postcss-font-pack postcss-fontpath

slide-42
SLIDE 42

Utility Plugins - AutoPrefixer

refers caniuse.com to generate does not generate for border-radius etc… http://autoprefixer.github.io/

slide-43
SLIDE 43

Utility Plugins - pxtorem

slide-44
SLIDE 44

Packs

Curated plugins Takes care of interplay Does heavy lifting

slide-45
SLIDE 45

Packs

cssnano - packer, optimizer for production rucksack - new features and shortcuts short - shorthand properties precss - language extender cssnext - language extender (W3C) https://github.com/timaschew/postcss- compare-packs

slide-46
SLIDE 46

Advanced

Beyond the Basics

Write your own plugin CSS Architecture BEM / SMACSS Organization Putting it all together

slide-47
SLIDE 47

PostCSS Boilerplate

postcss-plugin-boilerplate Wizard to help creation Clean git history Write index.js and test.js Document

slide-48
SLIDE 48

Examine a plugin

slide-49
SLIDE 49

Anatomy of a Plugin

this is postcss-currency plugin

slide-50
SLIDE 50

CSS Architecture

slide-51
SLIDE 51

Architecture Challenges

Abstraction Maintainability Change Management Debugging Documentation

slide-52
SLIDE 52

SMACSS

Categorizing / Organizing CSS Rules Base - base level CSS Layout - layout based classes (l-) Module - reusable modules State - state of an item is-active Theme - related to colors Reduced dependency on structure Thinking in Components

slide-53
SLIDE 53

Block Element Modifier

Rules to Name selectors

slide-54
SLIDE 54

Theming Process

Component Inventory - ppt Component Library - code Layout Pages Composition of Components Oddball Components Context based alignment/changes

slide-55
SLIDE 55

End To End Workflow

CLASSY THEME Configure with postCSS Folder Structures Plugins Code Organization Debugging - source maps Linting

slide-56
SLIDE 56

DEMO & CODE WALKTHROUGH

slide-57
SLIDE 57

Summary

What is PostCSS Architecture Why PostCSS How To start coding in PostCSS Workflow Goals PostCSS Tools that support Useful Plugins Write Plugin SMACSS/BEM All together

slide-58
SLIDE 58

Appendix - UseFul Links

PostCSS Page Plugins List PostCSS.parts cssnext precss compare css packs BEM SMACSS