Supercharge _s's stylability with some additional conditional body classes. #86

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

Over the years I've found the conditional browser classes to be indespensible in theme development. When a particular browser is misbehaving it is extremely simple to conditionally alter a style (or fire some javascript) to handle its minor inconsistencies without having to load entirely separate stylesheets or conditional script files.

The post-/page-slug conditionals has also made it very easy to style a specific page/post on a dev server and have all the styles automatically match in production (in cases where a strict database export/import isn't used and post IDs change). It also makes it easier to read and write styles because a slug is more easily recognized than an arbitrary ID.

The category classes of course make it easier to style a site that uses thematically different categories (magazine style) and the date-based classes just allow for fun things like styling a site differently for Christmas or styling posts published in January in a way that separates them from posts published in otther times of the year.

The date-based classes require an additional function (_s_date_classes()). This functionality is probably superfluous for most sites, but is still a pretty clever trick and demo. Hat-tip to Ian and Themeatic for the inspiration behind this one… i think :)

@brichards brichards Added a handful of super-handy conditional body classes to super-char…
…ge _s's stylability.

Over the years I've found the conditional browser classes to be
indespensible in theme development. When a particular browser is
misbehaving it is extremely simple to conditionally alter a style (or
fire some javascript) to handle its minor inconsistencies without
having to load entirely separate stylesheets or conditional script
files.

The post-/page-slug conditionals has also made it very easy to style a
specific page/post on a dev server and have all the styles
automatically match in production (in cases where a strict database
export/import isn't used and post IDs change). It also makes it easier
to read and write styles because a slug is more easily recognized than
an arbitrary ID.

The category classes of course make it easier to style a site that uses
thematically different categories (magazine style) and the date-based
classes just allow for fun things like styling a site differently for
Christmas or styling posts published in January in a way that separates
them from posts published in otther times of the year.

The date-based classes require an additional function
(_s_date_classes()). This functionality is probably superfluous for
most sites, but is still a pretty clever trick and demo. (hat-tip to
ian and themeatic for the inspiration behind this one… i think :))
2c14062
Contributor

ianstewart commented Sep 22, 2012

These are indeed super-useful but out of scope for _s as they're likely to only be used in particular not general situations. Though I do like 'em. :)

Theme Lore: The originators of awesome conditional body classes are Andy Skelton and Scott Wallick in the Sandox theme.

ianstewart closed this Sep 22, 2012

Indeed, I knew Andy and Scott were responsible for body_class(), that was the entire reason I forked Sandbox into Startbox. I thought you were the crafty one behind some of the date or category based conditionals, though... maybe not. :)

You don't think even the browser classes are generic enough to benefit everyone, eh? I leverage those in almost every site I launch thanks to some small weird problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment