Skip to content

Instantly share code, notes, and snippets.

@davidkpiano
Created December 11, 2014 22:18
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 davidkpiano/08aee2e0b393924cec84 to your computer and use it in GitHub Desktop.
Save davidkpiano/08aee2e0b393924cec84 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
// Let's say I have a button component...
%button {
display: inline-block;
padding: 1rem;
border: 1px solid gray;
color: black;
background: #EFEFEF;
// ...etc.
}
// And I have a button group component that stacks all buttons inside
// and makes their backgrounds pink (for whatever reason)...
%buttonGroup {
display: block;
border: 2px solid gray;
// ...etc.
// Here is where the inner buttons are changed.
%button {
display: block;
background: pink;
}
}
//------------------------------------
// In a separate file, far far away...
//------------------------------------
// I can change the selectors just in this place, and
// the relationship between buttons and buttonGroups are preserved
button, input[type=button], input[type=submit], .button {
@extend %button;
}
.buttonGroup {
@extend %buttonGroup;
}
#epilogue {
content: 'Yes, @extend has great potential to be misused, especially when it can easily be';
content: 'substituted for a @mixin, but using placeholders for RELATIONSHIPS between';
content: 'components is much, much simpler than using mixins.';
}
button, input[type=button], input[type=submit], .button {
display: inline-block;
padding: 1rem;
border: 1px solid gray;
color: black;
background: #EFEFEF;
}
.buttonGroup {
display: block;
border: 2px solid gray;
}
.buttonGroup button, .buttonGroup input[type=button], .buttonGroup input[type=submit], .buttonGroup .button {
display: block;
background: pink;
}
#epilogue {
content: 'Yes, @extend has great potential to be misused, especially when it can easily be';
content: 'substituted for a @mixin, but using placeholders for RELATIONSHIPS between';
content: 'components is much, much simpler than using mixins.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment