A
5 ways to improve the sucky CSS you've got
Busy doing "REAL" work
Busy creating
"REAL" solutions
n00bs here
<ul id="tweets">
<li>
<h5> {{ user }} </h5>
<p> {{ body }} </p>
<ul id="tweets">
<li class="tweet">
<h5 class="tweet--user"> {{ user }} <h5>
<p class="tweet--body"> {{ body }} <p>
#tweets li { ... }
#tweets li h5 { ... }
#tweets li p { ... }
#tweets .tweet { ... }
#tweets .tweet .tweet--user { ... }
#tweets .tweet .tweet--body { ... }
<ul id="tweets">
<li class="tweet">
<h5 class="tweet--user"> {{ user }} <h5>
<p class="tweet--body"> {{ body }} <p>
<div id="tweets">
<div class="tweet">
<div class="tweet--user"> {{ user }} <div>
<div class="tweet--body"> {{ body }} <div>
#tweets .tweet { ... }
#tweets .tweet .tweet--user { ... }
#tweets .tweet .tweet--body { ... }
#tweets {
.tweet {
.tweet--user { ... }
.tweet--body { ... }
}
}
#tweets {
.tweet {
.tweet--user { ... }
.tweet--body { ... }
}
}
#tweets {...}
.tweet {
.tweet--user { ... }
.tweet--body { ... }
}
#tweets {...}
.tweet {
.tweet--user { ... }
.tweet--body { ... }
}
#tweets {...}
#tweets__featured {...}
#tweets__sponsored {...}
.tweet {
.tweet--user { ... }
.tweet--body { ... }
}
.tweet { // resource
.tweet--user {...} // instance variables
.tweet--body {...}
&.is-retweeted {...} // predicate methods
&.has-conversation {...}
}
#tweets { // resource collection
&.tweets__recent {...} // named scope
}
.tweet { // BLOCK
.tweet--user {...} // ELEMENT
.tweet--body {...} // ELEMENT
&.tweet__sponsored {...} // MODIFIER
}
#tweets { // BLOCK
.tweets--header {...} // ELEMENT
&.tweets__recent {...} // MODIFIER
}
p {...} /* BASE STYLE FOR ENTIRE PAGE */
h1 {...}
img {...}
div.no-semantic-element {...} /* crap. no element for this one */
p.my-super-special-p-tag {...}/* because we don't have p2, p3...*/
#header {...} /* WEBPAGE HEADER OVERRIDES */
#header h1 {...} /* base h1 + headery goodies */
#header a {...} /* base a + headery goodness */
#footer {...} /* WEBPAGE FOOTER OVERRIDES */
#footer h1 {...} /* base h1 + headery goodies */
#footer a {...} /* base h1 + headery goodies */
<ul id="tweets">
<li class="tweet">
<h5 class="tweet--user"> {{ user }} <h5>
<p class="tweet--body"> {{ body }} <p>
<div class="timeline" id="timeline">
<ul class="tweets" id="{{id}}">
<li class="tweet">
<h5 class="tweet--user {{#if verified}}is-verified{{/if}}"
data-user-id="{{user_id}}">
{{ user }}
<h5>
<p class="tweet--body"> {{ body }} <p>
.timeline {...}
.tweets {...}
.tweet {
.tweet--user {...}
.tweet--body {...}
&.is-verified {...}
}
# Show user profile
$('#timeline').on 'click', '.tweet--username', ->
user = $(this).data('user-id')
revealProfleModal(user)
# Expand Tweet
$('#timeline').on 'click', '.tweet--body', ->
tweet = $(this).closest('.tweet')
tweet.addClass('.tweet__expanded')
# Retweet
$('#timeline').on 'click', '.tweet--retweet', ->
tweet = $(this).closest('.tweet')
retweetTweet(tweet)
@chantastic
slid.es/chantastic/unsucking-css