Skip to content

Commit

Permalink
Merge pull request #1090 from CFXd/move-main-and-sidebar-markup-out-o…
Browse files Browse the repository at this point in the history
…f-php

Move <main> and .sidebar markup out of PHP and into LESS
  • Loading branch information
retlehs committed Aug 15, 2014
2 parents d12bd1d + 32acdb3 commit a1edc54
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 4 additions & 0 deletions assets/less/_variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
// -------------------------

@icon-font-path: "../vendor/bootstrap/fonts/";

@main-sm-columns: @grid-columns;

@sidebar-sm-columns: 4;
7 changes: 6 additions & 1 deletion assets/less/layouts/_general.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
.wrap { }

// Main content area
.main { }
.main {
.make-sm-column(@main-sm-columns);
.sidebar-primary & {
.make-sm-column(@main-sm-columns - @sidebar-sm-columns);
}
}
4 changes: 3 additions & 1 deletion assets/less/layouts/_sidebar.less
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.sidebar { }
.sidebar {
.make-sm-column(@sidebar-sm-columns);
}
4 changes: 2 additions & 2 deletions base.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

<div class="wrap container" role="document">
<div class="content row">
<main class="main <?php echo roots_main_class(); ?>" role="main">
<main class="main" role="main">
<?php include roots_template_path(); ?>
</main><!-- /.main -->
<?php if (roots_display_sidebar()) : ?>
<aside class="sidebar <?php echo roots_sidebar_class(); ?>" role="complementary">
<aside class="sidebar" role="complementary">
<?php include roots_sidebar_path(); ?>
</aside><!-- /.sidebar -->
<?php endif; ?>
Expand Down
21 changes: 5 additions & 16 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,15 @@
}

/**
* .main classes
* Add body class if sidebar is active
*/
function roots_main_class() {
function roots_sidebar_body_class($classes) {
if (roots_display_sidebar()) {
// Classes on pages with the sidebar
$class = 'col-sm-8';
} else {
// Classes on full width pages
$class = 'col-sm-12';
$classes[] = 'sidebar-primary';
}

return apply_filters('roots/main_class', $class);
}

/**
* .sidebar classes
*/
function roots_sidebar_class() {
return apply_filters('roots/sidebar_class', 'col-sm-4');
return $classes;
}
add_filter('body_class', 'roots_sidebar_body_class');

/**
* Define which pages shouldn't have the sidebar
Expand Down

0 comments on commit a1edc54

Please sign in to comment.