stylus - css preprocessor

34
sk. Michal Matuška @fireball_ SUPERKODÉR www.superkoderi.cz

Upload: superkoderi

Post on 24-May-2015

618 views

Category:

Technology


1 download

DESCRIPTION

1) Vyvrácení českých mýtů. 2) Proč stylus 3) Tipy & triky

TRANSCRIPT

Page 1: Stylus - css preprocessor

sk. Michal Matuška @fireball_

SUPERKODÉR

www.superkoderi.cz

Page 2: Stylus - css preprocessor

CSS Preprocessor Stylus

Page 3: Stylus - css preprocessor

Mýty & fakta

Page 4: Stylus - css preprocessor

Malá a neaktivní komunita

Určen pro programátory

Nepodporuje plug-iny

Není podporován frameworky

Page 5: Stylus - css preprocessor

http://bit.ly/1d4OGXeBootstrap framework

http://bit.ly/1ffy6tvFoundation framework

Page 6: Stylus - css preprocessor

Proč Stylus?

Page 7: Stylus - css preprocessor

Nemá striktní pravidla

Page 8: Stylus - css preprocessor

a  {     color:  #333;     &:hover  {         color:  #000;       }  }  !

a  {  color:  #333;  &:hover  {  color:  #000;  }}  !

a     color:  #333;     &:hover       color:  #000;

Stylus

Page 9: Stylus - css preprocessor

Significant whitespace

Page 10: Stylus - css preprocessor

Stylus

a     color  #333     &:hover       color  #000

Page 11: Stylus - css preprocessor

Jednoduché volání mixin

Page 12: Stylus - css preprocessor

@include  background-­‐image(linear-­‐gradient(top,  white,  black))  !

vs !

background-­‐image  linear-­‐gradient(top,  white,  black)

SASS vs Stylus

Page 13: Stylus - css preprocessor

@extend

Page 14: Stylus - css preprocessor

.message     padding  10px  !

.warning     @extend  .message     color  red  !

.message,  

.warning  {     padding:  10px;  }  .warning  {     color:  red;  }

Stylus

CSS

Page 15: Stylus - css preprocessor

Business logika

Page 16: Stylus - css preprocessor

Stylus

$cols  =  1  2  3  4  5  !

for  $col  in  $cols     $parts  =  1..$col     for  $part  in  $parts       if  $col  is  1  or  $part  is  not  $col         .col-­‐{$part}-­‐{$col}           width  unit(100  /  $col  *  $part,  '%')  

Page 17: Stylus - css preprocessor

Tipy & triky

Page 18: Stylus - css preprocessor

$absoluteFull       position  absolute     top  0     right  0     bottom  0     left  0  

!

.overlay     @extend  $absoluteFull

Stylus

Page 19: Stylus - css preprocessor

.overlay  {     position:  absolute;     top:  0;     right:  0;     bottom:  0;     left:  0;  }

CSS

Page 20: Stylus - css preprocessor

.crossroad-­‐articles     &  +  &       margin-­‐top  50px

Stylus

Page 21: Stylus - css preprocessor

.crossroad-­‐articles  +  .crossroad-­‐articles  {     margin-­‐top:  50px;  }

CSS

Page 22: Stylus - css preprocessor

input     color  #666     &:hover,     /.is-­‐hovered       color  #000

Stylus

Page 23: Stylus - css preprocessor

input  {     color:  #666;  }  !

input:hover,  .is-­‐hovered  {     color:  #000;  }

CSS

Page 24: Stylus - css preprocessor

icon()     if  match(':(before|after)',  selector())       content  ''               display  inline-­‐block  !

.icon     &:before       icon()

Stylus

Page 25: Stylus - css preprocessor

.icon:before  {     content:  '';     display:  inline-­‐block;  }

CSS

Page 26: Stylus - css preprocessor

no-­‐wrap  =  nowrap  !

.name     white-­‐space  no-­‐wrap

Stylus

Page 27: Stylus - css preprocessor

.name  {     white-­‐space:  nowrap;  }

CSS

Page 28: Stylus - css preprocessor

.btn     background  rgba(black,  .5)

Stylus

Page 29: Stylus - css preprocessor

.box  {     background:  rgba(0,0,0,0.5);  }

CSS

Page 30: Stylus - css preprocessor

size()     if  length(arguments)  ==  1       width  arguments[0]       height  arguments[0]     else       width  arguments[0]       height  arguments[1]  !

.square     size  30px  !

.rectangle     size  30px  15px

Stylus

Page 31: Stylus - css preprocessor

.square  {     width:  30px;     height:  30px;  }  !

.rectangle  {     width:  30px;     height:  15px;  }

CSS

Page 32: Stylus - css preprocessor

.icon-­‐add     absolute  top  50%  left  0     size  16px       margin-­‐top  (@height  /  -­‐2)

Stylus

Page 33: Stylus - css preprocessor

.icon-­‐add  {     position:  absolute;     top:  50%;     left:  0;     width:  16px;     height:  16px;     margin-­‐top:  -­‐8px;  }

CSS

Page 34: Stylus - css preprocessor

Děkuji za pozornosttwitter.com/fireball_

[email protected]

www.superkoderi.cz