Follow along at:
http://wpshout.com/sass-presentation
WPShout | wpshout.com | @wpshout
Press Up | pressupinc.com | @pressupinc
Easy, flexible control over almost every aspect of layout
Probably the technical language I feel most mastery over
Keep these in mind as we go through…
/* I'm repetitive CSS */
.container { background: #fff; }
.container .box { background: #eee; }
.container .box .link { color: #333; }
/* I'm DRYer Sass */
.container { background: #fff;
.box { background: #eee;
.link { color: #333; }
}
}
/* I'm static CSS */
.page-title {
color: #249AC8;
}
.footer {
background: #249AC8;
}
.bordered-box {
border: 1px #249AC8 solid;
}
/* I'm dynamic Sass */
$theme-accent-color: #249AC8; // Change me *once* sitewide
.page-title {
color: $theme-accent-color;
}
.footer {
background: $theme-accent-color;
}
.bordered-box {
border: 1px $theme-accent-color solid;
}
/* I'm static CSS */
.small-rounded-square {
height: 16px;
width: 16px;
border: 1px #333 solid;
border-radius: 1px;
}
.medium-rounded-square {
height: 32px;
width: 32px;
border: 2px #333 solid;
border-radius: 2px;
}
.large-rounded-square {
height: 48px;
width: 48px;
border: 3px #333 solid;
border-radius: 3px;
}
/* I'm dynamic Sass */
@mixin rounded-square($side: 16px) {
width: $side;
height: $side;
border: $side/16 #333 solid;
border-radius: $side/16;
}
.small-rounded-square {
@include rounded-square;
}
.medium-rounded-square {
@include rounded-square(32px);
}
.large-rounded-square {
@include rounded-square(48px);
}
@function ensureTextContrast($link-color, $background-color) {
/* Getting value for contrast */
$diff: lightness($link-color) - lightness($background-color);
/* If high enough contrast, @return original color */
@if abs($diff) > 15% {
@return $link-color;
}
/* Dark background; lighten */
@if lightness($background-color) < lightness(#aaaaaa) {
@return lighten($link-color, 30);
}
/* Light background; darken */
@else {
@return darken($link-color, 30);
}
}
.base-font {
font-family: $base-font-stack; /* $base-font-stack = Arial, sans-serif */
}
p {
@extend .base-font;
}
/* Compiles to this CSS: */
.base-font, p {
font-family: Arial, sans-serif;
}
/* In style.scss, main Sass stylesheet */
@import 'libs/bourbon/bourbon';
@import 'libs/neat/neat';
@import 'libs/font_awesome';
.page-content {
.widget-areas {
.widget {
.widget-title {
font-weight: bold;
}
}
}
}
/*Compiles to: */
.page-content .widget-areas .widget .widget-title {
font-weight: bold;
}
/* Way too specific! Can =/= Should */
/* Why are these things linked? Not clear here or in HTML markup */
h1, article .title, footer .big-deal h2 {
font-size: 2rem;
line-height: 1.75;
}
/* Give elements this class where it's needed */
.standout-headline {
font-size: 2rem;
line-height: 1.75;
}
.product .single_add_to_cart_button, .cart .button, input.checkout-button.alt.button, .shipping-calculator-form .button, .multistep_step .button, #place_order.button, .single-product .single_add_to_cart_button.button.alt, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit, .woocommerce #content input.button, .woocommerce-page a.button, .woocommerce-page button.button, .woocommerce-page input.button, .woocommerce-page #respond input#submit, .woocommerce-page #content input.button {
background-color: #605f5e;
}
.colored-button {
background-color: #605f5e;
}
/* Plus appropriate HTML markup */
// I'm always removed in compiled CSS
/* I'll appear in normal CSS, but not "compressed"/minified CSS */
/*! I'm a "loud" comment that'll appear in (even minified) CSS! */
Theme developers: You'll need a "loud" comment at the top of style.scss
to give theme info.
/* In style.scss */
@import 'functions';
@import 'libs';
@import 'vars';
@import 'vars_derived';
@import 'mixins';
@import 'extends';
@import 'wp_defaults';
@import 'plugins';
@import 'elements';
/* In elements.scss */
@import "elements/header";
@import "elements/slider";
@import "elements/content";
@import "elements/sidebar";
@import "elements/blog";
@import "elements/footer";
/* Sidebar partial */
.widget-area {
@include clearfix;
font-size: 1.2em;
}
.widget {
@include rounded-corners(.5em);
background: #eee;
}
.widget-title {
font-weight: normal;
}
You will love your life
It's very easy to set up
Savings minimal in small projects, but hey
Vanilla CSS will compile as Sass, so @import
still works in style.scss
But on some themes (and for some clients) you may be too far from elegance for Sass to help you
[email protected] | @wpshout