Skip to content
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

Mu-plugins: Add margin to fixed navigation on sites with the latest event banner #1100

Open
wants to merge 1 commit into
base: production
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion public_html/wp-content/mu-plugins/latest-site-hints.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function canonical_link_past_home_pages_to_current_year() {
*/
function add_notification_styles() { ?>
<style type="text/css">
html:not(#specificity-hack) {
html:not(#specificity-hack),
.wordcamp-latest-site-notify-fixed-position-fix {
/* 44 = 10px x2 for padding, 24px for line height. */
margin-top: calc(44px + var(--wp-admin--admin-bar--height, 0px)) !important;
}
Expand Down Expand Up @@ -110,6 +111,23 @@ function add_notification_styles() { ?>
color: #72aee6;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", (event) => {
const fixedElements = document.querySelectorAll('nav, nav *'); // Select all elements
const fixedElementsArray = Array.from(fixedElements);

const fixedElementsWithPositionFixed = fixedElementsArray.filter(element => {
const computedStyle = getComputedStyle(element);
return computedStyle.position === 'fixed';
});

console.log(fixedElementsWithPositionFixed);

fixedElementsWithPositionFixed.forEach(element => {
element.classList.add('wordcamp-latest-site-notify-fixed-position-fix')
});
});
</script>
<?php }

/**
Expand Down
Loading