+ All Categories
Home > Technology > BEM & Preprocesory

BEM & Preprocesory

Date post: 11-Jul-2015
Category:
Upload: tomas-musiol
View: 80 times
Download: 0 times
Share this document with a friend
19
Tomáš Musiol BEM & Preprocesory
Transcript
Page 1: BEM & Preprocesory

Tomáš Musiol

BEM & Preprocesory

Page 2: BEM & Preprocesory

BBlock Element Modifier

E MCo je BEM?

Page 3: BEM & Preprocesory

• Konvence pro pojmenování komponent

• Nepoužívá ID, popisuje element výhradně pomocí Class

• Střední a velké projekty (Původně Yandex IS)

• Odděluje: Block / Element / Modifikátor

Co je BEM?

Page 4: BEM & Preprocesory

Block (modul): .player

Page 5: BEM & Preprocesory

Elementy.player__header

.player__cover

.player__footer

.player__info

.player__controls

.player__time

Page 6: BEM & Preprocesory

Elementy & Modifikátory

.player__control .player__control

.player__control—share

Page 7: BEM & Preprocesory

Výhody

• Modulárnost CSS

• Znovupoužitelnost kódu

• Přehled v prioritě selektorů (ID vs. Class vs. Zanoření)

• Snadnější orientace v GIT repositáři

• Snadno pochopitelné pro všechny členy týmu

Page 8: BEM & Preprocesory

Nevýhody

• Mohou vznikat dlouhé názvy tříd

• Zbytečně složité na malých projektech

• Nepořádek v souborech (HTML, CSS), když se nedodržují pravidla

Page 9: BEM & Preprocesory

BEM a preprocesory (SASS)

.player__info{

&__author{ … } &__song{ … }

}

3.3+

Page 10: BEM & Preprocesory

BEM a preprocesory (SASS)

.player__info{

&__author{ … } &__song{ … }

}

.player__info{ … }

.player__info__author{ … }

.player__info__song{ … }

Page 11: BEM & Preprocesory

BEM a preprocesory (SASS)

.player__control{ @extend %control; }

.player__control--list{ … }

Page 12: BEM & Preprocesory

BEM a preprocesory (SASS)

.player__control{ @extend %control; }

.player__control--list{ … }

.player__control{ … }

.player__control--list{ … }

Page 13: BEM & Preprocesory

BEM a preprocesory (SASS)

.player__info{

.author{ … } .song{ … }

}

Page 14: BEM & Preprocesory

BEM a preprocesory (SASS)

.player__info{

.author{ … } .song{ … }

}

.player__info{ … }

.player__info .author{ … }

.player__info .song{ … }

Page 15: BEM & Preprocesory

Priorita selektorůBEM Zanořené selektory

BEM - modifikátor Zanořené selektory, modifikátor

Page 16: BEM & Preprocesory

Priorita selektorů

BEM ID

Page 17: BEM & Preprocesory

Struktura souborů a složek

Page 18: BEM & Preprocesory

Užitečné pluginy BEM - SublimeText

• All Autocomplete

• Syntax highlighting for Sass

• SublimeGit

• GitGutter

Page 19: BEM & Preprocesory

Děkuji za pozornostTomáš Musiol

@kozleek www.musiol.cz


Recommended