-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Global Header: Try unsticking the global header, maki…
1 parent
6bfa569
commit d146c0f
Showing
9 changed files
with
111 additions
and
59 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Render the block content. | ||
*/ | ||
|
||
use function WordPressdotorg\MU_Plugins\Global_Header_Footer\get_home_url; | ||
?> | ||
|
||
<div <?php echo get_block_wrapper_attributes(); // phpcs:ignore ?> > | ||
<figure class="wp-block-image global-header__wporg-logo-mark"> | ||
<a href="<?php echo esc_url( get_home_url() ); ?>"> | ||
<?php require dirname( __DIR__ ) . '/global-header-footer/images/w-mark.svg'; ?> | ||
</a> | ||
</figure> | ||
<?php echo $content // phpcs:ignore ?> | ||
</div> |
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,41 @@ | ||
function debounce( callback ) { | ||
// This holds the requestAnimationFrame reference, so we can cancel it if we wish | ||
let frame; | ||
|
||
// The debounce function returns a new function that can receive a variable number of arguments | ||
return ( ...params ) => { | ||
// If the frame variable has been defined, clear it now, and queue for next frame | ||
if ( frame ) { | ||
window.cancelAnimationFrame( frame ); | ||
} | ||
|
||
// Queue our function call for the next frame | ||
frame = window.requestAnimationFrame( () => { | ||
// Call our function and pass any params we received | ||
callback( ...params ); | ||
} ); | ||
}; | ||
} | ||
|
||
function init() { | ||
const container = document.querySelector( '.wp-block-wporg-local-navigation-bar' ); | ||
// The div will hit the "sticky" position when the top offset is 0, or if | ||
// the admin bar exists, 32px (height of admin bar). The bar unstickies | ||
// on smaller screens, so the admin bar height change does not affect this. | ||
const topOffset = document.body.classList.contains( 'admin-bar' ) ? 32 : 0; | ||
if ( container ) { | ||
const onScroll = () => { | ||
const { top } = container.getBoundingClientRect(); | ||
|
||
if ( top <= topOffset ) { | ||
container.classList.add( 'is-sticking' ); | ||
} else { | ||
container.classList.remove( 'is-sticking' ); | ||
} | ||
}; | ||
|
||
document.addEventListener( 'scroll', debounce( onScroll ), { passive: true } ); | ||
onScroll(); | ||
} | ||
} | ||
window.addEventListener( 'load', init ); |
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 |
---|---|---|
|
@@ -25,8 +25,4 @@ | |
} | ||
} | ||
} | ||
|
||
& .is-current-page { | ||
color: var(--wp--preset--color--charcoal-1); | ||
} | ||
} |