Created
June 17, 2014 14:48
-
-
Save luca85perez/0826c46c8a96406a4511 to your computer and use it in GitHub Desktop.
Sass maps examples.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="box">\o/</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.8) | |
// ---- | |
//******************************************** | |
// | |
// MEDIA QUERIES BREAKPOINTS | |
// | |
//******************************************** | |
$breakpoints: ( | |
pequeno: 767px, | |
medio: 992px, | |
grande: 1200px | |
); | |
@mixin responde-a($tamanho) { | |
@if map-has-key($breakpoints, $tamanho) { | |
@media (min-width: #{map-get($breakpoints, $tamanho)}) { | |
@content; | |
} | |
} | |
@else { | |
@warn "Infelizmente não foi possível encontrar o valor " + #{$tamanho} + " definido em '$breakpoints'."; | |
} | |
} | |
.elemento { | |
width: 300px; | |
@include responde-a(pequeno) { | |
width: 100%; | |
} | |
} | |
//******************************************** | |
// | |
// CORES | |
// | |
//******************************************** | |
$paleta: ( | |
turquoise: #1abc9c, | |
green-sea: #16a085, | |
esmerald: #2ecc71, | |
nephritis: #27ae60, | |
black: #303030, | |
white: #ededed | |
); | |
@function cor($cor) { | |
@if map-has-key($paleta, $cor) { | |
@return #{map-get($paleta, $cor)}; | |
} | |
@warn "Cor " + #{$cor} + " não listada em '$paleta' map."; | |
@return null; | |
} | |
.box { | |
display: inline-block; | |
padding: 1em; | |
background: cor(turquoise); | |
color: cor(white); | |
} | |
//******************************************** | |
// | |
// CAMADAS Z-INDEX | |
// | |
//******************************************** | |
$camadas-z: ( | |
buraco: -9999, | |
padrao: 1, | |
dropdown: 3000, | |
overlay: 4000, | |
modal: 4001 | |
); | |
@function z($posicao) { | |
@if map-has-key($camadas-z, $posicao) { | |
@return #{map-get($camadas-z, $posicao)}; | |
} | |
@warn "Posição " + #{$posicao} + " não encontrada em '$camada-z' map."; | |
@return null; | |
} | |
.box { | |
z-index: z(modal); | |
} | |
//******************************************** | |
// | |
// ICONS CLASS | |
// | |
//******************************************** | |
$icones: ( | |
glass: "\f000", | |
music: "\f001", | |
search: "\f002", | |
envelope-o: "\f003", | |
heart: "\f004" | |
); | |
@each $nome, $icone in $icones { | |
.i-#{$nome}:before { | |
content: '#{$icone}'; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.elemento { | |
width: 300px; | |
} | |
@media (min-width: 767px) { | |
.elemento { | |
width: 100%; | |
} | |
} | |
.box { | |
display: inline-block; | |
padding: 1em; | |
background: #1abc9c; | |
color: #ededed; | |
} | |
.box { | |
z-index: 4001; | |
} | |
.i-glass:before { | |
content: "\f000"; | |
} | |
.i-music:before { | |
content: "\f001"; | |
} | |
.i-search:before { | |
content: "\f002"; | |
} | |
.i-envelope-o:before { | |
content: "\f003"; | |
} | |
.i-heart:before { | |
content: "\f004"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="box">\o/</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment