-
Notifications
You must be signed in to change notification settings - Fork 815
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
Add Twentyseventeen Infinite Scroll support #5940
Merged
jeherve
merged 8 commits into
Automattic:master
from
stoyan0v:fix/add-twentyseventeen-infinite-scroll-support
Feb 28, 2017
+393
−0
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
38b4967
Add Twentyseventeen infinite scroll support
stoyan0v 4f0f50f
Change font-family. Reorder properties to match WordPress coding stan…
stoyan0v eaef399
Add twentyseventeen-rtl.css
stoyan0v 7fab884
Add check for footer sidebars. Delete empty spaces in css
stoyan0v 5b29abe
Fix visual issues
stoyan0v ea2da6d
Hide mobile link on touch devices. Fix loader and footer on mobile & …
stoyan0v c1ac3ba
Change dark scheme button color. Replace jetpack-social-menu with soc…
stoyan0v 0e554d7
Namespace Twentyseventeen Infinite Scroll functions
stoyan0v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
.infinite-scroll .pagination { | ||
display: none; | ||
} | ||
|
||
.infinite-wrap > article:before, | ||
.infinite-wrap > article:after { | ||
content: ""; | ||
display: table; | ||
} | ||
|
||
.infinite-wrap > article:after { | ||
clear: both; | ||
} | ||
|
||
.infinite-wrap > article { | ||
padding-bottom: 2em; | ||
} | ||
|
||
/* Spinner */ | ||
.site-main .infinite-loader { | ||
clear: both; | ||
color: currentColor; | ||
height: 42px; | ||
margin-bottom: 3.5em; | ||
} | ||
|
||
.blog:not(.has-sidebar) .infinite-loader { | ||
width: 100%; | ||
} | ||
|
||
.site-main .infinite-loader .spinner { | ||
right: 50%!important; | ||
} | ||
|
||
/* Click-to-load */ | ||
#infinite-handle { | ||
clear: both; | ||
margin: 0 7.6923% 2em; | ||
text-align: center; | ||
} | ||
|
||
/* Style "Load More" button */ | ||
.site-main #infinite-handle span { | ||
background: #1a1a1a; | ||
border-radius: 2px; | ||
color: #fff; | ||
font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; | ||
font-size: inherit; | ||
font-weight: 700; | ||
letter-spacing: 0.046875em; | ||
line-height: 1; | ||
padding: 0.84375em 0.875em 0.78125em; | ||
text-transform: uppercase; | ||
} | ||
|
||
#infinite-handle span:hover, | ||
#infinite-handle span:focus { | ||
background: #767676; | ||
} | ||
|
||
/* Style "Load More" button when dark color scheme is used */ | ||
.colors-dark .site-main #infinite-handle span { | ||
background: #f8f8f8; | ||
border-radius: 2px; | ||
color: #222; | ||
font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; | ||
font-size: inherit; | ||
font-weight: 700; | ||
letter-spacing: 0.046875em; | ||
line-height: 1; | ||
padding: 0.84375em 0.875em 0.78125em; | ||
text-transform: uppercase; | ||
} | ||
|
||
.colors-dark #infinite-handle span:hover, | ||
.colors-dark #infinite-handle span:focus { | ||
background: #bbb; | ||
columns: #222; | ||
} | ||
|
||
/* Style Infinite Footer */ | ||
#infinite-footer { | ||
position: fixed !important; | ||
} | ||
|
||
#infinite-footer .container { | ||
background-color: #fff; | ||
border-color: #d1d1d1; | ||
padding: 0 7.6923%; | ||
} | ||
|
||
#infinite-footer .blog-info, | ||
#infinite-footer .blog-credits { | ||
font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; | ||
text-align: center; | ||
width: auto; | ||
} | ||
|
||
#infinite-footer .blog-info a, | ||
#infinite-footer .blog-credits, | ||
#infinite-footer .blog-credits a { | ||
color: #222222; | ||
} | ||
|
||
#infinite-footer .blog-info a:hover, | ||
#infinite-footer .blog-info a:focus, | ||
#infinite-footer .blog-credits a:hover, | ||
#infinite-footer .blog-credits a:focus { | ||
color: #767676; | ||
text-decoration: none; | ||
} | ||
|
||
.infinite-scroll #navigation, | ||
.infinite-scroll.neverending .jetpack-mobile-link, | ||
.infinite-scroll.neverending .site-footer { | ||
display: none; | ||
} | ||
|
||
/* Shows the footer & mobile link again in case all posts have been loaded */ | ||
.infinity-end.neverending .jetpack-mobile-link, | ||
.infinity-end.neverending .site-footer { | ||
display: block; | ||
} | ||
|
||
@media screen and (min-width: 44.375em) { | ||
#infinite-handle { | ||
margin: 0 0 1em 0; | ||
text-align: center; | ||
} | ||
|
||
.has-sidebar #infinite-handle { | ||
text-align: right; | ||
} | ||
|
||
.site-main #infinite-handle span { | ||
display: inline-block; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 48em) { | ||
.infinite-wrap > article { | ||
padding-bottom: 4em; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 48em) { | ||
#infinite-footer .blog-info, | ||
#infinite-footer .blog-credits { | ||
line-height: 35px; | ||
} | ||
|
||
#infinite-footer .blog-info { | ||
font-size: 1.1rem; | ||
} | ||
|
||
#infinite-footer .blog-credits { | ||
font-size: 0.9rem; | ||
} | ||
|
||
.blog:not(.has-sidebar) .infinite-loader { | ||
float: left; | ||
width: 58%; | ||
} | ||
|
||
.site-main .infinite-loader .spinner { | ||
margin-right: -17px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
.infinite-scroll .pagination { | ||
display: none; | ||
} | ||
|
||
.infinite-wrap > article:before, | ||
.infinite-wrap > article:after { | ||
content: ""; | ||
display: table; | ||
} | ||
|
||
.infinite-wrap > article:after { | ||
clear: both; | ||
} | ||
|
||
.infinite-wrap > article { | ||
padding-bottom: 2em; | ||
} | ||
|
||
/* Spinner */ | ||
.site-main .infinite-loader { | ||
clear: both; | ||
color: currentColor; | ||
height: 42px; | ||
margin-bottom: 3.5em; | ||
} | ||
|
||
.blog:not(.has-sidebar) .infinite-loader { | ||
width: 100%; | ||
} | ||
|
||
.site-main .infinite-loader .spinner { | ||
left: 50%!important; | ||
} | ||
|
||
/* Click-to-load */ | ||
#infinite-handle { | ||
clear: both; | ||
margin: 0 7.6923% 2em; | ||
text-align: center; | ||
} | ||
|
||
/* Style "Load More" button */ | ||
.site-main #infinite-handle span { | ||
background: #1a1a1a; | ||
border-radius: 2px; | ||
color: #fff; | ||
font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; | ||
font-size: inherit; | ||
font-weight: 700; | ||
letter-spacing: 0.046875em; | ||
line-height: 1; | ||
padding: 0.84375em 0.875em 0.78125em; | ||
text-transform: uppercase; | ||
} | ||
|
||
#infinite-handle span:hover, | ||
#infinite-handle span:focus { | ||
background: #767676; | ||
} | ||
|
||
/* Style "Load More" button when dark color scheme is used */ | ||
.colors-dark .site-main #infinite-handle span { | ||
background: #f8f8f8; | ||
border-radius: 2px; | ||
color: #222; | ||
font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; | ||
font-size: inherit; | ||
font-weight: 700; | ||
letter-spacing: 0.046875em; | ||
line-height: 1; | ||
padding: 0.84375em 0.875em 0.78125em; | ||
text-transform: uppercase; | ||
} | ||
|
||
.colors-dark #infinite-handle span:hover, | ||
.colors-dark #infinite-handle span:focus { | ||
background: #bbb; | ||
columns: #222; | ||
} | ||
|
||
/* Style Infinite Footer */ | ||
#infinite-footer { | ||
position: fixed !important; | ||
} | ||
|
||
#infinite-footer .container { | ||
background-color: #fff; | ||
border-color: #d1d1d1; | ||
padding: 0 7.6923%; | ||
} | ||
|
||
#infinite-footer .blog-info, | ||
#infinite-footer .blog-credits { | ||
font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; | ||
text-align: center; | ||
width: auto; | ||
} | ||
|
||
#infinite-footer .blog-info a, | ||
#infinite-footer .blog-credits, | ||
#infinite-footer .blog-credits a { | ||
color: #222222; | ||
} | ||
|
||
#infinite-footer .blog-info a:hover, | ||
#infinite-footer .blog-info a:focus, | ||
#infinite-footer .blog-credits a:hover, | ||
#infinite-footer .blog-credits a:focus { | ||
color: #767676; | ||
text-decoration: none; | ||
} | ||
|
||
.infinite-scroll #navigation, | ||
.infinite-scroll.neverending .jetpack-mobile-link, | ||
.infinite-scroll.neverending .site-footer { | ||
display: none; | ||
} | ||
|
||
/* Shows the footer & mobile link again in case all posts have been loaded */ | ||
.infinity-end.neverending .jetpack-mobile-link, | ||
.infinity-end.neverending .site-footer { | ||
display: block; | ||
} | ||
|
||
@media screen and (min-width: 44.375em) { | ||
#infinite-handle { | ||
margin: 0 0 1em 0; | ||
text-align: center; | ||
} | ||
|
||
.has-sidebar #infinite-handle { | ||
text-align: left; | ||
} | ||
|
||
.site-main #infinite-handle span { | ||
display: inline-block; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 48em) { | ||
.infinite-wrap > article { | ||
padding-bottom: 4em; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 48em) { | ||
#infinite-footer .blog-info, | ||
#infinite-footer .blog-credits { | ||
line-height: 35px; | ||
} | ||
|
||
#infinite-footer .blog-info { | ||
font-size: 1.1rem; | ||
} | ||
|
||
#infinite-footer .blog-credits { | ||
font-size: 0.9rem; | ||
} | ||
|
||
.blog:not(.has-sidebar) .infinite-loader { | ||
float: right; | ||
width: 58%; | ||
} | ||
|
||
.site-main .infinite-loader .spinner { | ||
margin-left: -17px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Infinite Scroll Theme Assets | ||
* | ||
* Register support for Twenty Seventeen. | ||
*/ | ||
|
||
/** | ||
* Add theme support for infinite scroll | ||
*/ | ||
function twentyseventeen_infinite_scroll_init() { | ||
add_theme_support( 'infinite-scroll', array( | ||
'container' => 'main', | ||
'render' => 'twentyseventeen_infinite_scroll_render', | ||
'footer' => 'content', | ||
'footer_widgets' => twentyseventeen_has_footer_widgets(), | ||
) ); | ||
} | ||
add_action( 'init', 'twentyseventeen_infinite_scroll_init' ); | ||
|
||
/** | ||
* Custom render function for Infinite Scroll. | ||
*/ | ||
function twentyseventeen_infinite_scroll_render() { | ||
while ( have_posts() ) { | ||
the_post(); | ||
if ( is_search() ) { | ||
get_template_part( 'template-parts/post/content', 'search' ); | ||
} else { | ||
get_template_part( 'template-parts/post/content', get_post_format() ); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Custom function to check for the presence of footer widgets or the social links menu | ||
*/ | ||
function twentyseventeen_has_footer_widgets() { | ||
if ( is_active_sidebar( 'sidebar-2' ) || | ||
is_active_sidebar( 'sidebar-3' ) || | ||
has_nav_menu( 'social' ) ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Enqueue CSS stylesheet with theme styles for Infinite Scroll. | ||
*/ | ||
function twentyseventeen_infinite_scroll_enqueue_styles() { | ||
if ( wp_script_is( 'the-neverending-homepage' ) ) { | ||
wp_enqueue_style( 'infinity-twentyseventeen', plugins_url( 'twentyseventeen.css', __FILE__ ), array( 'the-neverending-homepage' ), '20161219' ); | ||
wp_style_add_data( 'infinity-twentyseventeen', 'rtl', 'replace' ); | ||
} | ||
} | ||
add_action( 'wp_enqueue_scripts', 'twentyseventeen_infinite_scroll_enqueue_styles', 25 ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @stoyan0v! this all looks great and I'd really like to merge this today to make it into the next release.
My only request is to please name space the functions in this file with
jetpack_
to eliminate any possibility of redeclaration. Thanks!(mostly looking at
twentyseventeen_has_footer_widgets()
, the rest will probably be fine but won't hurt to change for consistency)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @dereksmart. I have namespaced all functions for twentyseventeen.
I didn't add the prefix in the beginning, because the functions in other theme files don't have such( twentysixteen.php, twentyfifteen.php etc ) . So I think that it will be nice to add such prefix to all themes too. I can prepare a separate PR if you agree with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stoyan0v thanks, yes that makes sense and a PR would be most welcome :)