Skip to content

Commit

Permalink
Adjust menu popup behavior contextually (forem#20718)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhalpern authored Mar 1, 2024
1 parent f2968ba commit 0140a76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/assets/stylesheets/billboards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,13 @@
animation: popoverEnter 0.5s;
box-shadow: 0 0 100px 60px rgba(0, 0, 0, 0.2) !important;
max-height: calc(100vh - var(--header-height));
overflow-y: auto;
.text-styles {
padding-top: var(--su-4);
padding-bottom: var(--su-4);
font-size: calc(0.8em + 0.58vw);
max-width: calc(var(--site-width) - var(--su-8));
}
.sponsorship-dropdown {
top: auto;
bottom: var(--su-8);
overflow-y: auto;
max-height: calc(100vh - var(--header-height) - var(--su-8));
}
@media (min-width: $breakpoint-xl) {
.crayons-sponsorship__header,
Expand All @@ -80,6 +77,13 @@
}
}

.popover-billboard--menuopenupwards {
.sponsorship-dropdown {
top: auto;
bottom: var(--su-8);
}
}

.hide-popover-billboard .popover-billboard {
display: none;
}
Expand Down
6 changes: 6 additions & 0 deletions app/javascript/utilities/billboardInteractivity.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export function setupBillboardInteractivity() {

sponsorshipDropdownButton.dataset.initialized = 'true';
}

const popoverParent = sponsorshipDropdownButton.closest('.popover-billboard');
if (popoverParent &&
sponsorshipDropdownButton.getBoundingClientRect().top > window.innerHeight / 2) {
popoverParent.classList.add('popover-billboard--menuopenupwards');
}
});
}
const sponsorshipCloseButtons = document.querySelectorAll(
Expand Down

0 comments on commit 0140a76

Please sign in to comment.