-
Notifications
You must be signed in to change notification settings - Fork 43
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
Carousel Block #143
Carousel Block #143
Conversation
Any chance we can have some settings for the autoplay like for Jetpack Slideshow? (and maybe the effect). |
We can support the toggle and the interval, but AFAIK |
Ok, no problem for the transitions. The autoplay is much more needed 😊 |
Added in 07a9db4 |
That was quick! 😊 |
@jeffersonrabb I committed a bunch of fixes:
How about we add a new style? Something like this: Can we have 2 toggles (on by default) to:
|
Added in Correction: ce71688 @thomasguillot I left the play/pause button in the upper left corner, for you to position however you see fit. |
Wouldn't hiding these be compromising the block's usability and accessibility? |
I like the alternate style. Another possible style might be to use thumbnails instead of bullets? |
Yes and no 😊
I think allowing these to be hidden offers a bit more flexibility to the block and front-end design. |
Thumbnails would be great! |
In b981df6 I added a few more changes: I moved the play/pause button to the top right corner like for Jetpack Slideshow. |
src/blocks/carousel/view.php
Outdated
wp_enqueue_script( | ||
'amp-carousel', | ||
'https://cdn.ampproject.org/v0/amp-carousel-0.1.js', | ||
null, | ||
NEWSPACK_BLOCKS__VERSION, | ||
true | ||
); | ||
wp_enqueue_script( | ||
'amp-selector', | ||
'https://cdn.ampproject.org/v0/amp-selector-0.1.js', | ||
null, | ||
NEWSPACK_BLOCKS__VERSION, | ||
true | ||
); |
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.
The AMP plugin is already registering this script in amp_register_default_scripts()
: https://github.com/ampproject/amp-wp/blob/039554da947563bd7a3432aa724282b1c20a86b9/includes/amp-helper-functions.php#L435-L499
These scripts are registered even when the page is not AMP. They are registered always. It gets amp-runtime
as a dependency.
So no script is registered here.
So all you need to do here is:
wp_enqueue_script( 'amp-carousel' );
wp_enqueue_script( 'amp-selector' );
In reality, you can even remove the Newspack_Blocks::is_amp()
check because enqueueing those scripts will not hurt in AMP pages. The AMP plugin will ensure that those scripts are present if they weren't already enqueued when there is an amp-carousel
or amp-selector
in the page.
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.
The AMP plugin is already registering this script in
amp_register_default_scripts()
:
What if the AMP plugin is not installed at all?
Should be resolved in b2c2a5b |
Editor implementation using Swiper: 5dc0ddb |
I added a few changes to the editor's stylesheet in 4f4523c |
* Have links in white for better contrast against black * Make sure `.entry-wrapper` doesn't overflow * Add a `cursor: pointer` to the prev/next buttons
* Reposition the play/pause button to the top right corner * Increase maximum delay time to 20 s * Set default delay time to 5 s
14f178b
to
14d3921
Compare
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.
Looks good, just needs some minor tweaks. I'll make those updates on Monday and then this should be good to go.
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.
This should be good to go. We can fine-tune the customization options in future PRs if needed.
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Adds a Carousel block that uses
amp-carousel
to display posts.amp-carousel
cannot currently be used in the editor because it does not support DOM mutation after page load, which occurs whenever the array of posts to be displayed changes. Eventually Bento AMP will resolve this, but until this is available we will use the Swiper library to make the block functional in the editor. Currently, there is only a placeholder in the editor.Closes #48.
How to test the changes in this Pull Request:
npm run build:webpack
Other information: