Skip to content

Instantly share code, notes, and snippets.

@alecperkins
Last active August 29, 2015 14:07
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 alecperkins/b32ebf51d76b064693b6 to your computer and use it in GitHub Desktop.
Save alecperkins/b32ebf51d76b064693b6 to your computer and use it in GitHub Desktop.
Demonstrating how placeholder classes and a naming scheme (with a helper mixin) can create cleanly semantic output. (Also shows how marvelous the Sass indented syntax is :P)
%Highlight {
color: black;
font-size: 14px;
&%-image--right {
._Image {
float: right;
}
}
&%-image--left {
._Image {
float: left;
}
}
&%-large {
font-size: 18px;
}
&%-dark {
background: black;
color: white;
}
}
.ProductShowcase
+extend(Highlight, dark, image right)
.TeamMemberProfile
+extend(Highlight, image left)
&.-featured
+extend-variants(Highlight, large)
.ProductShowcase {
@include extend(Highlight, dark, image right);
}
.TeamMemberProfile {
@include extend(Highlight, image left);
&.-featured {
@include extend-variants(Highlight, large);
}
}
.ProductShowcase, .TeamMemberProfile {
color: black;
font-size: 14px;
}
.ProductShowcase ._Image {
float: right;
}
.TeamMemberProfile ._Image {
float: left;
}
.TeamMemberProfile.-featured {
font-size: 18px;
}
.ProductShowcase {
background: black;
color: white;
}
<div class="ProductShowcase">
<img class="_Image" src="...">
<p class="_Description">...</p>
</div>
<div class="TeamMemberProfile -featured">
<img class="_Image" src="...">
<p class="_Description">...</p>
</div>
<div class="TeamMemberProfile">
<img class="_Image" src="...">
<p class="_Description">...</p>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment