Last active
January 3, 2016 20:18
-
-
Save finteractive/8513630 to your computer and use it in GitHub Desktop.
Example 1 - Plain old CSS before doing any SASS, Adding Variables
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
<html> | |
<body> | |
<div class="message-box">Hey Something happened</div> | |
<div class="message-box--success">Yay something worked!</div> | |
<div class="message-box--error">Warning Something is bad here <a href="#">Details</a></div> | |
<footer>© 2014 - Someone <a href="#">legal link</a></a> </footer> | |
</body> | |
</html> |
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
<html> | |
<body> | |
<div class="message-box">Hey Something happened</div> | |
<div class="message-box--success">Yay something worked!</div> | |
<div class="message-box--error">Warning Something is bad here</div> | |
<footer>© 2014 - Someone </footer> | |
</body> | |
</html> |
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.0.rc.2) | |
// Compass (v1.0.0.alpha.17) | |
// ---- | |
// CSS default state - This is valid SCSS syntax | |
// Example 1 - Plain old css is valid scss | |
.message-box { | |
background-color: #ddd; | |
border: 1px solid #444; | |
margin: 2em; | |
padding: 1em; | |
text-align: center; | |
} | |
.message-box--success { | |
background-color: #aaffaa; | |
border: 1px solid #444; | |
margin: 2em; | |
padding: 1em; | |
text-align: center; | |
} | |
.message-box--error { | |
background-color: #ffaaaa; | |
border: 1px solid #444; | |
margin: 2em; | |
padding: 1em; | |
text-align: center; | |
} | |
// Example 2 Let's add some variables to make this more DRY | |
// Color Variables | |
$grey-light: #ddd; | |
$grey-dark: #444; | |
$red: #ffaaaa; | |
$green: #aaffaa; | |
// Layout Variables | |
$margins: 2em; | |
$padding: 1em; | |
// .message-box { | |
// background-color: $grey-light; | |
// border: 1px solid $grey-dark; | |
// margin: $margins; | |
// padding: $padding; | |
// text-align: center; | |
// } | |
// .message-box--success { | |
// background-color: $green; | |
// border: 1px solid $grey-dark; | |
// margin: $margins; | |
// padding: $padding; | |
// text-align: center; | |
// } | |
// .message-box--error { | |
// background-color: $red; | |
// border: 1px solid $grey-dark; | |
// margin: $margins; | |
// padding: $padding; | |
// text-align: center; | |
// } | |
// It's getting easier to maintain, but still | |
// lots of duplication in the sass and css output |
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
.message-box { | |
background-color: #ddd; | |
border: 1px solid #444; | |
margin: 2em; | |
padding: 1em; | |
text-align: center; | |
} | |
.message-box--success { | |
background-color: #aaffaa; | |
border: 1px solid #444; | |
margin: 2em; | |
padding: 1em; | |
text-align: center; | |
} | |
.message-box--error { | |
background-color: #ffaaaa; | |
border: 1px solid #444; | |
margin: 2em; | |
padding: 1em; | |
text-align: center; | |
} |
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
<html> | |
<body> | |
<div class="message-box">Hey Something happened</div> | |
<div class="message-box--success">Yay something worked!</div> | |
<div class="message-box--error">Warning Something is bad here <a href="#">Details</a></div> | |
<footer>© 2014 - Someone <a href="#">legal link</a></a> </footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment