Skip to content

Commit

Permalink
Update preview layout (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
medied authored Jun 25, 2024
1 parent 868d8e7 commit 429e1e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 14 additions & 1 deletion src/link/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ export const PreviewEditUI = ( {
}
}, [] );

const addScrollListener = useCallback( () => {
const scrollCue = document.querySelector( '.wikipediapreview-scroll-cue' );
const body = document.querySelector( '.wikipediapreview-body' );
if ( scrollCue ) {
body.addEventListener( 'scroll', ( e ) => {
if ( e.target.scrollTop > 0 ) {
scrollCue.remove();
}
} );
}
}, [] );

useEffect( () => {
const { title, lang } = activeAttributes;
if ( title && lang ) {
Expand All @@ -69,6 +81,7 @@ export const PreviewEditUI = ( {
}, [ activeAttributes ] );

useEffect( () => {
addScrollListener();
if ( isPopoverExpanded() ) {
// The parent header div (where the menu needs to be inserted)
// comes from previewHtml so we need to construct the menu on the fly
Expand All @@ -82,7 +95,7 @@ export const PreviewEditUI = ( {
?.removeEventListener( 'click', toggleControllersMenu );
};
}
}, [ previewHtml, selectingSection, insertControllersMenu ] );
}, [ previewHtml, selectingSection, insertControllersMenu, addScrollListener ] );

useLayoutEffect( () => {
document
Expand Down
5 changes: 1 addition & 4 deletions src/link/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ body {
.components-popover__content {
overflow: unset !important;
border-radius: 8px 8px 0 0;
height: unset !important;
}

@media (prefers-color-scheme: dark ) {
Expand Down Expand Up @@ -418,10 +419,6 @@ body {
.wikipediapreview {
box-shadow: none;

&-gallery {
display: none;
}

.wikipediapreview-footer {

&-cta-readmore {
Expand Down

0 comments on commit 429e1e5

Please sign in to comment.