Skip to content

Instantly share code, notes, and snippets.

@luca85perez
Created June 17, 2014 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luca85perez/0826c46c8a96406a4511 to your computer and use it in GitHub Desktop.
Save luca85perez/0826c46c8a96406a4511 to your computer and use it in GitHub Desktop.
Sass maps examples.
<div class="box">\o/</div>
// ----
// 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}';
}
}
.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";
}
<div class="box">\o/</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment