-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Experiment: Add lightbox to Image block using directives #49621
Closed
artemiomorales
wants to merge
38
commits into
WordPress:add-interactivity-runtime
from
artemiomorales:experiment/image-with-interactivity-api
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
ebba7b4
Add interactivity runtime
luisherranz af59781
Add it to the image block
luisherranz cca3d60
Add a separate webpack config
luisherranz 160a029
Make sure the runtime is imported only once
luisherranz 7f16f27
Use sideEffects instead of init
luisherranz f4b2ee8
Move script registration to a general file
luisherranz 378b041
Add `defer` to the interactivity scripts
luisherranz 409d161
Revert changes of the image block
luisherranz 29e11ab
Fix init import name
luisherranz f4b6c0a
Move and refactor the interactive scritps registration
gziolo 3d94473
Fix code style violations
gziolo 6ae760f
Use `wp-interactivity-` prefix for script handles
gziolo 9d6869e
Improve the matcher for side effects in `package.json`
gziolo c6d02d8
Add custom useSignalEffect
DAreRodz af55917
Call `init` after `store` has been initialized
DAreRodz 7c1f2d1
Add lightbox to image block
artemiomorales 9507199
Add logic for hiding lightbox on esc key press and overlay click
artemiomorales 3f89d9b
Improve styles and add note to add conditional for lightbox markup
artemiomorales cb7f89a
Add editor UI and attribute for toggling lightbox
artemiomorales 437d873
Remove image translation animation and add fade instead
artemiomorales 7bd6b25
Add accessibility; clean up styles; fix bug regarding ref in directives
artemiomorales 109344c
Configure image to use new Interactivity API runtime included in Gute…
artemiomorales f95a2cd
Remove viewScript from image config
artemiomorales e37e228
Add Portal directive to Interactivity API runtime
artemiomorales e17e564
Set scrim to site background color
artemiomorales f481a35
Remove extraneous image CSS declaration
artemiomorales 848a8fa
Improve aria labeling
artemiomorales 2204a50
Code cleanup; simplify syntax, consolidate code
artemiomorales 6244e14
Refactor code, remove event listeners, consolidate logic
artemiomorales c388721
Fix formatting in SCSS file
artemiomorales 9754edb
Change CheckboxControl to a ToggleControl; update API docs
artemiomorales b337272
Update wp_enqueue_script to correctly add interactivity runtime
artemiomorales ee679e6
Fix linter errors
artemiomorales ddbf32c
Update to use core.image namespace
artemiomorales f82d8f5
Pause closing of lightbox slightly when using the mousewheel
artemiomorales 8ce00cd
Rename portal directive to 'wp-body' and remove unused reference
artemiomorales 1427e8a
Add internal dependencies flag; update comment
artemiomorales 58b0ef5
Remove extraneous code
artemiomorales 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
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,50 @@ | ||
<?php | ||
/** | ||
* Updates the script-loader.php file | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Registers interactivity runtime and vendor scripts to use with interactive blocks. | ||
* | ||
* @param WP_Scripts $scripts WP_Scripts instance. | ||
*/ | ||
function gutenberg_register_interactivity_scripts( $scripts ) { | ||
gutenberg_override_script( | ||
$scripts, | ||
'wp-interactivity-runtime', | ||
gutenberg_url( | ||
'build/block-library/interactive-blocks/interactivity.min.js' | ||
), | ||
array( 'wp-interactivity-vendors' ) | ||
); | ||
|
||
gutenberg_override_script( | ||
$scripts, | ||
'wp-interactivity-vendors', | ||
gutenberg_url( | ||
'build/block-library/interactive-blocks/vendors.min.js' | ||
) | ||
); | ||
} | ||
add_action( 'wp_default_scripts', 'gutenberg_register_interactivity_scripts', 10, 1 ); | ||
|
||
/** | ||
* Adds the "defer" attribute to all the interactivity script tags. | ||
* | ||
* @param string $tag The generated script tag. | ||
* @param string $handle The script's registered handle. | ||
* | ||
* @return string The modified script tag. | ||
*/ | ||
function gutenberg_interactivity_scripts_add_defer_attribute( $tag, $handle ) { | ||
if ( 0 === strpos( $handle, 'wp-interactivity-' ) ) { | ||
$p = new WP_HTML_Tag_Processor( $tag ); | ||
$p->next_tag( array( 'tag' => 'script' ) ); | ||
$p->set_attribute( 'defer', true ); | ||
return $p->get_updated_html(); | ||
} | ||
return $tag; | ||
} | ||
add_filter( 'script_loader_tag', 'gutenberg_interactivity_scripts_add_defer_attribute', 10, 2 ); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
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.
Not 100% sure but, shouldn't we define the default value in the
block.json
instead of here? Something like: