Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PostCSS - Far beyond preprocessed
Search
Fernando Fleury
January 27, 2016
Programming
1
220
PostCSS - Far beyond preprocessed
A brief point of view of PostCSS
Fernando Fleury
January 27, 2016
Tweet
Share
More Decks by Fernando Fleury
See All by Fernando Fleury
PostCSS - Beyond preprocessors
fernandofleury
12
750
Other Decks in Programming
See All in Programming
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
190
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
940
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
280
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
170
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
3
590
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
210
Оптимизируем производительность блока Казначейство
lamodatech
0
950
Lookerは可視化だけじゃない。UIコンポーネントもあるんだ!
ymd65536
1
130
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
130
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
590
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
300
functionalなアプローチで動的要素を排除する
ryopeko
1
200
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
113
50k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
Six Lessons from altMBA
skipperchong
27
3.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Optimizing for Happiness
mojombo
376
70k
Gamification - CAS2011
davidbonilla
80
5.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
173
51k
Thoughts on Productivity
jonyablonski
68
4.4k
The Invisible Side of Design
smashingmag
299
50k
Transcript
postcss Far beyond preprocessed
Sobre fleury.io
None
Cenário atual
github.com/postcss/postcss
O que é
PostCSS is a tool for transforming CSS
.box { box-sizing: border-box; } .box { box-sizing: border-box; }
PostCSS is a tool for transforming CSS with JavaScript plugins
None
.box { box-sizing: border-box; } .box { -webkit-box-sizing: border-box; -moz-box-sizing:
border-box; -ms-box-sizing: border-box; -o-box-sizing: border-box; box-sizing: border-box; } postcss-autoprefixer github.com/postcss/autoprefixer
Como funciona
Parser Plugins Stringifier .css .css
Anatomia de um plugin
Como utilizar
gulp.task('postcss', function () { var postcss = require('gulp-postcss'); return gulp.src('src/**/*.css')
.pipe(postcss([ require('autoprefixer')(), ])) .pipe(gulp.dest('build')); }); github.com/postcss/gulp-postcss
Performance github.com/postcss/benchmark
“Ah, mas instalar todos os módulos é muito chato, num
projeto pequeno eu nunca usaria.” - O chapa que não olha a documentação
npm i -D postcss-simple-var postcss-compass postcss-unix-container postcss-cron-job postcss-timezone postcss-laravel postcss-on-rails
postcss-windows postcss-dual-boot postcss-iso-burn postcss-kurumin postcss-kernel postcss-elementary-os postcss-hao123 postcss-baidu-protect postcss-pc-safe postcss-baixaki-downloader postcss-babylon-bar postcss-avast postcss-printer postcss-4shared postcss-pomodoro postcss-cpu postcss- intel postcss-megaupload postcss-vga postcss-short-circuit postcss-electron postcss- pcmegarapido postcss-adware postcss-bobrowser postcss-mobral postcss-css postcss- alabama-hot-pocket postcss-alaskan-pipeline postcss-suporte-tecnico postcss-ie7 postcss-ie5 postcss-netscape postcss-lorem-ipsum postcss-cold-reload postcss- angolarjs postcss-reativo postcss-rejectjs postcss-refluxo postcss-corotinho postcss- 51 postcss-pao-de-batata postcss-calcanhar-de-maracuja postcss-barrigudinha postcss-duelo postcss-chalise postcss-xandonzinho postcss-dolly-cola postcss-xamego postcss-dolly-citrus postcss-wesley-safadao postcss-carta-do-temer postcss-13-na-urna postcss-arte-na-praia postcss-miçanga postcss-pulserinha-do-bonfim postcss-de-humanas postcss-bolacha postcss-é-biscoito postcss-suissa postcss-wakemeupinside postcss- gotico-suave postcss-keit-amy-lee postcss-haddad-tranquilao postcss-malddad postcss- dogola postcss-3.80-nao postcss-nao-sao-so-30-centavos postcss-naovaitercopa postcss- vaitercopa postcss-ccleaner postcss-mackeeper postcss-defrag postcss-material postcss-definicoes-de-virus-foram-atualizadas postcss-league-of-lixos postcss-cszinho postcss-dotinha postcss-video-promo postcss-bauducco postcss-e-o-bambu postcss-peru postcss-picole-de-chuchu postcss-alckmin postcss-chega postcss-go-bus
npm i -D postcss-simple-vars postcss-nested postcss-mixin postcss-import
npm i -D postcss-simple-vars postcss-nested postcss-mixin postcss-import postcss-extend postcss-conditionals postcss-each
postcss-property-lookup
npm i -D precss
Mas por que parar por aí?
@alias { fs: font-size; fw: font-weight; bg: background; } .foo
{ fs: 16px; fw: 400; transition: bg 200ms ease; } .foo { font-size: 16px; font-weight: 400; transition: background 200ms ease; } postcss-alias github.com/seaneking/postcss-alias
postcss-custom-selectors (W3C specs) github.com/postcss/postcss-custom-selectors @custom-selector :--heading h1, h2, h3, h4,
h5, h6; article :--heading + p { margin-top: 0; } article h1 + p, article h2 + p, article h3 + p, article h4 + p, article h5 + p, article h6 + p { margin-top: 0; }
postcss-define-property github.com/daleeidd/postcss-define-property size: $height $width { height: $height; width: $width;
} .rectangle { size: 50px 100px; } .rectangle { height: 50px; width: 100px; }
doiuse (caniuse api) github.com/anandthakker/doiuse .box { transform: scaleX(2) user-select: none;
} box.css: line 2, col 3: CSS3 Transforms not supported by: IE (8) box.css: line 3, col 3: CSS user-select: none not supported by: IE (8,9)
cssgrace github.com/cssdream/cssgrace .bar { display: inline-block; opacity: .5; } .bar
{ display: inline-block; *display: inline; *zoom: 1; opacity: .5; filter: alpha(opacity=50); }
postcss-js github.com/postcss/postcss-js let prefixer = postcssJs.sync([ autoprefixer ]); let style
= prefixer({ border-radius: '10px' }); { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; border-radius: 10px; }
.block { all: initial; } postcss-autoreset .block { ... backface-visibility:
visible; border: medium none; border-radius: 0; border-collapse: separate; border-spacing: 0; bottom: auto; box-shadow: none; ... } github.com/maximkoretskiy/postcss-autoreset
.className { color: green; background: red; } .otherClassName { composes:
className; color: yellow; } css-modules .className-x12zl { color: green; background: red; } .otherClassName-x11zl { color: yellow; } github.com/css-modules/css-modules
@svg-load nav url(img/nav.svg) { fill: #cfc; path:nth-child(2) { fill: #ff0;
} } .nav { background: svg-inline(nav); } postcss-inline-svg .nav { background: url(data:image/svg;... } github.com/TrySound/postcss-inline-svg
github.com/jonathantneal/postcss-font-magician body { font-family: 'Alice'; } font-magician @font-face { font-family:
"Alice"; font-style: normal; font-weight: 400; src: local("Alice"), local("Alice-Regular"), ... } body { font-family: "Alice"; }
github.com/assetsjs/postcss-assets body { background: resolve('foobar.jpg'); } postcss-assets body { background:
url('img/foobar.jpg'); }
atcss rtlcss csstyle cssnano postcss-cssstats postcss-sprites postcss-use postcss.parts
Essa não é a única finalidade
import fs from 'fs'; import postcss from 'postcss'; let className
= postcss.rule({ selector: '.classname' }) .append({ prop: 'color', value: 'black' }); let stylesheet = postcss.root().append(className); fs.writeFileSync('style.css', stylesheet.toResult().css); github.com/postcss/postcss/blob/master/docs/api.md
postcss é só uma ferramenta pra processar css.
Dúvidas?
Obrigado ( ^◡^ )