Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move <main> and .sidebar markup out of PHP and into LESS #1090

Merged
merged 1 commit into from
Aug 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls switch to 2 spaces, not tabs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's funny, I actually always use two spaces in my PHP but somehow got in the habit long ago of using tabs in my CSS.

Can you point me to the coding standard you prefer? Curious too because the WordPress PHP coding standards are rather dreadful imho. Their spacing inside parenthesis drives me especially mad.

.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 @@ -14,26 +14,15 @@
define('GOOGLE_ANALYTICS_ID', ''); // UA-XXXXX-Y (Note: Universal Analytics only, not Classic Analytics)

/**
* .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