massive css issues I met
no-longer used
always be overrided
find unused selectors
specificity war
<div id="web">
<ul>
<li class="rule">
<a href="">hello</a>
</li>
<li class="rule">
<a href="">world</a>
</li>
</ul>
</div>
// how we style <a>
who wins?
no matter who wins
we lose
what we learn
maintenance
is a problem
massive CSS maintenance
is a HUGE problem
how Fuse works
<module id="core">
<file type="css" src="path/css/core.css" />
<file type="js" src="path/js/core.js" />
</module>
<module id="base">
<require module="core" />
<file type="css" src="path/css/base.css" />
<file type="js" src="path/js/base.js" />
</module>
<module id="base">
<require module="core" />
<file type="css" src="path/css/base.css" />
<file type="js" src="path/js/base.js" />
</module>
<module id="override">
<require module="base" />
<exclude type="css" src="path/css/core.css" />
<file type="css" src="path/js/override.css" />
<file type="js" src="path/js/override.js" />
</module>
<module id="override">
<require module="base" />
<exclude type="css" src="path/css/core.css" />
<file type="css" src="path/js/override.css" />
<file type="js" src="path/js/override.js" />
</module>
modulize CSS/JS resources
variables
@LINK_COLOR: #0000de;
@RESULT_COLOR: #008000;
a:link {
color: @LINK_COLOR;
}
#web ol li a:link {
color: @RESULT_COLOR;
}
// actually I'd like to use it as a constant
mixin
a bigger variables. Awesome!
.rounded-corners (@radius: 5px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}
// shortcut to add rounded-corner
#header { .rounded-corners; }
#footer { .rounded-corners(10px); }
nested rules
#header {
h1 {
font-size: 26px;
font-weight: bold;
}
p {
font-size: 12px;
a {
text-decoration: none;
}
}
}
Fuse + LESS
write LESS
deploy CSS
// CSS
#web .url {
font-weight: bold;
}
#web li em {
color: #008000;
font-weight: bold;
}
// LESS : rollup concept
.highlight () {
font-weight: bold;
}
#web {
li em {
color: #008000;
.highlight;
}
.url { .highlight; }
}
.highlight () {
font-weight: bold;
color: #ff0000;
// blah blah
}
#web {
li em {
color: #008000;
.highlight; // applied
}
.url { .highlight; } // applied
}
// CSS : smelly
#module a { color: #008000; }
#module p { font-size: 1.2em; }
...
.smelly { display: none; } // what the..
...
#module .cl { background-color; silver; }
// LESS : much easier to see
#module {
a { color: #008000; }
p { font-size: 1.2em; }
...
.cl { background-color: silver; }
...
}
.smelly { display: none; }
syntax ~= DOM tree
extend via concept roll-up
wrong code looks wrong
END & Q & A
appendix