Skip to content

Commit

Permalink
Merge pull request #1173 from benoitchantre/no-sidebar-class
Browse files Browse the repository at this point in the history
no-sidebar class
  • Loading branch information
laurelfulford authored Apr 6, 2018
2 parents c4ad625 + 100081f commit f5f3a0a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ My ultra-minimal CSS might make me look like theme tartare but that means less s
* Some small tweaks in `inc/template-functions.php` that can improve your theming experience.
* A script at `js/navigation.js` that makes your menu a toggled dropdown on small screens (like your phone), ready for CSS artistry. It's enqueued in `functions.php`.
* 2 sample CSS layouts in `layouts/` for a sidebar on either side of your content.
Note: `.no-sidebar` styles are not automatically loaded.
* Smartly organized starter CSS in `style.css` that will help you to quickly get your design off the ground.
* Licensed under GPLv2 or later. :) Use it to make something cool.

Expand Down
5 changes: 5 additions & 0 deletions inc/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function _s_body_classes( $classes ) {
$classes[] = 'hfeed';
}

// Adds a class of no-sidebar when there is no sidebar present.
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
$classes[] = 'no-sidebar';
}

return $classes;
}
add_filter( 'body_class', '_s_body_classes' );
Expand Down
9 changes: 9 additions & 0 deletions layouts/content-sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@
clear: both;
width: 100%;
}

.no-sidebar .content-area {
float: none;
margin-left: auto;
margin-right: auto;
}
.no-sidebar .site-main {
margin-right: 0;
}
9 changes: 9 additions & 0 deletions layouts/sidebar-content.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@
clear: both;
width: 100%;
}

.no-sidebar .content-area {
float: none;
margin-left: auto;
margin-right: auto;
}
.no-sidebar .site-main {
margin-right: 0;
}
2 changes: 2 additions & 0 deletions sass/layout/_content-sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
clear: both;
width: $size__site-main;
}

@import "no-sidebar";
11 changes: 11 additions & 0 deletions sass/layout/_no-sidebar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.no-sidebar {
.content-area {
float: none;
margin-left: auto;
margin-right: auto;
}

.site-main {
margin-right: 0;
}
}
2 changes: 2 additions & 0 deletions sass/layout/_sidebar-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
clear: both;
width: $size__site-main;
}

@import "no-sidebar";
1 change: 1 addition & 0 deletions sass/site/_site.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @import "../layout/content-sidebar";
// @import "../layout/sidebar-content";

/*--------------------------------------------------------------
## Posts and pages
--------------------------------------------------------------*/
Expand Down

0 comments on commit f5f3a0a

Please sign in to comment.