Skip to content

Commit

Permalink
PLANET-4811 Add scroll padding
Browse files Browse the repository at this point in the history
* Prevents the navbar covering the element we're scrolling to. We
probably want to add this site-wide, but probably best handled
distinctly so we can check if this works everywhere.
* For now this padding is tuned for non-logged in users, as the admin
area needs some additional padding which is more tricky to detect. The
scroll-padding-top needs to be on html but on that element we can't know
if we're logged in or not.
  • Loading branch information
Inwerpsel committed Sep 21, 2020
1 parent f6627cb commit 5707528
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/src/blocks/Submenu/SubmenuEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const renderView = (attributes, setAttributes, className) => {

const { blocks } = useSelect(select => {
return ({ blocks: select('core/editor').getBlocks() });
});
}, null);

const flatHeadings = getHeadingsFromBlocks(blocks, attributes.levels);

Expand Down
2 changes: 1 addition & 1 deletion assets/src/blocks/Submenu/SubmenuFrontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const SubmenuFrontend = ({ title, className, levels, submenu_style }) =>
if (!backTop) {
return;
}
backTop.style.display = 'block';
backTop.classList.remove('d-none');
};

// Enable back top on initial render.
Expand Down
2 changes: 1 addition & 1 deletion assets/src/styles/blocks/Submenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ div[data-render="planet4-blocks/submenu"] {

html {
scroll-behavior: smooth;
scroll-padding-top: 4rem;
}

.back-top,
Expand All @@ -134,7 +135,6 @@ div.page-template > .back-top {
background-color: #074365;
text-align: center;
box-shadow: 0 2px 5px rgba(0, 0, 0, .25);
display: none;
z-index: 1000;

@include x-large-and-up {
Expand Down

0 comments on commit 5707528

Please sign in to comment.