SlideShare a Scribd company logo
1 of 53
Download to read offline
Quem sou eu?
Andréa Zambrana
front-end @ Amil [multicanais]
@akfzambrana
http://andreazambrana.com.br
Vamos ao que interessa?
Sass maps
O que é isso?
Vetores associativos
Basicamente =P
$mapa: (
chave: valor,
outra-chave: outro-valor
);
Chave
Qualquer coisa
Única
Valor
Qualquer coisa
Lista superpoderosa
O que precisa saber...
Funções nativas
http://sass-lang.com/documentation/Sass/Script/Functions.html#map-
functions
Pode ter vírgula no fim
Não estressa
Chaves únicas
Só pra fixar =P
Qualquer tipo de dado
Aceito pelo Sass, claro
Números
Strings, com ou sem aspas
Cores
Valores booleanos
Null
Listas
Mapas
Legal, ne?
Exemplos
Úteis
Paleta de cores
*___*
$base-color-grey: #666;
$base-color-red: rgb(255, 0, 0);
$palette: (
red: (
base: $base-color-red,
light: lighten($base-color-red, 20%),
dark: darken($base-color-red, 20%)
),
grey: (
base: $base-color-grey,
light: lighten($base-color-grey, 20%),
dark: darken($base-color-grey, 20%)
)
);
@function get-color($color, $tone: 'base') {
@return map-get(
map-get($palette, $color),
$tone
);
}
.primary-link {
color: get-color(red);
&:hover {
color: get-color(red, light);
}
}
.secondary-link {
color: get-color(grey);
&:hover {
color: get-color(grey, dark);
}
}
.primary-link {
color: red;
}
.primary-link:hover {
color: #ff6666;
}
.secondary-link {
color: #666;
}
.secondary-link:hover {
color: #333333;
}
Media querie, vem ni mim
Breakpoints
$screen-size: (
small: 767px,
medium: 992px,
large: 1200px
);
@mixin respond-to($size) {
@media (min-width: #{map-get($screen-size,
$size)}) {
@content;
}
}
.my-link {
color: black;
@include respond-to(small) { color: tomato; }
@include respond-to(medium) { color: blue; }
@include respond-to(large) { color: orange; }
}
.my-link {
color: black;
}
@media (min-width: 767px) {
.my-link { color: tomato; }
}
@media (min-width: 992px) {
.my-link { color: blue; }
}
@media (min-width: 1200px) {
.my-link { color: orange; }
}
use com moderação
z-index
$z-layers: (
hell-pit: -9999,
default: 1,
component: 50,
overlay: 4000,
modal: 4001
);
@function layer($key) {
@if map-has-key($z-layers, $key) {
@return map-get($z-layers, $key);
} @else {
@warn "Unknown `#{$key}` in $z-layers.";
}
@return null;
}
.dropdown {
z-index: layer(component);
}
.content {
z-index: layer(default);
}
.dialog-box {
z-index: layer(modal);
}
Social media icons
ctrl + c, ctrl + v... nunca mais!
$icons: (
twitter: (char: "f099", color: #55acee),
google: (char: "f0d5", color: #dd4b39),
facebook:(char: "f09a", color: #3b5998),
github: (char: "f09b", color: #231f20)
);
@each $social, $icon in $icons {
&[href*="#{$social}"] {
background-color: map-get($icon, color);
&:before {
content: map-get($icon, char);
}
}
}
Yes, we can
Controle de snippets
Hack clearfix
quem nunca?
IE 6 e 7
%clearfix {
&:before,
&:after {
content: '';
display: table;
}
&:after {
clear: both;
}
& {
zoom: 1;
}
}
IE 8+
%clearfix {
&:after {
content: '';
display: table;
clear: both;
}
}
$browser-min: (
'chrome': 33,
'firefox': 26,
'ie': 8,
'safari': 5,
'opera': 10
);
%clearfix {
$min-support: map-get($browser-min, 'ie');
@if $min-support < 8 {
…
} @else {
…
}
}
e ser feliz!
Agora, é só soltar
a imaginação
Concluindo
Maps são poderosos
e muito úteis
Código mais estruturado
Melhor organização
Fácil manutenção
Menos código repetido
Menor tempo
de desenvolvimento
Cuidado com mapas
dentro de mapas
Cuidado com mapas
dentro de mapas
http://www.sitepoint.com/using-sass-maps/
https://pt.wikipedia.org/wiki/Vetor_associativo
http://pt.slideshare.net/loumontano/sassconf-maps
http://erskinedesign.com/blog/friendlier-colour-names-sass-maps/
http://www.sitepoint.com/managing-responsive-breakpoints-sass/
https://css-tricks.com/handling-z-index/
https://robots.thoughtbot.com/removing-sass-duplication
https://css-tricks.com/snippets/css/clear-fix/
http://andreazambrana.com.br/grande-clearfix/
Referências
Obrigada!
Front in Rio 2015 @akfzambrana

More Related Content

More from Andréa Zambrana

More from Andréa Zambrana (13)

Version all the things - Workshop
Version all the things - WorkshopVersion all the things - Workshop
Version all the things - Workshop
 
Caipirinha CSS
Caipirinha CSSCaipirinha CSS
Caipirinha CSS
 
Caipirinha CSS
Caipirinha CSSCaipirinha CSS
Caipirinha CSS
 
Viajando no front
Viajando no frontViajando no front
Viajando no front
 
Version all the things [Workflows com Git]
Version all the things [Workflows com Git]Version all the things [Workflows com Git]
Version all the things [Workflows com Git]
 
Sass maps, my precious! 2.0
Sass maps, my precious! 2.0Sass maps, my precious! 2.0
Sass maps, my precious! 2.0
 
Curso front-end - Aula 004 - Comandos git (cont.)
Curso front-end - Aula 004 - Comandos git (cont.)Curso front-end - Aula 004 - Comandos git (cont.)
Curso front-end - Aula 004 - Comandos git (cont.)
 
Curso front-end - Aula 003 - Comandos git
Curso front-end - Aula 003 - Comandos git Curso front-end - Aula 003 - Comandos git
Curso front-end - Aula 003 - Comandos git
 
Curso front-end - Aula 002 - Git
Curso front-end - Aula 002 - GitCurso front-end - Aula 002 - Git
Curso front-end - Aula 002 - Git
 
Curso front-end - Aula 001
Curso front-end - Aula 001Curso front-end - Aula 001
Curso front-end - Aula 001
 
Sass - css bomba[do]
Sass - css bomba[do]Sass - css bomba[do]
Sass - css bomba[do]
 
b ou strong eis a questão! HTML semântico, o santo graal do front-end =]
 b ou strong eis a questão! HTML semântico, o santo graal do front-end =] b ou strong eis a questão! HTML semântico, o santo graal do front-end =]
b ou strong eis a questão! HTML semântico, o santo graal do front-end =]
 
Acessibilidade web, perda de tempo?
Acessibilidade web, perda de tempo?Acessibilidade web, perda de tempo?
Acessibilidade web, perda de tempo?
 

Sass maps, my precious!