Merge pull request #1173 from benoitchantre/no-sidebar-class

no-sidebar class
This commit is contained in:
Laurel 2018-04-06 11:02:47 -07:00 committed by GitHub
commit f5f3a0a05b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 0 deletions

View File

@ -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. * 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`. * 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. * 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. * 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. * Licensed under GPLv2 or later. :) Use it to make something cool.

View File

@ -17,6 +17,11 @@ function _s_body_classes( $classes ) {
$classes[] = 'hfeed'; $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; return $classes;
} }
add_filter( 'body_class', '_s_body_classes' ); add_filter( 'body_class', '_s_body_classes' );

View File

@ -23,3 +23,12 @@
clear: both; clear: both;
width: 100%; width: 100%;
} }
.no-sidebar .content-area {
float: none;
margin-left: auto;
margin-right: auto;
}
.no-sidebar .site-main {
margin-right: 0;
}

View File

@ -23,3 +23,12 @@
clear: both; clear: both;
width: 100%; width: 100%;
} }
.no-sidebar .content-area {
float: none;
margin-left: auto;
margin-right: auto;
}
.no-sidebar .site-main {
margin-right: 0;
}

View File

@ -18,3 +18,5 @@
clear: both; clear: both;
width: $size__site-main; width: $size__site-main;
} }
@import "no-sidebar";

View File

@ -0,0 +1,11 @@
.no-sidebar {
.content-area {
float: none;
margin-left: auto;
margin-right: auto;
}
.site-main {
margin-right: 0;
}
}

View File

@ -18,3 +18,5 @@
clear: both; clear: both;
width: $size__site-main; width: $size__site-main;
} }
@import "no-sidebar";

View File

@ -1,5 +1,6 @@
// @import "../layout/content-sidebar"; // @import "../layout/content-sidebar";
// @import "../layout/sidebar-content"; // @import "../layout/sidebar-content";
/*-------------------------------------------------------------- /*--------------------------------------------------------------
## Posts and pages ## Posts and pages
--------------------------------------------------------------*/ --------------------------------------------------------------*/