Tim Hacker
These slides have lots of links!
But these are just down to discipline. We need help!
<form class="form form--theme-xmas form--simple">
<input class="form__input" type="text" />
<input
class="form__submit form__submit--disabled"
type="submit" />
</form>
But this is fiddly to get right...
Variables
Nesting
&
Imports
Mixins
Extends
CSS preprocessor that adds features to CSS
@import "variables";
.selector {
margin: $size;
background-color: $brandColor;
.nested {
margin: $size / 2;
&:hover {
text-decoration: underline;
}
}
}
.selector {
margin: 1em;
background-color: #f60;
}
.selector .nested {
margin: 0.5em;
}
.selector .nested:hover {
text-decoration: underline;
}
$brandColor: #f60;
$size: 1em;
_variables.scss
Going quite a long way away from 'normal' CSS
A tool for transforming CSS with JavaScript
Into JSON AST
(Abstract Syntax Tree)
Back to CSS the browser can read
Each plugin works its magic in JS
Magically add browser vendor prefixes without you having to remember all the syntax!
a {
width: calc(50% - 2em);
transition: transform 1s
}
a {
width: -webkit-calc(1% + 1em);
width: calc(1% + 1em);
-webkit-transition: -webkit-transform 1s;
transition: -ms-transform 1s;
transition: transform 1s
}
A mistake preventing machine for a language that is really easy to be sloppy with...
Use all the new features from CSS4 today!
Write future proof CSS without worrying about specific preprocessor syntax
.link {
all: initial;
}
.link {
animation: none 0s ease 0s 1 normal none running;
backface-visibility: visible;
background: transparent none repeat 0 0 / auto auto padding-box border-box scroll;
border: medium none currentColor;
border-collapse: separate;
border-image: none;
border-radius: 0;
...
}
Once we have full browser support we can just remove the redundant PostCSS plugins