Skip to content

Instantly share code, notes, and snippets.

@jensgro
Created February 25, 2014 07:50
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 jensgro/9204670 to your computer and use it in GitHub Desktop.
Save jensgro/9204670 to your computer and use it in GitHub Desktop.
Hint-boxes with Sass-lists - comaptible with Sass 3.2
<p class="message-info">You might want to know this.</p>
<p class="message-error">There might be something wrong.</p>
<p class="message-warn">You should pay attention!</p>
<p class="message-valid">Everything is okay, move on.</p>
// ----
// Sass (v3.2.14)
// Compass (v0.12.2)
// ----
// See: http://codepen.io/HugoGiraudel/pen/Dzloe
// Switched to Sass-list instead of Sass-maps
// Configuration variables
// Type name | color scheme
$message-types:
error #b94a48,
warn #c09853,
valid #468847,
info #3a87ad;
// Mixin for dynamic values
// Extending the placeholder
@mixin message($color) {
@extend %message;
color: $color;
background: lighten($color, 38%);
border-color: lighten($color, 20%);
}
// Loop doing all the dumping
@each $type in $message-types {
.message-#{nth($type,1)} {
@include message(nth($type,2));
}
}
// Placeholder can be placed on the end of everything
// Placeholder for static values
%message {
padding: .5em;
margin: .5em;
border-radius: .15em;
border: 1px solid;
}
.message-error {
color: #b94a48;
background: #efd5d4;
border-color: #d59392;
}
.message-warn {
color: #c09853;
background: #f4ede1;
border-color: #dbc59e;
}
.message-valid {
color: #468847;
background: #b6dab7;
border-color: #7aba7b;
}
.message-info {
color: #3a87ad;
background: #bfdcea;
border-color: #7ab5d3;
}
.message-error, .message-warn, .message-valid, .message-info {
padding: .5em;
margin: .5em;
border-radius: .15em;
border: 1px solid;
}
<p class="message-info">You might want to know this.</p>
<p class="message-error">There might be something wrong.</p>
<p class="message-warn">You should pay attention!</p>
<p class="message-valid">Everything is okay, move on.</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment